:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #334155;
  --on-accent: #ffffff;
  --accent-soft: #e2e8f0;
  --ok: #15803d;
  --mid: #b45309;
  --bad: #b91c1c;
  --banner-bg: #e8edf5;
  --banner-text: #1f2937;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --surface: #1e1e1e;
    --text: #ececec;
    --muted: #9a9a9a;
    --line: #2e2e2e;
    --accent: #e8edf5;
    --on-accent: #111827;
    --accent-soft: #2a2f38;
    --ok: #4ade80;
    --mid: #fbbf24;
    --bad: #f87171;
    --banner-bg: #e8edf5;
    --banner-text: #111827;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 "Pretendard", -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
}

a { color: var(--accent); }

.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  display: block;
  padding: 10px 16px;
  text-align: center;
  background: var(--banner-bg);
  color: var(--banner-text);
  font-weight: 600;
  text-decoration: none;
}
.banner[hidden] { display: none; }

.top {
  display: flex;
  align-items: center;
  gap: 32px;
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
nav { display: flex; flex: 1; }
nav a { flex: 1; text-align: center; color: var(--muted); text-decoration: none; padding: 4px 0; }
nav a.on { color: var(--text); border-bottom: 2px solid var(--accent); }

main { max-width: 820px; margin: 0 auto; padding: 28px 24px 80px; }

h1 { font-size: 22px; margin: 0 0 20px; }
h2 { font-size: 18px; margin: 32px 0 12px; }
h3 { font-size: 15px; margin: 18px 0 10px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 14px;
}

/* 시작 모달 */
#start {
  width: min(560px, calc(100% - 32px));
  padding: 44px 28px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
}
#start::backdrop { background: rgb(0 0 0 / .45); }
#start .close {
  position: absolute;
  top: 8px;
  right: 10px;
  margin: 0;
  padding: 4px 10px;
  background: none;
  color: var(--muted);
  font-size: 22px;
  font-weight: 400;
}
.start-body { display: flex; flex-direction: column; gap: 16px; }
.start-review {
  display: block;
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--banner-bg);
  color: var(--banner-text);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.todo-add input { padding: 14px 16px; font-size: 17px; border-radius: 12px; }
.todo-add .hint { min-height: 1.6em; margin-top: 6px; font-size: 14px; color: var(--muted); }

/* 오늘 */
.today-item {
  display: block;
  padding: 12px 14px;
  margin: 0 -14px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
a.today-item:hover { background: var(--surface); }
.today-item.done .title { text-decoration: line-through; color: var(--muted); }
.todo { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.todo input { margin-top: 6px; width: 18px; height: 18px; }
.todo.done .title { text-decoration: line-through; color: var(--muted); }
.kind { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); margin-right: 6px; }
.detail { color: var(--muted); font-size: 14px; white-space: pre-wrap; }
.late { color: var(--mid); font-size: 13px; }

/* 복습 */
.q { white-space: pre-wrap; margin: 0 0 14px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
textarea, input[type=text], input[type=search] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
button {
  margin-top: 12px;
  padding: 9px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }
.verdict { font-weight: 700; font-size: 18px; margin-right: 8px; }
.v-○ { color: var(--ok); } .v-△ { color: var(--mid); } .v-✗ { color: var(--bad); }
.answer { white-space: pre-wrap; border-left: 3px solid var(--line); padding-left: 12px; margin: 8px 0; }
.err { color: var(--bad); font-size: 14px; }

/* 용어 */
.term-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.term-form .wide { grid-column: 1 / -1; }
.term { padding: 10px 0; border-bottom: 1px solid var(--line); }
.term b { margin-right: 6px; }

/* 커리큘럼 */
.track summary { cursor: pointer; font-weight: 600; }
.track .meta { font-size: 14px; color: var(--muted); margin: 8px 0; }
.lesson { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.lesson .code { font-family: ui-monospace, Consolas, monospace; color: var(--muted); min-width: 48px; }
.status { font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; height: fit-content; }
.status.done { color: var(--ok); border-color: currentColor; }
.status.doing { color: var(--accent); border-color: currentColor; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* 선택지 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.tpick { display: flex; align-items: center; gap: 6px; }
.tpick select {
  flex: 1;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); margin-top: 14px; }

/* 아침 수면 체크 */
.sleep-form .sleep-title { font-weight: 600; margin-bottom: 4px; }

/* 일지 */
.grass { display: grid; grid-template-columns: repeat(35, 1fr); gap: 3px; max-width: 560px; }
.grass i { aspect-ratio: 1; border-radius: 3px; background: var(--line); }
.grass .g1 { background: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.grass .g2 { background: color-mix(in srgb, var(--accent) 65%, var(--line)); }
.grass .g3 { background: var(--accent); }
.sleep-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; margin-bottom: 8px; }
.sbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.sbar i { width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); min-height: 2px; }
.sbar span { font-size: 12px; color: var(--muted); }
.log-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.log-day p { margin: 8px 0 0; }
.claude-note { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--muted); }
input[type=time] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.tsel { position: relative; }
.tsel-btn {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-weight: 400;
  text-align: left;
}
.tsel-pop {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgb(0 0 0 / .3);
}
.tsel-pop[hidden] { display: none; }
.tsel-col { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; }
.tsel-col button {
  margin: 0;
  padding: 6px 14px;
  background: none;
  color: var(--text);
  font-weight: 400;
}
.tsel-col button:hover { background: var(--accent-soft); }
.tsel-col button.on { background: var(--accent); color: var(--on-accent); }
.cond { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.cond input[type=range] { flex: 1; accent-color: var(--accent); cursor: pointer; }
.cond output { min-width: 2ch; font-weight: 700; text-align: right; }
.cond > span { font-size: 26px; line-height: 1; }
.due { margin-right: 6px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
details.topic > summary { margin: 32px 0 12px; cursor: pointer; user-select: none; }
details.topic > summary h2 { display: inline; margin: 0; }
/* 요약 탭 */
#sum select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
button.link { background: none; color: var(--accent); padding: 0 6px; margin: 0 0 0 6px; text-decoration: underline; cursor: pointer; }
/* 커리큘럼: 차시 제목은 그 차시 퀴즈로, 아래 줄은 강의·자료·책 */
.lesson a.code { text-decoration: none; }
.lesson a.ltitle { color: var(--text); text-decoration: none; }
.lesson a.ltitle:hover, .lesson a.code:hover { text-decoration: underline; }
.lesson .lmeta { font-size: 13px; margin-top: 2px; }
h2.group { margin: 28px 0 10px; font-size: 18px; }
