/* World: an answer sheet filled in with blue ink. Cool ink neutrals, one blue accent.
   Signature: lettered answer bubbles that fill with blue (round = choose 1, square = choose several). */
:root {
  --bg: #f5f7fa; --card: #ffffff; --raised: #eceff4;
  --fg: #111827; --fg2: #4b5565; --muted: #6b7487;
  --line: rgba(17, 24, 39, .08); --line-strong: rgba(17, 24, 39, .18);
  --accent: #2563eb; --accent-hover: #1d4ed8; --on-accent: #ffffff;
  --accent-soft: #eef3ff; --accent-ink: #1d4ed8;
  --ok: #15803d; --ok-soft: #effaf3; --bad: #b91c1c; --bad-soft: #fdf2f2;
  --shadow: 0 1px 2px rgba(17, 24, 39, .05);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d14; --card: #11141c; --raised: #1a1e28;
    --fg: #eef0f5; --fg2: #a3a9b8; --muted: #8a92a6;
    --line: rgba(238, 240, 245, .08); --line-strong: rgba(238, 240, 245, .16);
    --accent: #60a5fa; --accent-hover: #93c5fd; --on-accent: #0b0d14;
    --accent-soft: rgba(96, 165, 250, .12); --accent-ink: #93c5fd;
    --ok: #4cc38a; --ok-soft: rgba(76, 195, 138, .1); --bad: #f87171; --bad-soft: rgba(248, 113, 113, .1);
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; -webkit-tap-highlight-color: transparent; background: var(--bg); color: var(--fg); font: 16px/24px 'Instrument Sans', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, p, ul, dl, dd { margin: 0; }
h2 { font-size: 20px; line-height: 28px; font-weight: 500; }
code { font: 14px var(--mono); }
.muted { color: var(--muted); font-size: 14px; line-height: 20px; }
.icon { flex: none; }
.vh { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

/* ---- Top bar ---- */
.top { position: sticky; top: 0; z-index: 2; height: 64px; padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: var(--fg); font-family: inherit; font-size: 16px; font-weight: 500; line-height: 1; cursor: pointer; }
span.brand { cursor: default; }
.mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font: 500 12px/1 var(--mono); }
.top-right { display: flex; align-items: center; gap: 16px; }
.timer { display: inline-flex; align-items: center; gap: 8px; font: 500 15px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--fg); }
.timer.low { color: var(--bad); }

main { max-width: 720px; margin: 0 auto; padding: 48px max(24px, env(safe-area-inset-right)) 96px max(24px, env(safe-area-inset-left)); }
.enter { animation: rise 300ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---- Buttons ---- */
.primary, .secondary { white-space: nowrap; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid transparent; font-family: inherit; font-size: 16px; font-weight: 500; line-height: 1; cursor: pointer; transition: background-color 150ms var(--ease), border-color 150ms var(--ease), transform 150ms var(--ease); }
.primary { background: var(--accent); color: var(--on-accent); }
@media (hover: hover) { .primary:hover:not(:disabled) { background: var(--accent-hover); } }
.secondary { background: var(--card); color: var(--fg); border-color: var(--line-strong); }
@media (hover: hover) { .secondary:hover:not(:disabled) { background: var(--raised); } }
.small { height: 36px; padding: 0 12px; font-size: 14px; }
.primary:active:not(:disabled), .secondary:active:not(:disabled) { transform: scale(.98); }
:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible, label:has(> .vh:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.actions.split { justify-content: space-between; }

/* ---- Home ---- */
.intro { margin-bottom: 32px; }
.intro h1 { font-size: 36px; line-height: 44px; font-weight: 500; margin-bottom: 12px; }
.lede { color: var(--fg2); font-size: 18px; line-height: 28px; max-width: 36rem; }
.notice { margin-bottom: 16px; padding: 16px 20px; border-radius: 12px; background: var(--accent-soft); font-size: 15px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.exam { display: grid; gap: 24px; margin-bottom: 16px; }
.exam-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.eyebrow { margin-bottom: 4px; font: 500 13px/20px var(--mono); color: var(--accent-ink); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px 0; border-block: 1px solid var(--line); }
.facts dt { font-size: 13px; line-height: 20px; color: var(--muted); }
.facts dd { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 12px; font-weight: 500; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { position: relative; display: grid; gap: 4px; padding: 16px; border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
@media (hover: hover) { .tile:hover { background: var(--raised); } }
.tile-title { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.tile-title::before { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--muted); transition: border 150ms var(--ease); }
.tile-text { padding-left: 24px; font-size: 14px; line-height: 20px; color: var(--fg2); }
.tile:has(input:checked), .seg label:has(input:checked) span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tile:has(input:checked) .tile-title::before { border: 5px solid var(--accent); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; border-radius: 10px; }
.seg span { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 10px; font-variant-numeric: tabular-nums; cursor: pointer; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
@media (hover: hover) { .seg span:hover { background: var(--raised); } }
.seg label:has(input:checked) span { color: var(--accent-ink); font-weight: 500; }


/* ---- Question ---- */
.progress { margin-bottom: 32px; }
.progress-text { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 8px; font-size: 14px; line-height: 20px; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-text span:first-child { color: var(--fg); font-weight: 500; }
.track { height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.track i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 300ms var(--ease); }

.domain { margin-bottom: 8px; font-size: 14px; line-height: 20px; color: var(--muted); }
.q { margin-bottom: 8px; font-size: 22px; line-height: 32px; font-weight: 500; }
.hint { margin-bottom: 20px; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--accent-ink); }

.opts { display: grid; gap: 12px; margin-bottom: 24px; }
.opt { position: relative; display: flex; align-items: flex-start; gap: 16px; padding: 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--card); cursor: pointer; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
@media (hover: hover) { .opt:hover { border-color: var(--accent); } }
.bubble { flex: none; width: 28px; height: 28px; margin-top: -2px; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; font: 500 13px/1 var(--mono); color: var(--fg2); transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease); }
.opt.multi .bubble { border-radius: 8px; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.opt:has(input:checked) .bubble { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.opt:has(input:disabled) { cursor: default; }
@media (hover: hover) { .opt:has(input:disabled):not(:has(input:checked)):hover { border-color: var(--line-strong); } }
.opt.right, .opt.right:has(input:checked) { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok); }
.opt.right .bubble { border-color: var(--ok); color: var(--ok); }
.opt.right:has(input:checked) .bubble { background: var(--ok); color: var(--on-accent); }
.opt.wrong, .opt.wrong:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }
.opt.wrong .bubble, .opt.wrong:has(input:checked) .bubble { background: var(--bad); border-color: var(--bad); color: var(--on-accent); }

.feedback { scroll-margin: 80px 0 96px; margin-bottom: 24px; padding: 16px 20px; border-radius: 12px; color: var(--fg2); }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.fb-title { margin-bottom: 4px; font-weight: 500; }
.feedback.ok .fb-title { color: var(--ok); }
.feedback.bad .fb-title { color: var(--bad); }

.keys { margin-top: 16px; font-size: 13px; line-height: 24px; color: var(--muted); }
kbd { display: inline-block; min-width: 20px; padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--card); font: 500 12px/16px var(--mono); color: var(--fg2); text-align: center; }

.map { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.map-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
.map h2 { font-size: 16px; line-height: 24px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; line-height: 20px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend span::before { content: ''; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.legend .answered::before { background: var(--accent); border-color: var(--accent); }
.legend .right::before { background: var(--ok); border-color: var(--ok); }
.legend .wrong::before { background: var(--bad); border-color: var(--bad); }
.grid { display: flex; flex-wrap: wrap; gap: 8px; }
.grid button { width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--card); color: var(--fg2); font: 500 13px/1 var(--mono); cursor: pointer; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
@media (hover: hover) { .grid button:hover { border-color: var(--accent); } }
.grid .answered { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.grid .right { background: var(--ok); border-color: var(--ok); color: var(--on-accent); }
.grid .wrong { background: var(--bad); border-color: var(--bad); color: var(--on-accent); }
.grid .current { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }

/* ---- Result (the moment) ---- */
.result { display: grid; gap: 24px; margin-bottom: 48px; }
.result .eyebrow { margin: 0; }
.result-main { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.figure { font: 500 64px/1 var(--mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.verdict { font-size: 24px; line-height: 32px; font-weight: 500; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.scorebar { position: relative; height: 12px; margin-bottom: 20px; border-radius: 6px; background: var(--raised); }
.scorebar i { position: absolute; inset: 0; border-radius: 6px; background: var(--accent); transform-origin: left; }
.scorebar b { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--fg); }
.scorebar span { position: absolute; top: 20px; transform: translateX(-50%); font: 12px/16px var(--mono); color: var(--fg2); white-space: nowrap; }

.block + .block { margin-top: 48px; }
.block > .muted { margin-top: 4px; }
.topics { display: grid; gap: 20px; margin-top: 24px; }
.topic-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 8px; font-size: 15px; line-height: 22px; }
.num { flex: none; font-size: 14px; color: var(--fg2); font-variant-numeric: tabular-nums; }
.num.low { color: var(--bad); }
.thin { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.thin i { display: block; height: 100%; background: var(--fg2); transform-origin: left; }

.miss { display: grid; gap: 16px; margin-top: 16px; }
.miss .domain { margin: 0; }
.miss-q { font-weight: 500; }
.miss-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label { margin-bottom: 4px; font-size: 13px; line-height: 20px; color: var(--muted); }
.miss ul { padding: 0; list-style: none; display: grid; gap: 4px; font-size: 15px; line-height: 22px; }
.miss li { display: flex; gap: 8px; }
.miss li b { flex: none; font: 500 13px/22px var(--mono); }
.miss ul.bad b { color: var(--bad); }
.miss ul.ok b { color: var(--ok); }
.why { padding-top: 16px; border-top: 1px solid var(--line); font-size: 15px; line-height: 22px; color: var(--fg2); }


/* ---- Core concepts ---- */
h3 { margin: 0 0 12px; font-size: 15px; line-height: 22px; font-weight: 500; color: var(--fg2); }
.link { padding: 0; margin-top: 8px; border: 0; background: none; color: var(--accent-ink); font-family: inherit; font-size: 14px; line-height: 20px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.toc { display: grid; gap: 4px; margin-bottom: 32px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.toc a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 8px; color: var(--fg); text-decoration: none; transition: background-color 150ms var(--ease); }
@media (hover: hover) { .toc a:hover { background: var(--raised); } }
.toc-n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font: 500 12px/1 var(--mono); }
.toc-w { margin-left: auto; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson { display: grid; gap: 28px; margin-bottom: 16px; scroll-margin-top: 80px; }
.lesson-sum { margin-top: 8px; color: var(--fg2); }
.terms { display: grid; }
.terms > div { display: grid; grid-template-columns: 200px 1fr; gap: 4px 24px; padding: 12px 0; border-top: 1px solid var(--line); }
.terms dt { font-weight: 500; font-size: 15px; line-height: 22px; }
.terms dd { color: var(--fg2); font-size: 15px; line-height: 22px; }
.traps { padding: 16px 20px; border-radius: 12px; background: var(--accent-soft); }
.traps h3 { color: var(--accent-ink); margin-bottom: 8px; }
.traps ul { padding-left: 20px; display: grid; gap: 8px; font-size: 15px; line-height: 22px; }
.actions .muted { align-self: center; }

@media (max-width: 600px) {
  .top { height: 56px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
  span.brand .brand-text { display: none; }
  .top-right { gap: 12px; }
  main { padding: 24px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); }
  .intro { margin-bottom: 24px; }
  .intro h1 { font-size: 28px; line-height: 36px; }
  .lede { font-size: 16px; line-height: 24px; }
  .card { padding: 20px 16px; border-radius: 12px; }
  .exam { gap: 20px; }
  .facts { grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 12px; }
  .facts dd { font-size: 14px; line-height: 20px; }
  .modes, .miss-answers, .terms > div { grid-template-columns: 1fr; }
  .exam > .actions > *, .lesson .actions .primary { flex: 1; }
  .q { font-size: 19px; line-height: 28px; }
  .opt { padding: 12px; gap: 12px; }
  /* thumb-reach action bar that stays on screen while reading long questions */
  .actions.split { position: sticky; bottom: 0; z-index: 1; margin: 0 calc(-1 * max(16px, env(safe-area-inset-left))); padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: var(--bg); border-top: 1px solid var(--line); }
  .actions.split > * { flex: 1; }
  .actions.split > .secondary { flex: 0 0 auto; }
  .keys { display: none; }
  .map { margin-top: 32px; }
  .grid button { width: 40px; height: 40px; }
  .toc a { min-height: 48px; }
  .result { gap: 20px; }
  .figure { font-size: 48px; }
  .verdict { font-size: 20px; line-height: 28px; }
  .result .actions > *, .actions.split > * { flex: 1; padding: 0 16px; }
  .lesson { gap: 24px; scroll-margin-top: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
