/* Grile — styles. Tokens from the Claude Design canvas "Grile — design" (grile-tokens.css). */
:root {
  color-scheme: light dark;
  --bg: #F6F0E8; --surface: #FDF9F4; --surface-sunk: #EFE5DA; --ink: #231A15; --muted: #6B5D54;
  --line: #E2D5C8; --track: #EADFD5;
  --primary: #B54A2A; --primary-hover: #9C3D21; --primary-soft: #F5E1D6; --on-primary: #FFFFFF;
  --chip-bg: #F1E5DA; --chip-text: #7E3218;
  --xp: #F2B33D; --xp-soft: #F8DC9C; --xp-ring: #FBE3A8; --on-xp: #231A15; --xp-text: #7A4B00;
  --ok: #1A6B41; --ok-soft: #E1F1E7; --on-ok: #FFFFFF;
  --bad: #9F1D3A; --bad-soft: #F8E0E5; --on-bad: #FFFFFF;
  --warn: #E0A325; --warn-soft: #FBEFD3; --warn-text: #6B4400; --on-warn: #231A15;
  --disabled-bg: #E6DACE; --disabled-fg: #7A6B60;
  --focus-ring: 0 0 0 3px #F6F0E8, 0 0 0 5px #B54A2A;
  --nav-bg: #231A15; --nav-fg: #E9DDD3; --nav-active-bg: #EE8664; --nav-active-fg: #231A15;
  --stage-bg: #14100D; --stage-surface: #211A16; --stage-line: #3A2F29; --stage-ink: #F4ECE5; --stage-muted: #B9A89D;
  --font-display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius-xs: 6px; --radius-sm: 8px; --radius-md: 14px; --radius-lg: 20px; --radius-xl: 24px;
  --shadow-card: 0 1px 2px rgba(35, 26, 21, .06);
  --shadow-float: 0 8px 24px rgba(35, 26, 21, .14);
  --shadow-sheet: 0 -10px 30px rgba(35, 26, 21, .14);
  --scrim: rgba(35, 26, 21, .35);
  --dur-fast: 150ms; --dur: 250ms; --dur-slow: 900ms; --ease: cubic-bezier(.2, .8, .2, 1);
  --side: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14100D; --surface: #211A16; --surface-sunk: #2E2520; --ink: #F4ECE5; --muted: #B9A89D;
    --line: #3A2F29; --track: #3A2F29;
    --primary: #EE8664; --primary-hover: #F49B7D; --primary-soft: #3A241B; --on-primary: #1A120E;
    --chip-bg: #2E231D; --chip-text: #F2A98E;
    --xp: #F5C451; --xp-soft: #7A5F22; --xp-ring: #4A3A14; --on-xp: #1A120E; --xp-text: #F5C451;
    --ok: #7EDCA6; --ok-soft: #16301F; --on-ok: #0E1F15;
    --bad: #F79AAB; --bad-soft: #3B1820; --on-bad: #2A0E14;
    --warn: #F5C451; --warn-soft: #3A2C12; --warn-text: #F5C451; --on-warn: #1A120E;
    --disabled-bg: #2E2520; --disabled-fg: #9C8B80;
    --focus-ring: 0 0 0 3px #14100D, 0 0 0 5px #EE8664;
    --nav-bg: #2A211C; --nav-fg: #D9CBC0; --nav-active-bg: #EE8664; --nav-active-fg: #1A120E;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4); --shadow-float: 0 8px 24px rgba(0, 0, 0, .5); --shadow-sheet: 0 -10px 30px rgba(0, 0, 0, .5);
    --scrim: rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  --bg: #14100D; --surface: #211A16; --surface-sunk: #2E2520; --ink: #F4ECE5; --muted: #B9A89D;
  --line: #3A2F29; --track: #3A2F29;
  --primary: #EE8664; --primary-hover: #F49B7D; --primary-soft: #3A241B; --on-primary: #1A120E;
  --chip-bg: #2E231D; --chip-text: #F2A98E;
  --xp: #F5C451; --xp-soft: #7A5F22; --xp-ring: #4A3A14; --on-xp: #1A120E; --xp-text: #F5C451;
  --ok: #7EDCA6; --ok-soft: #16301F; --on-ok: #0E1F15;
  --bad: #F79AAB; --bad-soft: #3B1820; --on-bad: #2A0E14;
  --warn: #F5C451; --warn-soft: #3A2C12; --warn-text: #F5C451; --on-warn: #1A120E;
  --disabled-bg: #2E2520; --disabled-fg: #9C8B80;
  --focus-ring: 0 0 0 3px #14100D, 0 0 0 5px #EE8664;
  --nav-bg: #2A211C; --nav-fg: #D9CBC0; --nav-active-bg: #EE8664; --nav-active-fg: #1A120E;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .4); --shadow-float: 0 8px 24px rgba(0, 0, 0, .5); --shadow-sheet: 0 -10px 30px rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .55);
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-reduced-motion: reduce) { :root { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; } }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -.01em; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0 0 .75em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.muted { color: var(--muted); } .small { font-size: 14px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; } .pre { white-space: pre-wrap; } .hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; } .grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- shell ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: -.03em; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo-mark { --s: 32px; width: var(--s); height: var(--s); border-radius: calc(var(--s) * .25); background: var(--primary); display: inline-flex; flex-direction: column; justify-content: center; gap: calc(var(--s) * .1); padding: 0 calc(var(--s) * .2); flex: none; }
.logo-mark i { display: block; height: calc(var(--s) * .14); border-radius: 99px; background: var(--surface); }
.logo-mark i:last-child { width: 60%; background: var(--xp); }
main { padding: 16px 16px 120px; max-width: 1180px; margin: 0 auto; }
.bottomnav {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
  height: 64px; border-radius: 22px; background: var(--nav-bg); color: var(--nav-fg); box-shadow: var(--shadow-float);
  display: flex; align-items: center; justify-content: space-around; padding: 0 8px; max-width: 520px; margin: 0 auto;
}
.bottomnav a { display: flex; align-items: center; gap: 6px; height: 44px; min-width: 44px; justify-content: center; padding: 0 10px; border-radius: 14px; color: var(--nav-fg); font-weight: 700; font-size: 14px; }
.bottomnav a:hover { text-decoration: none; }
.bottomnav a .lbl { display: none; }
.bottomnav a.on { background: var(--nav-active-bg); color: var(--nav-active-fg); }
.bottomnav a.on .lbl { display: inline; }
.bottomnav a.play { width: 56px; height: 56px; border-radius: 18px; background: var(--xp); color: var(--on-xp); transform: translateY(-14px); box-shadow: var(--shadow-float); }
.sidebar { display: none; }
@media (min-width: 900px) {
  .bottomnav { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: 6px; position: fixed; top: 0; bottom: 0; left: 0; width: var(--side); padding: 24px 16px; border-right: 1px solid var(--line); background: var(--bg); z-index: 20; }
  .sidebar .logo { margin: 0 8px 24px; }
  .sidebar a.item { display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 14px; border-radius: var(--radius-md); color: var(--muted); font-weight: 600; }
  .sidebar a.item:hover { text-decoration: none; background: var(--surface-sunk); color: var(--ink); }
  .sidebar a.item.on { background: var(--primary-soft); color: var(--chip-text); }
  .sidebar .play { margin-top: auto; }
  body.has-side main { margin-left: var(--side); padding: 32px 40px 48px; }
}
body.focus .bottomnav, body.focus .sidebar { display: none !important; }
body.focus #view { margin-left: 0 !important; padding: 0 !important; max-width: none; }

/* page header with chips */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.chip.xp { background: var(--xp); color: var(--on-xp); transition: box-shadow var(--dur) var(--ease); }
.chip.xp.pulse { box-shadow: 0 0 0 5px var(--xp-ring); }
.chip.streak { color: var(--xp-text); padding: 0 6px; }
.chip.streak svg { color: var(--xp); fill: var(--xp); }
.chip.streak.off { color: var(--muted); } .chip.streak.off svg { color: var(--muted); fill: none; }
.chip.type { background: var(--chip-bg); color: var(--chip-text); height: 28px; font-size: 13px; }
.chip.soft { background: var(--surface-sunk); color: var(--ink); }

/* ---------- surfaces & buttons ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-card); }
.card.tight { padding: 16px; }
.card.flat { box-shadow: none; }
.card.accent { border: 2px solid var(--primary); }
.card + .card, .card + .section, .section + .card { margin-top: 16px; }
.section { margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.gold { background: var(--xp); border-color: var(--xp); color: var(--on-xp); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-sunk); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn.xs { min-height: 34px; padding: 0 10px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 17px; }
.btn:disabled, .btn.disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-fg); cursor: not-allowed; transform: none; }
.kbd { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 1px 7px; line-height: 1.4; }
.btn .kbd { color: inherit; border-color: currentColor; opacity: .75; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-height: 48px; }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.error-box { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; border-radius: 12px; font-weight: 600; }
.note { background: var(--surface-sunk); padding: 12px 14px; border-radius: 12px; }
.seg { display: inline-flex; background: var(--surface-sunk); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; font-weight: 700; color: var(--muted); padding: 0 14px; height: 36px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }

/* ---------- progress ---------- */
.bar { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s var(--ease); }
.bar.gold > i { background: var(--xp); } .bar.ok > i { background: var(--ok); } .bar.thick { height: 12px; }
.passes { display: inline-flex; gap: 3px; align-items: center; }
.passes i { width: 18px; height: 6px; border-radius: 3px; background: var(--track); position: relative; overflow: hidden; }
.passes i.done { background: var(--xp); }
.passes i.cur { background: var(--track); }
.passes i.cur > b { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w, 0%); background: var(--xp-soft); }
.passes.big i { width: 28px; height: 8px; border-radius: 4px; }
.ring { --p: 0; --size: 56px; --c: var(--ok); width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; flex: none; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--track) 0); }
.ring > span { width: calc(var(--size) - 10px); height: calc(var(--size) - 10px); border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-sunk); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn-text); } .pill.primary { background: var(--primary-soft); color: var(--chip-text); }
.pill.gold { background: var(--xp); color: var(--on-xp); }

/* ---------- home ---------- */
.home-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.home-grid > * { min-width: 0; }
@media (min-width: 900px) { .home-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; } }
.continue-card { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.continue-card .eyebrow { color: inherit; opacity: .8; }
.continue-card .btn:not(.ghost) { background: var(--surface); color: var(--ink); border-color: var(--surface); }
.continue-card .btn.ghost { color: inherit; border-color: rgba(255, 255, 255, .45); }
.continue-card .btn.ghost:hover { background: rgba(255, 255, 255, .12); color: inherit; }
.level-card .title { font-family: var(--font-display); font-size: 26px; font-weight: 800; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 14px; align-items: center; padding: 14px 4px; border-top: 1px solid var(--line); color: inherit; }
.list-item:first-child { border-top: 0; }
a.list-item:hover { text-decoration: none; background: var(--surface-sunk); border-radius: 12px; }
.list-item .title { font-weight: 700; }
.big-num { font-family: var(--font-display); font-size: 40px; font-weight: 800; line-height: 1; }

/* ---------- exam page ---------- */
.exam-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.ch-table { width: 100%; border-collapse: collapse; }
.ch-table th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 8px; }
.ch-table td { padding: 12px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.ch-table .pc { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pass-cell { display: flex; flex-direction: column; gap: 4px; min-width: 70px; }
.mastery-cell { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.mastery-cell .bar { flex: 1; }
.book-head { display: flex; align-items: center; gap: 12px; cursor: pointer; background: none; border: 0; width: 100%; text-align: left; padding: 0; }
.ch-row { display: flex; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
@media (max-width: 899px) { .desk-only { display: none !important; } }
@media (min-width: 900px) { .phone-only { display: none !important; } }

/* chapter map */
.map { position: relative; padding: 8px 0 24px; }
.map-node { position: relative; display: flex; flex-direction: column; align-items: center; width: 150px; text-align: center; gap: 6px; color: inherit; }
.map-node:hover { text-decoration: none; }
.map-row { display: flex; }
.map-row:nth-child(4n+1) { justify-content: center; }
.map-row:nth-child(4n+2) { justify-content: flex-start; padding-left: 12%; }
.map-row:nth-child(4n+3) { justify-content: center; }
.map-row:nth-child(4n) { justify-content: flex-end; padding-right: 12%; }
.map-dot { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--track) 0); position: relative; transition: transform var(--dur-fast); }
.map-node:hover .map-dot { transform: scale(1.05); }
.map-dot > span { width: 62px; height: 62px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 22px; border: 2px solid var(--line); }
.map-node.done3 .map-dot > span { background: var(--xp); border-color: var(--xp); color: var(--on-xp); }
.map-node.current .map-dot > span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.map-node .t { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.map-node .here { position: absolute; top: -30px; background: var(--primary); color: var(--on-primary); font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-svg path { fill: none; stroke: var(--line); stroke-width: 6; stroke-dasharray: 2 12; stroke-linecap: round; }

/* ---------- question card (focus mode) ---------- */
.qwrap { min-height: 100vh; display: flex; flex-direction: column; }
.qhead { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.qhead .bar { flex: 1; }
.qhead .meta { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.qbody { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.qtext { font-family: var(--font-display); font-size: 22px; line-height: 1.3; font-weight: 600; white-space: pre-wrap; }
.qfoot { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); width: 100%; max-width: 760px; margin: 0 auto; }
.keys-hint { display: none; justify-content: center; gap: 24px; padding: 10px 0 18px; font-size: 13px; color: var(--muted); }
@media (min-width: 900px) {
  .qhead { padding: 14px 32px; border-bottom: 1px solid var(--line); gap: 20px; }
  .qbody { padding-top: 44px; gap: 20px; }
  .qtext { font-size: 30px; line-height: 1.25; }
  .qfoot { display: flex; justify-content: flex-end; padding-bottom: 8px; }
  .qfoot .btn { width: auto; min-width: 200px; }
  .keys-hint { display: flex; }
  .opt .kbd { display: inline-flex; }
}
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 10px 16px; text-align: left;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-md); cursor: pointer; color: var(--ink);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.opt:hover:not(:disabled) { border-color: var(--muted); }
.opt .badge { width: 30px; height: 30px; flex: none; border-radius: var(--radius-sm); background: var(--surface-sunk); border: 2px solid var(--surface-sunk); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.opt .t { flex: 1; font-size: 16px; line-height: 1.35; font-weight: 500; white-space: pre-wrap; }
.opt .box { width: 22px; height: 22px; flex: none; border: 2px solid var(--muted); border-radius: 11px; display: grid; place-items: center; color: var(--on-primary); }
.opt.multi .box { border-radius: var(--radius-xs); }
.opt .kbd { display: none; }
.opt .res { flex: none; display: none; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; }
.opt.sel { border: 2px solid var(--primary); background: var(--primary-soft); padding: 9px 15px; }
.opt.sel .badge { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.opt.sel .box { background: var(--primary); border-color: var(--primary); }
.opt:disabled { cursor: default; }
.opt.locked .box, .opt.locked .kbd { display: none !important; }
.opt.locked .res { display: flex; }
.opt.right { border: 2px solid var(--ok); background: var(--ok-soft); padding: 9px 15px; }
.opt.right .badge { background: var(--ok); border-color: var(--ok); color: var(--on-ok); } .opt.right .res { color: var(--ok); }
.opt.wrong { border: 2px solid var(--bad); background: var(--bad-soft); padding: 9px 15px; }
.opt.wrong .badge { background: var(--bad); border-color: var(--bad); color: var(--on-bad); } .opt.wrong .res { color: var(--bad); }
.opt.missed { border: 2px dashed var(--ok); padding: 9px 15px; }
.opt.missed .badge { background: transparent; border-color: var(--ok); color: var(--ok); } .opt.missed .res { color: var(--ok); }
.opt.dim { color: var(--muted); }
@media (min-width: 900px) { .opt .t { font-size: 17px; } }

/* verdict: bottom sheet on phone, inline panel on laptop */
.verdict { border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sheet); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; border-top: 3px solid var(--vc); background: var(--vs); animation: rise var(--dur) var(--ease); max-height: 70vh; overflow: auto; }
.verdict.ok { --vc: var(--ok); --vs: var(--ok-soft); --vt: var(--ok); --vi: var(--on-ok); }
.verdict.bad { --vc: var(--bad); --vs: var(--bad-soft); --vt: var(--bad); --vi: var(--on-bad); }
.verdict.part { --vc: var(--warn); --vs: var(--warn-soft); --vt: var(--warn-text); --vi: var(--on-warn); }
.verdict .vhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.verdict .vicon { width: 36px; height: 36px; border-radius: 18px; background: var(--vc); color: var(--vi); display: grid; place-items: center; flex: none; }
.verdict .vtitle { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--vt); }
.verdict .vsub { font-size: 14px; font-weight: 700; color: var(--vt); }
.verdict .vbody { font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.verdict .btn { width: 100%; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 900px) {
  .verdict { position: static; border-radius: 18px; border: 2px solid var(--vc); box-shadow: none; flex-direction: row; align-items: center; gap: 16px; padding: 16px 18px; max-height: none; animation: none; }
  .verdict .vmain { flex: 1; display: flex; flex-direction: column; gap: 4px; }
  .verdict .btn { width: auto; flex: none; }
}
.qbody.has-sheet { padding-bottom: 280px; }
@media (min-width: 900px) { .qbody.has-sheet { padding-bottom: 24px; } }
.explain-grid { display: grid; gap: 12px; }
@media (min-width: 900px) { .explain-grid { grid-template-columns: 1fr 1fr; } }
.explain-box { border-radius: 16px; background: var(--surface); border: 1px solid var(--line); padding: 16px 18px; white-space: pre-wrap; line-height: 1.55; }
.explain-box.mine { background: transparent; border-style: dashed; color: var(--muted); }
.grade-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grade-row .btn { flex: 1; min-height: 52px; border-width: 2px; }
.grade-row .g0 { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.grade-row .g1 { border-color: var(--warn); background: var(--warn-soft); color: var(--warn-text); }
.grade-row .g2 { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.reward-chips { display: inline-flex; gap: 6px; }
.combo { display: inline-flex; align-items: center; gap: 4px; background: var(--primary); color: var(--on-primary); font-size: 13px; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.combo svg { color: var(--xp); fill: var(--xp); }
.xp-float { position: fixed; pointer-events: none; z-index: 60; font-family: var(--font-display); font-weight: 800; color: var(--xp-text); font-size: 20px; animation: float 1s var(--ease) forwards; }
@keyframes float { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-40px); } }

/* ---------- simulation ---------- */
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; display: inline-flex; align-items: center; gap: 6px; }
.timer.low { color: var(--bad); }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.navgrid button { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; position: relative; }
.navgrid button.ans { background: var(--primary-soft); color: var(--ink); border-color: var(--primary-soft); }
.navgrid button.cur { border: 2px solid var(--primary); color: var(--ink); }
.navgrid button.flag::after { content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--xp); }
.navgrid button.r-good { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-soft); }
.navgrid button.r-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-soft); }
.navgrid button.r-mid { background: var(--warn-soft); color: var(--warn-text); border-color: var(--warn-soft); }
.sim-layout { display: grid; gap: 24px; width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px 16px 24px; }
@media (min-width: 1100px) { .sim-layout { grid-template-columns: 1fr 320px; padding-top: 32px; } .sim-side { position: sticky; top: 24px; align-self: start; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line); }
.legend .l-ans::before { background: var(--primary-soft); border-color: var(--primary-soft); }
.legend .l-flag::before { background: var(--xp); border-color: var(--xp); border-radius: 50%; }
.legend .l-cur::before { border: 2px solid var(--primary); }

/* ---------- live (always dark stage) ---------- */
.stage { min-height: 100vh; background: var(--stage-bg); color: var(--stage-ink); --surface: var(--stage-surface); --line: var(--stage-line); --ink: var(--stage-ink); --muted: var(--stage-muted); --track: #3A2F29; --primary: #EE8664; --on-primary: #1A120E; --primary-soft: #3A241B; --surface-sunk: #2E2520; --ok: #7EDCA6; --ok-soft: #16301F; --on-ok: #0E1F15; --bad: #F79AAB; --bad-soft: #3B1820; --on-bad: #2A0E14; --warn: #F5C451; --warn-soft: #3A2C12; --warn-text: #F5C451; --xp: #F5C451; --on-xp: #1A120E; --xp-text: #F5C451; --chip-bg: #2E231D; --chip-text: #F2A98E; }
.live-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; letter-spacing: .08em; color: #F79AAB; }
.live-tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #F79AAB; }
.avatars { display: flex; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--surface-sunk); border: 2px solid var(--stage-bg); margin-left: -6px; color: var(--ink); }
.avatar.done { background: var(--ok); color: var(--on-ok); }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.lb-row.me { border: 2px solid var(--primary); background: var(--primary-soft); }
.lb-row .mv { font-size: 12px; font-weight: 800; min-width: 28px; text-align: right; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 16px 0; }
.podium > div { text-align: center; flex: 1; max-width: 170px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.podium .col { width: 100%; border-radius: 14px 14px 0 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 32px; font-weight: 800; }
.podium .p1 { background: var(--xp); color: var(--on-xp); } .podium .p2 { background: var(--surface-sunk); } .podium .p3 { background: #3A241B; color: var(--primary); }
.dist { display: flex; flex-direction: column; gap: 6px; }
.dist .r { display: grid; grid-template-columns: 24px 1fr 28px; gap: 8px; align-items: center; font-size: 14px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-top: 0; }
.table tr.me td { background: var(--primary-soft); }
.table-wrap { overflow-x: auto; }
.rank { font-weight: 800; width: 2.5rem; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { color: var(--primary); border-color: var(--primary); }

/* ---------- profile: levels & badges ---------- */
.ladder { display: flex; flex-direction: column; gap: 6px; }
.ladder .step { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); }
.ladder .step.past { color: var(--muted); }
.ladder .step.now { border: 2px solid var(--primary); background: var(--primary-soft); }
.ladder .step .n { font-family: var(--font-display); font-weight: 800; width: 28px; }
.badges { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.badge-tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 16px 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
.badge-tile .medal { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--xp); color: var(--on-xp); }
.badge-tile.locked { opacity: .55; }
.badge-tile.locked .medal { background: var(--surface-sunk); color: var(--muted); }
.badge-tile .bt { font-weight: 700; font-size: 14px; }
.badge-tile .bd { font-size: 12px; color: var(--muted); }

/* ---------- admin ---------- */
.tree-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; flex-wrap: wrap; }
.tree-row .grow { font-weight: 600; }
.tree-book { margin-left: 16px; } .tree-ch { margin-left: 32px; }
.qedit .optrow { display: grid; grid-template-columns: 28px 1fr 40px; gap: 8px; align-items: center; margin-bottom: 6px; }
.qitem { border-top: 1px solid var(--line); padding: 14px 0; } .qitem:first-child { border-top: 0; }
.qitem .opts-mini { margin: 6px 0 0; padding-left: 1.2rem; font-size: 14px; }
.qitem .opts-mini li.c { color: var(--ok); font-weight: 700; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85em; }

/* ---------- overlays ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 420px); }
@media (min-width: 900px) { .toasts { bottom: 24px; left: auto; right: 24px; transform: none; } }
.toast { display: flex; align-items: center; gap: 10px; background: var(--nav-bg); color: var(--nav-fg); padding: 12px 16px; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow-float); animation: rise var(--dur) var(--ease); width: 100%; }
.toast.good { background: var(--xp); color: var(--on-xp); } .toast.bad { background: var(--bad); color: var(--on-bad); }
.overlay { position: fixed; inset: 0; z-index: 70; background: var(--scrim); display: grid; place-items: center; padding: 16px; animation: fade var(--dur-fast) ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; width: min(100%, 520px); max-height: 90vh; overflow: auto; box-shadow: var(--shadow-float); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.modal.dark { background: var(--nav-bg); color: #F6EEE8; }
.celebrate { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.celebrate .huge { font-family: var(--font-display); font-size: 40px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.celebrate .medal { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--xp); color: var(--on-xp); }
.confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 90; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
.center-page { max-width: 420px; margin: 8vh auto 0; }
.loading { padding: 3rem 0; text-align: center; color: var(--muted); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .confetti, .xp-float { display: none; } }

/* theme switch + logout in the side menu */
.side-foot { display: flex; gap: 8px; margin-top: 12px; }
.side-foot .btn { flex: 1; min-width: 0; padding: 0 10px; font-size: 14px; min-height: 44px; }
.side-foot .btn:last-child { flex: none; }
.icon-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; }

/* ---------- review (Corectură) ---------- */
.review-layout { display: grid; gap: 20px; width: 100%; max-width: 1500px; margin: 0 auto; padding: 12px 16px 24px; }
@media (min-width: 1100px) { .review-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-top: 20px; } .scan-wrap { position: sticky; top: 12px; align-self: start; } }
.scan-box { height: min(78vh, 1100px); overflow: auto; background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--radius-md); cursor: grab; touch-action: none; }
.scan-box:active { cursor: grabbing; }
.scan-box img { display: block; width: 100%; user-select: none; }
@media (max-width: 1099px) { .scan-box { height: 55vh; } }
.review-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.review-opt { display: grid; grid-template-columns: 40px 1fr 34px; gap: 8px; align-items: center; }
.review-opt.on input { border-color: var(--ok); background: var(--ok-soft); }
.review-opt .btn.primary { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.ocr-diff { font-size: 13px; line-height: 1.5; color: var(--muted); padding: 6px 10px; border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 6px; }
.ocr-diff mark { background: var(--xp-soft); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.ocr-diff s { color: var(--bad); }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
.key-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.key-cell { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); position: relative; }
.key-cell.changed { border: 2px solid var(--primary); }
.key-cell.hidden-q { border-style: dashed; }
.key-cell .key-n { width: 34px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.key-cell button { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 700; font-size: 12px; cursor: pointer; }
.key-cell button.on { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.key-cell .key-ok { position: absolute; top: 3px; right: 5px; color: var(--ok); }

/* head-to-head */
.cmp-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); text-align: center; }
.cmp-row:first-of-type { border-top: 0; }
.cmp-row > :first-child { text-align: right; } .cmp-row > :last-child { text-align: left; }
.cmp-row .win { color: var(--ok); }
.cmp-head { padding-bottom: 14px; }
.cmp-ch { padding: 8px 0; border-top: 1px solid var(--line); }
.cmp-bars { display: grid; gap: 4px; margin: 6px 0 4px; }
