/* ---------- Tokens ---------- */
:root {
  --bg: #f5f5f9;
  --surface: #ffffff;
  --surface-2: #efeff5;
  --text: #191927;
  --muted: #646477;
  --faint: #9a9aab;
  --border: #e3e3ec;
  --accent: #5b5bd6;
  --accent-ink: #ffffff;
  --accent-soft: #ececfb;
  --good: #17844a;
  --good-soft: #e2f5e9;
  --bad: #c93636;
  --bad-soft: #fde7e7;
  --gold: #d48a00;
  --shadow: 0 1px 2px rgb(16 16 40 / 0.05), 0 6px 20px rgb(16 16 40 / 0.06);
  --radius: 18px;
  --radius-sm: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Kohinoor Devanagari", "Noto Sans Gurmukhi", "Gurmukhi MN", "Raavi", sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f17;
    --surface: #191924;
    --surface-2: #232331;
    --text: #ececf4;
    --muted: #a5a5ba;
    --faint: #6e6e84;
    --border: #2d2d3d;
    --accent: #8d8df2;
    --accent-ink: #11111a;
    --accent-soft: #272750;
    --good: #52cf8b;
    --good-soft: #163324;
    --bad: #f27474;
    --bad-soft: #3b1d21;
    --gold: #f2b84b;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f0f17;
  --surface: #191924;
  --surface-2: #232331;
  --text: #ececf4;
  --muted: #a5a5ba;
  --faint: #6e6e84;
  --border: #2d2d3d;
  --accent: #8d8df2;
  --accent-ink: #11111a;
  --accent-soft: #272750;
  --good: #52cf8b;
  --good-soft: #163324;
  --bad: #f27474;
  --bad-soft: #3b1d21;
  --gold: #f2b84b;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
strong { font-weight: 650; }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.main {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.sidebar { display: none; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--faint);
  font-size: 11.5px; font-weight: 600;
  position: relative;
}
.tabbar a.active { color: var(--accent); }
.tabbar .badge {
  position: absolute; top: 6px; left: 50%; transform: translateX(6px);
  background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 99px;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; top: 0; bottom: 0; left: 0; width: 232px;
    padding: 22px 14px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .sidebar .brand { margin: 0 10px 18px; }
  .sidebar a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 600; font-size: 15px;
  }
  .sidebar a:hover { background: var(--surface-2); color: var(--text); }
  .sidebar a.active { background: var(--accent-soft); color: var(--accent); }
  .sidebar .badge { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
  .sidebar .spacer { flex: 1; }
  .main { margin-left: 232px; margin-right: 0; padding: 28px 40px 48px; max-width: none; }
  .main > * { max-width: 820px; margin-left: auto; margin-right: auto; }
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6d6df0, #4a3fc4);
  color: #fff; font-size: 18px; font-weight: 800;
}

/* ---------- Building blocks ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.center { text-align: center; }
.mt { margin-top: 22px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.block-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
  margin: 26px 2px 10px;
}
.block-title:first-child { margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-weight: 650; font-size: 15px;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.good { background: var(--good-soft); border-color: transparent; color: var(--good); }
.btn.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.icon-btn {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.on { color: var(--gold); }
.icon-btn.on svg { fill: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 99px;
  font-size: 12.5px; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.bar { display: block; height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width .4s ease; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar-title { font-size: 19px; font-weight: 750; letter-spacing: -0.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Home ---------- */
.home-head { display: flex; align-items: flex-start; gap: 12px; margin: 4px 0 18px; }
.home-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.home-head .sub { color: var(--muted); font-size: 14.5px; margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { padding: 14px; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.continue {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #5b5bd6, #7a4fd1);
  color: #fff; border: 0;
}
.continue .k { font-size: 12.5px; opacity: .85; font-weight: 600; }
.continue .t { font-size: 17px; font-weight: 750; line-height: 1.3; }
.continue .go { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgb(255 255 255 / .18); flex: none; }

.subject-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .subject-grid { grid-template-columns: repeat(3, 1fr); } }
.subject-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; transition: transform .12s ease, border-color .12s ease; }
.subject-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.subject-icon {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-size: 23px;
  background: color-mix(in srgb, var(--c) 15%, var(--surface));
  margin-bottom: 8px;
}
.subject-name { font-weight: 750; font-size: 16px; line-height: 1.25; }
.subject-hi { color: var(--muted); font-size: 13.5px; }
.subject-card .bar { margin-top: 10px; }
.subject-meta { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }

.tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .tools { grid-template-columns: repeat(4, 1fr); } }
.tool { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.tool .ti { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tool .tt { font-weight: 700; font-size: 15px; line-height: 1.25; }
.tool .ts { font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* ---------- Subject page ---------- */
.hero {
  border-radius: var(--radius);
  padding: 22px 20px;
  background: color-mix(in srgb, var(--c) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 22%, var(--border));
}
.hero .eyebrow { font-size: 13px; font-weight: 700; color: color-mix(in srgb, var(--c) 72%, var(--text)); letter-spacing: .02em; }
.hero h1 { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin-top: 4px; }
.hero p { color: var(--muted); margin-top: 8px; font-size: 15px; }
.hero .bar { margin-top: 14px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.hero-actions .btn { min-height: 40px; padding: 0 14px; font-size: 14px; }

.section-label { font-size: 15px; font-weight: 750; margin: 26px 2px 10px; display: flex; align-items: center; gap: 8px; }
.section-label .count { color: var(--faint); font-weight: 600; font-size: 13px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.chapter-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; transition: border-color .12s ease; }
.chapter-row:hover { border-color: color-mix(in srgb, var(--c, var(--accent)) 45%, var(--border)); }
.ch-num {
  width: 36px; height: 36px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 750; font-size: 14.5px;
  background: color-mix(in srgb, var(--c, var(--accent)) 13%, var(--surface));
  color: color-mix(in srgb, var(--c, var(--accent)) 75%, var(--text));
}
.ch-num.done { background: var(--good); color: #fff; }
.ch-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-title { font-weight: 680; line-height: 1.3; }
.ch-sum { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.ch-tag { font-size: 11.5px; font-weight: 700; color: color-mix(in srgb, var(--c, var(--accent)) 72%, var(--text)); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Chapter page ---------- */
.tabs {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 4px;
  margin: 16px -16px 18px; padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: 1; min-width: max-content;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 12px;
  font-weight: 650; font-size: 14.5px; color: var(--muted);
}
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs a svg.i { width: 18px; height: 18px; }
@media (max-width: 440px) {
  .tabs a { padding: 9px 8px; }
  .tabs a svg.i { display: none; }
}

.note h3 { font-size: 17px; font-weight: 750; margin-bottom: 8px; line-height: 1.3; }
.note ul, .formula-box ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; }
.note li::marker { color: var(--c, var(--accent)); }

.formula-box {
  background: color-mix(in srgb, var(--c, var(--accent)) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--c, var(--accent)) 25%, var(--border));
}
.formula-box h3 { font-size: 15px; font-weight: 750; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; color: color-mix(in srgb, var(--c, var(--accent)) 72%, var(--text)); }
.formula-box ul { list-style: none; padding: 0; gap: 8px; }
.formula-box li {
  padding: 9px 12px; border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.terms { display: grid; gap: 10px; margin: 0; }
.terms > div { padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.terms > div:last-child { border-bottom: 0; padding-bottom: 0; }
.terms dt { font-weight: 700; }
.terms dd { margin: 2px 0 0; color: var(--muted); font-size: 15px; }

.done-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.done-row .btn { flex: 1; min-width: 200px; }

.pager { display: flex; gap: 10px; margin-top: 26px; }
.pager a { flex: 1; min-width: 0; padding: 12px 14px; }
.pager .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.pager .t { font-weight: 680; font-size: 14.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager .next { text-align: right; }

.example .q { font-weight: 600; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); margin-right: 6px; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.reveal { margin-top: 12px; }
.reveal > summary {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); font-weight: 650; font-size: 14.5px;
  padding: 6px 12px; border-radius: 10px; background: var(--accent-soft);
}
.reveal[open] > summary { margin-bottom: 10px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.answer { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--good-soft); color: var(--good); font-weight: 650; }

.qa > summary { display: flex; gap: 12px; align-items: flex-start; font-weight: 620; }
.qa > summary::after { content: "+"; margin-left: auto; font-size: 22px; line-height: 1; color: var(--accent); font-weight: 400; }
.qa[open] > summary::after { content: "−"; }
.qa .a { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); color: var(--text); font-size: 15px; }

/* ---------- Quiz ---------- */
.quiz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; font-weight: 650; color: var(--muted); }
.quiz-clock { margin-left: auto; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 6px; }
.quiz-clock.low { color: var(--bad); }
.quiz-clock svg.i { width: 17px; height: 17px; }
.quiz-q { font-size: 18px; font-weight: 650; line-height: 1.45; margin: 16px 0 16px; }
.quiz-from { font-size: 12.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 13px 14px; min-height: 54px;
  border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 15.5px; line-height: 1.4;
  transition: border-color .12s ease, background .12s ease;
}
.option:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.option .letter {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
  font-size: 13.5px; font-weight: 750;
}
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.selected .letter { background: var(--accent); color: var(--accent-ink); }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.correct .letter { background: var(--good); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.wrong .letter { background: var(--bad); color: #fff; }
.option.locked { pointer-events: none; }
.option.locked:not(.correct):not(.wrong) { opacity: .6; }

.feedback { margin-top: 14px; padding: 14px 16px; border-radius: 14px; font-size: 15px; }
.feedback.good { background: var(--good-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback .h { font-weight: 750; margin-bottom: 4px; }
.feedback.good .h { color: var(--good); }
.feedback.bad .h { color: var(--bad); }

.quiz-nav { display: flex; gap: 10px; margin-top: 18px; }
.quiz-nav .btn { flex: 1; }

.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.palette button {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.palette button.answered { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.palette button.current { outline: 2px solid var(--accent); outline-offset: 1px; }

.result-top { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 26px 18px; }
.ring {
  --p: 0;
  width: 132px; height: 132px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--ring, var(--accent)) calc(var(--p) * 1%), var(--surface-2) 0);
}
.ring > div {
  width: 104px; height: 104px; border-radius: 50%;
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring .v { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.ring .l { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.result-msg { font-size: 20px; font-weight: 750; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.review-item .opts { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 14.5px; }
.review-item .yours { color: var(--bad); }
.review-item .right { color: var(--good); font-weight: 650; }
.review-item .why { margin-top: 8px; color: var(--muted); font-size: 14.5px; }
.review-item.ok { border-left: 4px solid var(--good); }
.review-item.no { border-left: 4px solid var(--bad); }

.breakdown { display: flex; flex-direction: column; gap: 14px; }
.breakdown .lbl { font-size: 14px; }
.breakdown .val { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.breakdown .bar { margin-top: 6px; }

/* ---------- Flashcards ---------- */
.flashcard { perspective: 1400px; height: 300px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.flashcard-inner { position: relative; height: 100%; transition: transform .5s cubic-bezier(.3,.7,.3,1); transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 26px; text-align: center; overflow: auto;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow);
}
.face.front { background: color-mix(in srgb, var(--c, var(--accent)) 10%, var(--surface)); }
.face.back { transform: rotateY(180deg); }
.face .term { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.3; }
.face .meaning { font-size: 17px; line-height: 1.55; }
.face .hint { font-size: 12.5px; color: var(--faint); font-weight: 600; }
.face .from { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.card-actions { display: flex; gap: 10px; margin-top: 14px; }
.card-actions .btn { flex: 1; }

/* ---------- Timer ---------- */
.timer-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 26px 18px; }
.timer-ring { position: relative; width: 240px; height: 240px; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 12; }
.timer-ring .track { stroke: var(--surface-2); }
.timer-ring .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .3s linear; }
.timer-ring .read { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-ring .time { font-size: 50px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.timer-ring .mode { color: var(--muted); font-weight: 650; }
.timer-controls { display: flex; gap: 12px; }
.timer-controls .btn { min-width: 130px; }

/* ---------- Progress ---------- */
.stats-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .stats-4 { grid-template-columns: repeat(4, 1fr); } }
.week { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.week .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week .col { width: 100%; max-width: 38px; border-radius: 8px 8px 4px 4px; background: var(--accent); min-height: 4px; }
.week .col.zero { background: var(--surface-2); }
.week .d { font-size: 12px; color: var(--muted); font-weight: 650; }
.week .m { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.subj-progress { display: flex; flex-direction: column; gap: 16px; }
.subj-progress .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; margin-bottom: 6px; }
.history-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: 0; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 650; color: var(--muted); }
.input {
  width: 100%; min-height: 48px; padding: 0 14px;
  border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 16px;
}
.input:focus { outline: none; border-color: var(--accent); }
.seg { display: flex; padding: 4px; gap: 4px; border-radius: 14px; background: var(--surface-2); }
.seg button {
  flex: 1; min-height: 40px; border: 0; border-radius: 11px; padding: 0 6px;
  background: transparent; font-weight: 650; color: var(--muted); white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.check-list { display: flex; flex-direction: column; max-height: 320px; overflow: auto; margin-top: 10px; }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 9px 4px; font-size: 15px; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-list input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch input { width: 46px; height: 28px; appearance: none; -webkit-appearance: none; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .15s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- Onboarding ---------- */
.onboard { max-width: 440px; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 22px; }
.onboard .brand { font-size: 28px; }
.onboard .brand-mark { width: 48px; height: 48px; font-size: 25px; border-radius: 14px; }
.onboard h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.class-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.class-pick button {
  padding: 18px 12px; border-radius: var(--radius);
  border: 2px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.class-pick button .n { font-size: 32px; font-weight: 800; line-height: 1.1; }
.class-pick button .s { font-size: 13px; color: var(--muted); font-weight: 600; }
.class-pick button.on { border-color: var(--accent); background: var(--accent-soft); }
.class-pick button.on .n { color: var(--accent); }

.class-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 520px) { .class-grid { grid-template-columns: repeat(6, 1fr); } }
.class-grid button { padding: 12px 4px; border-radius: 14px; }
.class-grid button .n { font-size: 24px; }
.stream-label { font-size: 14px; font-weight: 700; color: var(--muted); margin: 16px 2px 10px; }
.stream-label:first-of-type { margin-top: 0; }

/* ---------- Search ---------- */
.search-box { position: relative; }
.search-box svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search-box .input { padding-left: 44px; }
mark { background: color-mix(in srgb, var(--gold) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

@media (hover: none) { .kbd-tip { display: none; } }
.ch-num svg.i { width: 18px; height: 18px; }

/* ---------- QOTD ---------- */
.qotd .options { margin-top: 12px; }
.qotd .option { min-height: 46px; padding: 10px 12px; font-size: 15px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 14px;
  background: var(--text); color: var(--bg);
  font-weight: 650; font-size: 14.5px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { #toast { bottom: 28px; left: calc(50% + 116px); } }

/* ---------- Print (formula sheets) ---------- */
@media print {
  .tabbar, .sidebar, .topbar .icon-btn, .no-print, #toast { display: none !important; }
  body { background: #fff; color: #000; }
  .main { margin: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

[hidden] { display: none !important; }
