/* Shared look for every page: warm paper, ruled panels, one dark specimen window. */
:root {
  --paper: #f2eee5;
  --paper-bright: #faf7f0;
  --paper-deep: #e8e1d5;
  --line: #c9c1b4;
  --line-strong: #a69c8e;
  --muted: #6d756f;
  --text: #26332f;
  --text-soft: #3f4a46;
  --teal: #28766b;
  --blue: #3f7eae;
  --amber: #bf8d2e;
  --magenta: #bf607c;
  --red: #c86d4d;
  --ink: #0d1413;
  --ink-line: #24312e;
  --ink-text: #c9d3cf;
  --ink-muted: #7f8f8a;
  /* One colour per brain copy, as in the game's neuron map. */
  --sense-taste: #e0a63a;
  --sense-loom: #e36a4f;
  --sense-target: #4fa3e0;
  --sense-touch: #6fcf8e;
  --sense-obstacle: #d77ab0;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--teal); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px 64px; }

/* Site navigation */
nav.site {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 22px;
  padding: 14px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 26px;
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
}
nav.site .home { font-family: var(--serif); font-size: 19px; letter-spacing: -.01em; text-transform: none; color: var(--text); text-decoration: none; margin-right: auto; }
nav.site a { color: var(--muted); text-decoration: none; padding-bottom: 2px; border-bottom: 1px solid transparent; }
nav.site a:hover { color: var(--text); }
nav.site a[aria-current="page"] { color: var(--text); border-bottom-color: var(--red); }

/* Masthead */
header.masthead {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 32px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line-strong);
}
.wordmark { font-family: var(--serif); font-size: 30px; letter-spacing: -.01em; margin: 0 0 10px; }
.label { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.masthead .side { border-right: 1px solid var(--line); padding-right: 24px; }
h1 {
  font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 5.2vw, 58px);
  line-height: 1.04; letter-spacing: -.02em; margin: 0 0 14px; text-wrap: balance;
}
.lede { max-width: 64ch; margin: 0; color: var(--text-soft); font-size: 16px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; padding: 6px 12px;
  border: 1px solid var(--teal); border-radius: 3px; background: #e3ece6;
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--teal);
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.loading { border-color: var(--line-strong); background: var(--paper-deep); color: var(--muted); }
.status-pill.error { border-color: var(--red); background: #f3e2da; color: var(--red); }

/* Panels */
section.panel {
  margin-top: 28px; background: var(--paper-bright); border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
}
.panel-head h2 .num { color: var(--red); margin-right: 10px; font-weight: 500; }
.panel-head .note { font-size: 11px; color: var(--muted); letter-spacing: .04em; text-align: right; }
.figure-label {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px;
}
canvas { display: block; width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span::before {
  content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 6px; vertical-align: -1px; background: var(--c);
}
.callout {
  margin: 0; padding: 14px 18px; background: var(--paper-deep); border-top: 1px solid var(--line);
  font-family: var(--serif); font-size: 15px; line-height: 1.55;
}
.callout strong {
  font-family: var(--sans); font-size: 10.5px; font-weight: 600; letter-spacing: .15em;
  text-transform: uppercase; color: var(--teal); margin-right: 6px;
}

/* Buttons */
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
button {
  font: inherit; font-size: 13px; padding: 8px 14px; border-radius: 3px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--paper-bright); color: var(--text);
}
button:hover { border-color: var(--teal); }
button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
button.warn.on { background: var(--red); border-color: var(--red); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Readout grid */
.readout { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); margin-top: 14px; }
.readout > div { padding: 10px 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.readout > div.l { border-right: 1px solid var(--line); }
.readout > div.wide { grid-column: 1 / -1; }
.readout > div.end { border-bottom: 0; }
.readout .k { font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
.readout .v { font-size: 19px; font-variant-numeric: tabular-nums; }

/* Ledger: real / ours / checked */
.ledger { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ledger > div { padding: 16px 18px 18px; }
.ledger > div + div { border-left: 1px solid var(--line); }
.ledger h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: 20px; }
.ledger ul { margin: 0; padding-left: 18px; }
.ledger li { margin: 4px 0; }
.tag { font-size: 10.5px; letter-spacing: .15em; text-transform: uppercase; }
.tag.real { color: var(--teal); }
.tag.ours { color: var(--red); }
.tag.checked { color: var(--blue); }

.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.gallery figure { margin: 0; padding: 14px 16px 16px; }
.gallery figure + figure { border-left: 1px solid var(--line); }
.gallery img { width: 100%; display: block; border: 1px solid var(--line); }
.gallery figcaption { margin-top: 8px; font-size: 13px; color: var(--text-soft); }

footer { margin-top: 30px; font-size: 13px; color: var(--muted); max-width: 90ch; }
footer p { margin: 6px 0; }
noscript p { padding: 16px 18px; }

/* ---------- Atlas (home page) ---------- */
.atlas { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); }
.atlas > div + div { border-left: 1px solid var(--line); }
.specimen {
  position: relative; background: var(--ink); color: var(--ink-text); min-height: 520px;
  overflow: hidden; touch-action: none; cursor: grab;
}
.specimen.dragging { cursor: grabbing; }
.specimen canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.specimen .hud {
  position: absolute; left: 14px; right: 14px; pointer-events: none;
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-muted);
}
.specimen .hud.top { top: 12px; }
.specimen .hud.bottom { bottom: 12px; align-items: flex-end; }
.specimen .clock { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--ink-text); text-transform: none; }
.specimen .stim {
  display: inline-block; padding: 3px 8px; border: 1px solid var(--ink-line); border-radius: 2px;
  color: var(--ink-muted); transition: color .15s, border-color .15s, background .15s;
}
.specimen .stim.on { color: #0d1413; background: var(--sense); border-color: var(--sense); }
.specimen .action-flag {
  font-family: var(--serif); font-size: 26px; letter-spacing: 0; text-transform: none;
  color: var(--ink-text); opacity: .18; transition: opacity .12s;
}
.specimen .action-flag.on { opacity: 1; color: var(--sense); }
.specimen .tip {
  position: absolute; pointer-events: none; padding: 7px 10px; max-width: 260px;
  background: rgba(13, 20, 19, .92); border: 1px solid var(--ink-line); border-radius: 3px;
  font-size: 12px; line-height: 1.4; color: var(--ink-text); transform: translate(12px, 12px);
}
.specimen .tip b { font-weight: 600; color: #fff; }
.specimen .tip span { color: var(--ink-muted); }
.specimen .fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--ink-muted); }
.tag-layer { position: absolute; inset: 0; pointer-events: none; }
.tag-layer div {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap;
  font-size: 11px; letter-spacing: .06em; color: var(--ink-text); padding-bottom: 10px;
  text-shadow: 0 0 4px var(--ink), 0 0 2px var(--ink);
}
.tag-layer div::after {
  content: ""; position: absolute; left: 50%; bottom: 0; width: 7px; height: 7px; margin-left: -4px;
  border: 1.5px solid currentColor; border-radius: 50%;
}
.tag-layer div.t-readout { color: #fff; font-weight: 600; }
.tag-layer div.t-input { color: var(--ink-muted); }

.side-panel { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.scenarios { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.scenarios button {
  text-align: left; padding: 8px 10px 9px; display: grid; gap: 1px; position: relative;
  border-left: 3px solid var(--sense);
}
.scenarios button b { font-weight: 600; font-size: 13px; }
.scenarios button span { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.scenarios button[aria-pressed="true"] { background: var(--text); border-color: var(--text); border-left-color: var(--sense); color: var(--paper-bright); }
.scenarios button[aria-pressed="true"] span { color: #bfc8c4; }
.transport { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.transport .speed { margin-left: auto; display: flex; gap: 0; }
.transport .speed button { border-radius: 0; padding: 6px 10px; font-size: 12px; }
.transport .speed button + button { border-left: 0; }
.transport .speed button[aria-pressed="true"] { background: var(--text); color: var(--paper-bright); border-color: var(--text); }
.wiring { display: flex; border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
.wiring button { flex: 1; border: 0; border-radius: 0; padding: 8px 10px; }
.wiring button + button { border-left: 1px solid var(--line-strong); }
.wiring button[aria-pressed="true"] { background: var(--teal); color: #fff; }
.wiring button.cut[aria-pressed="true"] { background: var(--red); }
#chart { height: 150px; border: 1px solid var(--line); background: #fffdf8; }
#scrub { width: 100%; accent-color: var(--text); margin: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--c); vertical-align: 3px; margin-right: 5px; }
.chart-legend i.thin { border-top-width: 1px; }
.chart-legend i.dash { border-top-style: dashed; }
.story { font-family: var(--serif); font-size: 15px; line-height: 1.55; margin: 0; }
.story p { margin: 0 0 8px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); }
.facts > div { padding: 8px 10px; min-width: 0; }
.facts > div + div { border-left: 1px solid var(--line); }
.facts .k { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.facts .v { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.doors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.doors a { display: block; padding: 18px 18px 20px; color: inherit; text-decoration: none; }
.doors a + a { border-left: 1px solid var(--line); }
.doors a:hover { background: #fffdf8; }
.doors h3 { margin: 6px 0 6px; font-family: var(--serif); font-weight: 400; font-size: 23px; }
.doors p { margin: 0; color: var(--text-soft); font-size: 14px; }
.doors .go { display: inline-block; margin-top: 10px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); }

/* ---------- Live demo page ---------- */
.demo { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.demo > div { padding: 16px 18px; }
.demo > div + div { border-left: 1px solid var(--line); }
#brain { aspect-ratio: 0.82; background: var(--paper-bright); }
#arena {
  aspect-ratio: 1.25; border: 1px solid var(--line);
  background-color: #f7f3ea;
  background-image: linear-gradient(var(--paper-deep) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-deep) 1px, transparent 1px);
  background-size: 24px 24px;
}
.readout .v.action-backing { color: var(--magenta); }
.readout .v.action-pressing { color: var(--blue); }
.meter { position: relative; height: 12px; background: var(--paper-deep); margin-top: 6px; }
.meter i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--magenta); }
.meter b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
#trace { height: 70px; margin-top: 6px; }

/* ---------- Explainer page ---------- */
.prose { padding: 18px 22px 22px; max-width: 76ch; }
.prose p, .prose li { font-family: var(--serif); font-size: 16.5px; line-height: 1.62; }
.prose p { margin: 0 0 12px; }
.prose h3 { font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--teal); margin: 20px 0 8px; }
.prose h3:first-child { margin-top: 0; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--paper-deep); padding: 1px 4px; border-radius: 2px; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.split > div + div { border-left: 1px solid var(--line); }
.pipeline { padding: 18px; }
.pipeline svg { width: 100%; height: auto; display: block; }
table.reactions { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.reactions th, table.reactions td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.reactions th { font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--paper-deep); }
table.reactions td:first-child { font-family: var(--serif); font-size: 17px; white-space: nowrap; }
table.reactions td:first-child::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--sense); margin-right: 8px; vertical-align: 1px; }
table.reactions tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }
.numbers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.numbers > div { padding: 16px 18px; }
.numbers > div + div { border-left: 1px solid var(--line); }
.numbers .v { font-family: var(--serif); font-size: 34px; line-height: 1; letter-spacing: -.01em; }
.numbers .k { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

@media (max-width: 960px) {
  .atlas { grid-template-columns: 1fr; }
  .atlas > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .specimen { min-height: 0; aspect-ratio: 1 / 1.2; }
}
@media (max-width: 860px) {
  .wrap { padding: 0 16px 48px; }
  header.masthead { grid-template-columns: 1fr; gap: 14px; }
  .masthead .side { border-right: 0; padding-right: 0; }
  .demo, .ledger, .gallery, .doors, .split { grid-template-columns: 1fr; }
  .demo > div + div, .ledger > div + div, .gallery figure + figure, .doors a + a, .split > div + div {
    border-left: 0; border-top: 1px solid var(--line);
  }
  .numbers { grid-template-columns: 1fr 1fr; }
  .numbers > div:nth-child(3) { border-left: 0; }
  .numbers > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  nav.site .home { width: 100%; }
}
@media (max-width: 480px) {
  .scenarios button { padding: 7px 8px 8px; }
  .scenarios button span { font-size: 11px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .facts > div:nth-child(3) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .specimen .action-flag, .specimen .stim { transition: none; }
}
.story .fine { font-family: var(--sans); font-size: 12.5px; line-height: 1.45; color: var(--muted); }
/* Input tags hang below their marker so they do not collide with readout tags above. */
.tag-layer div.t-input { transform: translate(-50%, 0); padding: 10px 0 0; }
.tag-layer div.t-input::after { top: 0; bottom: auto; margin-top: -4px; }
.facts > div:last-child .v { white-space: normal; font-size: 15px; line-height: 1.25; }

/* Seven-step flow on the explainer page */
ol.flow { list-style: none; margin: 0; padding: 16px 18px 18px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; counter-reset: step; }
ol.flow li { padding: 10px 12px 12px; border: 1px solid var(--line); background: #fffdf8; font-size: 13px; line-height: 1.4; color: var(--text-soft); counter-increment: step; }
ol.flow li.real { border-top: 3px solid var(--teal); }
ol.flow li.ours { border-top: 3px solid var(--red); }
ol.flow li.assumed { border-top: 3px solid var(--blue); }
ol.flow li b { display: block; font-family: var(--serif); font-weight: 400; font-size: 17px; line-height: 1.2; color: var(--text); margin: 4px 0; }
ol.flow li b::before { content: counter(step) " "; color: var(--muted); font-family: var(--sans); font-size: 11px; }
@media (max-width: 1000px) { ol.flow { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px) { ol.flow { grid-template-columns: 1fr 1fr; } }
