:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fcfcfb;
  --surface-2: #f0ede6;
  --line: #e2ded4;
  --grid: #ebe8e0;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #77756f;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --good: #1f7a3a;
  --good-bg: #e6f3e9;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  /* chart series (validated: all-pairs CVD and normal-vision pass) */
  --s-model: #2a78d6;
  --s-you: #eb6834;
  --s-humans: #1baf7a;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #34332f;
    --grid: #2a2a27;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a998f;
    --accent: #e2574c;
    --accent-ink: #120d0c;
    --good: #5cc27a;
    --good-bg: #17291c;
    --bad: #ef7d73;
    --bad-bg: #321a18;
    --s-model: #3987e5;
    --s-you: #d95926;
    --s-humans: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --line: #34332f;
  --grid: #2a2a27;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #9a998f;
  --accent: #e2574c;
  --accent-ink: #120d0c;
  --good: #5cc27a;
  --good-bg: #17291c;
  --bad: #ef7d73;
  --bad-bg: #321a18;
  --s-model: #3987e5;
  --s-you: #d95926;
  --s-humans: #199e70;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
h1, h2 { font-family: var(--serif); line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: clamp(28px, 5vw, 44px); letter-spacing: -0.01em; }
h2 { font-size: 24px; }
.sub, .muted { color: var(--text-2); margin: 0 0 16px; }
.muted { color: var(--muted); }

.hero { padding: 56px 0 32px; }
.eyebrow { color: var(--accent); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; margin: 0 0 12px; }
.lede { font-size: 18px; color: var(--text-2); max-width: 62ch; margin: 0 0 24px; }
.hero-actions, .actions { display: flex; flex-wrap: wrap; gap: 12px; }
.resume { color: var(--text-2); margin: 16px 0 0; }

.btn {
  font: inherit; font-weight: 600;
  padding: 11px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--text-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .opt:focus-visible, .chip:focus-visible, summary:focus-visible { outline: 3px solid var(--s-model); outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--text-2); text-decoration: underline; cursor: pointer; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 0 0 24px;
}
@media (max-width: 560px) { .card { padding: 18px 16px; } }

/* --- quiz --- */
.quiz .meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.progress { height: 4px; border-radius: 4px; background: var(--surface-2); margin-bottom: 20px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.quiz h3:focus { outline: none; }
.quiz h3 { font-family: var(--serif); font-size: 22px; line-height: 1.3; margin: 0 0 20px; font-weight: 600; }
.opts { display: grid; gap: 10px; margin: 0 0 20px; padding: 0; list-style: none; }
.opt {
  width: 100%; text-align: left; font: inherit; color: var(--text);
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start;
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer;
}
.opt:hover:not(:disabled) { border-color: var(--text-2); }
.opt .key {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2); font-weight: 700; font-size: 13px;
}
.opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.opt[aria-pressed="true"] .key { background: var(--accent); color: var(--accent-ink); }
.opt.none-opt { font-style: italic; }
.opt:disabled { cursor: default; }
.opt.is-right { border-color: var(--good); background: var(--good-bg); box-shadow: none; }
.opt.is-right .key { background: var(--good); color: var(--surface); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: none; }
.opt.is-wrong .key { background: var(--bad); color: var(--surface); }
.opt .tag { display: block; font-size: 13px; font-style: normal; font-weight: 600; margin-top: 2px; }
.opt.is-right .tag { color: var(--good); }
.opt.is-wrong .tag { color: var(--bad); }

.verdict { border-radius: 10px; padding: 14px 16px; margin: 0 0 16px; }
.verdict.good { background: var(--good-bg); }
.verdict.bad { background: var(--bad-bg); }
.verdict strong { display: block; font-size: 18px; }
.verdict p { margin: 6px 0 0; color: var(--text-2); }
.crowd { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0 0 16px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
.stat b { font-size: 22px; display: block; font-variant-numeric: tabular-nums; }
.stat span { color: var(--text-2); font-size: 14px; }
.model-answers { margin: 0 0 20px; }
.model-answers summary { cursor: pointer; color: var(--text-2); font-weight: 600; }
.model-answers ul { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.model-answers li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; }
.model-answers .mk { font-weight: 700; }
.model-answers .mk.ok { color: var(--good); }
.model-answers .mk.no { color: var(--bad); }
.model-answers .who { font-weight: 600; }
.model-answers .said { color: var(--text-2); }

/* --- leaderboard --- */
.board table, .grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.board th, .board td, .grid th, .grid td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.board th, .grid th { font-size: 13px; color: var(--muted); font-weight: 600; }
.board td.num, .grid td.num, .board th.num, .grid th.num { text-align: right; }
.board .rank { color: var(--muted); width: 2.2em; }
.board .name { font-weight: 600; }
.board .maker { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.bar { position: relative; height: 8px; background: var(--surface-2); border-radius: 4px; min-width: 80px; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--s-model); border-radius: 0 4px 4px 0; }
.board tr.top .name::after { content: " · perfect"; color: var(--accent); font-weight: 600; font-size: 13px; }
.board .score { font-weight: 700; width: 4em; }
@media (max-width: 560px) { .board .barcell { display: none; } }

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid { font-size: 14px; min-width: 640px; }
.grid th:first-child, .grid td:first-child { position: sticky; left: 0; background: var(--surface); }
.grid tr.human td { font-weight: 700; }
.grid tr.human td:first-child::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.grid tr.you td:first-child::before { background: var(--s-you); }
.grid tr.everyone td:first-child::before { background: var(--s-humans); }
.grid td.dim { color: var(--muted); }

/* --- chart --- */
.toggle { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip { font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--surface-2); color: var(--text); border-color: var(--text-2); font-weight: 600; }
.chart { position: relative; margin: 0 0 12px; }
.chart figcaption { color: var(--text-2); font-size: 14px; margin: 0 0 8px; }
.chart figcaption strong { color: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-2); margin: 0 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--s-model); }
.legend .dash { width: 18px; height: 0; border-top: 2px dashed; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot .gridline { stroke: var(--grid); stroke-width: 1; }
.plot .axis-label, .plot .tick { fill: var(--muted); font-size: 12px; }
.plot .model-dot { fill: var(--s-model); stroke: var(--surface); stroke-width: 2; }
.plot .model-dot.hot { r: 7; }
.plot .hit { fill: transparent; cursor: pointer; }
.plot .dlabel { fill: var(--text-2); font-size: 12px; }
.plot .frontier-line { fill: none; stroke: var(--s-model); stroke-width: 2; opacity: .35; stroke-linejoin: round; }
.legend .frontier-key { width: 18px; height: 0; border-top: 2px solid var(--s-model); opacity: .5; }
.plot .you-line { stroke: var(--s-you); stroke-width: 2; stroke-dasharray: 6 4; }
.plot .crowd-line { stroke: var(--s-humans); stroke-width: 2; stroke-dasharray: 2 4; stroke-linecap: round; }
.plot .line-label { font-size: 12px; font-weight: 700; fill: var(--text); }
.plot .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--text); color: var(--surface);
  font-size: 13px; line-height: 1.4; padding: 8px 10px; border-radius: 8px;
  max-width: 220px; transform: translate(-50%, calc(-100% - 12px));
}
.tip b { display: block; }
.table-view summary { cursor: pointer; color: var(--text-2); font-size: 14px; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.table-view td, .table-view th { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; }
.table-view td.num, .table-view th.num { text-align: right; }

.foot { color: var(--muted); font-size: 13px; padding: 8px 0 48px; }
.foot p { margin: 0; max-width: 70ch; }
