:root {
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 14px;
  --radius-sm: 10px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-code: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --topbar-h: 52px;
  --tabbar-h: 58px;
  --content-w: 760px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #15171c;
  --muted: #5f6775;
  --border: #e1e4ea;
  --accent: #3b5bdb;
  --accent-contrast: #ffffff;
  --ok: #178a50;
  --bad: #d23f38;
  --warn: #a96a10;
  --flag: #d99a00;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
  --code-bg: #f3f4f7;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #20242e;
  --text: #e8eaf0;
  --muted: #949bab;
  --border: #2a2f3b;
  --accent: #7c9cff;
  --accent-contrast: #0c1020;
  --ok: #3ecf8e;
  --bad: #ff6f66;
  --warn: #f0b95a;
  --flag: #f5c542;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --code-bg: #12151b;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 1.125rem; line-height: 1.3; }
h3 { font-size: 1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, pre, kbd { font-family: var(--font-code); }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { text-align: center; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 650; font-size: 1.05rem; letter-spacing: -.01em; color: var(--text); }
.topbar-title:hover { text-decoration: none; }
.topnav { display: none; gap: var(--s1); margin-left: var(--s5); }
.topnav a {
  padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 550; font-size: .95rem;
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.topnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topnav a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s1); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h);
  color: var(--muted); font-size: .7rem; font-weight: 550;
  transition: color .15s var(--ease-out);
}
.tabbar a:hover { text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .icon { width: 22px; height: 22px; }

.page {
  width: 100%; max-width: var(--content-w);
  margin: 0 auto;
  padding: var(--s4) var(--s4) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s6));
}
.page-wide { max-width: 1120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin: var(--s2) 0 var(--s4); }
.page-head p { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.section-title { font-size: .8rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: var(--s5) 0 var(--s2); }
body.no-chrome .page { padding-bottom: var(--s6); }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .topnav { display: flex; }
  .topbar { padding: 0 var(--s5); }
  .page { padding: var(--s5) var(--s5) var(--s6); }
  h1 { font-size: 1.75rem; }
}

.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  padding: 10px var(--s4);
  background: color-mix(in srgb, var(--warn) 12%, var(--bg));
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, var(--border));
  font-size: .875rem;
}
.banner strong { color: var(--warn); font-weight: 650; }
.banner a { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
  box-shadow: var(--shadow);
}
.card-flat { box-shadow: none; }
.card-tight { padding: var(--s3); }
.card h2 + p, .card h3 + p { margin-top: var(--s1); }
.card-link { display: block; color: inherit; transition: border-color .15s var(--ease-out), transform .15s var(--ease-out); }
.card-link:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card-link:active { transform: scale(.995); }
@media (min-width: 900px) { .card { padding: var(--s5); } .card-tight { padding: var(--s4); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-weight: 600; font-size: .95rem; line-height: 1; white-space: nowrap;
  background: var(--surface-2); color: var(--text);
  transition: background .15s var(--ease-out), border-color .15s var(--ease-out), transform .12s var(--ease-out), opacity .15s;
  user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-secondary:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 20%, var(--surface)); }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 1.02rem; border-radius: 14px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn-block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: 999px;
  font-size: .74rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.chip-junior { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.chip-middle { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.chip-senior { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.chip-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.chip-bad { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.chip-toggle {
  height: 40px; padding: 0 14px; font-size: .88rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  transition: background .15s var(--ease-out), border-color .15s var(--ease-out), color .15s var(--ease-out);
}
.chip-toggle[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: var(--accent); color: var(--accent); }
.chip-toggle.is-flag[aria-pressed="true"] { background: color-mix(in srgb, var(--flag) 16%, var(--surface)); border-color: var(--flag); color: color-mix(in srgb, var(--flag) 75%, var(--text)); }

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; width: var(--value, 0%); border-radius: inherit; background: var(--accent); transition: width .5s var(--ease-out); }
.progress-ok > span { background: var(--ok); }
.progress-thin { height: 5px; }

.ring { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: var(--ring-w, 4); }
.ring .ring-track { stroke: var(--surface-2); }
.ring .ring-value { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease-out); }
.ring-ok .ring-value { stroke: var(--ok); }
.mini-ring { width: 26px; height: 26px; flex: none; }

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 52px; padding: 10px var(--s1);
  border-bottom: 1px solid var(--border); color: inherit;
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { text-decoration: none; color: var(--accent); }
.list-row .title { font-weight: 550; line-height: 1.35; }
.list-row .chev { color: var(--muted); margin-left: auto; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s6) var(--s4); color: var(--muted); }
.empty-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 18px; background: var(--surface-2); color: var(--muted); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty h2 { color: var(--text); }
.empty p { max-width: 38ch; }

.skeleton { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 50%, var(--surface)) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton-line { height: 14px; margin: 10px 0; }
.skeleton-block { height: 56px; margin: 10px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toasts {
  position: fixed; left: 0; right: 0; z-index: 80;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s3));
  display: flex; flex-direction: column; align-items: center; gap: var(--s2);
  pointer-events: none; padding: 0 var(--s4);
}
body.no-chrome .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .toasts { bottom: var(--s5); } }
.toast {
  pointer-events: auto; max-width: 440px;
  padding: 11px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: .9rem; font-weight: 550; box-shadow: var(--shadow);
  animation: toast-in .2s var(--ease-out);
}
.toast.is-error { background: var(--bad); color: #fff; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(8, 10, 16, .5);
  animation: fade-in .16s var(--ease-out);
}
.sheet {
  width: 100%; max-height: 88dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: var(--s3) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  animation: sheet-in .2s var(--ease-out);
}
.sheet::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto var(--s3); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.sheet-actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.sheet-actions .btn { flex: 1; }
@media (min-width: 700px) {
  .overlay { align-items: center; padding: var(--s5); }
  .sheet { max-width: 560px; border-radius: 20px; padding: var(--s5); animation-name: modal-in; }
  .sheet-wide { max-width: 720px; }
  .sheet::before { display: none; }
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: .6; } }
@keyframes modal-in { from { transform: scale(.97); opacity: 0; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: .88rem; font-weight: 600; }
.field .help { font-size: .8rem; color: var(--muted); line-height: 1.4; }
.field .error, .errorlist { margin: 0; padding: 0; list-style: none; font-size: .82rem; color: var(--bad); font-weight: 550; }
.input, .field input[type="text"], .field input[type="password"], .field input[type="number"], .field input[type="url"], .field input[type="search"], .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field textarea.code { font-family: var(--font-code); font-size: .82rem; min-height: 260px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field-check { flex-direction: row; align-items: flex-start; gap: var(--s3); }
.field-check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.form-grid { display: grid; gap: var(--s4); }
@media (min-width: 700px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } .form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; border: 1px solid var(--border); background: var(--surface-2); }
.alert-ok { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-bad { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert-warn { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.table-wrap { overflow-x: auto; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }

.pager { display: flex; align-items: center; justify-content: center; gap: var(--s3); margin-top: var(--s4); font-size: .9rem; color: var(--muted); }

.hl { position: relative; margin: var(--s4) 0; border-radius: var(--radius-sm); background: var(--code-bg) !important; border: 1px solid var(--border); }
.hl pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: .84rem; line-height: 1.6; tab-size: 4; background: transparent; }
.hl pre code { padding: 0; background: none; border: 0; font-size: inherit; }
.hl.has-copy pre { padding-right: 52px; }
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--muted);
  opacity: .85; transition: opacity .15s, color .15s, border-color .15s;
}
.copy-btn:hover { opacity: 1; color: var(--text); }
.copy-btn.is-done { color: var(--ok); border-color: var(--ok); opacity: 1; }
.copy-btn .icon { width: 16px; height: 16px; }

.prose { font-size: 17px; line-height: 1.7; overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.05em; }
.prose h2 { font-size: 1.35em; line-height: 1.3; margin-top: 2em; letter-spacing: -.01em; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.prose h3 { font-size: 1.12em; margin-top: 1.7em; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.prose h4 { font-size: 1em; margin-top: 1.5em; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .4em; }
.prose li > ul, .prose li > ol { margin-top: .4em; }
.prose :not(pre) > code, .inline-code code, .opt-text code, .q-prompt :not(pre) > code {
  padding: .12em .38em; border-radius: 6px; font-size: .88em;
  background: var(--surface-2); border: 1px solid var(--border);
}
.prose blockquote { margin-left: 0; padding: 2px 0 2px 16px; border-left: 3px solid var(--accent); color: var(--muted); }
.prose table { width: 100%; border-collapse: collapse; font-size: .92em; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 8px 10px; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--surface-2); font-weight: 650; }
.prose img { display: block; border-radius: var(--radius-sm); cursor: zoom-in; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose .anchor { margin-left: 8px; color: var(--muted); font-weight: 400; opacity: 0; transition: opacity .15s; text-decoration: none; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus-visible, .prose .is-tapped .anchor { opacity: 1; }
@media (hover: none) { .prose .anchor { opacity: .45; } }
@media (min-width: 900px) { .prose { font-size: 18px; } }

.lightbox { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: var(--s4); background: rgba(5, 6, 10, .9); cursor: zoom-out; animation: fade-in .16s var(--ease-out); touch-action: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; transition: transform .15s var(--ease-out); }

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: var(--s4); }
.login-card { width: 100%; max-width: 380px; }
.brand-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: var(--accent-contrast); font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em; }

.hero { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s5); }
.hero-kicker { font-size: .78rem; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); }
.hero .btn { margin-top: var(--s2); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
.tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; }
.tile-value small { font-size: .8rem; font-weight: 550; color: var(--muted); }
.tile-label { font-size: .76rem; color: var(--muted); line-height: 1.3; }
.quick { display: grid; gap: var(--s3); }
@media (min-width: 560px) { .quick { grid-template-columns: 1fr 1fr; } }
.mastery-row .progress { margin-top: 8px; }
.list-btn { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); text-align: left; border-radius: 0; }
.list-btn:hover { color: var(--accent); }
.foot-line { text-align: center; padding: var(--s2) 0; }

.segments { display: flex; gap: 3px; align-items: center; min-width: 0; }
.seg { flex: 1 1 0; min-width: 3px; height: 6px; padding: 0; border: 0; border-radius: 3px; background: var(--surface-2); transition: background .15s var(--ease-out), box-shadow .15s var(--ease-out); }
.seg.is-answered { background: var(--accent); }
.seg.is-flagged { background: var(--flag); }
.seg.is-current { box-shadow: 0 0 0 1.5px var(--bg), 0 0 0 3px var(--accent); }
.segments-static .seg { height: 7px; }

.session { min-height: 100dvh; display: flex; flex-direction: column; }
.session-head {
  position: sticky; top: 0; z-index: 30;
  padding: 6px var(--s3) 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.session-head-row { display: flex; align-items: center; gap: var(--s2); max-width: calc(var(--content-w) - 8px); margin: 0 auto; }
.session-status { display: flex; align-items: center; gap: var(--s2); max-width: calc(var(--content-w) - 8px); margin: 0 auto; min-height: 32px; padding: 0 var(--s1) 2px var(--s2); font-size: .76rem; color: var(--muted); }
.save-ind { display: inline-flex; align-items: center; gap: 6px; min-width: 0; line-height: 1.25; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex: none; transition: background .2s; }
.save-ind[data-state="saved"] .save-dot { background: var(--ok); }
.save-ind[data-state="saving"] .save-dot { background: var(--accent); }
.save-ind[data-state="retrying"] .save-dot { background: var(--warn); }
.save-ind[data-state="offline"] { color: var(--warn); }
.save-ind[data-state="offline"] .save-dot { background: var(--warn); }
.elapsed { opacity: .8; }
.timer { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.timer-ring { width: 18px; height: 18px; }
.timer-ring .ring-value { stroke: var(--muted); transition: stroke-dashoffset 1s linear; }
.timer.is-low { color: var(--bad); }
.timer.is-low .ring-value { stroke: var(--bad); }
.timer.is-pulse { animation: timer-pulse .9s var(--ease-out) 1; }
@keyframes timer-pulse { 0% { transform: scale(1); } 35% { transform: scale(1.25); } 100% { transform: scale(1); } }
.help-btn { display: none; width: 32px; height: 32px; }
.help-pop { position: absolute; right: var(--s3); top: calc(100% + 6px); z-index: 40; width: 300px; padding: var(--s3) var(--s4); font-size: .85rem; }
.help-pop dl { margin: 0; display: grid; gap: 8px; }
.help-pop dl > div { display: flex; justify-content: space-between; gap: var(--s3); }
.help-pop dt { white-space: nowrap; }
.help-pop dd { margin: 0; color: var(--muted); text-align: right; }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); font-size: .78rem; text-align: center; }

.session-body { flex: 1; width: 100%; max-width: var(--content-w); margin: 0 auto; padding: var(--s4) var(--s4) calc(96px + env(safe-area-inset-bottom)); }
.q-wrap { display: flex; flex-direction: column; gap: var(--s3); }
.q-card { padding: var(--s4); }
.q-number { margin-top: var(--s3); font-size: .8rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.q-prompt { margin-top: 6px; font-size: 1.08rem; line-height: 1.55; font-weight: 500; overflow-wrap: break-word; }
.q-prompt > * + * { margin-top: .7em; }
.q-prompt ul, .q-prompt ol { padding-left: 1.2em; }
.q-code .hl { margin: var(--s3) 0 0; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: flex-start; gap: var(--s3);
  width: 100%; min-height: 56px; padding: 14px;
  text-align: left; line-height: 1.45;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  transition: border-color .13s var(--ease-out), background .13s var(--ease-out), transform .1s var(--ease-out);
}
.option:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.option:active { transform: scale(.992); }
.option.is-selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.opt-index { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: .82rem; font-weight: 650; transition: background .13s, color .13s; }
.option.is-selected .opt-index { background: var(--accent); color: var(--accent-contrast); }
.opt-text { flex: 1; min-width: 0; padding-top: 2px; overflow-wrap: anywhere; }
.q-toggles { margin-top: var(--s1); }

.navigator { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.navigator-inline { display: none; margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border); }
.nav-cell {
  position: relative; height: 44px; padding: 0;
  border: 1.5px solid transparent; border-radius: 12px;
  background: var(--surface-2); color: var(--muted); font-weight: 650; font-size: .9rem;
  transition: background .13s, color .13s, box-shadow .13s;
}
.nav-cell.is-answered { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }
.nav-cell.is-flagged { background: color-mix(in srgb, var(--flag) 24%, var(--surface)); color: color-mix(in srgb, var(--flag) 70%, var(--text)); }
.nav-cell.is-flagged.is-answered::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.nav-cell.is-current { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.legend { margin-top: var(--s4); font-size: .78rem; color: var(--muted); gap: var(--s4); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 4px; }
.dot-ok { background: var(--ok); } .dot-flag { background: var(--flag); } .dot-empty { background: var(--surface-2); border: 1px solid var(--border); }
.dot-bad { background: var(--bad); } .dot-warn { background: var(--warn); }

.session-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s2); align-items: center;
  padding: 10px var(--s3) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.session-bar > .btn { min-height: 48px; }
.session-bar > .btn:first-child { justify-self: start; }
.session-bar > .btn:last-child { justify-self: end; }
.session-bar > .btn:first-child, .session-bar > .btn:last-child { min-width: 118px; }

@media (min-width: 900px) {
  .help-btn { display: inline-grid; }
  .navigator-inline { display: grid; }
  .nav-trigger { pointer-events: none; }
  .nav-trigger .icon { display: none; }
  .session-bar { position: sticky; max-width: var(--content-w); width: 100%; margin: 0 auto; border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
  .session-body { padding-bottom: var(--s5); }
  .q-card { padding: var(--s5); }
}

.score-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s5) var(--s4); }
.score-ring-wrap { position: relative; width: 188px; height: 188px; }
.score-ring { width: 100%; height: 100%; --ring-w: 9; }
.score-ring .ring-value { transition: none; }
.score-ring.is-animating .ring-value { transition: stroke-dashoffset .9s var(--ease-out); }
.score-number { position: absolute; inset: 0; display: grid; place-items: center; grid-auto-flow: column; align-content: center; justify-content: center; font-size: 3.1rem; font-weight: 750; letter-spacing: -.04em; }
.score-number small { font-size: 1.3rem; font-weight: 650; color: var(--muted); margin-left: 2px; align-self: center; padding-top: 12px; }
.score-main { font-size: 1.15rem; font-weight: 650; }
.score-facts { justify-content: center; }
.compare-title { font-size: .95rem; }
.compare-bar { position: relative; height: 6px; margin: 18px 6px 12px; border-radius: 3px; background: var(--surface-2); }
.compare-avg { position: absolute; top: -5px; width: 2px; height: 16px; background: var(--muted); transform: translateX(-1px); border-radius: 1px; }
.compare-dot { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); transform: translate(-50%, -50%); }
.delta-up { color: var(--ok); } .delta-down { color: var(--bad); }
.cat-grid { display: grid; gap: var(--s3); }
@media (min-width: 560px) { .cat-grid { grid-template-columns: 1fr 1fr; } }
.cat-card .progress { margin-top: 8px; }
.cat-acc { font-weight: 700; font-size: 1.05rem; }
.reveal { opacity: 0; animation: rise .42s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 80ms + 350ms); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.radar { max-width: 380px; margin: var(--s3) auto 0; }
.radar svg { display: block; width: 100%; height: auto; overflow: visible; }
.radar .grid { fill: none; stroke: var(--border); stroke-width: 1; }
.radar .axis { stroke: var(--border); stroke-width: 1; }
.radar .label { fill: var(--muted); font-size: 11px; font-family: var(--font-ui); }
.radar .poly { fill-opacity: 0; stroke-width: 2; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.1s var(--ease-out), fill-opacity .6s var(--ease-out) .7s; }
.radar .poly-session { stroke: var(--accent); fill: var(--accent); }
.radar .poly-mastery { stroke: var(--muted); fill: var(--muted); stroke-width: 1.5; opacity: .55; }
.radar.is-drawn .poly { stroke-dashoffset: 0; }
.radar.is-drawn .poly-session { fill-opacity: .16; }
.radar.is-drawn .poly-mastery { fill-opacity: .08; }
.radar .pt { fill: var(--accent); opacity: 0; transition: opacity .3s var(--ease-out) 1s; }
.radar.is-drawn .pt { opacity: 1; }

.heatmap { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: 8px; margin: var(--s3) auto var(--s4); max-width: 440px; }
.heat-cell { position: relative; aspect-ratio: 1.25; min-height: 44px; padding: 0; border: 0; border-radius: 12px; font-weight: 700; font-size: .92rem; color: #fff; transition: transform .12s var(--ease-out), filter .12s; }
.heat-cell:hover { filter: brightness(1.06); }
.heat-cell:active { transform: scale(.96); }
.heat-cell.is-correct { background: var(--ok); }
.heat-cell.is-guessed { background: var(--warn); }
.heat-cell.is-wrong { background: var(--bad); }
.heat-cell.is-skipped { background: var(--surface-2); color: var(--muted); }
[data-theme="dark"] .heat-cell:not(.is-skipped) { color: #0d1014; }
.heat-flag { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }

.review-options { margin-top: var(--s4); }
.review-options .option { cursor: default; min-height: 48px; padding: 11px 12px; }
.review-options .option:hover { border-color: var(--border); }
.review-options .option:active { transform: none; }
.review-options .option.is-correct, .review-options .option.is-correct:hover { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.review-options .option.is-correct .opt-index { background: var(--ok); color: #fff; }
.review-options .option.is-wrong, .review-options .option.is-wrong:hover { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, var(--surface)); }
.review-options .option.is-wrong .opt-index { background: var(--bad); color: #fff; }
.opt-note { display: block; margin-top: 3px; font-size: .76rem; font-style: normal; font-weight: 600; color: var(--muted); }
.explain { margin-top: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--radius-sm); background: var(--surface-2); }
.explain h3 { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.prose-sm { font-size: .95rem; line-height: 1.6; }
.detail-meta { margin-top: var(--s4); }
.share-preview { display: block; width: 100%; max-width: 300px; margin: 0 auto; border-radius: var(--radius); border: 1px solid var(--border); }

.search { position: relative; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 44px; min-height: 48px; border-radius: var(--radius); }
.htmx-indicator { display: none; margin-top: var(--s3); }
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { display: block; }
details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 44px; }
details > summary::-webkit-details-marker { display: none; }
details > summary .icon { transition: transform .18s var(--ease-out); }
details[open] > summary .icon { transform: rotate(180deg); }
.cat-desc { margin: 2px 0 var(--s2); }
.topic-title { margin: var(--s4) 0 2px; font-size: .78rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.read-mark { color: var(--ok); }

.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 70; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
.reader { display: block; }
.reader-main { max-width: 70ch; margin: 0 auto; min-width: 0; }
.reader-main > h1 { margin-top: 6px; font-size: 1.7rem; }
.crumbs a { font-weight: 600; }
.reader-meta { margin: var(--s3) 0 var(--s5); gap: var(--s2) var(--s3); }
.mastery-ind { gap: 6px; }
.toc-mobile { margin-bottom: var(--s5); box-shadow: none; }
.toc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.toc a { display: block; padding: 7px 12px; border-left: 2px solid var(--border); color: var(--muted); font-size: .9rem; line-height: 1.35; transition: color .15s, border-color .15s; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-l3 a { padding-left: 26px; font-size: .85rem; }
.toc-side { display: none; }
.note-card { margin-top: var(--s5); box-shadow: none; border-left: 3px solid var(--accent); }
.note-card.note-warn { border-left-color: var(--warn); }
.note-card h2 { font-size: 1rem; margin-bottom: var(--s2); }
.note-card ul { padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; line-height: 1.55; }
.note-card + .note-card { margin-top: var(--s3); }
.reader-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin: var(--s5) 0; }
.reader-nav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.reader-nav .card-link { display: flex; flex-direction: column; gap: 2px; box-shadow: none; }
.reader-nav .next { text-align: right; grid-column: 2; }
@media (min-width: 900px) { .reader-main > h1 { font-size: 2.1rem; } }
@media (min-width: 1100px) {
  .reader.has-toc { display: grid; grid-template-columns: minmax(0, 70ch) 240px; gap: 56px; justify-content: center; }
  .reader.has-toc .reader-main { margin: 0; }
  .toc-side { display: block; position: sticky; top: calc(var(--topbar-h) + 24px); align-self: start; max-height: calc(100dvh - var(--topbar-h) - 48px); overflow: auto; }
  .toc-mobile { display: none; }
}

.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; margin: var(--s4) 0 var(--s2); padding-bottom: 1px; border-bottom: 1px solid var(--border); }
.bar-col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; }
.bar { display: block; width: 100%; height: max(var(--h), 3%); border-radius: 4px 4px 0 0; background: var(--accent); opacity: .9; transition: opacity .15s; }
.bar-col:hover .bar { opacity: 1; }
.bar.is-empty { height: 3px; background: var(--surface-2); }
.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s5); margin-top: var(--s3); }
.donut { width: 132px; height: 132px; flex: none; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 220px; display: flex; flex-direction: column; gap: 10px; font-size: .9rem; }
.donut-legend li { display: flex; align-items: center; gap: 10px; }

.anchor-nav { position: sticky; top: var(--topbar-h); z-index: 20; padding: 10px 0; margin-bottom: var(--s2); background: var(--bg); overflow-x: auto; flex-wrap: nowrap; }
.anchor-nav .chip { height: 32px; padding: 0 14px; font-size: .82rem; }
.anchor-nav .chip:hover { text-decoration: none; color: var(--text); }
.settings-form section { scroll-margin-top: calc(var(--topbar-h) + 60px); }
.save-bar { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); z-index: 20; }
@media (min-width: 900px) { .save-bar { bottom: var(--s4); } }
.manage-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s2) var(--s3); align-items: center; padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.manage-row:last-child { border-bottom: 0; }
.manage-row .actions { display: flex; align-items: center; gap: 2px; }
.manage-row.is-inactive .title { color: var(--muted); text-decoration: line-through; }
.counter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
.check-list > div { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.check-list label { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; font-weight: 500; }
.check-list input { width: 18px; height: 18px; accent-color: var(--accent); }
.curr-topic { margin-top: var(--s4); }
.curr-row { display: flex; align-items: center; gap: var(--s3); padding: 6px 0; }
.curr-row input[type="checkbox"] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.run-details { margin-top: 8px; font-size: .8rem; }
.run-details pre { margin: 6px 0 0; padding: 10px; border-radius: 8px; background: var(--code-bg); overflow-x: auto; font-size: .76rem; max-height: 260px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; }
  .reveal { opacity: 1; animation: none; }
  .skeleton { animation: none; }
}
