/* Tokens. Cool paper, navy ink, one cobalt accent; green and red are reserved for scoring. */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --tint: #eaeefa;
  --ink: #101b33;
  --muted: #55607a;
  --line: #d6dcea;
  --brand: #1f3fd0;
  --brand-strong: #17309f;
  --brand-ink: #ffffff;
  --brand-soft: #e7ecff;
  --good: #0b7a4b;
  --good-bg: #e2f5ea;
  --bad: #b93424;
  --bad-bg: #fcebe8;
  --warn-bg: #fff3c9;
  --warn-ink: #564000;
  --shadow: 0 1px 2px rgba(16, 27, 51, 0.06), 0 12px 32px -12px rgba(16, 27, 51, 0.22);
  --r-card: 16px;
  --r-ctl: 9px;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1322;
    --surface: #141d31;
    --tint: #111a2d;
    --ink: #e9edf7;
    --muted: #a3aec7;
    --line: #2a3550;
    --brand: #93a9ff;
    --brand-strong: #b3c3ff;
    --brand-ink: #0b1330;
    --brand-soft: #1d2950;
    --good: #62d59c;
    --good-bg: #12301f;
    --bad: #f39483;
    --bad-bg: #3b1c17;
    --warn-bg: #3a3010;
    --warn-ink: #f3e3a8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--sans);
}
[hidden] { display: none !important; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 780px; }

h1, h2, h3 { font-family: var(--display); line-height: 1.15; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(2rem, 4.6vw, 3.15rem); font-weight: 700; line-height: 1.07; letter-spacing: -0.028em; text-wrap: balance; }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); font-weight: 700; text-wrap: balance; }
h3 { font-size: 1.15rem; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-underline-offset: 3px; }
.small { font-size: 0.875rem; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: 8px 14px; z-index: 20; }
.skip:focus { left: 8px; top: 8px; }

.draft { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 20px; font-size: 0.875rem; text-align: center; }

/* Header */
header.site { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.02em; }
.brand-mark { color: var(--brand); flex: none; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: var(--r-ctl); font-size: 0.95rem; }
.site-nav a:hover { color: var(--ink); background: var(--tint); }
body[data-view="exam"] .site-nav a:not(.keep) { display: none; }

/* Buttons and controls */
button { font: inherit; cursor: pointer; border-radius: var(--r-ctl); padding: 10px 18px; min-height: 44px; }
button.primary { background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); font-weight: 650; }
button.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); font-weight: 600; }
button.ghost:hover { border-color: var(--brand); }
button.big { padding: 13px 24px; font-size: 1.05rem; }
button.link { background: none; border: none; color: var(--brand); padding: 4px 0; min-height: 0; text-decoration: underline; font-size: 0.875rem; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px;
}
select, textarea, input[type=email] {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
}
select { padding: 7px 10px; max-width: 100%; }

/* Hero */
.hero { background: var(--surface); border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 56px; align-items: center; padding-top: 64px; padding-bottom: 72px; }
.lead { font-size: 1.2rem; line-height: 1.55; color: var(--muted); margin: 20px 0 28px; max-width: 34em; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.hero-facts { font-size: 0.925rem; color: var(--muted); margin: 0; max-width: 34em; }
.hero-facts span { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

/* The one loud element: a live exam item */
.teaser {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow); padding: 24px 24px 20px; position: relative;
}
.teaser::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px;
  background: var(--brand); border-radius: var(--r-card) var(--r-card) 0 0;
}
.teaser h2 { font-size: 1.05rem; letter-spacing: 0; }
.teaser .rule { margin: 6px 0 16px; }
.teaser .q { font-weight: 600; margin-bottom: 12px; }
.teaser-opts { display: grid; gap: 8px; }
.teaser-opts button {
  text-align: left; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); padding: 11px 14px; display: flex; justify-content: space-between; gap: 12px;
  font-variant-numeric: tabular-nums;
}
.teaser-opts button:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.teaser-opts button:disabled { cursor: default; opacity: 1; color: var(--ink); }
.teaser-opts button.correct { background: var(--good-bg); border-color: var(--good); }
.teaser-opts button.chosen-wrong { background: var(--bad-bg); border-color: var(--bad); }
.teaser-opts .mark { font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.teaser-opts .correct .mark { color: var(--good); }
.teaser-opts .chosen-wrong .mark { color: var(--bad); }
.teaser-out { margin-top: 14px; }
.teaser-out .verdict { font-weight: 700; margin-bottom: 4px; }
.teaser-out .verdict.good { color: var(--good); }
.teaser-out .verdict.bad { color: var(--bad); }
.teaser-out p { margin-bottom: 12px; }

/* Bands */
.band { padding: 64px 0; }
.band.tinted { background: var(--tint); border-block: 1px solid var(--line); }
.band-lead { color: var(--muted); font-size: 1.08rem; max-width: 40em; margin: 12px 0 28px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr); gap: 56px; align-items: start; }
.split h2 { margin-bottom: 16px; }
.split p { max-width: 36em; }

table { border-collapse: collapse; width: 100%; }
.contents { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; border-collapse: separate; border-spacing: 0; margin-bottom: 14px; }
.contents th, .contents td { text-align: left; padding: 14px 18px; vertical-align: top; border-top: 1px solid var(--line); }
.contents thead th { border-top: 0; font-size: 0.875rem; color: var(--muted); font-weight: 600; }
.contents tbody th { font-family: var(--display); font-size: 1.05rem; font-weight: 650; white-space: nowrap; }
.contents td.num, .contents th.num { text-align: right; }
.contents ul { margin: 0; padding: 0; list-style: none; color: var(--muted); }

.ledger { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); border-collapse: separate; border-spacing: 0; box-shadow: var(--shadow); }
.ledger caption { caption-side: top; text-align: left; font-size: 0.9rem; color: var(--muted); padding: 0 4px 10px; }
.ledger th, .ledger td { padding: 13px 18px; text-align: left; border-top: 1px solid var(--line); font-weight: 400; }
.ledger tbody tr:first-child th, .ledger tbody tr:first-child td { border-top: 0; }
.ledger tbody th { width: 2.5em; color: var(--muted); }
.ledger td.num { text-align: right; font-weight: 650; }
.ledger .plus { color: var(--good); }
.ledger .minus { color: var(--bad); }
.ledger tfoot th, .ledger tfoot td { font-weight: 700; border-top: 2px solid var(--ink); }

.quality { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 56px; }
.quality li { padding: 16px 0; border-top: 1px solid var(--line); color: var(--muted); }
.quality strong { color: var(--ink); }

/* Sign-up */
.signup-band { background: var(--surface); border-top: 1px solid var(--line); }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-card); padding: 24px; }
#signup-form { display: grid; gap: 8px; }
#signup-form label { font-weight: 600; margin-top: 6px; }
#signup-form input[type=email], #signup-form select { padding: 11px 12px; width: 100%; }
#signup-form label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 8px 0; }
#signup-form label.check input { width: 18px; height: 18px; margin-top: 0.3em; flex: none; accent-color: var(--brand); }
.msg { min-height: 1.5em; margin: 4px 0 0; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--good); }
#signup-form .small { margin: 0; }

footer.site { border-top: 1px solid var(--line); padding: 24px 0 40px; }
footer.site p { max-width: 46em; margin: 0; }

/* Exam view */
#exam { padding-bottom: 24px; }
.bar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 10px 0 0; margin-bottom: 20px;
}
.bar-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem; min-width: 5.5ch; }
.timer.over { color: var(--bad); }
.progress { color: var(--muted); font-size: 0.9rem; flex: 1; }
.bar-meter { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.bar-meter span { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.2s ease; }
@media (prefers-reduced-motion: reduce) { .bar-meter span { transition: none; } }
.jump { display: flex; gap: 4px; padding: 6px 0; overflow-x: auto; }
.jump a { color: var(--muted); text-decoration: none; font-size: 0.9rem; padding: 6px 10px; border-radius: var(--r-ctl); white-space: nowrap; }
.jump a:hover { background: var(--tint); color: var(--ink); }
.confirm { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r-ctl); padding: 14px 16px; margin-bottom: 20px; }
.confirm p { margin: 0 0 10px; }
.confirm button.ghost { color: var(--warn-ink); border-color: currentColor; }

.section-title { margin: 40px 0 4px; padding-bottom: 8px; border-bottom: 2px solid var(--ink); scroll-margin-top: 130px; }
.task {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 22px 22px 10px; margin: 16px 0;
}
.task h3 { margin-bottom: 8px; }
.task .pts { color: var(--muted); font-weight: 400; font-size: 0.95rem; font-family: var(--sans); letter-spacing: 0; white-space: nowrap; }
.intro { color: var(--muted); }
.rule { font-size: 0.875rem; color: var(--muted); margin: 14px 0 6px; }

fieldset.item { border: 0; padding: 0; margin: 20px 0; min-width: 0; }
fieldset.item legend { padding: 0; font-weight: 600; margin-bottom: 8px; }
label.opt {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 12px; margin: 4px 0; border: 1px solid var(--line); border-radius: var(--r-ctl); cursor: pointer;
}
label.opt:hover { border-color: var(--brand); }
label.opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
label.opt:has(input:disabled) { cursor: default; }
label.opt:has(input:disabled):hover { border-color: var(--line); }
label.opt input { margin-top: 0.3em; flex: none; width: 18px; height: 18px; accent-color: var(--brand); }
label.opt .mark { margin-left: auto; padding-left: 12px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
label.opt.correct, label.opt.correct:hover { background: var(--good-bg); border-color: var(--good); }
label.opt.chosen-wrong, label.opt.chosen-wrong:hover { background: var(--bad-bg); border-color: var(--bad); }
label.opt.correct .mark { color: var(--good); }
label.opt.chosen-wrong .mark { color: var(--bad); }

.cloze { line-height: 2.5; }
select.ok { border-color: var(--good); background: var(--good-bg); }
select.no { border-color: var(--bad); background: var(--bad-bg); }
.compact-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 12px 0; }
.compact-row .q { flex: 1 1 260px; font-weight: 600; }

textarea { width: 100%; min-height: 9rem; padding: 12px; line-height: 1.5; }
.count { font-size: 0.8rem; color: var(--muted); text-align: right; margin: 4px 0 0; }

.fb { margin: 8px 0 0; padding: 8px 12px; border-left: 3px solid var(--line); font-size: 0.95rem; }
.fb.good { border-color: var(--good); }
.fb.bad { border-color: var(--bad); }
.fb .score { font-weight: 700; }
.selfmark { background: var(--bg); border-radius: var(--r-ctl); padding: 12px 14px; margin: 12px 0; }
.selfmark .rule { margin-top: 0; }
.selfmark label { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.selfmark input { width: 18px; height: 18px; margin-top: 0.3em; flex: none; accent-color: var(--brand); }
.solution { padding-left: 1.3rem; }

/* Results */
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 26px; margin-bottom: 28px; position: relative; }
.summary::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--brand); border-radius: var(--r-card) var(--r-card) 0 0; }
.summary h2 { font-size: 1.05rem; letter-spacing: 0; color: var(--muted); font-weight: 600; }
.summary .total { font-family: var(--display); font-size: clamp(2.4rem, 7vw, 3.4rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.summary .total small { font-size: 0.45em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.meter { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand); }
.summary table { margin-top: 18px; }
.summary th, .summary td { text-align: left; padding: 9px 4px; border-top: 1px solid var(--line); }
.summary thead th { font-size: 0.875rem; color: var(--muted); font-weight: 600; border-top: 0; }
.summary td.bar-cell { width: 45%; }
.summary td.num, .summary th.num { text-align: right; }
.tally { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 20px 0 6px; padding: 0; }
.tally div { background: var(--bg); border-radius: var(--r-ctl); padding: 10px 14px; }
.tally dt { font-size: 0.875rem; color: var(--muted); }
.tally dd { margin: 0; font-family: var(--display); font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary .note { margin: 12px 0 16px; }

@media (max-width: 860px) {
  .hero-grid, .split { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .hero-grid { padding-top: 40px; padding-bottom: 48px; }
  .band { padding: 48px 0; }
  .quality { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .wrap { padding: 0 16px; }
  .task { padding: 16px 14px 6px; }
  .teaser, .summary, .card { padding: 20px 16px 16px; }
  .contents th, .contents td { padding: 12px 12px; }
  .contents tbody th { white-space: normal; }
  .site-nav a { padding: 8px 8px; }
  .summary td.bar-cell { display: none; }
}

/* ---------- guide pages ---------- */
.guide { padding-top: 48px; padding-bottom: 72px; }
.guide h1 { margin-bottom: 0; }
.guide .lead { max-width: 36em; margin: 18px 0 8px; }
.guide h2 { font-size: clamp(1.3rem, 2.2vw, 1.55rem); margin: 44px 0 12px; }
.guide p, .guide li { max-width: 40em; }
.guide ul { padding-left: 1.2rem; margin: 0 0 1em; }
.guide li { margin-bottom: 0.5em; }
.guide li strong { font-weight: 650; }
a.button { display: inline-block; background: var(--brand); color: var(--brand-ink); text-decoration: none; font-weight: 650; border-radius: var(--r-ctl); padding: 12px 22px; }
a.button:hover { background: var(--brand-strong); }
.guide-cta { margin: 48px 0 28px; background: var(--surface); }
.guide-cta h2 { margin-top: 0; }
.guide-cta p:last-child { margin-bottom: 0; }

.calc { background: var(--surface); box-shadow: var(--shadow); margin: 20px 0 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.presets button { padding: 6px 14px; min-height: 40px; font-variant-numeric: tabular-nums; color: var(--ink); }
.calc-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.calc-fields label { display: grid; gap: 6px; font-weight: 600; font-size: 0.925rem; align-content: space-between; }
.calc-fields input {
  font: inherit; font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 10px 12px; width: 100%;
}
.calc-out { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.calc-verdict { font-family: var(--display); font-size: 1.2rem; font-weight: 650; line-height: 1.35; margin-bottom: 20px; max-width: 30em; }
.calc-verdict.good { color: var(--good); }
.calc-verdict.bad { color: var(--bad); }
.calc-out.invalid .odds, .calc-out.invalid .calc-nums { display: none; }

/* The bar runs from 0 to 100 % confidence. The tinted part is where answering pays off. */
.odds { margin: 0 6px 18px; }
.odds-track { position: relative; height: 12px; background: var(--line); border-radius: 6px; }
.odds-zone { position: absolute; top: 0; bottom: 0; right: 0; background: var(--good-bg); border: 1px solid var(--good); border-left: 0; border-radius: 0 6px 6px 0; }
.odds-limit { position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: var(--ink); }
.odds-you { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); transition: left 0.2s ease; }
.odds-you.good { background: var(--good); box-shadow: 0 0 0 1px var(--good); }
.odds-you.bad { background: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
@media (prefers-reduced-motion: reduce) { .odds-you { transition: none; } }
.odds-scale { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin-top: 10px; font-variant-numeric: tabular-nums; }
.calc-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.calc-nums div { background: var(--bg); border-radius: var(--r-ctl); padding: 10px 14px; display: grid; align-content: space-between; gap: 4px; }
.calc-nums dt { font-size: 0.85rem; color: var(--muted); }
.calc-nums dd { margin: 0; font-family: var(--display); font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.table-scroll { overflow-x: auto; margin: 16px 0 18px; }
.rules { min-width: 460px; font-variant-numeric: tabular-nums; }
.rules thead th { font-size: 0.875rem; color: var(--muted); font-weight: 600; border-top: 0; vertical-align: bottom; }
.rules td { font-weight: 400; }
.rules td.plus, .rules td.minus { font-weight: 650; }

@media (max-width: 620px) {
  .calc-fields, .calc-nums { grid-template-columns: minmax(0, 1fr); }
  .calc-nums div { grid-template-columns: 1fr auto; align-items: baseline; }
}
