@font-face {
  font-family: "Particle Sans";
  src: url("../assets/fonts/ParticleSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4efe6;
  --bg-2: #fbf7f0;
  --ink: #2c241c;
  --muted: #5c5148;
  --dim: #6b5e54;
  --line: rgba(44, 36, 28, 0.18);
  --glow: #3d6a86;
  --copper: #b85a48;
  --p: #6f97b8;
  --s: #d4846a;
  --love: #6f8a4e;
  --ray: #a78bbd;
  --paper: none;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Particle Sans", sans-serif;
  --display: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 12rem; }
html.reduce-motion { scroll-behavior: auto; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    var(--paper),
    radial-gradient(680px 320px at 12% -8%, rgba(197, 215, 228, 0.65), transparent 60%),
    radial-gradient(520px 280px at 100% 0%, rgba(224, 212, 238, 0.55), transparent 55%),
    radial-gradient(480px 240px at 80% 100%, rgba(213, 221, 192, 0.4), transparent 50%);
  background-size: 256px 256px, auto, auto, auto;
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1.7;
}
body.is-body { overflow: hidden; }
a { color: var(--glow); text-underline-offset: 0.18em; }
::selection { background: rgba(183, 240, 223, 0.28); color: #fff; }
:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; font-size: 1rem; }
button, a, input, select { touch-action: manipulation; }
button {
  background: var(--surface, #fffdf9);
  border: 1px solid var(--border-strong, rgba(44, 36, 28, 0.22));
  border-radius: var(--radius-sm, 10px);
  padding: 0.5rem 1rem;
  min-height: 44px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:hover { border-color: var(--glow); }
button:active { transform: translateY(1px); }
/* choice chips: anything that toggles (pressed / radio / checked) is a pill */
button[aria-pressed], button[role="radio"], button[aria-checked] { border-radius: 999px; }
button[aria-pressed="true"], button[aria-checked="true"] {
  background: var(--glow);
  color: #fff;
  border-color: var(--glow);
}
button.primary { background: var(--glow); color: #fff; border-color: var(--glow); }
button.primary:hover { background: #335a72; border-color: #335a72; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.phase { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; }
.phase::before { content: ""; width: 10px; height: 10px; flex: 0 0 auto; }
.phase-p { background: #d5e3f0; color: #1a3344; border-color: #7aa4c4; }
.phase-s { background: #f3d2c6; color: #4a241c; border-color: #d4846a; }
.phase-love { background: #dde6cc; color: #243018; border-color: #7d8f55; }
.phase-ray { background: #e6dcf2; color: #3a2a4a; border-color: #b39bc8; }
.phase-p::before { background: var(--p); border-radius: 50%; }
.phase-s::before { background: var(--s); border-radius: 2px; }
.phase-love::before { background: var(--love); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.phase-ray::before { background: var(--ray); transform: rotate(45deg); width: 8px; height: 8px; }
.phase[aria-pressed="true"] { box-shadow: inset 0 0 0 2px currentColor; }
img, canvas, svg { max-width: 100%; }
canvas { display: block; width: 100%; }
.skip {
  position: absolute;
  left: 0.8rem;
  top: -4rem;
  background: var(--ink);
  color: #10211c;
  padding: 0.4rem 0.7rem;
  z-index: 40;
}
.skip:focus { top: 0.6rem; }

#prologue[hidden] { display: none !important; }
#prologue {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #f4efe6;
  color: var(--ink);
}
html.prologue-seen #prologue { display: none; }
.prologue-stage { position: relative; min-height: 0; }
.prologue-scene {
  position: absolute;
  inset: 8vh 8vw auto;
  max-width: 40rem;
  margin: 0 auto;
  left: 0;
  right: 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  pointer-events: none;
}
.prologue-scene.is-on { opacity: 1; transform: none; }
.prologue-scene h2 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 400;
  line-height: 1.25;
  margin: 0.3rem 0 0.8rem;
}
.prologue-body { font-size: clamp(1.05rem, 2vw, 1.35rem); line-height: 1.6; max-width: 36rem; }
.prologue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 8vw 28px;
}
html.reduce-motion .prologue-scene { transition: none; transform: none; }
.narrative {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  margin: 0 0 6px;
  min-width: 0;
}
.narrative-toggle, .narrative-next {
  min-height: 32px;
  padding: 0.1rem 0.6rem;
  font-size: var(--fs-xs);
}
.narrative-index { color: var(--glow); margin-right: 0.35rem; }
.narrative-line {
  margin: 0;
  min-width: 0;
  font-size: var(--fs-sm);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}
html.narrative-collapsed .narrative-line { display: none; }
.story-caption {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 6px;
  z-index: 2;
  margin: 0;
  pointer-events: none;
  text-align: center;
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--ink);
  background: rgba(244, 239, 230, 0.88);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
}
.story-caption[hidden] { display: none !important; }
.music-readout {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  z-index: 2;
  margin: 0;
  padding: 0.12rem 0.75rem;
  pointer-events: none;
  text-align: center;
  font-size: var(--fs-xs);
  line-height: 1.35;
  color: #3d342c;
  background: rgba(255, 250, 244, 0.86);
  border: 1px solid rgba(92, 81, 72, 0.28);
  border-radius: 16px;
  white-space: normal;
  overflow: hidden;
  /* t26: always reserve two lines so playback does not jump as the wording changes.
     Height includes padding (0.12rem×2) and the 1px border on each side. */
  min-height: calc(2 * 1.35em + 0.24rem + 2px);
  max-height: calc(2 * 1.35em + 0.24rem + 2px);
  box-sizing: border-box;
}
.music-readout-line {
  display: block;
  white-space: nowrap;
  overflow: hidden;
}
.music-readout[hidden] { display: none !important; }
.body-caption {
  position: absolute;
  top: 8px;
  left: 12px;
  right: 12px;
  z-index: 3;
}
#gate[hidden] { display: none !important; }
#gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 2rem 1.2rem 3rem;
}
#gate-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.gate-inner { position: relative; text-align: center; max-width: 40rem; }
h1, h2, .brand, .speed-figure { font-family: var(--display); }
h1 {
  margin: 0.2rem 0 0.6rem;
  font-size: clamp(3.4rem, 12vw, 7.2rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1.05;
}
h2 { font-weight: 400; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: 0.06em; margin: 0.2rem 0 0.6rem; }
.kicker { margin: 0 0 0.35rem; color: var(--glow); letter-spacing: 0.06em; font-size: var(--fs-xs); }
.gate-lead { font-size: clamp(1.25rem, 2.4vw, 1.7rem); margin: 0.4rem 0 1rem; }
.gate-ask, .hint, .lede { color: var(--muted); }
.lede { max-width: 42rem; }
.gate-actions, .row { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
.gate-actions { justify-content: center; margin-top: 1.2rem; }
.caption, .prose { max-width: 46rem; }
.caption { color: var(--muted); border-top: 1px solid var(--line); padding-top: 0.8rem; }
.badge {
  border: 1px solid var(--glow);
  color: var(--glow);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  letter-spacing: 0.06em;
  font-size: var(--fs-xs);
}
.banner {
  margin: 0;
  padding: 0.7rem 1rem;
  background: #f3d2c6;
  color: #4a241c;
  text-align: center;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: center;
  padding: 0.8rem 1rem 0.2rem;
}
.brand { margin: 0; letter-spacing: 0.06em; }
.top nav { display: flex; gap: 0.35rem; overflow-x: auto; max-width: 100%; }
.volume { display: flex; gap: 0.45rem; align-items: center; color: var(--muted); }
.volume input { width: 7rem; }
.transport-wrap { position: sticky; top: 0; z-index: 8; background: rgba(7, 7, 11, 0.94); }
.transport {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.8rem;
  align-items: center;
  padding: 0.7rem 1rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.transport label, .controls label, .journal label, .volume {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: stretch;
}
.transport label { min-width: 10rem; }
.scrub { flex: 1 1 220px; min-width: 180px; }
select, input[type="text"], textarea {
  background: #fffaf4;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  width: 100%;
}
textarea { min-height: 6.5rem; resize: vertical; }
input[type="range"] {
  width: 100%;
  appearance: none;
  height: 28px;
  background: transparent;
  accent-color: #3d6a86;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6f97b8 var(--pct, 30%), rgba(44, 36, 28, 0.18) var(--pct, 30%));
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border-radius: 50%;
  background: #f7f3ea;
  border: 2px solid #3d6a86;
  box-shadow: 0 0 0 1px rgba(44, 36, 28, 0.15);
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
.chapter { padding: 2.2rem 1rem 1rem; max-width: 1100px; margin: 0 auto; scroll-margin-top: 12rem; }
.controls { display: grid; gap: 0.8rem; margin: 0.8rem 0 1rem; }
@media (min-width: 800px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .controls .row, .controls .wide { grid-column: 1 / -1; }
}
.frame {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  scroll-margin-top: 16rem;
}
.hodo-grid, .pair { display: grid; gap: 0.7rem; }
.hodo-grid figure, .pair > div { margin: 0; }
figcaption { color: var(--muted); font-size: var(--fs-sm); padding: 0.35rem 0.2rem 0.8rem; }
@media (min-width: 900px) {
  .hodo-grid { grid-template-columns: repeat(3, 1fr); }
  .pair { grid-template-columns: 1.15fr 0.85fr; }
}
#canvas-3d { touch-action: none; cursor: grab; }
.journal { display: grid; gap: 0.75rem; max-width: 42rem; }
.preview {
  white-space: pre-wrap;
  background: rgba(255, 250, 244, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  color: var(--muted);
  overflow: auto;
  max-height: 22rem;
}
details { margin: 0.6rem 0 1.5rem; }
summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
ol { padding-left: 1.2rem; color: var(--muted); }

#body-layer[hidden] { display: none; }
#body-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.body-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 8px 12px 0;
}
.body-pane {
  min-width: 0;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.body-pane figcaption {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 2px;
  color: var(--ink);
  font-size: var(--fs-sm);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.body-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
}
.body-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
}
.body-ui {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  padding: 8px 12px 10px;
  background: rgba(255, 250, 244, 0.96);
  border-top: 1px solid var(--line);
}
#body-readout {
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  line-height: 1.35;
  margin: 0 0 6px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.body-ui .hint {
  margin: 6px 0 0;
  font-size: var(--fs-xs);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.body-ui .row { gap: 8px; }
.body-dock { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin-top: 8px; }
.body-pace { margin: 0; color: var(--ink); font-size: var(--fs-sm); line-height: 1.3; overflow-wrap: anywhere; }
.body-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.body-chips button { min-height: 40px; padding: 0.12rem 0.6rem; width: auto; flex: 0 0 auto; }
.body-chips .phase { width: auto; min-height: 40px; }
.body-speed-field { margin: 0; }
#body-sound-note { margin: 0; }
@media (max-width: 800px), (max-height: 640px) {
  .body-chips button { min-height: 34px; padding: 0.04rem 0.4rem; font-size: var(--fs-xs); }
  .body-pace, #body-sound-note { font-size: var(--fs-xs); }
  .body-ui .row button { min-height: 36px; padding: 0.15rem 0.55rem; }
  #body-readout { font-size: var(--fs-sm); }
}
@media (max-width: 800px) {
  .body-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    padding: 6px 8px 0;
  }
  .body-ui { padding: 6px 8px 8px; }
  #body-readout { font-size: var(--fs-sm); }
  .body-ui .hint { font-size: var(--fs-xs); }
}

@media (max-width: 720px) {
  .top { align-items: stretch; }
  .volume { width: 100%; }
  .volume input { flex: 1; }
  .chapter { padding-top: 1.5rem; }
}
.panel {
  background: rgba(255, 250, 244, 0.62);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem 0.95rem 0.35rem;
  margin: 0.8rem 0 1rem;
}
.panel h3 {
  margin: 0 0 0.55rem;
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--glow);
}
.duo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin: 0.4rem 0 1rem;
}
.duo article {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.75rem 0.9rem;
  background: rgba(183, 240, 223, 0.05);
}
.duo article.art { background: rgba(215, 180, 255, 0.07); }
.help-slot { display: inline-flex; flex-direction: column; align-items: stretch; max-width: 100%; min-width: 0; position: relative; vertical-align: top; }
.controls > .help-slot, .journal > .help-slot, .panel .help-slot { width: 100%; }
.top nav .help-slot { width: 7.2rem; }
.transport .help-slot { max-width: 18rem; }
.help-pair { display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%; }
.top nav, .transport, .row { align-items: flex-start; }
label.with-help { position: relative; padding-right: 2rem; }
label.with-help > .help-i { position: absolute; top: 0; right: 0; }
.help-i {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
}
.help-line { display: none !important; }
html.explain-on .help-line {
  display: block !important;
  position: static;
  width: auto;
  height: auto;
  max-width: none;
  margin: 4px 0 0;
  overflow: visible;
  clip: auto;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
#help-pop {
  position: fixed;
  z-index: 40;
  width: min(26rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 32rem);
  overflow: auto;
  background: #fffaf4;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.9rem 1rem 0.8rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
#help-pop[hidden] { display: none; }
#help-pop h3 {
  margin: 0.85rem 0 0.2rem;
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--glow);
}
.help-kicker { margin: 0; color: var(--ink); }
#tour-bar {
  position: fixed;
  z-index: 26;
  left: 50%;
  bottom: 0.8rem;
  transform: translateX(-50%);
  width: min(40rem, calc(100% - 1.2rem));
  background: rgba(16, 18, 24, 0.96);
  border: 1px solid var(--glow);
  border-radius: 18px;
  padding: 0.85rem 1rem 1rem;
}
#tour-bar[hidden] { display: none; }
#tour-title { margin: 0.15rem 0; font-size: 1.15rem; }
.is-tour-target { outline: 2px solid var(--glow); outline-offset: 6px; }
@media (max-width: 700px) {
  .duo { grid-template-columns: 1fr; }
}
.top, .page { width: 100%; max-width: none; box-sizing: border-box; }
.page { padding: 8px 16px 16px; }
.page[hidden] { display: none !important; }
.stage { display: grid; gap: 16px; align-items: stretch; }
@media (min-width: 1200px) {
  #listen .stage {
    height: calc(100dvh - 118px);
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 16px;
  }
}
.station-row, .wave-row { display: grid; gap: 8px; }
.station-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wave-row { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 8px; }
.station, .phase, button.play {
  width: 100%;
  min-height: 52px;
}
.station {
  border-radius: 18px;
  padding: 0.75rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  text-align: left;
}
.station-place { font-size: 1.05rem; letter-spacing: 0.02em; white-space: nowrap; }
.station-note { color: var(--muted); font-size: var(--fs-sm); line-height: 1.35; }
button.play { min-height: 56px; margin-top: 8px; font-size: 1.25rem; border-radius: 999px; }
.play-line { display: flex; gap: 6px; align-items: stretch; margin-top: 6px; min-width: 0; }
.play-line > .play,
.play-line > .help-pair,
.play-line > .help-slot,
.play-line > .help-host { flex: 0.8 1 88px; width: auto; min-width: 0; margin-top: 0; }
.play-line .play { width: 100%; margin-top: 0; min-height: 44px; font-size: 1.05rem; }
.sound-mode { flex: 1.8 1 180px; display: flex; gap: 4px; min-width: 0; align-items: stretch; }
.sound-mode > button,
.sound-mode > .help-host,
.sound-mode > .help-pair,
.sound-mode > .help-slot { flex: 1 1 0; min-width: 0; width: auto; }
.sound-mode button { width: 100%; min-height: 40px; padding: 0.1rem 0.25rem; font-size: var(--fs-xs); white-space: nowrap; }
.sound-mode .help-i { width: 32px; min-width: 32px; height: 32px; min-height: 32px; align-self: center; }
.instrument-row { display: flex; gap: 4px; margin-top: 4px; min-width: 0; }
.instrument-row[hidden] { display: none !important; }
.instrument-row > button,
.instrument-row > .help-host,
.instrument-row > .help-slot,
.instrument-row .help-pair { flex: 1 1 0; min-width: 0; }
.instrument-row button {
  width: 100%;
  min-height: 28px;
  height: 28px;
  padding: 0 0.15rem;
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.instrument-row .help-i { width: 22px; min-width: 22px; height: 22px; min-height: 22px; flex: 0 0 auto; }
@media (max-height: 640px) and (max-width: 1199px) {
  /* t26: do not squash the trajectory/waveform to fit one screen. */
  .station { min-height: 34px; }
  .narrative { margin-bottom: 2px; }
  .page { padding-top: 2px; padding-bottom: 4px; }
}
#simple-controls > .help-host { display: block; width: 100%; }
#simple-controls .help-pair, #simple-controls .help-slot { width: 100%; }
.station-row > .help-host,
.wave-row > .help-host,
.speed-presets > .help-host,
#section-tabs > .help-host {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.station-row > .help-host > .station,
.wave-row > .help-host > .phase { width: 100%; }
#section-tabs > .help-host { flex: 0 0 auto; }
.speed-presets > .help-host { flex: 1 1 0; }
.speed-presets > .help-host > button { width: 100%; }
.phase { border-radius: 14px; font-size: 1rem; }
.tune { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 8px; align-items: end; }
.tune-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tune-name { display: flex; align-items: baseline; gap: 0.35rem; white-space: nowrap; }
#tune input[type="range"] { width: 100%; }
#speed-figure { font-size: 1.35rem; font-weight: 400; letter-spacing: 0.02em; }
.speed-presets { grid-column: 1 / -1; display: flex; flex-wrap: nowrap; gap: 8px; }
.speed-presets button { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0.2rem 0.35rem; }
.speed-plain, .volume-field { grid-column: 1 / -1; margin: 0; }
#simple-controls { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }
#make.page:not([hidden]) {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 84px);
  min-height: 0;
  overflow: hidden;
}
.make-layout { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.make-tools { min-width: 0; min-height: 0; overflow: auto; }
.make-tools h2 { margin: 0 0 0.35rem; }
.make-canvas-frame { position: relative; min-height: 0; height: 100%; }
.make-canvas-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#btn-draw-random { width: 100%; margin-top: 4px; }
#canvas-draw { touch-action: none; cursor: crosshair; }
.file-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; min-height: 44px; padding: 0.4rem 0.8rem; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
@media (max-width: 800px) {
  #make.page:not([hidden]) { height: calc(100dvh - 64px); }
  .make-layout { grid-template-columns: 1fr; grid-template-rows: 42vh minmax(0, 1fr); }
  .make-tools { overflow: auto; }
  .make-canvas-frame { order: -1; height: 100%; min-height: 0; }
}
.record-card {
  margin-top: auto;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 250, 244, 0.72);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.visual {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(280px, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: stretch;
}
.hero-frame { position: relative; height: 100%; aspect-ratio: 1; width: auto; max-width: 100%; justify-self: start; }
.hero-frame canvas, .wave-plot canvas, .spec-plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  cursor: ew-resize;
  display: flex;
  flex-direction: column;
}
.wave-plot { position: relative; flex: 1 1 71%; min-height: 0; }
.spec-plot { position: relative; flex: 0 0 29%; min-height: 28px; }
.spec-switch {
  position: absolute;
  top: 2px;
  right: 4px;
  z-index: 3;
  display: flex;
  gap: 2px;
  align-items: center;
}
.spec-switch button,
.spec-switch .help-host > button,
.spec-switch .help-pair > button {
  width: auto;
  min-height: 22px;
  height: 22px;
  padding: 0 0.4rem;
  font-size: var(--fs-xs);
  line-height: 1;
}
.spec-switch .help-i { width: 22px; min-width: 22px; height: 22px; min-height: 22px; }
.time-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 0; }
.time-row p { margin: 0; }
.time-row .scrub { flex: 1 1 180px; min-width: 140px; }
.wave-hint { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; margin: 0; }
.wave-hint[hidden] { display: none; }
.wave-hint { display: grid; gap: 0.25rem; margin: 0 0 0.7rem; max-width: 40rem; }
.wave-hint[hidden] { display: none; }
#wave-science { color: var(--ink); }
#wave-art { color: var(--muted); }
#advanced { margin-top: 1.6rem; border-top: 1px solid var(--line); padding-top: 0.4rem; }
#advanced > summary, #about-data > summary, #make-tune > summary { min-height: 48px; }
.menu-wrap { position: relative; margin-left: auto; }
#btn-menu { width: 44px; min-width: 44px; height: 44px; padding: 0; border-radius: 50%; }
#btn-menu.has-hint { box-shadow: inset 0 0 0 2px var(--glow); }
#help-menu {
  position: absolute;
  right: 0;
  top: 50px;
  z-index: 12;
  width: 16rem;
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
  background: #fffaf4;
  border: 1px solid var(--line);
  border-radius: 16px;
}
#help-menu[hidden] { display: none; }
#section-tabs { display: flex; gap: 0.35rem; overflow-x: auto; flex: 1; flex-wrap: nowrap; }
.nav { flex: 0 0 auto; white-space: nowrap; }
.nav[aria-selected="true"] { border-color: var(--glow); background: rgba(61, 106, 134, 0.16); }
#make-result[hidden] { display: none; }
label.check { display: flex; flex-direction: row; align-items: center; gap: 0.7rem; min-height: 44px; }
label.check input { width: 1.35rem; height: 1.35rem; accent-color: var(--glow); }
#sync-flash {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  background: rgba(244, 239, 230, 0.38);
  opacity: 0;
}
#sync-flash.is-on { opacity: 1; }
@media (max-width: 1199px) {
  #listen .stage { height: auto; display: flex; flex-direction: column; }
  /* t26: on landscape laptops, sit the square trajectory beside the waveform
     so it stays usable instead of becoming a wide, short strip. The page may
     scroll; phones keep the stacked t25 clamp below. */
  .visual {
    order: -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: stretch;
  }
  .hero-frame {
    width: auto;
    height: clamp(180px, 42vh, 280px);
    aspect-ratio: 1;
    max-width: 100%;
    justify-self: start;
  }
  .wave-panel { width: 100%; height: auto; min-height: 180px; }
  .time-row { grid-column: 1 / -1; }
  .record-card { display: none; }
}
@media (max-width: 760px) {
  .top {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    padding: 6px 8px;
    gap: 6px;
  }
  .brand { font-size: 0.95rem; }
  .menu-wrap { margin-left: 0; }
  #section-tabs { flex: 1; min-width: 0; max-width: none; }
  .nav { padding: 0.3rem 0.5rem; font-size: var(--fs-sm); }
  .page { padding: 4px 12px 12px; }
  .stage { gap: 8px; }
  .station { min-height: 40px; padding: 2px 6px; }
  .station-place { font-size: var(--fs-sm); }
  .station-note { font-size: var(--fs-xs); line-height: 1.2; }
  button.play { min-height: 40px; margin-top: 4px; font-size: 1.05rem; }
  .wave-row { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 4px; }
  .phase { min-height: 34px; }
  .tune { margin-top: 2px; gap: 2px; }
  #simple-controls { gap: 2px; }
  .hero-frame { width: 100%; height: 28px; aspect-ratio: auto; }
  .narrative-toggle, .narrative-next { min-height: 28px; padding: 0 0.4rem; font-size: var(--fs-xs); }
  .narrative-line { font-size: var(--fs-xs); }
  .wave-panel { width: 100%; height: 336px; }
  .time-row .scrub { position: absolute; width: 1px; height: 1px; overflow: hidden; }
  .speed-plain { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-xs); line-height: 1.2; margin: 0; }
  .time-row { gap: 0; max-height: 20px; overflow: hidden; }
  .time-row p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wave-hint { max-height: 1.3em; overflow: hidden; margin: 0; }
  .speed-presets { flex-wrap: nowrap; }
  .speed-presets > .help-host, .speed-presets button { flex: 1 1 0; font-size: var(--fs-xs); padding: 0 2px; min-height: 36px; }
  .volume-field { flex-direction: row; align-items: center; gap: 8px; }
  .volume-field .tune-name { flex: 0 0 auto; }
  .volume-field input { flex: 1; }
  .visual { display: flex; flex-direction: column; order: -1; }
  .record-card { display: none; }
  .station-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button:active { transform: none; }
}
/* Station cards (t23): equal rounded rectangles, no irregular blobs that clip text.
   4 columns when the row is wide (761–1199px layout); 2×2 in the 380px
   desktop sidebar (≥1200px) and on phones. */
.station-row { gap: 6px; }
.station-row > .help-host { display: flex; flex-direction: column; min-width: 0; }
.station-row .station,
.station-row > .help-host > .station {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0.3rem 0.7rem 0.35rem;
  border-radius: 12px;
  border: 1px solid rgba(44, 36, 28, 0.16);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(255, 255, 255, 0.75), transparent 55%),
    #f8f3ea;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  text-align: left;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.4;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.station-row .station:hover { border-color: rgba(61, 106, 134, 0.55); }
.station-row .station[aria-pressed="true"] {
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(255, 255, 255, 0.5), transparent 55%),
    rgba(111, 151, 184, 0.2);
  border-color: var(--glow);
  box-shadow: inset 0 0 0 1px var(--glow);
}
.station-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
}
.station-row .station-place {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--ink);
}
.station-dist {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  line-height: 1.35;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.station-row .station-note {
  display: block;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--muted);
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
  overflow-wrap: anywhere;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.station-row .station[aria-pressed="true"] .station-note { color: #3f362e; }
@media (min-width: 1200px) {
  .station-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-height: 640px) and (max-width: 1199px) {
  .station-row .station { padding: 0.25rem 0.6rem 0.3rem; }
  .station-row .station-note { line-height: 1.35; }
}
@media (max-width: 760px) {
  .station-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .station-row .station { padding: 0.2rem 0.55rem 0.25rem; }
  .station-row .station-place { font-size: 0.95rem; line-height: 1.3; }
  .station-row .station-note { font-size: var(--fs-xs); line-height: 1.35; }
}

/* Filter chips: always visible on Listen & Look, same chip look as the instrument row. */
.filter-row { align-items: center; }
.filter-row .filter-label {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  color: var(--muted);
  padding: 0 2px 0 4px;
  white-space: nowrap;
}

/* t25: speed-up factor value and its "i" button never overlap; trajectory readable on phones. */
#tune label.tune-field.with-help {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 6px;
  row-gap: 4px;
  align-items: center;
  padding-right: 0;
}
#tune label.tune-field.with-help > .tune-name { grid-column: 1; grid-row: 1; min-width: 0; }
#tune label.tune-field.with-help > .help-i {
  position: static;
  grid-column: 2;
  grid-row: 1;
  flex-shrink: 0;
  width: 30px; min-width: 30px; height: 30px; min-height: 30px;
}
#tune label.tune-field.with-help > input[type="range"] { grid-column: 1 / -1; grid-row: 2; }
#tune .tune-name { flex-wrap: wrap; row-gap: 0; min-width: 0; }
#tune .tune-name output, #speed-figure { font-variant-numeric: tabular-nums; white-space: nowrap; }
#speed-figure { font-size: 1.1rem; min-width: 3.7em; display: inline-block; }
#tune .tune-name { gap: 0.25rem; }
@media (max-width: 760px) {
  /* t25 + t26: keep the phone trajectory clamp; mid-width short-height no longer overrides it. */
  .hero-frame { width: 100%; height: clamp(180px, 62vw, 360px); aspect-ratio: auto; }
}

/* ---------- Chapter 5: That Night 23:05 ---------- */
.night-wrap { display: grid; gap: 0.6rem; }
.night-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  background: #05080f;
  color: #e8ecf4;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(10, 14, 24, 0.25);
  min-width: 0;
}
.night-map { position: relative; min-width: 0; min-height: max(300px, min(72vh, 640px)); overflow: hidden; }
.night-shake { position: absolute; inset: 0; will-change: transform; }
.night-shake canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.night-vignette {
  --warm: rgba(0, 0, 0, 0);
  position: absolute; inset: 0; pointer-events: none; opacity: 0.25;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(0, 0, 0, 0.85) 100%),
    radial-gradient(ellipse at 50% 50%, var(--warm), transparent 70%);
  transition: opacity 0.12s linear;
}
.night-clock {
  position: absolute; left: 12px; top: 10px; pointer-events: none;
  display: grid; line-height: 1.15; text-shadow: 0 1px 6px #000;
}
.night-clock-label { font-size: var(--fs-xs); color: #aab4c8; }
.night-clock strong { font-size: 1.9rem; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; font-weight: 400; }
.night-legend {
  position: absolute; right: 10px; top: 10px; display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end;
  font-size: var(--fs-xs); color: #c9d1e2; pointer-events: none; max-width: 60%;
}
.night-legend span { display: inline-flex; align-items: center; gap: 0.2rem; }
.night-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.night-tip {
  position: absolute; left: 10px; right: 10px; bottom: 36px; margin: 0;
  background: rgba(10, 14, 24, 0.85); border: 1px solid rgba(200, 210, 230, 0.25); border-radius: 10px;
  padding: 0.35rem 0.6rem; font-size: var(--fs-xs); line-height: 1.45;
}
.night-side {
  display: grid; align-content: start; gap: 0.55rem; padding: 0.8rem 0.9rem 0.9rem;
  border-left: 1px solid rgba(200, 210, 230, 0.12); min-width: 0;
}
.night-readout {
  --lv: #2b3346;
  margin: 0; font-size: 1.02rem; line-height: 1.45; padding-left: 0.6rem;
  border-left: 4px solid var(--lv); min-height: 2.9em;
}
.night-feel { margin: 0; font-size: var(--fs-sm); line-height: 1.55; color: #c3cbdb; min-height: 4.65em; }
.night-controls { display: grid; gap: 0.5rem; }
.night-row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.night-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.night-side button {
  background: #141c2c; color: #e8ecf4; border-color: rgba(200, 210, 230, 0.28);
  min-height: 40px; padding: 0.35rem 0.8rem; font-size: 0.95rem;
}
.night-side button.primary { background: #3d6a86; border-color: #6f97b8; }
.night-side button[aria-pressed="true"] { background: #2e4f66; border-color: #9fc2dc; }
.night-scrub input { width: 100%; accent-color: #d4846a; }
.night-field { display: grid; gap: 0.2rem; font-size: var(--fs-xs); color: #aab4c8; min-width: 0; }
.night-field select {
  background: #141c2c; color: #e8ecf4; border: 1px solid rgba(200, 210, 230, 0.28); border-radius: 10px;
  padding: 0.35rem 0.5rem; min-height: 40px; max-width: 100%; font-size: 0.95rem;
}
.night-vol { flex: 1 1 120px; }
.night-vol input { width: 100%; accent-color: #9fc2dc; }
.night-note { margin: 0; font-size: var(--fs-xs); }
.night-ref summary { cursor: pointer; font-size: var(--fs-sm); }
.night-ref img { display: block; width: 100%; max-width: 760px; height: auto; margin-top: 0.4rem; border-radius: 8px; }
@media (max-width: 860px) {
  .night-stage { grid-template-columns: minmax(0, 1fr); }
  .night-map { min-height: max(280px, min(62vh, 520px)); }
  .night-side { border-left: 0; border-top: 1px solid rgba(200, 210, 230, 0.12); }
}
@media (max-width: 480px) {
  .night-map { min-height: max(300px, 56vh); }
  .night-clock strong { font-size: 1.5rem; }
  .night-legend { top: auto; bottom: 8px; right: 8px; max-width: 70%; }
}
@media (max-height: 640px) and (min-width: 861px) {
  .night-map { min-height: max(360px, calc(100vh - 150px)); }
}
.night-side button:hover { background: #1f2a40; }
.night-side button.primary:hover { background: #4a7c9b; }
/* Intensity time-history chart */
.night-hist { background: #05080f; color: #e8ecf4; border-radius: 18px; padding: 0.7rem 0.8rem 0.8rem; min-width: 0; }
.night-hist-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; }
.night-hist-head h3 { margin: 0; font-size: 1.05rem; font-weight: 400; }
.night-hist button {
  background: #141c2c; color: #e8ecf4; border-color: rgba(200, 210, 230, 0.28);
  min-height: 36px; padding: 0.25rem 0.75rem; font-size: var(--fs-sm);
}
.night-hist button[aria-pressed="true"] { background: #2e4f66; border-color: #9fc2dc; }
.night-hist-sortf { grid-auto-flow: column; align-items: center; gap: 0.4rem; }
.night-hist select {
  background: #141c2c; color: #e8ecf4; border: 1px solid rgba(200, 210, 230, 0.28); border-radius: 10px;
  padding: 0.25rem 0.4rem; min-height: 36px; font-size: var(--fs-sm); max-width: 100%;
}
.night-hist-cap { margin: 0.4rem 0; font-size: var(--fs-xs); line-height: 1.5; color: #aab4c8; }
.night-hist-scroll { display: flex; overflow-x: auto; overflow-y: hidden; max-width: 100%; -webkit-overflow-scrolling: touch; }
#canvas-hist-labels { position: sticky; left: 0; z-index: 1; box-shadow: 4px 0 6px -4px rgba(0, 0, 0, 0.8); }
.night-hist-scroll canvas { display: block; cursor: pointer; max-width: none !important; width: auto; flex: none; }
.night-hist-live { display: grid; gap: 0.15rem; margin-top: 0.45rem; }
.night-hist-live p { margin: 0; font-size: var(--fs-sm); line-height: 1.5; }
#night-seq { color: #aab4c8; font-size: var(--fs-xs); min-height: 1.5em; }

/* ---------- t31: disaster-preparedness focus ---------- */
.nav-sub { font-size: var(--fs-xs); opacity: 0.82; padding-left: 0.55rem; padding-right: 0.55rem; }
.nav-sub::before { content: "· "; opacity: 0.6; }
/* Alert card */
.night-alert {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: min(360px, calc(100% - 24px)); box-sizing: border-box;
  background: rgba(22, 10, 12, 0.9); border: 1px solid rgba(255, 110, 95, 0.75); border-radius: 14px;
  padding: 0.55rem 0.75rem 0.6rem; color: #fff3ef; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  display: grid; gap: 0.25rem; z-index: 3;
}
.night-alert[hidden] { display: none; }
.night-alert p { margin: 0; }
.night-alert-head { font-size: var(--fs-xs); display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.4rem; color: #ffb3a8; }
.night-alert-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff5a4a; box-shadow: 0 0 8px #ff5a4a; animation: alert-blink 0.9s steps(2) infinite; }
.night-alert-meta { color: #d9c3bf; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.night-alert-count { display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
.night-alert-count strong { font-size: 2.3rem; line-height: 1; font-weight: 400; font-variant-numeric: tabular-nums; color: #ffffff; }
.night-alert-count span { font-size: 0.95rem; }
.night-alert[data-phase="count"] .night-alert-count strong { color: #ffe08a; }
.night-alert[data-phase="shake"] .night-alert-count strong { color: #ff9a7a; }
.night-alert-msg { font-size: var(--fs-xs); line-height: 1.45; color: #f3dcd7; }
.night-alert-do { font-size: 1.02rem; color: #ffffff; letter-spacing: 0.04em; }
.night-alert-after { margin: 0; padding-left: 1.1rem; font-size: var(--fs-xs); line-height: 1.45; }
.night-alert button {
  justify-self: start; background: #b03a2e; color: #fff; border: 1px solid #ff8a7a; border-radius: 10px;
  min-height: 40px; padding: 0.3rem 0.8rem; font-size: 0.95rem;
}
.night-alert button[aria-pressed="true"] { background: #2e6650; border-color: #8fd8b0; }
.night-alert-fb { font-size: var(--fs-xs); line-height: 1.45; color: #e7f6ee; }
.night-map.alerting { box-shadow: inset 0 0 0 3px rgba(255, 90, 74, 0.9), inset 0 0 60px rgba(255, 60, 40, 0.35); }
.reduce-motion .night-alert-dot { animation: none; }
@keyframes alert-blink { 50% { opacity: 0.25; } }
@media (max-width: 480px) {
  .night-alert { bottom: 34px; padding: 0.45rem 0.6rem; gap: 0.18rem; }
  .night-alert-count strong { font-size: 1.8rem; }
  .night-alert-msg, .night-alert-after { font-size: var(--fs-xs); }
  .night-alert-do { font-size: var(--fs-sm); }
}
/* Chapter 2: Those Few Seconds */
.lead-wrap { display: grid; gap: 0.7rem; }
.lead-top {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 460px); gap: 0;
  background: #05080f; color: #e8ecf4; border-radius: 18px; overflow: hidden; min-width: 0;
}
.lead-mapbox { position: relative; min-width: 0; }
.lead-map { position: relative; height: min(78vh, 720px); min-height: 360px; }
.lead-map canvas { display: block; width: 100%; height: 100%; cursor: crosshair; max-width: none; }
.lead-legend {
  position: absolute; left: 10px; top: 10px; display: flex; flex-wrap: wrap; gap: 0.3rem 0.5rem; max-width: 70%;
  font-size: var(--fs-xs); color: #c9d1e2; pointer-events: none;
}
.lead-legend span { display: inline-flex; align-items: center; gap: 0.2rem; }
.lead-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.lead-side { display: grid; align-content: start; gap: 0.5rem; padding: 0.8rem 0.9rem; border-left: 1px solid rgba(200, 210, 230, 0.12); min-width: 0; }
.lead-side button, .lead-transport button {
  background: #141c2c; color: #e8ecf4; border: 1px solid rgba(200, 210, 230, 0.28); border-radius: 10px;
  min-height: 38px; padding: 0.3rem 0.7rem; font-size: var(--fs-sm);
}
.lead-side button[aria-pressed="true"] { background: #2e4f66; border-color: #9fc2dc; }
.lead-transport button.primary { background: #3d6a86; border-color: #6f97b8; }
.lead-explain, .lead-pick { margin: 0; font-size: var(--fs-xs); line-height: 1.55; color: #c3cbdb; }
.lead-pick { color: #ffffff; min-height: 3em; }
.lead-side .hint { color: #98a3b8; margin: 0; font-size: var(--fs-xs); }
.lead-tablebox { max-height: 430px; overflow: auto; border-radius: 10px; border: 1px solid rgba(200, 210, 230, 0.12); }
.lead-table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.lead-table caption { text-align: left; font-size: var(--fs-xs); color: #aab4c8; padding: 0.35rem 0.5rem; }
.lead-table th, .lead-table td { padding: 0.25rem 0.4rem; text-align: right; white-space: nowrap; border-top: 1px solid rgba(200, 210, 230, 0.08); }
.lead-table th[scope="row"], .lead-table thead th:first-child { text-align: left; }
.lead-table thead th { position: sticky; top: 0; background: #0b101b; color: #aab4c8; font-weight: 400; }
.lead-table tbody tr { cursor: pointer; }
.lead-table tbody tr:hover, .lead-table tbody tr:focus { background: rgba(159, 194, 220, 0.12); outline: none; }
.lead-cell { color: var(--lc); }
.lead-cell.is-thr { font-weight: 700; }
.lead-table tr.is-blind th { color: #ff8a7a; }
.lead-transport { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.lead-transport strong { font-variant-numeric: tabular-nums; font-weight: 400; font-size: 1.1rem; }
.lead-transport span { font-size: var(--fs-xs); color: #c3cbdb; }
@media (max-width: 860px) {
  .lead-top { grid-template-columns: minmax(0, 1fr); }
  .lead-side { border-left: 0; border-top: 1px solid rgba(200, 210, 230, 0.12); }
  .lead-map { height: min(120vw, 70vh); min-height: 340px; }
  .lead-tablebox { max-height: none; }
}
/* Chapter 3: Why Are There a Few Seconds */
.why-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.8rem; }
.why-fig { margin: 0; background: #05080f; color: #e8ecf4; border-radius: 18px; padding: 0.7rem 0.8rem; min-width: 0; display: grid; gap: 0.45rem; align-content: start; }
.why-fig figcaption { font-size: var(--fs-xs); line-height: 1.5; color: #c3cbdb; }
.why-fig figcaption strong { color: #fff; font-weight: 400; }
.why-canvasbox { position: relative; height: 340px; min-width: 0; }
.why-canvasbox canvas { display: block; width: 100%; height: 100%; max-width: none; }
.why-dist canvas { cursor: crosshair; touch-action: pan-y; }
.why-row { gap: 0.6rem; }
.why-row .hint { margin: 0; color: #c3cbdb; font-size: var(--fs-xs); flex: 1 1 200px; }
.why-fig button { background: #3d6a86; color: #fff; border: 1px solid #6f97b8; border-radius: 10px; min-height: 40px; padding: 0.3rem 0.8rem; }
.why-readout { margin: 0; font-size: var(--fs-xs); line-height: 1.55; color: #ffffff; min-height: 4.6em; }
.why-text { grid-column: 1 / -1; }
.why-text h3 { margin: 0.2rem 0 0.3rem; font-weight: 400; }
.why-text ul { margin: 0; padding-left: 1.2rem; line-height: 1.7; }
@media (max-width: 860px) {
  .why-wrap { grid-template-columns: minmax(0, 1fr); }
  .why-canvasbox { height: 300px; }
}
/* Chapter 4: Taking the Right Action */
.act-wrap { display: grid; gap: 0.8rem; }
.act-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.act-step { background: #05080f; color: #e8ecf4; border-radius: 16px; padding: 0.7rem 0.8rem; display: grid; gap: 0.2rem; justify-items: start; }
.act-step svg { width: 84px; height: 62px; fill: none; stroke: #ffd38a; stroke-width: 3; stroke-linecap: round; }
.act-step svg circle { fill: #ffd38a; stroke: none; }
.act-step h3 { margin: 0; font-size: 1.4rem; font-weight: 400; letter-spacing: 0.06em; }
.act-step p { margin: 0; font-size: var(--fs-sm); line-height: 1.5; color: #c3cbdb; }
.act-practice { background: rgba(61, 106, 134, 0.1); border: 1px solid rgba(61, 106, 134, 0.35); border-radius: 16px; padding: 0.7rem 0.9rem; transition: box-shadow 0.2s; }
.act-practice h3 { margin: 0 0 0.3rem; font-weight: 400; }
.act-practice p { margin: 0 0 0.5rem; line-height: 1.6; }
.act-practice.is-alerting { box-shadow: 0 0 0 3px rgba(255, 90, 74, 0.85); }
.act-result { min-height: 1.6em; font-size: 0.95rem; }
.act-h { margin: 0.4rem 0 0; font-weight: 400; }
.act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.6rem; }
.act-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.6rem; }
.act-card { background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(60, 70, 90, 0.15); border-radius: 14px; padding: 0.6rem 0.8rem; }
.act-card h4 { margin: 0 0 0.3rem; font-size: 1rem; }
.act-card p, .act-card li { margin: 0; font-size: var(--fs-sm); line-height: 1.6; }
.act-card ul { margin: 0; padding-left: 1.1rem; }
.act-no { border-color: rgba(200, 70, 50, 0.4); }
.act-after { border-color: rgba(60, 140, 100, 0.4); }
.act-sources { font-size: var(--fs-xs); }
.act-sources h3 { font-size: 0.95rem; font-weight: 400; margin: 0.2rem 0; }
.act-sources ul { margin: 0; padding-left: 1.1rem; line-height: 1.7; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .act-steps { grid-template-columns: minmax(0, 1fr); }
  .act-step { grid-template-columns: auto 1fr; align-items: center; column-gap: 0.6rem; }
  .act-step svg { grid-row: span 2; width: 64px; height: 48px; }
}

/* t32: pre-event noise note */
.night-hist-noise { margin: 6px 0 0; font-size: var(--fs-xs); color: #d9cfa8; display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; }
.night-hist-noise[hidden] { display: none; }
.night-hist-noise .hatch { flex: 0 0 auto; width: 18px; height: 12px; margin-top: 3px; border: 1px solid rgba(255,211,107,0.6);
  background: repeating-linear-gradient(135deg, #ffd36b 0 1px, rgba(152,201,255,0.35) 1px 3px); }
/* t33: map range — All Taiwan + 4 regions on one row, Max intensity below */
.night-views { display: grid; width: 100%; flex: 1 1 100%; grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.75fr); gap: 0.3rem; }
.night-views button { min-width: 0; padding-left: 0.15rem; padding-right: 0.15rem; white-space: nowrap; text-align: center; }
@media (min-width: 900px) {
  /* narrow side panel: All Taiwan + 4 regions on one row, Max intensity below */
  .night-views { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .night-views #night-view-max { grid-column: span 2; }
}

/* t34: Finale task — click-only flow */
.tk { display: grid; gap: 1rem; max-width: 72rem; min-width: 0; }
.tk-progress { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; margin: 0; padding: 0; font-size: var(--fs-sm); }
.tk-progress li { padding: 0.25rem 0.65rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: rgba(255,250,244,0.6); }
.tk-progress li.done { color: #2e5f4f; border-color: rgba(46,95,79,0.45); }
.tk-progress li[aria-current="step"] { background: #2c241c; color: #f7f1e6; border-color: #2c241c; }
.tk-card { background: rgba(255,250,244,0.72); border: 1px solid var(--line); border-radius: 18px; padding: 0.9rem 1rem 1rem; min-width: 0; }
.tk-card[hidden] { display: none; }
.tk-card h3 { margin: 0 0 0.6rem; font-size: 1.08rem; }
.tk-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tk-chips button { min-height: 40px; padding: 0.4rem 0.8rem; }
.tk-chips button[aria-pressed="true"], .tk-chips button[aria-checked="true"] { background: #2c241c; color: #f7f1e6; border-color: #2c241c; }
.tk-place { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 0.8rem; margin-top: 0.7rem; align-items: start; }
.tk-mapbox canvas { display: block; width: 100%; border-radius: 12px; cursor: pointer; touch-action: manipulation; }
.tk-place-chips { display: grid; gap: 0.45rem; min-width: 0; }
.tk-region { display: grid; grid-template-columns: 2.6rem 1fr; gap: 0.4rem; align-items: start; }
.tk-region-name { font-size: var(--fs-xs); color: var(--muted); padding-top: 0.6rem; }
.tk-place-chips .tk-chips button { min-height: 36px; padding: 0.3rem 0.6rem; font-size: var(--fs-sm); }
.tk-note { margin: 0.55rem 0 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.5; }
.tk-opt { margin-top: 0.5rem; font-size: var(--fs-sm); color: var(--muted); }
.tk-opt input { display: block; margin-top: 0.35rem; width: min(16rem, 100%); padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: 10px; background: #fffdf8; }
.tk-slider { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.8rem; align-items: center; font-size: 0.95rem; }
.tk-slider input { grid-column: 1; width: 100%; }
.tk-slider output { grid-column: 2; grid-row: 2; font-size: 1.15rem; min-width: 7.5rem; text-align: right; }
.tk-q { margin: 0.8rem 0 0.35rem; font-size: 0.95rem; }
.tk-drawbox, .tk-revealbox { margin-top: 0.3rem; min-width: 0; }
.tk-drawbox canvas, .tk-revealbox canvas { display: block; width: 100%; border-radius: 12px; touch-action: none; cursor: crosshair; }
.tk-revealbox canvas { cursor: default; touch-action: auto; }
.tk-card .row { margin-top: 0.7rem; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tk-big { font-size: 1.05rem; line-height: 1.6; margin: 0.7rem 0 0.3rem; }
.tk-feedback { margin: 0.3rem 0 0; line-height: 1.6; background: rgba(61,106,134,0.1); border-left: 3px solid #3d6a86; padding: 0.5rem 0.7rem; border-radius: 0 10px 10px 0; }
.tk-make { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(16rem, 1fr); gap: 1rem; align-items: start; }
.tk-preview { position: sticky; top: 0.5rem; min-width: 0; }
.tk-preview canvas { display: block; width: 100%; border-radius: 12px; box-shadow: 0 6px 22px rgba(20,14,8,0.18); }
.tk-controls { min-width: 0; }
.tk-controls .tk-q:first-child { margin-top: 0; }
.tk-lines button { text-align: left; border-radius: 14px; }
@media (max-width: 820px) {
  .tk-make { grid-template-columns: 1fr; }
  .tk-preview { position: sticky; top: 0; z-index: 2; background: rgba(247,241,230,0.94); padding-bottom: 0.4rem; }
}
@media (max-width: 560px) {
  .tk-place { grid-template-columns: 1fr; }
  .tk-mapbox { max-width: 240px; }
  .tk-card { padding: 0.75rem 0.7rem 0.85rem; }
  .tk-chips button { padding: 0.35rem 0.6rem; }
  .tk-region { grid-template-columns: 2.3rem 1fr; }
}

/* ---------------------------------------------------------------
   t35: readability pass — one fluid type scale for every page.
   Floors: 13px on phones, 14px from ~800px wide; CJK line-height 1.6–1.8.
   --------------------------------------------------------------- */
:root {
  --fs-xs: clamp(0.8125rem, 0.75rem + 0.25vw, 0.875rem);     /* 13 → 14px: notes, captions, ticks */
  --fs-sm: clamp(0.875rem, 0.82rem + 0.25vw, 0.95rem);       /* 14 → 15.2px: chips, buttons, help */
  --fs-base: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);         /* 16 → 17.2px: body */
  --fs-lede: clamp(1.0625rem, 0.95rem + 0.5vw, 1.3rem);      /* 17 → 20.8px: chapter narrative */
  --fs-kicker: clamp(0.875rem, 0.82rem + 0.25vw, 1rem);      /* 14 → 16px: chapter index */
  --fs-title: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);         /* 28 → 44px: chapter title */
  --fs-h2: clamp(1.5rem, 1.1rem + 1.5vw, 2.3rem);            /* section heading, under the chapter title */
  --fs-h3: clamp(1.1rem, 1rem + 0.45vw, 1.35rem);
  --lh-cjk: 1.7;
}
body { font-size: var(--fs-base); line-height: var(--lh-cjk); }
h2 { font-size: var(--fs-h2); line-height: 1.25; }
.kicker { font-size: var(--fs-kicker); letter-spacing: 0.06em; }
.lede { font-size: var(--fs-lede); line-height: 1.75; max-width: 40em; color: var(--ink); }
.hint, .caption, figcaption { line-height: 1.65; }

/* chapter header: index + large title, then the full narrative paragraph (no truncation) */
.narrative {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "toggle next" "line line";
  align-items: end;
  gap: 0.2rem 1rem;
  margin: 0.3rem 0 0.9rem;
}
.narrative-toggle {
  grid-area: toggle;
  justify-self: start;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  min-height: 0; padding: 0.1rem 0.2rem; margin: 0;
  background: none; border: 0; border-radius: 8px; box-shadow: none;
  text-align: left; font-size: var(--fs-kicker);
}
.narrative-toggle:hover .narrative-title { color: var(--glow); }
.narrative-toggle[aria-pressed="true"], .narrative-toggle[aria-expanded] { background: none; }
.narrative-index { margin: 0; font-size: var(--fs-kicker); letter-spacing: 0.06em; line-height: 1.4; }
.narrative-title {
  font-family: var(--display); font-size: var(--fs-title); line-height: 1.2; letter-spacing: 0.06em; color: var(--ink);
  display: inline-flex; align-items: center; gap: 0.5em;
}
.narrative-title::after {
  content: ""; width: 0.32em; height: 0.32em; flex: 0 0 auto;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-0.12em) rotate(45deg);
}
html.narrative-collapsed .narrative-title::after { transform: rotate(-45deg); }
.narrative-line {
  grid-area: line;
  white-space: normal; overflow: visible; text-overflow: clip;
  font-size: var(--fs-lede); line-height: 1.75; max-width: 40em;
  margin-top: 0.25rem;
}
.narrative-next { grid-area: next; align-self: end; min-height: 40px; padding: 0.3rem 0.9rem; font-size: var(--fs-sm); }
@media (max-width: 760px) {
  .narrative { gap: 0.2rem 0.6rem; margin: 0.2rem 0 0.7rem; }
  .narrative-toggle, .narrative-next { font-size: var(--fs-sm); }
  .narrative-title { font-size: var(--fs-title); }
  .narrative-next { min-height: 36px; padding: 0.2rem 0.7rem; }
  .narrative-line { font-size: var(--fs-lede); line-height: 1.7; }
}
html.narrative-collapsed .narrative { margin-bottom: 0.5rem; }

/* listen: keep the one-screen layout by letting the stage take what the header leaves */
@media (min-width: 1200px) {
  #listen.page:not([hidden]) { display: flex; flex-direction: column; height: calc(100dvh - var(--top-h, 64px)); min-height: 620px; }
  #listen .stage { flex: 1 1 auto; height: auto; min-height: 0; }
}
#make.page:not([hidden]) { height: calc(100dvh - var(--top-h, 64px)); min-height: 560px; }

/* nav strip */
.nav { font-size: var(--fs-sm); }
.nav-sub { font-size: var(--fs-sm); opacity: 1; color: var(--muted); }
.nav-sub[aria-selected="true"], .nav-sub[aria-pressed="true"] { color: var(--ink); }
.badge { font-size: var(--fs-xs); }
.help-i { font-size: var(--fs-xs); }
@media (min-width: 1000px) {
  /* wide screens: title on the left, the narrative beside it — big type without pushing the work below the fold */
  .narrative {
    grid-template-columns: minmax(11rem, max-content) minmax(0, 44em) 1fr;
    grid-template-areas: "toggle line next";
    align-items: start;
    gap: 0.2rem 2rem;
  }
  .narrative-line { margin-top: 0.35rem; }
  .narrative-next { justify-self: end; align-self: start; margin-top: 0.4rem; }
  html.narrative-collapsed .narrative { grid-template-areas: "toggle . next"; }
}
.narrative-next { white-space: nowrap; }
@media (min-width: 1200px) {
  #listen.page:not([hidden]) { height: auto; min-height: calc(100dvh - var(--top-h, 64px)); }
  #listen .stage { flex: 1 0 600px; }
}
.make-tools h2, .stage h2 { font-size: clamp(1.35rem, 1.1rem + 0.8vw, 1.75rem); }
/* t35: the tour bar is dark — give it light text (was inheriting the paper ink colour) */
#tour-bar { color: #eef2f8; }
#tour-bar .kicker { color: #9cc3dd; }
#tour-text { font-size: var(--fs-base); line-height: 1.7; }
#tour-title { font-size: var(--fs-h3); }
#tour-bar button { color: var(--ink); }
/* t35: explain-mode lines inside the dark panels need light text */
html.explain-on .night-stage .help-line, html.explain-on .night-hist .help-line, html.explain-on .lead-top .help-line,
html.explain-on .why-fig .help-line, html.explain-on .act-step .help-line, html.explain-on #tour-bar .help-line { color: #c3cbdb; }
html.explain-on .help-line { font-size: var(--fs-xs); line-height: 1.55; }
/* t35: explain mode adds a line under every control; let the listen stage grow instead of overlapping */
@media (min-width: 1200px) {
  html.explain-on #listen .stage { flex: 1 0 auto; height: auto; min-height: 600px; }
}
/* the three Z/R/T switches sit on top of the spectrogram: their (identical) explain lines would cover it */
html.explain-on .spec-switch .help-line { display: none !important; }
@media (max-height: 640px) and (min-width: 761px) {
  /* short landscape screens: keep the header readable but compact */
  .narrative { margin: 0.1rem 0 0.6rem; }
  .narrative-title { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); }
  .narrative-line { line-height: 1.65; }
}

/* ---------- t36: Chapter 3 simplified — one idea, one race diagram; the real waveforms move to Advanced ---------- */
.why-simple { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 1000px) { .why-simple { grid-template-columns: minmax(17rem, 24rem) minmax(0, 1fr); align-items: start; } }
.why-idea { background: rgba(255, 252, 246, 0.72); border: 1px solid var(--line); border-radius: 18px; padding: 1rem 1.15rem; font-size: var(--fs-lede); line-height: 1.75; }
.why-idea p { margin: 0 0 0.55rem; }
.why-idea-lead { color: var(--ink); }
.why-waves { list-style: none; margin: 0 0 0.7rem; padding: 0; display: grid; gap: 0.35rem; }
.why-waves li { display: flex; align-items: center; gap: 0.6rem; }
.why-chip { display: inline-block; min-width: 3.4em; text-align: center; border-radius: 999px; padding: 0.05rem 0.6rem; font-size: var(--fs-sm); }
.why-chip-p { background: #d5e3f0; color: #1a3344; border: 1px solid #7aa4c4; }
.why-chip-s { background: #f3d2c6; color: #4a241c; border: 1px solid #d4846a; }
.why-idea-key { border-left: 4px solid var(--copper); padding-left: 0.7rem; color: var(--ink); }
.why-analogy { color: var(--muted); font-size: var(--fs-base); margin-bottom: 0 !important; }
.why-race { margin: 0; background: #05080f; color: #e8ecf4; border-radius: 18px; padding: 0.8rem; display: grid; gap: 0.6rem; min-width: 0; }
.why-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; }
.why-steps li { border: 1px solid rgba(200, 210, 230, 0.28); border-radius: 12px; padding: 0.3rem 0.5rem; font-size: var(--fs-sm); line-height: 1.4; color: #c3cbdb; text-align: center; }
.why-steps li.is-done { color: #e8ecf4; border-color: rgba(200, 210, 230, 0.5); }
.why-steps li.is-now { background: #ffd166; color: #1a1406; border-color: #ffd166; }
.why-race-box { position: relative; height: clamp(300px, 34vw, 440px); min-width: 0; }
.why-race-box canvas { display: block; width: 100%; height: 100%; border-radius: 12px; }
.why-race-bar { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 0.4rem 0.9rem; align-items: center; }
.why-race-bar button { background: #ffd166; color: #1a1406; border: 1px solid #e6b94a; border-radius: 12px; min-height: 44px; min-width: 6rem; padding: 0.3rem 1rem; font-size: var(--fs-base); }
.why-race-bar p { margin: 0; }
.why-race-clock { font-variant-numeric: tabular-nums; color: #c3cbdb; font-size: var(--fs-sm); white-space: nowrap; }
.why-race-say { font-size: var(--fs-base); line-height: 1.6; color: #ffffff; min-height: 3.2em; }
.why-towns { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }
.why-town { border: 1px solid rgba(200, 210, 230, 0.28); border-radius: 14px; padding: 0.5rem 0.7rem; display: grid; gap: 0.1rem; align-content: start; }
.why-town-name { font-size: var(--fs-base); color: #ffffff; }
.why-town-km { font-size: var(--fs-xs); color: #aab4c8; }
.why-town-state { font-weight: 400; font-size: var(--fs-sm); line-height: 1.45; color: #c3cbdb; min-height: 2.9em; }
.why-town.is-wait { border-color: #ffd166; } .why-town.is-wait .why-town-state { color: #ffd166; }
.why-town.is-blind { border-color: #ff8a7a; } .why-town.is-blind .why-town-state { color: #ff9d90; }
.why-town.is-done { border-color: #7fd39a; } .why-town.is-done .why-town-state { color: #a6e8b9; }
.why-race-note { font-size: var(--fs-xs); line-height: 1.6; color: #c3cbdb; }
.why-adv { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 0.4rem; }
.why-adv > summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-size: var(--fs-base); color: var(--glow); }
.why-adv-intro { margin: 0.2rem 0 0.5rem; color: var(--muted); }
.why-adv-links { margin-bottom: 0.8rem; }
@media (max-width: 760px) {
  .why-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .why-towns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .why-race-box { height: 300px; }
  .why-race-bar { grid-template-columns: auto minmax(0, 1fr); }
  .why-race-say { grid-column: 1 / -1; }
  .why-idea { padding: 0.85rem 0.95rem; }
}
html.explain-on .why-race .help-line { color: #c3cbdb; }
@media (max-width: 480px) {
  /* phones: the chapter title gets the whole row; the next-chapter button goes under the narrative */
  .narrative { grid-template-columns: minmax(0, 1fr); grid-template-areas: "toggle" "line" "next"; }
  .narrative-next { justify-self: start; }
}

/* ---------- t37: Chapter 4 simplified — one idea, three big animated steps, where-am-I chips, practice ---------- */
.act-core { margin: 0; font-size: clamp(1.25rem, 1rem + 1.1vw, 1.75rem); line-height: 1.6; color: var(--ink); background: rgba(255, 252, 246, 0.72); border-left: 6px solid var(--copper); border-radius: 12px; padding: 0.7rem 1rem; }
.act-core strong { font-weight: 400; color: #8a3a2a; }
ol.act-steps { list-style: none; margin: 0; padding: 0; }
.act-step { padding: 0.9rem 1rem 1rem; gap: 0.35rem; border: 2px solid transparent; animation: actStep 6s infinite; }
.act-step:nth-child(2) { animation-delay: 2s; }
.act-step:nth-child(3) { animation-delay: 4s; }
.act-step svg { width: 100%; height: auto; max-height: 190px; aspect-ratio: 160 / 110; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.act-step svg .act-person { stroke: #ffd38a; stroke-width: 8; }
.act-step svg .act-person circle { fill: #ffd38a; stroke: none; }
.act-step svg .act-table { stroke: #9cc3dd; stroke-width: 6; }
.act-step svg .act-floor { stroke: rgba(200, 210, 230, 0.4); stroke-width: 3; }
.act-step svg .act-arrow, .act-step svg .act-shake { stroke: #ff8a7a; stroke-width: 4; }
.act-step svg circle { fill: #ffd38a; }
.act-step h3 { display: flex; align-items: center; gap: 0.5rem; font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); }
.act-num { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: #ffd38a; color: #1a1406; font-size: 0.6em; letter-spacing: 0; }
.act-step p { font-size: var(--fs-base); line-height: 1.6; color: #dfe5ef; }
.act-step .act-person { transform-box: fill-box; transform-origin: center bottom; animation: actPerson 6s infinite; animation-delay: inherit; }
@keyframes actStep { 0%, 30% { border-color: #ffd38a; transform: translateY(-3px); } 36%, 100% { border-color: transparent; transform: none; } }
@keyframes actPerson { 0% { transform: translateY(-6px); } 10%, 30% { transform: translateY(0); } 100% { transform: translateY(0); } }
.act-step:nth-child(3) .act-shake { animation: actShake 0.5s infinite; }
@keyframes actShake { 50% { transform: translateX(3px); } }
html.reduce-motion .act-step, html.reduce-motion .act-step *, html.reduce-motion .act-step .act-person { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .act-step, .act-step * { animation: none !important; } }
.act-where { background: rgba(255, 252, 246, 0.72); border: 1px solid var(--line); border-radius: 16px; padding: 0.8rem 1rem 1rem; display: grid; gap: 0.6rem; }
.act-where .act-h { margin: 0; font-size: var(--fs-h3); }
.act-where-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }
.act-where-chips button { min-height: 56px; font-size: var(--fs-lede); }
.act-where-chips button[aria-pressed="true"] { background: #ffd38a; border-color: #c9932f; color: #1a1406; }
.act-where-panel { display: grid; gap: 0.35rem; }
.act-where-panel p, .act-after-line { margin: 0; display: flex; gap: 0.6rem; align-items: flex-start; font-size: var(--fs-lede); line-height: 1.65; }
.act-where-panel svg, .act-after-line svg { flex: 0 0 auto; width: 1.4em; height: 1.4em; margin-top: 0.15em; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.act-do svg { stroke: #3c8c64; }
.act-dont { color: #7a2e22; }
.act-dont svg { stroke: #c2412f; }
.act-practice { background: #05080f; color: #e8ecf4; border: 2px solid #ffd166; padding: 1rem 1.1rem; }
.act-practice h3 { font-size: var(--fs-h3); color: #ffffff; }
.act-practice p { color: #dfe5ef; }
.act-practice-row { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.act-practice-row button { min-height: 56px; min-width: 9rem; font-size: var(--fs-lede); border-radius: 14px; }
.act-practice-row #act-start { background: #ffd166; color: #1a1406; border-color: #e6b94a; }
.act-practice-row #act-duck { background: #3d6a86; color: #ffffff; border-color: #6f97b8; }
.act-practice-row #act-duck:disabled { opacity: 0.6; }
.act-result { font-size: var(--fs-base); line-height: 1.65; color: #ffffff; min-height: 1.7em; }
.act-compare { list-style: none; margin: 0.3rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }
.act-compare li { border: 1px solid rgba(200, 210, 230, 0.3); border-radius: 12px; padding: 0.45rem 0.6rem; display: grid; gap: 0.1rem; font-size: var(--fs-sm); line-height: 1.5; color: #dfe5ef; }
.act-compare strong { font-weight: 400; color: #ffffff; font-size: var(--fs-base); }
.act-compare li.is-ok { border-color: #7fd39a; } .act-compare li.is-ok span { color: #a6e8b9; }
.act-compare li.is-late { border-color: #ffd166; } .act-compare li.is-late span { color: #ffd166; }
.act-compare li.is-blind { border-color: #ff8a7a; } .act-compare li.is-blind span { color: #ff9d90; }
.act-after-line { background: rgba(60, 140, 100, 0.1); border: 1px solid rgba(60, 140, 100, 0.4); border-radius: 14px; padding: 0.6rem 0.9rem; }
.act-after-line svg { stroke: #3c8c64; }
.act-adv { border-top: 1px solid var(--line); padding-top: 0.4rem; }
.act-adv > summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-size: var(--fs-base); color: var(--glow); }
.act-adv[open] > * + * { margin-top: 0.6rem; }
@media (max-width: 760px) {
  .act-where-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .act-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .act-step svg { grid-row: span 2; width: 120px; height: auto; max-height: none; }
  .act-step { grid-template-columns: 120px 1fr; }
}
.act-step svg .act-arm { stroke: #e9a94a; stroke-width: 7; }

/* ==========================================================================
   t38 — one design system
   column · spacing · header · card · button family · calm background
   ========================================================================== */
:root {
  --bg: #f5f1ea;
  --surface: #fffdf9;
  --surface-2: #f9f5ee;
  --border: rgba(44, 36, 28, 0.13);
  --border-strong: rgba(44, 36, 28, 0.24);
  --dark: #070b14;
  --dark-line: rgba(200, 210, 230, 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --col: 1200px;
  --gutter: clamp(16px, 3.6vw, 40px);
  --shadow: 0 1px 2px rgba(44, 36, 28, 0.05), 0 4px 16px rgba(44, 36, 28, 0.05);
}
/* calm background: one flat paper tone, no texture tiles, no colour blooms */
body { background: var(--bg); background-image: none; }

/* ---- top bar: full-bleed strip, content aligned to the column ---- */
.top {
  position: relative;
  padding: var(--sp-2) max(var(--gutter), calc((100% - var(--col)) / 2 + var(--gutter)));
  gap: var(--sp-2) var(--sp-4);
  background: rgba(245, 241, 234, 0.96);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: var(--fs-base); color: var(--ink); }
.top nav { gap: 0; align-items: stretch; flex: 1 1 0; min-width: 0; }
/* tabs: no box, underline marks where you are */
.top nav .nav {
  background: none; border: 0; border-radius: 0; box-shadow: none;
  border-bottom: 2px solid transparent;
  min-height: 44px; padding: 0.35rem 0.7rem;
  color: var(--ink); font-size: var(--fs-sm);
}
.top nav .nav:hover { color: var(--glow); border-bottom-color: var(--border-strong); }
.top nav .nav[aria-selected="true"] { color: var(--glow); border-bottom-color: var(--glow); background: none; }
.top nav .nav-sub { color: var(--muted); padding-left: 0.45rem; padding-right: 0.45rem; }
.top nav .nav-sub[aria-selected="true"] { color: var(--glow); }
#btn-menu { border-radius: 50%; width: 44px; padding: 0; }
.badge { border-radius: 999px; }

/* ---- one content column for every page ---- */
.page {
  max-width: var(--col);
  margin: 0 auto;
  padding: var(--sp-5) var(--gutter) var(--sp-7);
}
#synthetic-banner { max-width: var(--col); margin: var(--sp-3) auto 0; border-radius: var(--radius-sm); }

/* ---- one chapter header: eyebrow, title, lede ---- */
.narrative,
html.narrative-collapsed .narrative {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "toggle next" "line line";
  align-items: end;
  gap: var(--sp-2) var(--sp-5);
  margin: 0 0 var(--sp-5);
  padding: 0 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.narrative-toggle { gap: var(--sp-1); padding: 0; }
.narrative-index { color: var(--glow); font-size: var(--fs-kicker); letter-spacing: 0.06em; }
.narrative-title { font-size: var(--fs-title); line-height: 1.2; }
.narrative-line {
  grid-area: line;
  margin: var(--sp-2) 0 0;
  max-width: 44em;
  color: var(--muted);
  font-size: var(--fs-lede); line-height: 1.75;
}
.narrative-next {
  grid-area: next; justify-self: end; align-self: end; margin: 0;
  min-height: 44px; padding: 0.4rem 1rem;
  font-size: var(--fs-sm);
}
html.narrative-collapsed .narrative { padding-bottom: var(--sp-3); margin-bottom: var(--sp-4); }
/* a page note: plain text right under the header, not a second header */
.page-note { margin: 0 0 var(--sp-4); max-width: 44em; color: var(--muted); font-size: var(--fs-base); line-height: 1.75; }
.page-note strong { color: var(--ink); font-weight: 400; }

/* ---- vertical rhythm: every block inside a page sits on the same 24px beat ---- */
.night-wrap, .lead-wrap, .act-wrap, .tk, .why-simple { gap: var(--sp-5); }
.duo { gap: var(--sp-4); margin: 0 0 var(--sp-5); }
.page > .row { margin: var(--sp-4) 0; }

/* ---- one card ---- */
.duo article,
.duo article.art,
.tk-card,
.why-idea,
.act-core,
.act-where,
.act-card,
.act-two > *,
.panel,
.act-after-line {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.duo article, .tk-card, .why-idea, .act-where, .panel { padding: var(--sp-4) var(--sp-5); }
.duo article .kicker { margin-bottom: var(--sp-1); }
.duo article p:last-child { margin-bottom: 0; }
.duo article p { margin-top: 0; }
.tk-card h3, .act-h, .act-where h3, .panel h3 { margin-top: 0; }
.act-core { border-left: 4px solid var(--copper); }
.act-after-line { border-left: 4px solid #3c8c64; }

/* dark stages share one radius and one surface */
.night-stage, .night-hist, .lead-top, .why-fig, .why-race, .act-step, .act-practice {
  border-radius: var(--radius);
}
.night-stage { box-shadow: var(--shadow); }

/* ---- buttons: primary · secondary · chip · tab ---- */
button.play { border-radius: var(--radius-sm); }
.station, .station[aria-pressed] { border-radius: var(--radius-sm); text-align: left; }
.station[aria-pressed="true"] { background: rgba(61, 106, 134, 0.1); color: var(--ink); border-color: var(--glow); box-shadow: inset 0 0 0 1px var(--glow); }
.narrative-toggle, .narrative-toggle:hover { background: none; border: 0; }
.help-i { border-radius: 50%; background: var(--surface); }
/* light-surface choice chips all look the same */
.tk-chips button, .act-where-chips button { border-radius: 999px; background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.tk-chips button[aria-pressed="true"], .tk-chips button[aria-checked="true"],
.act-where-chips button[aria-pressed="true"] { background: var(--glow); color: #fff; border-color: var(--glow); }
.tk-lines button { border-radius: var(--radius-sm); }
/* dark-surface buttons: same shapes, inverted */
.night-side button, .night-hist button, .lead-side button, .night-alert button { border-radius: var(--radius-sm); }
.night-side button[aria-pressed], .night-hist button[aria-pressed], .lead-side button[aria-pressed], .night-alert button[aria-pressed],
.night-side button[role="radio"], .lead-side button[role="radio"] { border-radius: 999px; }
.night-side button[aria-pressed="true"], .night-hist button[aria-pressed="true"], .lead-side button[aria-pressed="true"], .night-alert button[aria-pressed="true"] {
  background: var(--glow); border-color: #9fc2dc; color: #fff;
}
.why-fig button, .why-race-bar button, .act-practice-row button { border-radius: var(--radius-sm); }
.why-race-bar button { background: var(--glow); color: #fff; border-color: #6f97b8; }

/* ---- step tabs in Finale: tabs, not chips ---- */
.tk-progress { gap: 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.tk-progress li {
  background: none; border: 0; border-radius: 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 0.55rem 0.9rem; color: var(--muted);
}
.tk-progress li.done { color: var(--ink); border-color: transparent; border-bottom-color: transparent; }
.tk-progress li[aria-current="step"] { background: none; color: var(--glow); border-bottom-color: var(--glow); }
.tk { max-width: none; }

/* ---- Finale place picker: map and counties on one grid ---- */
.tk-place { grid-template-columns: 240px minmax(0, 1fr); gap: var(--sp-5); margin-top: var(--sp-4); }
.tk-mapbox canvas { border-radius: var(--radius-sm); }
.tk-place-chips { gap: var(--sp-2); align-content: start; }
.tk-region { grid-template-columns: 3rem minmax(0, 1fr); gap: var(--sp-3); align-items: center; }
.tk-region-name { padding-top: 0; color: var(--muted); }
.tk-place-chips .tk-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.4rem, 1fr)); gap: var(--sp-2); }
.tk-place-chips .tk-chips button { min-height: 40px; padding: 0.3rem 0.4rem; }
.tk-card .row { margin-top: var(--sp-4); gap: var(--sp-2); }
.tk-card > .tk-chips { gap: var(--sp-2); }
.tk-feedback { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tk-make { gap: var(--sp-5); }
.tk-opt input { border-radius: var(--radius-sm); background: var(--surface); border-color: var(--border-strong); }
select, input[type="text"], textarea { background: var(--surface); border-color: var(--border-strong); border-radius: var(--radius-sm); }

/* ---- Chapter 4 grids on the same gutter ---- */
.act-steps, .act-grid, .act-two, .why-towns { gap: var(--sp-4); }
.act-where { gap: var(--sp-3); }
.act-where-chips { gap: var(--sp-2); }

@media (max-width: 760px) {
  .page { padding-top: var(--sp-4); }
  .narrative, html.narrative-collapsed .narrative {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "toggle" "line" "next";
    gap: var(--sp-2); padding-bottom: var(--sp-4); margin-bottom: var(--sp-4);
  }
  .narrative-next { justify-self: start; margin-top: var(--sp-2); }
  .duo article, .tk-card, .why-idea, .act-where, .panel { padding: var(--sp-4); }
  .tk-place { grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
  .tk-mapbox { max-width: 260px; }
  .tk-region { grid-template-columns: 2.6rem minmax(0, 1fr); gap: var(--sp-2); }
  .tk-progress { overflow-x: auto; flex-wrap: nowrap; }
  .tk-progress li { white-space: nowrap; padding: 0.5rem 0.6rem; }
}
/* t38: Create tools column is narrow — stack its two cards; tool heading is a section heading, not a page title */
.make-tools .duo { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
.make-tools h2 { font-size: var(--fs-h3); letter-spacing: 0.04em; margin: 0 0 var(--sp-3); }
.make-tools { display: grid; align-content: start; gap: var(--sp-3); }
.make-tools > * { margin-top: 0; margin-bottom: 0; }
.make-layout { gap: var(--sp-5); }
.make-canvas-frame { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
@media (max-width: 760px) {
  .tk-place-chips .tk-chips { grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr)); }
  .tk-mapbox { margin: 0 auto; }
}
#tour-bar button.primary { color: #fff; }
#tour-bar { border-radius: var(--radius); }
#help-pop { border-radius: var(--radius); }

/* English edition: layout adjustments for longer Latin labels */
.nav-en { display: none; }
.instrument-row button,
.sound-mode button { white-space: normal; line-height: 1.15; }
.night-views button { font-size: 0.74rem; white-space: nowrap; padding-left: 0.1rem; padding-right: 0.1rem; }
.station-place { white-space: normal; }
.station-head { flex-wrap: wrap; column-gap: 0.4rem; }
.filter-row { flex-wrap: wrap; }
.filter-row > button, .filter-row > .help-host, .filter-row > .help-pair { flex: 1 1 auto; }
.filter-row button { white-space: nowrap; }
.tk-region { grid-template-columns: 3.6rem minmax(0, 1fr); }
.tk-place-chips .tk-chips { grid-template-columns: repeat(auto-fill, minmax(7.4rem, 1fr)); }
.tk-place-chips .tk-chips button { white-space: nowrap; font-size: 0.85rem; }
.filter-row button { min-width: max-content; padding-left: 0.5rem; padding-right: 0.5rem; }
@media (max-width: 760px) {
  .tk-place-chips .tk-chips { grid-template-columns: repeat(auto-fill, minmax(6.6rem, 1fr)); }
  .tk-place-chips .tk-chips button { white-space: normal; font-size: 0.8rem; line-height: 1.15; }
}
