:root {
  color-scheme: light;
  --paper: #f3efe7;
  --surface: #fffdf8;
  --surface-soft: #e9e3d8;
  --ink: #15181b;
  --muted: #55595e;
  --line: #b9b0a3;
  --line-strong: #6d675f;
  --accent: #9e3653;
  --accent-soft: #f1dce2;
  --student: #5c3fc4;
  --student-soft: #e6e0fb;
  --teacher: #0b685f;
  --teacher-soft: #d8ede9;
  --fixed: #865600;
  --fixed-soft: #f2e2bd;
  --positive: #0b685f;
  --negative: #9e3653;
  --focus: #0068c9;
  --shadow: rgba(30, 25, 18, 0.11);
  --measure: 47rem;
  --wide: 72rem;
  --radius: 0.7rem;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --serif: Iowan Old Style, Charter, "Palatino Linotype", Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f1114;
  --surface: #171a1f;
  --surface-soft: #22262c;
  --ink: #f5f0e7;
  --muted: #bbb6ad;
  --line: #4d535d;
  --line-strong: #949ba7;
  --accent: #ff93ae;
  --accent-soft: #512938;
  --student: #b7a3ff;
  --student-soft: #352d58;
  --teacher: #60d6c7;
  --teacher-soft: #193f3c;
  --fixed: #f2c66e;
  --fixed-soft: #4d3d20;
  --positive: #60d6c7;
  --negative: #ff93ae;
  --focus: #80c4ff;
  --shadow: rgba(0, 0, 0, 0.32);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), color-mix(in srgb, var(--line) 24%, transparent) 50%, transparent calc(50% + 1px)) 0 0 / 8rem 8rem,
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.97rem + 0.18vw, 1.1rem);
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 0.16em;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-160%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 0.85rem;
  border-radius: 0.35rem;
}

.skip-link:focus {
  transform: none;
}

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.2rem;
  padding: 0.75rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  color: var(--accent);
  font: 700 0.72rem/1 var(--mono);
  letter-spacing: 0.12em;
}

.brand-title {
  font: 600 0.95rem/1.2 var(--sans);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.quiet-button,
.primary-button,
.matrix-button,
.linear-matrix-button {
  min-height: 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.quiet-button,
.primary-button {
  padding: 0.55rem 0.95rem;
  font-weight: 700;
}

.quiet-button:hover,
.matrix-button:hover,
.linear-matrix-button:hover {
  background: var(--surface-soft);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

:root[data-theme="dark"] .primary-button {
  color: #1a0d12;
}

.primary-button:disabled {
  cursor: not-allowed;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  opacity: 0.75;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 5.5rem);
  width: min(100% - 2rem, 94rem);
  margin: 0 auto;
}

.contents {
  align-self: start;
  position: sticky;
  top: 6rem;
  padding: 3rem 0 2rem;
  font-size: 0.82rem;
}

.contents-label {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font: 700 0.7rem/1.2 var(--mono);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.contents ol {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contents a {
  display: block;
  padding: 0.33rem 0.55rem;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.contents a:hover,
.contents a[aria-current="location"] {
  border-left-color: var(--accent);
  color: var(--ink);
}

main {
  min-width: 0;
}

.article {
  padding: clamp(3.5rem, 8vw, 7rem) 0 6rem;
}

.article > section,
.article > header,
.article > footer {
  width: min(100%, var(--measure));
}

.article > section {
  margin-top: clamp(4.5rem, 9vw, 8rem);
}

.article > .wide-section {
  width: min(100%, var(--wide));
}

.hero {
  position: relative;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--line-strong);
}

.hero::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  width: min(38%, 17rem);
  border-bottom: 5px solid var(--accent);
}

.eyebrow,
.section-kicker,
.truth-tag,
.instrument-id {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow,
.section-kicker {
  color: var(--accent);
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.08;
  text-wrap: balance;
}

h1 {
  max-width: 12ch;
  margin-top: 1.2rem;
  font-size: clamp(3rem, 8vw, 6.8rem);
  letter-spacing: -0.055em;
}

h2 {
  margin-top: 0.5rem;
  font-size: clamp(2.15rem, 5vw, 4.2rem);
  letter-spacing: -0.038em;
}

h3 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

h4 {
  font-size: 1.24rem;
}

h5 {
  font-size: 1rem;
  font-family: var(--sans);
}

p,
ul,
ol,
dl,
table,
blockquote {
  margin-block: 1rem;
}

.dek {
  max-width: 40rem;
  margin-top: 1.5rem;
  color: var(--muted);
  font: 400 clamp(1.2rem, 2vw, 1.55rem)/1.55 var(--serif);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.4rem;
  margin-top: 2rem;
  color: var(--muted);
  font: 600 0.78rem/1.4 var(--mono);
}

.status-note,
.boundary-note,
.non-equivalence {
  padding: 1rem 1.15rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
}

.status-note {
  margin-top: 2.2rem;
}

.truth-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.4rem;
  padding: 0.22rem 0.45rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--muted);
  vertical-align: 0.12em;
}

.truth-tag.toy { color: var(--fixed); }
.truth-tag.sourced { color: var(--teacher); }
.truth-tag.derived { color: var(--student); }
.truth-tag.unresolved { color: var(--accent); }

.lead {
  color: var(--ink);
  font: 400 1.28rem/1.68 var(--serif);
}

.axis-glyph {
  margin: 2rem 0;
  padding: 1rem 1.15rem 1.2rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.axis-glyph figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}

.axis-glyph-diagram {
  position: relative;
  min-width: 0;
  height: 8.5rem;
}

.axis-glyph-diagram::before,
.axis-glyph-diagram::after {
  content: "";
  position: absolute;
  background: var(--line-strong);
}

.axis-glyph-diagram::before {
  top: 55%;
  right: 7%;
  left: 7%;
  height: 2px;
}

.axis-glyph-diagram::after {
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 2px;
}

.axis-glyph-label {
  position: absolute;
  z-index: 1;
  max-width: 48%;
  padding: 0.25rem 0.45rem;
  background: var(--surface);
  color: var(--ink);
  font: 700 0.72rem/1.25 var(--mono);
  letter-spacing: 0.07em;
  text-align: center;
  text-transform: uppercase;
}

.axis-glyph-source {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.axis-glyph-divergence {
  top: 55%;
  right: 0;
  transform: translateY(-50%);
}

.split-questions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 2rem 0;
  border: 1px solid var(--line-strong);
  background: var(--line-strong);
}

.question-pane {
  min-height: 15rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  background: var(--surface);
}

.question-pane .axis-number {
  display: block;
  color: var(--accent);
  font: 700 0.8rem/1 var(--mono);
}

.question-pane h3 {
  margin-top: 1.2rem;
}

.equation {
  overflow-x: auto;
  margin: 2rem 0;
  padding: 1.3rem 0;
  border-block: 1px solid var(--line);
  text-align: center;
}

.equation math {
  font-size: clamp(1.15rem, 2.3vw, 1.65rem);
}

.equation figcaption {
  max-width: 38rem;
  margin: 0.8rem auto 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: left;
}

code,
.number {
  font-family: var(--mono);
  font-size: 0.9em;
}

code {
  padding: 0.08em 0.24em;
  border-radius: 0.2rem;
  background: var(--surface-soft);
}

.requires-js {
  display: none;
}

.js .requires-js {
  display: block;
}

.js .screen-fallback {
  display: none;
}

.prediction-panel {
  margin-top: 2rem;
  padding: clamp(1.2rem, 3vw, 2.2rem);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: 0 1rem 3rem var(--shadow);
}

.prediction-panel fieldset,
.control-group,
.feedback-controls {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.prediction-panel legend,
.control-group legend,
.feedback-controls legend {
  max-width: 100%;
  padding: 0;
  color: var(--ink);
  font-weight: 750;
}

.prediction-scenario {
  margin: 0.85rem 0 1.3rem;
  padding-left: 1rem;
  border-left: 3px solid var(--student);
  font-family: var(--serif);
  font-size: 1.15rem;
}

.prediction-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.prediction-option,
.segment-option,
.feedback-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3rem;
  cursor: pointer;
}

.prediction-option {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--paper);
}

.prediction-option:has(input:checked) {
  border-color: var(--student);
  box-shadow: inset 0 0 0 2px var(--student);
}

.prediction-option input,
.segment-option input,
.feedback-option input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--student);
}

.prediction-actions,
.instrument-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.prediction-feedback {
  margin: 1.2rem 0 0;
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--teacher);
  background: var(--teacher-soft);
}

.prediction-feedback[data-correct="false"] {
  border-left-color: var(--fixed);
  background: var(--fixed-soft);
}

.observatory-frame {
  margin-top: 3rem;
  border-block: 2px solid var(--ink);
  background: var(--surface);
  box-shadow: 0 1.4rem 4rem var(--shadow);
}

.instrument-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
}

.instrument-id {
  color: var(--muted);
}

.instrument-controls {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(12rem, 1.25fr);
  gap: 1rem;
  padding: clamp(1rem, 3vw, 1.6rem);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.control-group {
  padding: 0.85rem;
  border: 1px solid var(--line);
  background: var(--surface);
}

.segment-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.segment-option {
  align-items: flex-start;
  min-height: 2.5rem;
  padding: 0.4rem 0.45rem;
  border-radius: 0.35rem;
}

.segment-option:has(input:checked) {
  background: var(--student-soft);
}

.segment-option small,
.control-help {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--student);
}

.temperature-value {
  min-width: 3.8rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  background: var(--paper);
  font-family: var(--mono);
  text-align: center;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font: 0.68rem/1 var(--mono);
}

.axis-readout {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.85rem clamp(1rem, 3vw, 1.6rem);
  border-bottom: 1px solid var(--line);
  font: 700 0.74rem/1.4 var(--mono);
  letter-spacing: 0.06em;
}

.axis-readout .axis-label {
  color: var(--muted);
  font-weight: 500;
}

.observatory-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(21rem, 0.92fr);
  gap: 0;
}

.instrument-pane {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.8rem);
  border-bottom: 1px solid var(--line);
}

.instrument-pane + .instrument-pane {
  border-left: 1px solid var(--line);
}

.pane-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.pane-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.tree-wide {
  overflow: hidden;
}

.tree-wide svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 18rem;
  background:
    linear-gradient(var(--line), var(--line)) 0 33% / 100% 1px no-repeat,
    linear-gradient(var(--line), var(--line)) 0 66% / 100% 1px no-repeat,
    var(--paper);
}

.tree-line {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 3;
  stroke-linecap: round;
}

.tree-line.fixed {
  stroke: var(--fixed);
  stroke-dasharray: 9 5;
}

.tree-line.student {
  stroke: var(--student);
  stroke-dasharray: 3 6;
}

.tree-line.student.is-visited {
  stroke-width: 8;
  stroke-dasharray: none;
}

.tree-node {
  fill: var(--surface);
  stroke: var(--line-strong);
  stroke-width: 2;
}

.tree-node.is-visited {
  fill: var(--student-soft);
  stroke: var(--student);
  stroke-width: 5;
}

.tree-text {
  fill: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
}

.tree-text.small {
  fill: var(--muted);
  font-size: 13px;
}

.tree-text.lane-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.tree-text.visited {
  fill: var(--student);
  font-size: 13px;
  font-weight: 700;
}

.tree-compact {
  display: none;
}

.lane-summary {
  margin-top: 1rem;
  padding: 0.65rem 0.8rem;
  border-left: 3px solid var(--line-strong);
  background: var(--surface-soft);
  font-size: 0.86rem;
}

.matrix-wide {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.matrix-wide caption {
  margin-bottom: 0.7rem;
  color: var(--muted);
  text-align: left;
}

.matrix-wide th,
.matrix-wide td {
  border: 1px solid var(--line);
}

.matrix-wide thead th {
  padding: 0.65rem 0.5rem;
  background: var(--surface-soft);
  font: 700 0.76rem/1.35 var(--mono);
}

.matrix-wide tbody th {
  width: 24%;
  padding: 0.65rem;
  background: var(--surface-soft);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: left;
}

.matrix-wide td {
  position: relative;
  padding: 0.45rem;
  background: var(--surface);
}

.matrix-wide td.is-current {
  box-shadow: inset 0 0 0 4px var(--accent);
}

.matrix-button {
  display: grid;
  width: 100%;
  min-height: 7.2rem;
  place-content: center;
  gap: 0.35rem;
  padding: 0.75rem;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  font-variant-numeric: tabular-nums;
}

.matrix-path {
  color: var(--muted);
  font: 0.78rem/1.3 var(--mono);
}

.matrix-value {
  font: 700 1.05rem/1.2 var(--mono);
}

.current-label {
  color: var(--accent);
  font: 700 0.66rem/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.matrix-linear {
  display: none;
}

.data-block {
  margin-top: 0;
  border-top: 1px solid var(--line);
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
}

.table-scroll:focus-visible {
  outline-offset: 2px;
}

.data-table {
  width: 100%;
  min-width: 39rem;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.data-table caption {
  padding: 0.85rem;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.data-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
}

.data-table thead th {
  background: var(--surface-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.data-table thead th:first-child {
  background: var(--surface-soft);
}

.term-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem;
}

.term-group {
  min-width: 0;
}

.term-row {
  display: grid;
  grid-template-columns: 4.2rem minmax(7rem, 1fr) 5.7rem;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  font-size: 0.76rem;
}

.term-track {
  position: relative;
  height: 1.15rem;
  border-inline: 1px solid var(--line);
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), var(--line-strong) 50%, transparent calc(50% + 0.5px)),
    var(--surface-soft);
}

.term-bar {
  position: absolute;
  top: 0.2rem;
  height: 0.75rem;
  min-width: 2px;
}

.term-bar.is-positive {
  left: 50%;
  background: repeating-linear-gradient(135deg, var(--positive), var(--positive) 4px, transparent 4px, transparent 7px);
  border: 1px solid var(--positive);
}

.term-bar.is-negative {
  right: 50%;
  background: repeating-linear-gradient(45deg, var(--negative), var(--negative) 4px, transparent 4px, transparent 7px);
  border: 1px solid var(--negative);
}

.term-value {
  font-family: var(--mono);
  text-align: right;
}

.term-sum {
  margin-top: 0.8rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.reduction-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.reduction-strip p {
  margin: 0.2rem 0;
}

.mean-box {
  min-width: 11rem;
  padding: 0.9rem 1.1rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  text-align: right;
}

.mean-box span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.mean-box output {
  display: inline;
  font: 750 1.6rem/1 var(--mono);
}

.state-summary {
  margin: 0;
  padding: 1.1rem clamp(1rem, 3vw, 1.6rem);
  border-top: 1px solid var(--line);
  background: var(--teacher-soft);
}

.update-lane {
  display: grid;
  grid-template-columns: repeat(6, minmax(8rem, 1fr));
  gap: 0;
  margin: 2rem 0;
  padding: 0;
  list-style: none;
  counter-reset: update-step;
}

.update-step {
  position: relative;
  min-height: 13rem;
  padding: 1rem 1.8rem 1rem 0.9rem;
  border-block: 1px solid var(--line-strong);
  border-left: 1px solid var(--line);
  background: var(--surface);
  counter-increment: update-step;
}

.update-step:last-child {
  border-right: 1px solid var(--line);
}

.update-step::before {
  content: "0" counter(update-step);
  display: block;
  margin-bottom: 1.5rem;
  color: var(--accent);
  font: 700 0.74rem/1 var(--mono);
}

.update-step:not(:last-child)::after {
  content: "→";
  position: absolute;
  z-index: 2;
  top: 50%;
  right: -0.68rem;
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font: 700 0.8rem/1 var(--sans);
}

.update-step strong {
  display: block;
  line-height: 1.25;
}

.update-step p {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.stop-gradient {
  border-top: 5px double var(--accent);
}

.feedback-lab {
  margin-top: 2rem;
  border-block: 2px solid var(--ink);
  background: var(--surface);
}

.feedback-lab-header {
  padding: clamp(1rem, 3vw, 1.8rem);
  border-bottom: 1px solid var(--line);
}

.feedback-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 1rem clamp(1rem, 3vw, 1.8rem);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.feedback-controls legend {
  flex: 0 0 100%;
}

.feedback-option {
  min-height: 2.75rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.feedback-option:has(input:checked) {
  border-color: var(--student);
  box-shadow: inset 0 0 0 2px var(--student);
}

.feedback-status {
  margin: 0;
  padding: 0.7rem clamp(1rem, 3vw, 1.8rem);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font: 0.76rem/1.4 var(--mono);
}

.feedback-body {
  padding: clamp(1rem, 3vw, 1.8rem);
}

.feedback-body h4 {
  margin-bottom: 0.6rem;
}

.feedback-table-scroll {
  margin-top: 1.2rem;
}

.feedback-table {
  margin-top: 0;
}

.feedback-facts {
  display: grid;
  grid-template-columns: minmax(9rem, 0.38fr) minmax(0, 1fr);
  margin-top: 1.2rem;
  border-top: 1px solid var(--line);
}

.feedback-facts dt,
.feedback-facts dd {
  margin: 0;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

.feedback-facts dt {
  padding-right: 1rem;
  color: var(--muted);
  font: 700 0.74rem/1.5 var(--mono);
}

.method-table td,
.method-table th {
  vertical-align: top;
  white-space: normal;
}

.transfer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

details {
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

summary {
  padding: 1rem 1.1rem;
  cursor: pointer;
  font-weight: 750;
}

details[open] summary {
  border-bottom: 1px solid var(--line);
}

.details-body {
  padding: 0.2rem 1.1rem 1rem;
}

.carry-list {
  counter-reset: carry;
  display: grid;
  gap: 0;
  margin-top: 2rem;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-strong);
}

.carry-list li {
  counter-increment: carry;
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.8rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}

.carry-list li::before {
  content: counter(carry, decimal-leading-zero);
  color: var(--accent);
  font: 700 0.75rem/1.7 var(--mono);
}

.source-list {
  padding-left: 1.2rem;
}

.source-list li + li {
  margin-top: 0.75rem;
}

.screen-fallback {
  margin-top: 2rem;
  padding: clamp(1rem, 3vw, 2rem);
  border: 2px solid var(--ink);
  background: var(--surface);
}

.static-matrix {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.static-matrix th,
.static-matrix td {
  padding: 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
}

.static-matrix th {
  background: var(--surface-soft);
}

.static-snapshots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.static-snapshot {
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--line);
}

.article-footer {
  margin-top: 6rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.82rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.is-replaying .tree-line.student.is-visited,
.is-replaying .tree-node.is-visited {
  animation: replay-pulse 420ms ease-out;
}

@keyframes replay-pulse {
  50% { filter: drop-shadow(0 0 7px var(--student)); }
}

@media (max-width: 70rem) {
  .page-shell {
    grid-template-columns: minmax(0, 1fr);
    width: min(100% - 2rem, 72rem);
  }

  .contents {
    position: static;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    padding: 1rem 0 0;
  }

  .contents ol {
    display: flex;
    max-width: 100%;
    gap: 0.2rem;
    overflow-x: auto;
    padding-bottom: 0.6rem;
  }

  .contents a {
    min-width: max-content;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .contents a:hover,
  .contents a[aria-current="location"] {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .article {
    padding-top: 3rem;
  }

  .observatory-grid {
    grid-template-columns: 1fr;
  }

  .instrument-pane + .instrument-pane {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .update-lane {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .update-step:nth-child(3) {
    border-right: 1px solid var(--line);
  }

  .update-step:nth-child(3)::after {
    display: none;
  }
}

@media (max-width: 48rem) {
  body {
    font-size: 1rem;
  }

  .site-header {
    min-height: 3.7rem;
    padding-inline: 0.8rem;
  }

  .brand-title {
    display: none;
  }

  .quiet-button {
    min-height: 2.5rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.78rem;
  }

  .page-shell {
    width: min(100% - 1.25rem, 46rem);
  }

  .article > section {
    margin-top: 4.2rem;
  }

  h1 {
    font-size: clamp(2.65rem, 13.5vw, 4.4rem);
  }

  .split-questions,
  .prediction-grid,
  .transfer-grid,
  .static-snapshots,
  .term-groups {
    grid-template-columns: 1fr;
  }

  .question-pane {
    min-height: 0;
  }

  .axis-glyph-label {
    font-size: 0.64rem;
  }

  .instrument-header,
  .pane-heading {
    flex-direction: column;
  }

  .instrument-controls {
    grid-template-columns: 1fr;
  }

  .axis-readout {
    grid-template-columns: auto 1fr;
  }

  .matrix-wide,
  .tree-wide {
    display: none;
  }

  .matrix-linear,
  .tree-compact {
    display: grid;
    gap: 0.6rem;
  }

  .linear-matrix-button {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.45rem 1rem;
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 0.4rem;
    text-align: left;
  }

  .linear-matrix-button.is-current,
  [data-quadrant-linear].is-current .linear-matrix-button {
    box-shadow: inset 0 0 0 3px var(--accent);
  }

  .linear-matrix-button strong {
    grid-column: 1;
  }

  .linear-matrix-button .number {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .term-row {
    grid-template-columns: 4rem minmax(6rem, 1fr) 5.5rem;
  }

  .reduction-strip {
    grid-template-columns: 1fr;
  }

  .mean-box {
    text-align: left;
  }

  .update-lane {
    grid-template-columns: 1fr;
  }

  .update-step,
  .update-step:nth-child(3),
  .update-step:last-child {
    min-height: 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-bottom: 0;
  }

  .update-step:last-child {
    border-bottom: 1px solid var(--line);
  }

  .update-step::before {
    margin-bottom: 0.7rem;
  }

  .update-step:not(:last-child)::after {
    top: auto;
    right: 1rem;
    bottom: -0.7rem;
    content: "↓";
  }

  .feedback-facts {
    grid-template-columns: 1fr;
  }

  .feedback-facts dt {
    padding-bottom: 0.1rem;
    border-bottom: 0;
  }

  .feedback-facts dd {
    padding-top: 0;
  }

  .static-matrix {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 22rem) {
  .page-shell {
    width: calc(100% - 1rem);
  }

  .hero-meta,
  .prediction-actions,
  .instrument-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .prediction-actions button,
  .instrument-actions button {
    width: 100%;
  }

  .term-row {
    grid-template-columns: 3.6rem minmax(4.5rem, 1fr) 5rem;
    gap: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (forced-colors: active) {
  :root {
    --student: Highlight;
    --teacher: LinkText;
    --fixed: CanvasText;
    --accent: Highlight;
    --positive: LinkText;
    --negative: CanvasText;
  }

  .term-bar,
  .tree-line,
  .tree-node,
  .prediction-option:has(input:checked),
  .feedback-option:has(input:checked),
  .matrix-wide td.is-current {
    forced-color-adjust: auto;
  }
}

@media print {
  :root,
  :root[data-theme="dark"] {
    color-scheme: light;
    --paper: #fff;
    --surface: #fff;
    --surface-soft: #f3f3f3;
    --ink: #000;
    --muted: #333;
    --line: #aaa;
    --line-strong: #333;
    --accent: #70002b;
    --accent-soft: #f5e8ed;
    --student: #34206f;
    --student-soft: #eeeafd;
    --teacher: #004f49;
    --teacher-soft: #e5f3f1;
    --fixed: #634000;
    --fixed-soft: #f7edd4;
  }

  html,
  body {
    background: #fff !important;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.48;
  }

  .site-header,
  .contents,
  .requires-js,
  .skip-link,
  .header-actions {
    display: none !important;
  }

  .page-shell {
    display: block;
    width: 100%;
  }

  .article {
    padding: 0;
  }

  .article > section,
  .article > header,
  .article > footer,
  .article > .wide-section {
    width: 100%;
  }

  .article > section {
    margin-top: 2.4rem;
  }

  h1 {
    font-size: 42pt;
  }

  h2 {
    font-size: 25pt;
  }

  h2,
  h3,
  h4,
  .axis-glyph,
  .status-note,
  .boundary-note,
  .update-step,
  figure,
  table,
  details,
  .static-snapshot {
    break-inside: avoid;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    overflow-wrap: anywhere;
    color: #333;
    font: 7.5pt/1.2 var(--mono);
  }

  .screen-fallback {
    display: block !important;
    box-shadow: none;
  }

  .table-scroll {
    overflow: visible;
  }

  .data-table {
    min-width: 0;
    font-size: 8.5pt;
  }
}
