/* PSLE Maths design system — tokens, base, components. One stylesheet, no duplicated component CSS. */

/* Lexend, self-hosted (SIL Open Font License) */
@font-face { font-family: "Lexend"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/lexend-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Lexend"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/lexend-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Lexend"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/lexend-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Lexend"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/lexend-latin-700-normal.woff2") format("woff2"); }

:root {
  --paper: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F7;
  --ink: #17213A;
  --ink-2: #4A5572;
  --ink-3: #7480A0;
  --line: #DCE1EC;
  --grid: rgba(39, 71, 168, 0.07);
  --action: #2747A8;
  --action-ink: #FFFFFF;
  --action-soft: #E5EBFA;
  --highlight: #F5C400;
  --good: #0F8A6C;
  --good-soft: #E1F3EE;
  --warn: #B45309;
  --warn-soft: #FDF0DD;
  --bad: #B42318;
  --bad-soft: #FDE7E5;
  --strand-na: #2C6BD6;
  --strand-mg: #0F8A6C;
  --strand-st: #C77C02;
  --unit-empty: #E3E7F0;

  --font: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
  --shadow: 0 1px 2px rgba(23, 33, 58, 0.06), 0 4px 16px rgba(23, 33, 58, 0.05);
  --focus: 0 0 0 3px #FFFFFF, 0 0 0 5px var(--action);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10162A; --surface: #172038; --surface-2: #1E2944; --ink: #EEF1F8; --ink-2: #B9C1D6; --ink-3: #8691AE;
    --line: #2A3555; --grid: rgba(140, 165, 255, 0.06); --action: #7F9BFF; --action-ink: #0E1430; --action-soft: #233061;
    --good: #3CC69F; --good-soft: #143A33; --warn: #F2A541; --warn-soft: #3A2C14; --bad: #FF7A6E; --bad-soft: #3D1C1C;
    --strand-na: #6E9EF0; --strand-mg: #3CC69F; --strand-st: #F2B13D; --unit-empty: #26314F;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --focus: 0 0 0 3px var(--paper), 0 0 0 5px var(--action);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.55; color: var(--ink);
  background: var(--paper); font-feature-settings: "tnum" 1;
}
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 var(--s-3); font-weight: 600; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 var(--s-4); max-width: 68ch; }
a { color: var(--action); text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
img, svg { display: block; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 1.75rem; height: 1.75rem; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: var(--s-3); z-index: 100; }
.skip-link:focus { left: var(--s-3); }

/* ---------- Grid paper: the exercise-book texture used behind feature panels ---------- */
.grid-paper {
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh;
  background: linear-gradient(90deg, var(--surface) 247px, var(--line) 247px, var(--line) 248px, transparent 248px); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line);
  padding: var(--s-5) var(--s-4); display: flex; flex-direction: column; gap: var(--s-5);
}
.brand { white-space: nowrap; display: flex; align-items: center; gap: var(--s-2); font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav .nav-disabled {
  display: flex; align-items: center; gap: var(--s-3); padding: 0.6rem var(--s-3); border-radius: var(--r-md);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--action-soft); color: var(--action); }
.nav .nav-disabled { color: var(--ink-3); cursor: default; }
.nav .soon { margin-left: auto; font-size: 0.72rem; font-weight: 500; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 0.45rem; }
.nav-group-title { font-size: 0.8rem; color: var(--ink-3); padding: var(--s-3) var(--s-3) var(--s-1); font-weight: 500; }
.sidebar-foot { margin-top: auto; }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-6); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(6px);
}
.topbar .brand { display: none; }
.topbar-spacer { flex: 1; }
.content { padding: var(--s-6); max-width: 1120px; }
.page-head { margin-bottom: var(--s-5); }
.page-head p { color: var(--ink-2); margin: 0; }

.chip { display: inline-flex; align-items: center; gap: var(--s-1); padding: 0.3rem 0.65rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.875rem; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.chip-streak .icon { color: var(--warn); }
.chip-streak.on { border-color: var(--highlight); background: color-mix(in srgb, var(--highlight) 18%, var(--surface)); color: var(--ink); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 0.9rem; color: #fff; flex: none; }
.avatar.circle-teal { background: #0F8A6C; } .avatar.circle-coral { background: #C2410C; }
.avatar.circle-indigo { background: #3B4CC0; } .avatar.circle-amber { background: #A16207; } .avatar.neutral { background: var(--ink-2); }
.badge-dot { position: relative; }
.badge-dot[data-count]::after { content: attr(data-count); position: absolute; top: -6px; right: -8px; background: var(--bad); color: #fff; font-size: 0.68rem; border-radius: 999px; padding: 0 5px; line-height: 1.4; }

.bottom-nav { display: none; }
.menu-toggle { display: none; }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }
.panel + .panel { margin-top: var(--s-4); }
.cols > .panel + .panel { margin-top: 0; }
.panel-feature { border-radius: var(--r-lg); border: 1px solid var(--line); padding: var(--s-6); box-shadow: var(--shadow); }
.section { margin-top: var(--s-6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-3); }
.section-head h2 { margin: 0; }
.cols { display: grid; gap: var(--s-4); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.stack > * + * { margin-top: var(--s-4); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: var(--s-3) 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: var(--s-3); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }

.empty { color: var(--ink-2); padding: var(--s-4); border: 1px dashed var(--line); border-radius: var(--r-md); background: var(--surface); }
.empty strong { color: var(--ink); display: block; margin-bottom: 2px; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px; padding: 0 1.15rem;
  border-radius: var(--r-md); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--action); color: var(--action-ink);
}
.btn:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); filter: none; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-quiet { background: transparent; color: var(--action); padding: 0 0.5rem; min-height: 36px; }
.btn-sm { min-height: 34px; padding: 0 0.75rem; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.inline-form { display: inline; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field label { font-weight: 500; font-size: 0.95rem; }
.field .hint { font-size: 0.85rem; color: var(--ink-2); }
.input, select.input, textarea.input {
  font: inherit; min-height: 48px; padding: 0.6rem 0.85rem; border-radius: var(--r-md); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); width: 100%;
}
textarea.input { min-height: 90px; }
.input:focus { border-color: var(--action); outline: none; box-shadow: 0 0 0 3px var(--action-soft); }
.field.has-error .input { border-color: var(--bad); }
.field .error { color: var(--bad); font-size: 0.875rem; }
.check { display: flex; gap: var(--s-2); align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 2px; }

.alert { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); margin-bottom: var(--s-4); border: 1px solid; display: flex; gap: var(--s-2); }
.alert-success { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.alert-error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.alert-info { background: var(--action-soft); border-color: color-mix(in srgb, var(--action) 30%, transparent); }

/* ---------- Unit strip: mastery as 10 bar-model units (the signature element) ---------- */
.units { --c: var(--action); display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; height: 14px; }
.units > i { background: var(--unit-empty); border-radius: 3px; }
.units > i.on { background: var(--c); }
.units > i.part { background: linear-gradient(90deg, var(--c) var(--p), var(--unit-empty) var(--p)); }
.units-lg { height: 22px; gap: 4px; }
.units-lg > i { border-radius: 4px; }
.mastery-row, .list > li.mastery-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 56px; gap: var(--s-3); align-items: center; }
.mastery-row .value { text-align: right; font-weight: 600; }
.mastery-none { color: var(--ink-3); font-size: 0.875rem; text-align: right; }
.band { display: inline-block; font-size: 0.78rem; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.band.mastered, .band.strong { background: var(--good-soft); color: var(--good); }
.band.improving { background: var(--action-soft); color: var(--action); }
.band.developing, .band.needs { background: var(--warn-soft); color: var(--warn); }

.strand-na { --c: var(--strand-na); } .strand-mg { --c: var(--strand-mg); } .strand-st { --c: var(--strand-st); }
.strand-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--ink-2); }
.strand-tag::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

/* ---------- Student home ---------- */
.hello { display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-5); }
.hello h1 { margin: 0; }
.continue { display: grid; grid-template-columns: 1fr auto; gap: var(--s-5); align-items: end; }
.continue .topic-name { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); font-weight: 600; margin: 2px 0 var(--s-3); }
.continue .meta { display: flex; gap: var(--s-4); flex-wrap: wrap; align-items: center; color: var(--ink-2); }
.continue .units { max-width: 360px; margin-top: var(--s-4); }

.strand-card { padding: var(--s-5); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--c); }
.strand-card .strand-tag { min-height: 2.6em; align-items: flex-start; }
.strand-card .strand-tag::before { margin-top: 0.35em; }
.strand-card .big { font-size: 1.9rem; font-weight: 600; line-height: 1; margin: var(--s-3) 0; }
.strand-card .big.none { font-size: 1rem; color: var(--ink-3); font-weight: 500; line-height: 1.9; }

.achv { display: flex; gap: var(--s-3); align-items: center; }
.achv-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3); flex: none; }
.achv.earned .achv-icon { background: color-mix(in srgb, var(--highlight) 30%, var(--surface)); color: var(--ink); }
.achv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-3); }
.achv-grid .achv { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); }
.achv:not(.earned) .achv-name { color: var(--ink-2); }

/* ---------- Learn ---------- */
.strand-block { margin-top: var(--s-6); }
.strand-block > h2 { display: flex; align-items: center; gap: var(--s-2); }
.strand-block > h2::before { content: ""; width: 14px; height: 14px; border-radius: 4px; background: var(--c); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-3); }
.topic-link {
  display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); text-decoration: none; color: var(--ink); min-height: 120px;
}
.topic-link:hover { border-color: var(--c); }
.topic-link .t-head { display: flex; align-items: center; gap: var(--s-3); font-weight: 600; }
.topic-link .t-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--c); flex: none; }
.topic-link .t-foot { margin-top: auto; }
.subtopic { padding: var(--s-4) 0; border-top: 1px solid var(--line); }
.subtopic:first-of-type { border-top: 0; }
.skill-list { list-style: none; padding: 0; margin: var(--s-2) 0 0; display: grid; gap: 6px; }
.skill-list li { display: flex; gap: var(--s-2); color: var(--ink-2); }
.skill-list li::before { content: ""; width: 8px; height: 8px; margin-top: 0.55em; border-radius: 2px; background: var(--c); flex: none; opacity: 0.7; }
.tabs { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-4); }
.tabs a { padding: 0.4rem 0.9rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); background: var(--surface); font-weight: 500; }
.tabs a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Practice ---------- */
.mode-card { display: grid; grid-template-columns: auto 1fr; gap: var(--s-4); align-items: start; padding: var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.mode-card h2 { margin-bottom: var(--s-1); }
.mode-card p { margin: 0; }
.mode-card .btn { grid-column: 2; justify-self: start; }
.mode-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--action-soft); color: var(--action); }
.mode-icon.warn { background: var(--warn-soft); color: var(--warn); }
form.topic-link .btn { align-self: flex-start; }
.strand-block > h3.strand-tag { font-size: 1rem; font-weight: 600; color: var(--ink); margin-bottom: var(--s-3); }

.q-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: var(--s-3); margin-bottom: var(--s-4); }
.q-top p { margin: 0; }
.q-progress { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.q-count { font-weight: 600; }
.q-dots { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.q-dots li { width: 22px; height: 12px; border-radius: 3px; background: var(--unit-empty); position: relative; }
.q-dots li a { position: absolute; inset: -6px 0; }
.q-dots li.right { background: var(--good); }
.q-dots li.wrong { background: var(--bad); }
.q-dots li.current { outline: 2px solid var(--ink); outline-offset: 2px; }
.q-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s-4); align-items: start; }
.q-side > .panel + .panel { margin-top: var(--s-4); }
.q-card { border-top: 4px solid var(--c, var(--action)); padding: var(--s-5) var(--s-6); }
.q-meta { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-bottom: var(--s-4); }
.chip-meta { font-size: 0.8rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-weight: 500; }
.chip-meta.info { background: var(--action-soft); color: var(--action); }
.chip-meta.warn { background: var(--warn-soft); color: var(--warn); }
.chip-meta .diff { letter-spacing: 1px; font-size: 0.7rem; }
.q-text { font-size: 1.2rem; line-height: 1.7; max-width: 62ch; }
.q-instr { color: var(--ink-2); }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.05; font-size: 0.86em; margin: 0 0.1em; }
.frac .fn { border-bottom: 1.5px solid currentColor; padding: 0 0.15em; }
.frac .fd { padding: 0 0.15em; }

.answer-form, .options, .parts { margin-top: var(--s-5); }
.options { border: 0; padding: 0; display: grid; gap: var(--s-2); }
.option { display: grid; grid-template-columns: auto auto 1fr auto; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: pointer; background: var(--surface); }
.option:hover { border-color: var(--action); }
.option input { width: 18px; height: 18px; accent-color: var(--action); margin: 0; }
.option:has(input:focus-visible) { box-shadow: var(--focus); }
.option.is-chosen { border-color: var(--action); background: var(--action-soft); }
.option.is-right { border-color: var(--good); background: var(--good-soft); }
.option.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.options[disabled] .option { cursor: default; }
.opt-key { font-weight: 700; width: 1.6em; height: 1.6em; display: grid; place-items: center; border-radius: 6px; background: var(--surface-2); font-size: 0.9rem; }
.opt-mark { color: var(--good); }
.parts { display: grid; gap: var(--s-4); }
.part-prompt { margin: 0 0 var(--s-2); }
.part-key { font-weight: 700; }
.ans-line { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; }
.ans-label { font-weight: 600; }
.ans-affix { font-weight: 600; color: var(--ink-2); }
.ans-input { width: min(240px, 100%); font-size: 1.15rem; font-weight: 600; text-align: center; border-width: 0 0 2px; border-radius: 0; background: transparent; padding: 0.35rem 0.5rem; }
.ans-input:focus { border-bottom-color: var(--action); }
.ans-input[readonly] { color: var(--ink); }
.part.is-right .ans-input { border-bottom-color: var(--good); }
.part.is-wrong .ans-input { border-bottom-color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.part-result { text-align: right; margin: var(--s-2) 0 0; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn-text { color: var(--warn); }
.answer-actions { justify-content: flex-end; margin-top: var(--s-5); }

.feedback { margin-top: var(--s-5); padding: var(--s-4) var(--s-5); border-radius: var(--r-md); border-left: 5px solid var(--ink-3); background: var(--surface-2); }
.feedback:focus { outline: none; }
.feedback h2 { font-size: 1.1rem; margin-bottom: var(--s-2); }
.feedback.is-right { border-left-color: var(--good); background: var(--good-soft); }
.feedback.is-partial { border-left-color: var(--warn); background: var(--warn-soft); }
.feedback.is-wrong { border-left-color: var(--bad); background: var(--bad-soft); }
.feedback p:last-child { margin-bottom: 0; }
.mistake { margin-top: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--surface); border-radius: var(--r-sm); }
.mistake p { margin: var(--s-1) 0 0; }
.hint-list { margin: 0 0 var(--s-3); padding-left: 1.2rem; display: grid; gap: var(--s-2); }
.hint-list li::marker { font-weight: 700; color: var(--action); }
.next-steps { display: grid; gap: var(--s-2); }
.next-steps .kv { margin-top: var(--s-2); }

.solution h3 { font-size: 1rem; margin: var(--s-4) 0 var(--s-2); }
.how-why { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.how-why > div { padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-2); }
.how-why h3 { margin-top: 0; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8rem; color: var(--action); }
.how-why .why h3 { color: var(--good); }
.how-why p { margin: 0; }
.working { font-variant-numeric: tabular-nums; line-height: 1.8; }
.steps { margin: 0; padding-left: 1.4rem; display: grid; gap: var(--s-3); }
.steps p { margin: 2px 0 0; }
.concept { margin: var(--s-4) 0 0; padding: var(--s-3) var(--s-4); border-left: 4px solid var(--highlight); background: color-mix(in srgb, var(--highlight) 12%, var(--surface)); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.alt { margin-top: var(--s-3); }
.alt summary { cursor: pointer; color: var(--action); font-weight: 500; }

.summary-list > li { align-items: flex-start; }
.result-dot { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; flex: none; font-size: 0.85rem; }
.result-dot.right { background: var(--good-soft); color: var(--good); }
.result-dot.wrong { background: var(--bad-soft); color: var(--bad); }
@media (max-width: 1100px) { .q-layout { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .q-card { padding: var(--s-4); }
  .how-why { grid-template-columns: 1fr; }
  .q-text { font-size: 1.1rem; }
  .ans-line { justify-content: flex-start; }
}

/* ---------- Question manager (admin) ---------- */
.row-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); flex-wrap: wrap; }
.row-head h1 { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.tab-n { font-size: 0.78rem; opacity: 0.75; margin-left: 2px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-3); align-items: end; }
.filters .field { margin: 0; }
.filters .grow-2 { grid-column: span 2; }
.q-cell { min-width: 280px; max-width: 520px; }
.status.qs-draft { background: var(--surface-2); color: var(--ink-2); }
.status.qs-in_review { background: var(--action-soft); color: var(--action); }
.status.qs-approved { background: var(--warn-soft); color: var(--warn); }
.status.qs-published { background: var(--good-soft); color: var(--good); }
.status.qs-archived { background: var(--surface-2); color: var(--ink-3); text-decoration: line-through; }
.h1 .status, h1 .status { font-size: 0.8rem; vertical-align: middle; }
.pager { margin-top: var(--s-4); }
.workflow { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-4); }
.wf-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 0; counter-reset: wf; }
.wf-steps li { counter-increment: wf; display: flex; align-items: center; gap: 6px; padding: 4px 14px 4px 0; color: var(--ink-3); font-weight: 500; font-size: 0.9rem; }
.wf-steps li::before { content: counter(wf); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; background: var(--surface-2); }
.wf-steps li + li { padding-left: 14px; border-left: 1px solid var(--line); }
.wf-steps li.done { color: var(--good); }
.wf-steps li.done::before { content: "✓"; background: var(--good-soft); }
.wf-steps li.now { color: var(--ink); }
.wf-steps li.now::before { background: var(--action); color: var(--action-ink); }
.wf-actions { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.wf-actions p { margin: 0; }
.reject-form { display: flex; gap: var(--s-2); align-items: flex-start; margin-top: var(--s-2); }
.reject-form textarea { min-width: 260px; }
.admin-q { grid-template-columns: minmax(0, 1fr) 340px; }
.admin-q > div > .panel + .panel { margin-top: var(--s-4); }
.checks.is-ok { border-left: 4px solid var(--good); }
.checks.is-bad { border-left: 4px solid var(--bad); }
.check-list { margin: 0 0 var(--s-3); padding-left: 1.1rem; display: grid; gap: 4px; font-size: 0.9rem; }
.check-list.good { color: var(--ink-2); }
.check-list.good li::marker { color: var(--good); }
.q-editor fieldset.panel { border: 1px solid var(--line); margin: 0 0 var(--s-4); min-width: 0; }
.q-editor legend { font-weight: 600; font-size: 1.15rem; padding: 0 var(--s-2); margin-left: calc(-1 * var(--s-2)); }
.q-editor h3 { font-size: 1rem; margin: var(--s-5) 0 var(--s-3); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 var(--s-3); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-half { grid-column: span 2; }
.form-grid .span-full { grid-column: 1 / -1; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.95rem; }
.part-edit { border-top: 1px dashed var(--line); padding-top: var(--s-4); margin-top: var(--s-2); }
.part-edit:first-of-type { border-top: 0; padding-top: 0; }
.answer-row { display: grid; grid-template-columns: 1.3fr 1fr 0.9fr 0.8fr; gap: 0 var(--s-3); padding: var(--s-3) var(--s-3) 0; background: var(--surface-2); border-radius: var(--r-md); margin-bottom: var(--s-3); }
.checks-inline { grid-column: 1 / -1; display: flex; gap: var(--s-2) var(--s-5); flex-wrap: wrap; padding-bottom: var(--s-3); font-size: 0.9rem; }
.checks-inline .check input { width: 18px; height: 18px; }
.option-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 140px auto; gap: var(--s-3); align-items: end; }
.option-row .check { margin-bottom: var(--s-4); white-space: nowrap; }
.step-row { display: grid; grid-template-columns: 28px 1fr 1.3fr 1.6fr; gap: var(--s-3); align-items: end; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--action-soft); color: var(--action); display: grid; place-items: center; font-weight: 600; font-size: 0.85rem; margin-bottom: calc(var(--s-4) + 9px); }
.mistake-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 var(--s-3); padding: var(--s-3) var(--s-3) 0; border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: var(--s-3); }
.mistake-row .span-full { grid-column: 1 / -1; }
.narrow-form { max-width: 560px; }
.save-bar { position: sticky; bottom: var(--s-3); display: flex; gap: var(--s-4); align-items: end; flex-wrap: wrap; box-shadow: var(--shadow); z-index: 5; }
.save-bar .field { margin: 0; flex: 1 1 280px; }
[hidden] { display: none !important; }
@media (max-width: 900px) {
  .form-grid, .mistake-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answer-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .option-row { grid-template-columns: 56px minmax(0, 1fr); }
  .step-row { grid-template-columns: 1fr; }
  .step-n { display: none; }
  .filters .grow-2 { grid-column: 1 / -1; }
  .admin-q { grid-template-columns: 1fr; }
  .save-bar { bottom: 80px; }
}

/* ---------- Coming soon ---------- */
.soon-panel { max-width: 640px; }
.soon-panel .phase { display: inline-block; font-weight: 600; color: var(--action); margin-bottom: var(--s-2); }

/* ---------- Tables (admin) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 600; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.status { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.status-active { background: var(--good-soft); color: var(--good); }
.status-locked, .status-disabled { background: var(--bad-soft); color: var(--bad); }
.status-pending_verification, .status-invalidated, .status-expired, .status-logged_out { background: var(--surface-2); color: var(--ink-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s-4); margin: 0; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; }
.stat { padding: var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.stat .n { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.stat .l { color: var(--ink-2); font-size: 0.9rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--s-3); }
.code-box { font-size: 1.8rem; font-weight: 700; letter-spacing: 0.18em; padding: var(--s-4) var(--s-5); border: 2px dashed var(--action); border-radius: var(--r-md); display: inline-block; background: var(--action-soft); }
.temp-pass { font-size: 1.3rem; font-weight: 600; padding: var(--s-3) var(--s-4); background: var(--warn-soft); border-radius: var(--r-md); display: inline-block; }

/* Curriculum tree (admin) */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: var(--s-5); border-left: 2px solid var(--line); margin-left: var(--s-3); }
.tree-node { display: flex; align-items: center; gap: var(--s-2); padding: 6px 0; flex-wrap: wrap; }
.tree-node .name { font-weight: 500; }
.tree-node .kind { font-size: 0.75rem; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.tree-node .hidden-tag { font-size: 0.75rem; color: var(--warn); background: var(--warn-soft); border-radius: 999px; padding: 0 6px; }
.tree-node .actions { margin-left: auto; display: flex; gap: 2px; flex-wrap: wrap; }
details.editor > summary { cursor: pointer; list-style: none; color: var(--action); font-size: 0.875rem; padding: 2px 6px; border-radius: var(--r-sm); }
details.editor > summary::-webkit-details-marker { display: none; }
details.editor[open] { flex-basis: 100%; }
details.subtree > summary { cursor: pointer; font-size: 0.85rem; color: var(--ink-2); padding: 2px 0 2px var(--s-3); margin-left: var(--s-3); }
details.editor .editor-body { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-4); margin: var(--s-2) 0; display: grid; gap: var(--s-2); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
details.editor .field { margin: 0; }

/* ---------- Public / auth ---------- */
.public { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.public-art { padding: var(--s-7); display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); }
.public-art .brand { font-size: 1.2rem; }
.public-form { display: flex; align-items: center; justify-content: center; padding: var(--s-6) var(--s-5); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { margin-bottom: var(--s-2); }
.auth-alt { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--line); color: var(--ink-2); font-size: 0.95rem; }
.demo-model { max-width: 460px; }
.demo-model .q { font-size: 1.15rem; font-weight: 500; margin-bottom: var(--s-5); max-width: 32ch; }
.bm-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.bm-row .lbl { font-weight: 600; color: var(--ink-2); }
.bm-bar { display: flex; gap: 0; }
.bm-unit { height: 38px; flex: 0 0 60px; border: 2px solid var(--ink); margin-left: -2px; display: grid; place-items: center; font-weight: 600; background: var(--surface); }
.bm-unit:first-child { margin-left: 0; }
.bm-unit.a { background: color-mix(in srgb, var(--strand-na) 18%, var(--surface)); }
.bm-unit.b { background: color-mix(in srgb, var(--strand-st) 22%, var(--surface)); }
.bm-unit.bm-total { flex-basis: 296px; border-style: dashed; background: transparent; font-weight: 600; }
.bm-working { margin-top: var(--s-5); display: grid; gap: 4px; color: var(--ink-2); }
.bm-working b { color: var(--ink); }
.landing-points { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-2); color: var(--ink-2); }

/* ---------- Errors / minimal ---------- */
.minimal { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5); }
.minimal .panel { max-width: 520px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: var(--s-3) var(--s-4); }
  .topbar .brand { white-space: nowrap; display: flex; }
  .content { padding: var(--s-4) var(--s-4) 96px; }
  .menu-toggle { display: block; position: relative; }
  .menu-toggle > summary { list-style: none; cursor: pointer; padding: 6px; border-radius: var(--r-sm); }
  .menu-toggle > summary::-webkit-details-marker { display: none; }
  .menu-toggle .menu-panel { position: absolute; right: 0; top: 44px; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: var(--s-2); }
  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.72rem; color: var(--ink-3); text-decoration: none; padding: 4px 0; border-radius: var(--r-sm); }
  .bottom-nav a[aria-current="page"] { color: var(--action); }
  .public { grid-template-columns: 1fr; }
  .public-art { display: none; }
  .continue { grid-template-columns: 1fr; }
  .mastery-row { grid-template-columns: minmax(0, 1fr) 96px 48px; }
}
@media (max-width: 900px) { .shell { background: none; } }
@media (max-width: 640px) {
  .topbar .brand span { display: none; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .panel-feature { padding: var(--s-5); }
  .chip-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
