/* ==========================================================================
   Sparse World Models — live demo
   Tokens -> layout -> components. One accent (orange) for actions; the other
   colours are semantic and match what the canvas draws.
   ========================================================================== */

:root {
  --bg: #fdfbf7;
  --surface: #ffffff;
  --surface-2: #f6f2ec;
  --ink: #16181d;
  --ink-soft: #5c6472;
  --line: #e9e3da;
  --line-strong: #d8d0c4;
  --accent: #ff5a2b;
  --accent-ink: #c8400f;
  --gate: #0e9b8b;
  --truth: #e0332a;
  --ghost: #7c5cff;
  --goal: #e0a000;
  --shadow-sm: 0 1px 2px rgba(22, 24, 29, .04), 0 2px 8px rgba(22, 24, 29, .05);
  --shadow: 0 2px 6px rgba(22, 24, 29, .05), 0 12px 28px rgba(22, 24, 29, .07);
  --radius: 14px;
  --radius-sm: 10px;
  --wrap: 76rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --ink: #eef1f5;
    --ink-soft: #98a2b3;
    --line: #282e37;
    --line-strong: #38404c;
    --accent: #ff7a52;
    --accent-ink: #ff9370;
    --gate: #2ec4b6;
    --truth: #ff5b52;
    --ghost: #a99cff;
    --goal: #f0b429;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 28px rgba(0, 0, 0, .28);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1e232b;
  --ink: #eef1f5;
  --ink-soft: #98a2b3;
  --line: #282e37;
  --line-strong: #38404c;
  --accent: #ff7a52;
  --accent-ink: #ff9370;
  --gate: #2ec4b6;
  --truth: #ff5b52;
  --ghost: #a99cff;
  --goal: #f0b429;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 28px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* author rules below set display on several of these, so make [hidden] win */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.01em; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code {
  font-size: .88em;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  padding: .12em .36em;
  border-radius: 6px;
}

pre {
  margin: .4rem 0 .8rem;
  padding: .7rem .8rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: .78rem;
  line-height: 1.5;
}

pre code { background: none; padding: 0; font-size: inherit; }

a { color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.eyebrow {
  margin: 0;
  font-size: .76rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}

.hint { margin: 0; font-size: .82rem; color: var(--ink-soft); }
.hint.tiny { font-size: .76rem; }

/* --- masthead ------------------------------------------------------------ */

.masthead { max-width: var(--wrap); margin: 0 auto; padding: 1rem 1.25rem .25rem; }

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: .95rem;
}

.wordmark .mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--ink);
  position: relative;
  flex: none;
}

.wordmark .mark::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  right: 4px;
  bottom: 4px;
}

.wordmark-text { display: grid; line-height: 1.25; }
.wordmark small { font-weight: 500; font-size: .72rem; color: var(--ink-soft); }

.bar-links { display: flex; gap: .4rem; align-items: center; }

.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  padding: .38rem .8rem;
  border-radius: 999px;
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}

.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.ghost { background: var(--surface-2); }
.chip.icon { padding: .38rem .6rem; font-size: .95rem; line-height: 1; }

.hero {
  display: grid;
  grid-template-columns: 1.3fr .8fr;
  gap: 2rem;
  align-items: start;
  padding: 2rem 0 1.4rem;
}

.hero h1 {
  margin: .6rem 0 .8rem;
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  letter-spacing: -.025em;
}

.highlight { color: var(--accent-ink); }

.standfirst {
  margin: 0;
  max-width: 44rem;
  font-size: 1.03rem;
  color: var(--ink-soft);
}

.standfirst strong { color: var(--ink); font-weight: 650; }
.standfirst output { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  margin-top: 1.3rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: .62rem 1.15rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--accent); }

.btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--ink) 20%, transparent);
}

.btn.primary:hover { border-color: var(--ink); }

/* hero result card */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.05rem;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--line);
}

.mini-score { list-style: none; margin: .6rem 0 .5rem; padding: 0; display: grid; gap: .35rem; }

.mini-score li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: .5rem;
  padding: .45rem .55rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: .82rem;
}

.mini-score .rule { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; }
.mini-score b { font-variant-numeric: tabular-nums; font-size: .9rem; }

.mini-score .pill {
  font-size: .68rem;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .05rem .45rem;
  white-space: nowrap;
}

.mini-score .wins {
  background: color-mix(in srgb, var(--gate) 12%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gate) 30%, transparent);
}

.mini-score .wins b { color: var(--gate); }

.mini-score .model {
  background: color-mix(in srgb, var(--accent) 11%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
}

.card-foot { margin: 0; font-size: .78rem; color: var(--ink-soft); }

.status-line { padding-bottom: .4rem; }

.loading {
  margin: 0;
  font-size: .86rem;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  display: inline-block;
  padding: .35rem .75rem;
  border-radius: 999px;
}

.progress { height: 3px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: .5rem; max-width: 22rem; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* --- tabs ---------------------------------------------------------------- */

.tasks {
  position: sticky;
  top: 0;
  z-index: 30;
  max-width: var(--wrap);
  margin: .9rem auto 0;
  padding: .55rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.tasks button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  padding: .45rem .85rem;
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
  display: grid;
  gap: .05rem;
  text-align: left;
  line-height: 1.2;
  transition: background .15s, color .15s;
}

.tasks button b { font-size: .9rem; font-weight: 650; }
.tasks button small { font-size: .72rem; opacity: .75; font-weight: 500; }
.tasks button:hover { background: var(--surface-2); color: var(--ink); }

.tasks button.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.tasks button.active small { opacity: .7; }

.tasks .tab-paper { margin-left: auto; }

/* --- main layout --------------------------------------------------------- */

main { max-width: var(--wrap); margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }

.stage {
  display: grid;
  grid-template-columns: 1.15fr .95fr;
  gap: 1.25rem;
  align-items: start;
}

.stage, .paper-view, #scene { scroll-margin-top: 5.5rem; }

.stage[hidden] { display: none !important; }

/* --- canvas -------------------------------------------------------------- */

.canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .75rem;
  box-shadow: var(--shadow);
  position: relative;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  margin-bottom: .55rem;
  font-size: .76rem;
  color: var(--ink-soft);
}

.toolbar-label { font-variant-numeric: tabular-nums; }
.toolbar-actions { display: flex; gap: .25rem; }

.toolbar-actions button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
  border-radius: 8px;
  padding: .3rem .6rem;
  font: inherit;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
}

.toolbar-actions button:hover { border-color: var(--accent); color: var(--ink); }
.toolbar-actions button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  display: block;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  touch-action: none;
  cursor: crosshair;
}

.canvas-wrap.is-loading canvas { opacity: .5; filter: saturate(.7); }

.inspector {
  position: absolute;
  top: 3.1rem;
  right: 1.1rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .5rem .6rem;
  font-size: .73rem;
  line-height: 1.45;
  backdrop-filter: blur(8px);
  max-width: 13rem;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  font-variant-numeric: tabular-nums;
}

.canvas-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem 1rem;
  padding: .7rem .15rem 0;
  margin: 0;
  font-size: .77rem;
  color: var(--ink-soft);
}

.canvas-legend li { display: inline-flex; align-items: center; gap: .38rem; }
.legend-hint { margin-left: auto; opacity: .75; font-size: .73rem; }

.swatch { width: .72rem; height: .72rem; border-radius: 3px; display: inline-block; flex: none; }
.swatch.pusher { background: var(--ink); border-radius: 50%; }
.swatch.gate-on { background: var(--gate); }
.swatch.truth { background: transparent; border: 2px solid var(--truth); }
.swatch.ghost { background: transparent; border: 2px dashed var(--ghost); }
.swatch.goal { background: var(--goal); border-radius: 50%; }

.overlay {
  position: absolute;
  inset: 3.2rem .9rem auto .9rem;
  background: color-mix(in srgb, var(--ink) 86%, transparent);
  color: #fff;
  text-align: center;
  padding: .5rem;
  border-radius: var(--radius-sm);
  font-size: .86rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.challenges {
  margin-top: .8rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .65rem .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  align-items: center;
}

.challenges h4 {
  margin: 0;
  font-size: .78rem;
  flex: 1 0 100%;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
}

.challenges .counter {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 .45rem;
  letter-spacing: 0;
}

.challenges label { font-size: .78rem; color: var(--ink-soft); display: flex; gap: .35rem; align-items: center; }
.challenges input { accent-color: var(--gate); }
.challenges input:checked + span { text-decoration: line-through; color: var(--gate); }

/* --- side panel ---------------------------------------------------------- */

.panel { display: grid; gap: 1rem; }

.task-copy {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.task-copy h2 { margin: 0 0 .3rem; font-size: 1rem; }
.task-copy p { margin: 0; color: var(--ink-soft); font-size: .88rem; }

.controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .95rem 1rem;
  display: grid;
  gap: .9rem;
  box-shadow: var(--shadow-sm);
}

.control-group { display: grid; gap: .55rem; }
.control-group:not(:last-child) { padding-bottom: .85rem; border-bottom: 1px solid var(--line); }

.control-group h3 {
  margin: 0;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
}

.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-size: .86rem; }
.row[hidden] { display: none !important; }
.row.buttons { gap: .4rem; }
.row > label { color: var(--ink-soft); display: inline-flex; align-items: center; gap: .35rem; }
.row input[type="range"] { flex: 1 1 7rem; accent-color: var(--accent); }
.row output { font-variant-numeric: tabular-nums; min-width: 4rem; font-weight: 700; text-align: right; }

.controls button, select {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: .45rem .85rem;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  font-weight: 600;
}

.controls button:hover, select:hover { border-color: var(--accent); }
.controls button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
select { flex: 1 1 10rem; }

/* segmented radio group */
.segmented {
  display: inline-flex;
  gap: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  width: 100%;
}

.segmented label {
  flex: 1;
  display: block;
  text-align: center;
  padding: .35rem .5rem;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label:hover { color: var(--ink); }
.segmented label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

.checks { gap: .9rem; }
.checks label { font-size: .82rem; }
.checks input { accent-color: var(--accent); }

.advanced {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: .5rem .75rem;
}

.advanced[open] { padding-bottom: .8rem; }

.advanced summary {
  cursor: pointer;
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-soft);
  list-style: none;
}

.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "▸ "; display: inline-block; transition: transform .15s; }
.advanced[open] summary::before { content: "▾ "; }
.advanced > *:not(summary) { margin-top: .6rem; }

.warn {
  margin: 0;
  font-size: .79rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--goal) 16%, transparent);
  border-left: 3px solid var(--goal);
  border-radius: 8px;
  padding: .5rem .7rem;
}

.warn[hidden] { display: none !important; }

/* --- scoreboard ---------------------------------------------------------- */

.scoreboard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .95rem 1rem 1rem;
  box-shadow: var(--shadow-sm);
}

.scoreboard-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.scoreboard h2 { margin: 0; font-size: 1rem; }

.frames {
  font-size: .74rem;
  color: var(--ink-soft);
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: .15rem .5rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.scorenote { margin: .5rem 0 .75rem; font-size: .78rem; color: var(--ink-soft); }
.scorenote strong { color: var(--ink); }

.score-actions { display: flex; gap: .35rem; margin-bottom: .7rem; }

.small {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  padding: .28rem .65rem;
  font: inherit;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
}

.small:hover { border-color: var(--accent); color: var(--ink); }
.small.ghost { background: var(--surface-2); }
.small.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

table { width: 100%; border-collapse: collapse; font-size: .82rem; }

th, td {
  text-align: right;
  padding: .4rem .4rem;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

th:first-child, td:first-child { text-align: left; }

thead th {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  font-weight: 700;
}

tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

tr.model td { background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 700; }
tr.model:hover td { background: color-mix(in srgb, var(--accent) 16%, transparent); }
tr.zero-param td:nth-child(2) { color: var(--gate); font-weight: 700; }
tr.leader td:first-child::before { content: "★ "; color: var(--goal); }

td .rule-name { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }

td.metric { position: relative; }

.meter {
  display: block;
  height: 3px;
  margin-top: .18rem;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.meter i { display: block; height: 100%; background: var(--gate); border-radius: 999px; }
tr.model .meter i { background: var(--accent); }

.insight {
  margin: .75rem 0 0;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink);
  min-height: 1.2em;
}

.insight:not(:empty) {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: .55rem .7rem;
}

/* --- paper view ---------------------------------------------------------- */

.paper-view {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.paper-view[hidden] { display: none !important; }

.paper-head { padding: 1.6rem 1.5rem 1.3rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }

.paper-head .eyebrow { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.accepted {
  background: var(--gate);
  color: #fff;
  border-radius: 999px;
  padding: .12rem .55rem;
  letter-spacing: .06em;
  font-size: .68rem;
}

.paper-head h2 {
  margin: .7rem 0 1.2rem;
  font-size: clamp(1.25rem, 2.6vw, 1.85rem);
  max-width: 46rem;
}

.authors {
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
}

.author {
  display: grid;
  gap: .1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .7rem .85rem;
}

.author strong { font-size: .92rem; }
.author span { font-size: .79rem; color: var(--ink-soft); }
.author a { font-size: .76rem; text-decoration: none; word-break: break-all; }
.author a:hover { text-decoration: underline; }

.paper-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.paper-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.2rem 1.5rem 1.5rem;
  align-items: start;
}

.paper-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
}

.paper-card.wide { grid-column: 1 / -1; }
.paper-card.cite pre { max-width: 34rem; }
.paper-card h3 { margin: 0 0 .55rem; font-size: .95rem; }
.paper-card p { margin: 0 0 .7rem; font-size: .88rem; color: var(--ink-soft); }
.paper-card p:last-child { margin-bottom: 0; }
.paper-card strong { color: var(--ink); }
.paper-card.wide p { font-size: .92rem; }

.formula {
  text-align: center;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: .6rem;
  font-size: 1rem !important;
  color: var(--ink) !important;
}

.claims { font-size: .8rem; margin-bottom: .6rem; }
.claims td { text-align: left; color: var(--ink-soft); }
.claims td:last-child { text-align: right; font-weight: 700; color: var(--ink); white-space: nowrap; }
.claims tr.good td:last-child { color: var(--gate); }
.claims tr.bad td:last-child { color: var(--truth); }
.claims tr.mixed td:last-child { color: var(--goal); }

.tab-guide { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; font-size: .86rem; color: var(--ink-soft); }
.tab-guide li { padding-left: .1rem; }

.linkish {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.linkish:hover { color: var(--ink); }

/* --- explain strip ------------------------------------------------------- */

.explain-strip { margin-top: 2.4rem; }
.explain-strip[hidden] { display: none !important; }
.strip-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.strip-head h2 { font-size: 1.1rem; margin: 0 0 .9rem; }
.strip-head .small { margin-bottom: .9rem; }

.comic { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }

.comic li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem .9rem .9rem;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.comic .num {
  position: absolute;
  top: -9px;
  left: 14px;
  background: var(--ink);
  color: var(--bg);
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 800;
}

.comic h3 { margin: .1rem 0 .3rem; font-size: .9rem; }
.comic p { margin: 0; color: var(--ink-soft); font-size: .83rem; }
.strip-foot { font-size: .8rem; color: var(--ink-soft); margin: .9rem 0 0; max-width: 52rem; }
.strip-foot[hidden] { display: none !important; }

/* --- explainer cards ----------------------------------------------------- */

.explainer { margin-top: 2.6rem; }
.explainer[hidden] { display: none !important; }
.explainer h2 { font-size: 1.1rem; margin: 0 0 .9rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .9rem; }

.cards article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.cards h3 { margin: 0 0 .4rem; font-size: .92rem; }
.cards p { margin: 0 0 .8rem; font-size: .85rem; color: var(--ink-soft); }
.cards .chip { margin-top: auto; }

.site-foot { margin-top: 2.6rem; border-top: 1px solid var(--line); padding-top: 1.1rem; font-size: .8rem; color: var(--ink-soft); }
.site-foot p { margin: 0 0 .7rem; max-width: 56rem; }
.foot-links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* --- overlays ------------------------------------------------------------ */

.toast-stack { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 50; pointer-events: none; }

.toast {
  background: var(--ink);
  color: var(--bg);
  padding: .6rem .95rem;
  border-radius: 999px;
  font-size: .83rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: pop .35s ease;
}

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i { position: absolute; width: 8px; height: 8px; background: var(--accent); animation: fall 1.2s ease-in forwards; }

#tooltip {
  position: fixed;
  max-width: 18rem;
  background: var(--ink);
  color: var(--bg);
  padding: .5rem .65rem;
  border-radius: 8px;
  font-size: .78rem;
  line-height: 1.45;
  pointer-events: none;
  z-index: 70;
  box-shadow: var(--shadow);
}

#tooltip[hidden] { display: none !important; }

.skip-link { position: absolute; left: -999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.skip-link:focus { left: 1rem; top: 1rem; width: auto; height: auto; background: var(--ink); color: var(--bg); padding: .5rem .8rem; border-radius: 8px; z-index: 100; }

.skeleton-text {
  display: inline-block;
  width: 6rem;
  height: .7rem;
  background: linear-gradient(90deg, var(--line), color-mix(in srgb, var(--line) 50%, transparent), var(--line));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
  vertical-align: middle;
  margin-left: .4rem;
}

.tour, .help {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 40%, transparent);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 1rem;
}

.help { z-index: 61; }
.tour[hidden], .help[hidden] { display: none !important; }

.tour-card, .help-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  max-width: 28rem;
  width: 100%;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .22);
  position: relative;
}

.tour-card h3, .help-card h3 { margin: .5rem 0 .5rem; font-size: 1.1rem; }
.tour-card p, .help-card p { color: var(--ink-soft); font-size: .9rem; }
.help-card ul { margin: 0 0 .8rem; padding-left: 1.1rem; font-size: .86rem; color: var(--ink-soft); }
.help-card li { margin-bottom: .3rem; }

.tour-card .x, .help-card .x {
  position: absolute;
  top: .5rem;
  right: .6rem;
  border: none;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
}

.tour-dots { display: flex; gap: .35rem; margin: .9rem 0; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); display: block; }
.tour-dots i.on { background: var(--accent); }
.tour-nav { justify-content: space-between; }

.tour-card .primary {
  appearance: none;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: .45rem 1.1rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

/* --- motion -------------------------------------------------------------- */

@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fall { to { transform: translateY(100vh) rotate(540deg); opacity: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 1000px) {
  .stage { grid-template-columns: 1fr; }
  .paper-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 1.4rem; padding-top: 1.5rem; }
  .comic { grid-template-columns: 1fr 1fr; }
  .authors { grid-template-columns: 1fr; }
  .tasks .tab-paper { margin-left: 0; }
}

@media (max-width: 640px) {
  .masthead { padding: .8rem 1rem .25rem; }
  main { padding: 1rem 1rem 2.5rem; }
  .tasks { padding: .5rem 1rem; gap: .3rem; }
  .tasks button { padding: .5rem .7rem; min-height: 44px; }
  .tasks button small { display: none; }
  .comic { grid-template-columns: 1fr; }
  .toolbar-actions button { padding: .5rem .7rem; min-height: 40px; }
  .controls button, select { padding: .55rem .9rem; min-height: 40px; }
  .paper-head, .paper-grid { padding-left: 1rem; padding-right: 1rem; }
  .legend-hint { display: none; }
  .wordmark small { display: none; }
}
