:root {
  --paper: #e7dec8;
  --paper-light: #f2ead7;
  --paper-dark: #d1c4a7;
  --ink: #1d201d;
  --ink-soft: #5c5d54;
  --grid: rgba(36, 78, 83, 0.16);
  --grid-strong: rgba(36, 78, 83, 0.3);
  --recorded: #1e6170;
  --actual: #c13e2f;
  --heat: #d27b26;
  --safe: #487147;
  --danger: #a9362e;
  --line: 1px solid var(--ink);
  --shadow: 7px 8px 0 rgba(29, 32, 29, 0.16);
  --narrow: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  font-family: var(--narrow);
  background:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,.34), transparent 33rem),
    repeating-linear-gradient(0deg, rgba(42,38,28,.018) 0, rgba(42,38,28,.018) 1px, transparent 1px, transparent 5px),
    var(--paper);
}

button, input, select { font: inherit; }
button { color: inherit; }

.station-header {
  min-height: 70px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 2px solid var(--ink);
}

.station-mark {
  min-width: 310px;
  padding: 12px 22px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: inherit;
  text-decoration: none;
  border-right: 1px solid var(--ink);
  letter-spacing: .08em;
}

.station-mark span,
.runtime,
.eyebrow,
.micro,
.field-label,
.readout-label {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.25;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.station-mark strong {
  margin-top: 2px;
  font-size: 17px;
  letter-spacing: .055em;
}

.header-tools { display: flex; align-items: stretch; }
.runtime { display: flex; align-items: center; padding: 0 20px; border-right: 1px solid var(--ink); }
.text-button {
  padding: 0 22px;
  border: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  cursor: pointer;
}
.text-button:hover, .text-button:focus-visible { background: var(--ink); color: var(--paper-light); }

.progress-rail {
  position: relative;
  border-bottom: 1px solid var(--ink);
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: rgba(30, 97, 112, .13);
  border-right: 2px solid var(--recorded);
  transition: width .45s ease;
}

.progress-rail ol {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  list-style: none;
}

.progress-rail li {
  min-height: 39px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border-right: 1px solid rgba(29,32,29,.34);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.progress-rail li:last-child { border-right: 0; }
.progress-rail li span { font-weight: 700; color: var(--ink); }
.progress-rail li.active { background: var(--ink); color: var(--paper-light); }
.progress-rail li.active span { color: var(--paper-light); }
.progress-rail li.done::after { content: "✓"; margin-left: auto; color: var(--safe); font-weight: 700; }

.stage {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: clamp(26px, 4vw, 64px) clamp(18px, 4vw, 68px) clamp(42px, 6vw, 88px);
  outline: none;
}

.station-footer {
  min-height: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  border-top: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .11em;
}

.stage-grid {
  display: grid;
  grid-template-columns: minmax(250px, .72fr) minmax(520px, 1.55fr);
  gap: clamp(28px, 5vw, 76px);
  align-items: start;
}

.stage-copy { max-width: 520px; }
.eyebrow { margin: 0 0 14px; color: var(--recorded); font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 920px;
  margin-bottom: 25px;
  font-size: clamp(54px, 9vw, 132px);
  line-height: .79;
  letter-spacing: -.058em;
  font-weight: 800;
  text-transform: uppercase;
}
h2 {
  margin-bottom: 22px;
  font-size: clamp(37px, 5vw, 70px);
  line-height: .92;
  letter-spacing: -.045em;
  font-weight: 760;
  text-transform: uppercase;
}
h3 {
  margin-bottom: 12px;
  font-size: 20px;
  line-height: 1.05;
  letter-spacing: -.02em;
  text-transform: uppercase;
}
.lede {
  max-width: 680px;
  margin-bottom: 28px;
  font-size: clamp(19px, 2vw, 27px);
  line-height: 1.24;
}
.body-copy { font-size: 17px; line-height: 1.42; }
.soft { color: var(--ink-soft); }

.primary,
.secondary,
.choice,
.power-button,
.link-choice,
.preset,
.claim-choice {
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.primary,
.secondary {
  min-height: 48px;
  padding: 12px 18px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.primary { background: var(--ink); color: var(--paper-light); }
.primary:hover, .primary:focus-visible { background: var(--recorded); }
.secondary:hover, .secondary:focus-visible { background: rgba(29,32,29,.09); }
.primary:disabled, .secondary:disabled { opacity: .38; cursor: not-allowed; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.annotation {
  margin-top: 22px;
  padding: 12px 0 0 16px;
  border-left: 3px solid var(--actual);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
}

.cover {
  min-height: calc(100vh - 240px);
  display: grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(420px, .95fr);
  gap: 5vw;
  align-items: center;
}
.cover-copy { align-self: center; }
.cover .lede { max-width: 580px; }
.cover-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 30px 0 34px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.cover-meta div { padding: 12px 10px 12px 0; border-right: 1px solid rgba(29,32,29,.35); }
.cover-meta div + div { padding-left: 12px; }
.cover-meta div:last-child { border-right: 0; }
.cover-meta span { display: block; font-family: var(--mono); font-size: 9px; letter-spacing: .12em; }
.cover-meta strong { display: block; margin-top: 5px; font-size: 17px; }

.recorder-shell {
  position: relative;
  border: 2px solid var(--ink);
  padding: 28px 28px 22px;
  background: #cfc3a7;
  box-shadow: var(--shadow);
}
.recorder-shell::before,
.recorder-shell::after,
.instrument-panel::before,
.instrument-panel::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid var(--ink-soft);
  border-radius: 50%;
  background: var(--paper-dark);
}
.recorder-shell::before { left: 9px; top: 9px; }
.recorder-shell::after { right: 9px; top: 9px; }
.recorder-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
}
.chart-frame {
  position: relative;
  min-height: 300px;
  border: 1px solid var(--ink);
  background-color: #f4edda;
  background-image:
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 50px 50px, 50px 50px, 10px 10px, 10px 10px;
  overflow: hidden;
}
.chart-frame canvas { width: 100%; height: 100%; min-height: 300px; display: block; }
.chart-frame.compact, .chart-frame.compact canvas { min-height: 230px; }
.chart-frame.mini, .chart-frame.mini canvas { min-height: 180px; }
.chart-label {
  position: absolute;
  z-index: 2;
  padding: 3px 5px;
  background: rgba(244,237,218,.88);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .08em;
  pointer-events: none;
}
.chart-label.top { top: 8px; left: 9px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 17px; margin-top: 12px; font-family: var(--mono); font-size: 9px; letter-spacing: .08em; }
.key::before { content: ""; display: inline-block; width: 18px; height: 2px; margin: 0 7px 3px 0; background: currentColor; }
.key.recorded { color: var(--recorded); }
.key.actual { color: var(--actual); }
.key.target { color: var(--ink-soft); }
.key.power { color: var(--heat); }

.choices { display: grid; gap: 9px; margin-top: 27px; }
.choice {
  width: 100%;
  padding: 15px 16px;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 11px;
  text-align: left;
  font-size: 17px;
  line-height: 1.25;
}
.choice .choice-id { font-family: var(--mono); font-size: 10px; padding-top: 3px; }
.choice:hover, .choice:focus-visible { background: rgba(29,32,29,.07); }
.choice.selected { background: var(--recorded); color: var(--paper-light); }
.choice.correct { background: var(--safe); color: white; }
.choice.incorrect { background: var(--actual); color: white; }

.instrument-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 245px;
  gap: 18px;
}
.instrument-panel {
  position: relative;
  padding: 18px;
  border: 2px solid var(--ink);
  background: var(--paper-dark);
  box-shadow: 5px 6px 0 rgba(29,32,29,.14);
}
.instrument-panel::before { left: 7px; bottom: 7px; }
.instrument-panel::after { right: 7px; bottom: 7px; }
.digital-readout {
  padding: 18px 13px 15px;
  border: 2px inset #615f52;
  background: #202620;
  color: #d8e6c1;
  text-align: right;
  font-family: var(--mono);
  text-shadow: 0 0 8px rgba(216,230,193,.28);
}
.digital-readout output { display: block; font-size: 43px; line-height: 1; letter-spacing: -.08em; }
.digital-readout small { display: block; margin-top: 7px; font-size: 9px; letter-spacing: .12em; }
.power-bank { display: grid; gap: 10px; margin-top: 18px; }
.power-button {
  min-height: 58px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  background: var(--paper-light);
}
.power-button::before { content: ""; width: 10px; height: 10px; border: 1px solid var(--ink); border-radius: 50%; background: transparent; }
.power-button.active { background: var(--ink); color: var(--paper-light); }
.power-button.active::before { background: var(--heat); box-shadow: 0 0 0 3px rgba(210,123,38,.22); border-color: var(--heat); }
.power-button:disabled { cursor: not-allowed; opacity: .5; }
.trial-clock { margin-top: 18px; padding-top: 13px; border-top: 1px solid var(--ink); }
.trial-clock strong { display: block; margin-top: 5px; font-family: var(--mono); font-size: 23px; }
.trial-clock progress { width: 100%; height: 7px; margin-top: 9px; accent-color: var(--actual); }

.readout-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--ink);
  border-bottom: 0;
}
.readout {
  min-height: 73px;
  padding: 11px 12px;
  border-right: 1px solid var(--ink);
  background: rgba(244,237,218,.52);
}
.readout:last-child { border-right: 0; }
.readout strong { display: block; margin-top: 5px; font-family: var(--mono); font-size: 21px; }
.readout .recorded-text { color: var(--recorded); }
.readout .actual-text { color: var(--actual); }

.evidence-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 20px; background: var(--ink); border: 1px solid var(--ink); }
.evidence { padding: 16px; background: var(--paper-light); }
.evidence span { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; }
.evidence strong { display: block; margin-top: 7px; font-size: 27px; }
.evidence p { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }

.loop-board { border: 1px solid var(--ink); background: rgba(244,237,218,.5); }
.loop-row { display: grid; grid-template-columns: 1fr 58px 1fr 58px 1fr; align-items: center; min-height: 112px; padding: 18px; }
.loop-node { padding: 19px 12px; border: 2px solid var(--ink); background: var(--paper-light); text-align: center; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; }
.loop-arrow { text-align: center; font-size: 24px; }
.return-path { margin: 0 10%; padding: 12px 0 18px; border-top: 1px solid var(--ink); text-align: center; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; }
.link-choices { display: grid; gap: 8px; margin-top: 20px; }
.link-choice { padding: 14px 16px; text-align: left; font-family: var(--mono); font-size: 11px; line-height: 1.35; }
.link-choice:hover { background: rgba(29,32,29,.08); }
.link-choice.correct { background: var(--safe); color: white; }
.link-choice.incorrect { background: var(--actual); color: white; }

.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.compare-panel { border: 1px solid var(--ink); background: rgba(244,237,218,.43); }
.compare-head { padding: 13px 14px; display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--ink); font-family: var(--mono); font-size: 10px; letter-spacing: .08em; }
.compare-head strong { font-size: 12px; }
.compare-panel .chart-frame { border: 0; }
.compare-result { min-height: 52px; padding: 11px 14px; border-top: 1px solid var(--ink); font-size: 14px; }

.lab-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 20px; }
.control-desk { border: 2px solid var(--ink); padding: 18px; background: var(--paper-dark); box-shadow: 5px 6px 0 rgba(29,32,29,.13); }
.control-group { padding: 16px 0; border-top: 1px solid var(--ink); }
.control-group:first-of-type { margin-top: 10px; }
.control-group label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; }
.control-group output { font-size: 20px; font-weight: 700; letter-spacing: 0; }
input[type="range"] { width: 100%; margin: 18px 0 4px; accent-color: var(--recorded); }
.range-scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 8px; color: var(--ink-soft); }
.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 12px 0 18px; }
.preset { padding: 10px 8px; font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.preset:hover { background: var(--ink); color: var(--paper-light); }
.status-stamp { margin-top: 15px; padding: 10px; border: 2px solid currentColor; font-family: var(--mono); font-size: 10px; line-height: 1.4; text-align: center; transform: rotate(-1deg); }
.status-stamp.stable { color: var(--safe); }
.status-stamp.oscillating { color: var(--danger); }
.status-stamp.damped { color: #8a5d20; }
.status-stamp.slow { color: var(--recorded); }

.trial-log { width: 100%; margin-top: 16px; border-collapse: collapse; font-family: var(--mono); font-size: 10px; }
.trial-log caption { padding: 8px 0; text-align: left; font-weight: 700; letter-spacing: .09em; }
.trial-log th, .trial-log td { padding: 8px 7px; border: 1px solid var(--ink); text-align: left; }
.trial-log th { background: var(--ink); color: var(--paper-light); font-weight: 400; }
.trial-log tbody tr.stable td:last-child { color: var(--safe); font-weight: 700; }
.trial-log tbody tr.oscillating td:last-child { color: var(--danger); font-weight: 700; }

.claim-sheet { max-width: 900px; border-top: 2px solid var(--ink); }
.claim-line { display: grid; grid-template-columns: 48px minmax(0,1fr); gap: 20px; padding: 22px 0; border-bottom: 1px solid var(--ink); }
.claim-line > span { font-family: var(--mono); font-size: 12px; }
.claim-line p { margin: 0 0 12px; font-size: clamp(20px, 2.2vw, 28px); }
.claim-options { display: flex; flex-wrap: wrap; gap: 7px; }
.claim-choice { padding: 8px 11px; font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.claim-choice.selected { background: var(--recorded); color: white; }
.claim-choice.correct { background: var(--safe); color: white; }
.claim-choice.incorrect { background: var(--actual); color: white; }

.final-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(28px,5vw,75px); }
.final-statement { margin: 0 0 34px; padding-top: 15px; border-top: 4px solid var(--actual); font-size: clamp(34px,5vw,72px); line-height: .94; letter-spacing: -.045em; text-transform: uppercase; }
.field-record { border: 1px solid var(--ink); background: rgba(244,237,218,.45); }
.field-record h3 { padding: 14px; margin: 0; border-bottom: 1px solid var(--ink); font-family: var(--mono); font-size: 11px; letter-spacing: .1em; }
.record-row { display: grid; grid-template-columns: 145px 1fr; border-bottom: 1px solid var(--ink); }
.record-row:last-child { border-bottom: 0; }
.record-row span, .record-row strong { padding: 11px 13px; }
.record-row span { border-right: 1px solid var(--ink); font-family: var(--mono); font-size: 9px; letter-spacing: .08em; }
.record-row strong { font-size: 15px; font-weight: 500; }

.notes-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 35px);
  padding: 0 28px 28px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--paper-light);
  color: var(--ink);
  box-shadow: 10px 11px 0 rgba(0,0,0,.35);
}
.notes-dialog::backdrop { background: rgba(20,22,19,.62); }
.notes-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 16px 0 10px; background: var(--paper-light); border-bottom: 1px solid var(--ink); }
.notes-head .eyebrow { margin: 0; }
.close-button { width: 34px; height: 34px; border: 0; background: transparent; font: 26px/1 var(--narrow); cursor: pointer; }
.notes-dialog h2 { margin-top: 24px; font-size: 47px; }
.notes-dialog h3 { margin-top: 25px; font-size: 16px; }
.notes-dialog p, .notes-dialog li { font-size: 15px; line-height: 1.48; }
.notes-dialog li + li { margin-top: 7px; }
.notes-dialog a { color: var(--recorded); text-underline-offset: 3px; }
.notes-version { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--ink); font-family: var(--mono); font-size: 9px !important; letter-spacing: .1em; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
.fade-in { animation: fade-in .35s ease both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

@media (max-width: 980px) {
  .stage-grid, .cover, .final-grid { grid-template-columns: 1fr; }
  .cover { min-height: auto; }
  .cover-instrument { max-width: 720px; }
  .instrument-grid { grid-template-columns: 1fr; }
  .instrument-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
  .power-bank { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
  .lab-layout { grid-template-columns: 1fr; }
  .control-desk { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
  .control-desk h3, .control-desk .preset-row, .control-desk .button-row, .control-desk .status-stamp { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .station-header { min-height: 58px; }
  .station-mark { min-width: 0; flex: 1; padding: 8px 11px; }
  .station-mark span { display: none; }
  .station-mark strong { font-size: 13px; }
  .runtime { display: none; }
  .text-button { padding: 0 13px; }
  .progress-rail ol { grid-template-columns: repeat(7, minmax(42px,1fr)); }
  .progress-rail li { justify-content: center; padding: 0 3px; font-size: 0; }
  .progress-rail li span { font-size: 9px; }
  .progress-rail li.done::after { display: none; }
  .stage { padding: 27px 14px 48px; }
  h1 { font-size: clamp(50px, 18vw, 86px); }
  h2 { font-size: clamp(37px, 12vw, 54px); }
  .cover-meta { grid-template-columns: 1fr; }
  .cover-meta div, .cover-meta div + div { padding: 9px 0; border-right: 0; border-bottom: 1px solid rgba(29,32,29,.35); }
  .cover-meta div:last-child { border-bottom: 0; }
  .recorder-shell { padding: 23px 12px 15px; }
  .chart-frame, .chart-frame canvas { min-height: 250px; }
  .instrument-panel { display: block; }
  .power-bank { margin-top: 15px; }
  .readout-row { grid-template-columns: 1fr 1fr; }
  .readout:nth-child(2) { border-right: 0; }
  .readout:nth-child(-n+2) { border-bottom: 1px solid var(--ink); }
  .evidence-grid, .compare-grid { grid-template-columns: 1fr; }
  .loop-row { grid-template-columns: 1fr; gap: 6px; }
  .loop-arrow { transform: rotate(90deg); }
  .control-desk { display: block; }
  .claim-line { grid-template-columns: 34px 1fr; gap: 8px; }
  .record-row { grid-template-columns: 110px 1fr; }
  .station-footer { font-size: 8px; }
}

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