:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #1c2233;
  --muted: #5f6880;
  --border: #dde2ec;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --good: #2b8a3e;
  --bad: #c92a2a;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .05);
  --radius: 14px;

  --blue: #dbe4ff;   --blue-t: #2f4ac0;
  --purple: #ece0ff; --purple-t: #6a32c9;
  --green: #d3f9d8;  --green-t: #2b8a3e;
  --orange: #ffe8cc; --orange-t: #c25e00;
  --red: #ffe0e0;    --red-t: #c92a2a;
  --pink: #ffdeeb;   --pink-t: #c2255c;
  --teal: #c3fae8;   --teal-t: #087f5b;
  --plain: #eef1f7;  --plain-t: #5f6880;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11141c; --surface: #1a1f2b; --surface-2: #242a38; --text: #e8ebf2; --muted: #9aa3b8;
    --border: #2e3546; --accent: #748ffc; --accent-text: #0d1020; --good: #69db7c; --bad: #ff8787;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --blue: #22305c; --blue-t: #a5b8ff; --purple: #33264f; --purple-t: #d0b8ff;
    --green: #1e3b27; --green-t: #8ce99a; --orange: #44301a; --orange-t: #ffc078;
    --red: #482224; --red-t: #ffa8a8; --pink: #47233a; --pink-t: #faa2c1;
    --teal: #173d36; --teal-t: #63e6be; --plain: #242a38; --plain-t: #9aa3b8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11141c; --surface: #1a1f2b; --surface-2: #242a38; --text: #e8ebf2; --muted: #9aa3b8;
  --border: #2e3546; --accent: #748ffc; --accent-text: #0d1020; --good: #69db7c; --bad: #ff8787;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --blue: #22305c; --blue-t: #a5b8ff; --purple: #33264f; --purple-t: #d0b8ff;
  --green: #1e3b27; --green-t: #8ce99a; --orange: #44301a; --orange-t: #ffc078;
  --red: #482224; --red-t: #ffa8a8; --pink: #47233a; --pink-t: #faa2c1;
  --teal: #173d36; --teal-t: #63e6be; --plain: #242a38; --plain-t: #9aa3b8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.1rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.lead { color: var(--muted); margin: 0 0 1.25rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--muted); margin: 0 0 .25rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-weight: 800;
}
.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav a {
  padding: .45rem .75rem; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.menu-toggle, .theme-toggle {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: .4rem .7rem; font: inherit; cursor: pointer;
}
.menu-toggle { display: none; margin-left: auto; }

@media (max-width: 900px) {
  .menu-toggle { display: block; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; padding: .5rem 16px 1rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .nav.open { display: flex; }
}

/* ---------- layout ---------- */
main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.75rem 16px 3rem; flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem 16px 2rem; }

/* ---------- home ---------- */
.hero {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.hero .lead { margin-bottom: .25rem; }
.stat-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem 1rem; min-width: 110px; display: flex; flex-direction: column;
}
.stat-num { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .8rem; color: var(--muted); }
.list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.list .row > :last-child { white-space: nowrap; flex: none; }
.word { font-size: 1.6rem; font-weight: 700; margin: .25rem 0; color: var(--accent); }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: .9rem;
  cursor: pointer; text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }
.empty { color: var(--muted); font-style: italic; }

/* ---------- tags ---------- */
.tag {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--plain); color: var(--plain-t); white-space: nowrap;
}
.tag.blue { background: var(--blue); color: var(--blue-t); }
.tag.purple { background: var(--purple); color: var(--purple-t); }
.tag.green { background: var(--green); color: var(--green-t); }
.tag.orange { background: var(--orange); color: var(--orange-t); }
.tag.red { background: var(--red); color: var(--red-t); }
.tag.pink { background: var(--pink); color: var(--pink-t); }
.tag.teal { background: var(--teal); color: var(--teal-t); }

/* ---------- subjects ---------- */
.subject { border-top: 5px solid var(--plain-t); }
.subject.blue { border-top-color: var(--blue-t); }
.subject.purple { border-top-color: var(--purple-t); }
.subject.green { border-top-color: var(--green-t); }
.subject.orange { border-top-color: var(--orange-t); }
.subject.red { border-top-color: var(--red-t); }
.subject.pink { border-top-color: var(--pink-t); }
.subject.teal { border-top-color: var(--teal-t); }
.subject-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.subject-head h2 { margin: 0; }
.subject-icon { font-size: 1.5rem; }
.topics { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.topics li { padding: .15rem 0; }

/* ---------- lessons ---------- */
.lesson-group { margin: 1.5rem 0 .75rem; font-size: 1.2rem; }
.lesson-card { display: flex; flex-direction: column; gap: .35rem; color: var(--text); text-decoration: none; transition: transform .15s, box-shadow .15s; }
.lesson-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(20, 30, 60, .12); }
.lesson-card p { margin: 0; }
.lesson-unit { font-size: .85rem; font-weight: 600; color: var(--muted); }
.lesson-codes { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: auto; padding-top: .4rem; }
.badge-3d { margin-left: auto; flex: none; font-size: .72rem; font-weight: 800; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 999px; background: linear-gradient(135deg, #7048e8, #3b5bdb); color: #fff; }
.badge-extra { align-self: flex-start; font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: var(--orange); color: var(--orange-t); }
.extras-note { margin: -.4rem 0 .9rem; max-width: 70ch; }
.code-chip { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.subject .link-btn { display: inline-block; margin-top: .6rem; }

/* ---------- forms ---------- */
.form-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.form-row label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); flex: 1 1 160px; }
input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: .55rem .7rem; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 10px; padding: .6rem 1.2rem;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.filter-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.chip {
  font: inherit; font-size: .9rem; cursor: pointer;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: .4rem .9rem;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------- homework / reading lists ---------- */
.hw-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.hw-item {
  display: flex; align-items: center; gap: .85rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .75rem 1rem;
}
.hw-item input[type="checkbox"] { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); flex: none; }
.hw-body { display: flex; flex-direction: column; gap: .25rem; flex: 1; min-width: 0; }
.hw-title { font-weight: 600; overflow-wrap: anywhere; }
.hw-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .85rem; color: var(--muted); }
.hw-item.done .hw-title { text-decoration: line-through; color: var(--muted); }
.hw-item.done { opacity: .75; }
.overdue { color: var(--bad); font-weight: 600; }
.icon-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem;
  padding: .3rem .5rem; border-radius: 8px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--bad); }
.book-icon { font-size: 1.3rem; }

/* ---------- schedule ---------- */
.table-wrap { overflow-x: auto; padding: 0; }
.timetable { width: 100%; border-collapse: collapse; min-width: 640px; }
.timetable th, .timetable td { padding: .65rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.timetable thead th { font-size: .85rem; color: var(--muted); background: var(--surface-2); }
.timetable tbody th { font-weight: 500; font-size: .85rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timetable .today { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.timetable thead th.today { color: var(--accent); }

/* ---------- practice ---------- */
.quiz { max-width: 560px; }
.quiz-top { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: .6rem 0 1rem; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.question { font-size: clamp(1.3rem, 4vw, 1.8rem); font-weight: 700; margin: .5rem 0 1rem; font-variant-numeric: tabular-nums; }
.quiz-form { display: flex; gap: .5rem; }
.quiz-form input { flex: 1; font-size: 1.2rem; }
.feedback { min-height: 1.5em; font-weight: 600; margin: .75rem 0 .5rem; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

/* ---------- reading ---------- */
.goal { margin-bottom: 1rem; }
.goal-head { display: flex; justify-content: space-between; font-weight: 600; }
.goal .progress { margin-bottom: 0; }
