/* The Vietnam War: stage 1 shell. System fonts only (nothing to download). */
:root {
  --paper: #f5f0e5; --paper-2: #fbf8f1; --ink: #1f1c17; --muted: #5a5347; --rule: #cfc4ad; --rule-2: #8a7f6a;
  --sea: #dde5e1; --land: #e8ddc4; --land-2: #f0eadb; --accent: #7a2e0e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --rail-h: auto;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 17px/1.55 var(--serif); display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
:focus-visible { outline: 3px solid #111; outline-offset: 2px; box-shadow: 0 0 0 5px #fff8c4; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 10; font-family: var(--sans); }
.skip:focus { top: 8px; }
a { color: #173f73; }
button { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top { flex: none; display: flex; align-items: center; gap: 20px; padding: 8px 18px; border-bottom: 2px solid var(--ink); background: var(--paper-2); flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 24px; letter-spacing: .01em; line-height: 1.1; }
.brand .sub { margin: 2px 0 0; font: 13px/1.3 var(--sans); color: var(--muted); }
#chapterNav ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; font-family: var(--sans); font-size: 14px; }
#chapterNav a { display: inline-block; padding: 6px 10px; border-radius: 4px; text-decoration: none; color: var(--ink); border: 1px solid transparent; }
#chapterNav a[aria-current="page"] { border-color: var(--ink); font-weight: 650; background: #fff; }
#chapterNav a[aria-current="page"]::before { content: "▸ "; }
.tools { margin-left: auto; display: flex; gap: 6px; }
.btn { font-family: var(--sans); font-size: 14px; padding: 6px 12px; min-height: 32px; border: 1.5px solid var(--ink); border-radius: 4px; background: #fff; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #f1ead9; }
.btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.btn.primary { background: var(--ink); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
#ledgerBtn .count { font-size: 12px; padding: 0 6px; border-radius: 99px; background: #efe6d0; border: 1px solid var(--rule-2); }
html[data-motion="on"] #ledgerBtn.stamp { animation: stamp .9s ease-out; }
@keyframes stamp { 0% { transform: scale(1); } 25% { transform: scale(1.18) rotate(-3deg); background: #fff1c2; } 100% { transform: none; } }
.linklike { background: none; border: 0; padding: 0; color: #173f73; text-decoration: underline; cursor: pointer; font-family: var(--sans); font-size: inherit; }

/* ---------- layout ---------- */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 58fr) minmax(0, 28fr) minmax(210px, 14fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "stage story actors" "rail rail rail"; }
.stage { grid-area: stage; overflow: auto; display: flex; flex-direction: column; border-right: 1px solid var(--rule); background: var(--paper); }
.story { grid-area: story; overflow: auto; padding: 16px 24px 40px; background: var(--paper-2); border-right: 1px solid var(--rule); }
.actors { grid-area: actors; overflow: auto; padding: 14px 14px 30px; font-family: var(--sans); font-size: 14px; }
.rail { grid-area: rail; border-top: 2px solid var(--ink); background: var(--paper-2); padding: 6px 14px 8px; font-family: var(--sans); }

/* ---------- stage ---------- */
.stage-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px 6px; flex-wrap: wrap; }
.stage-title { margin: 0; font: 600 15px/1.3 var(--sans); letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.view-switch { margin-left: auto; display: flex; gap: 4px; }
.view-switch .btn { font-size: 13px; padding: 4px 10px; min-height: 28px; }
.view-region { flex: 1 1 auto; min-height: 340px; display: flex; flex-direction: column; padding: 0 12px; }
.view-region .map { flex: 1 1 auto; width: 100%; min-height: 0; height: 100%; }
.map-note { margin: 2px 4px 0; font: 12px var(--sans); color: var(--muted); }
.takeaway { flex: none; margin: 8px 16px 14px; padding: 10px 14px; border-left: 4px solid var(--ink); background: var(--paper-2); font-size: 15px; }
.takeaway p { margin: 0 0 4px; }
.takeaway summary { font: 14px var(--sans); cursor: pointer; padding: 4px 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font: 13px/1.45 var(--sans); margin-top: 6px; }
caption { text-align: left; font-weight: 600; padding-bottom: 4px; }
th, td { border: 1px solid var(--rule); padding: 6px 8px; vertical-align: top; text-align: left; }
thead th { background: #efe7d4; }
.not-public { color: var(--muted); font-style: italic; }

/* map drawing */
.map .sea { fill: var(--sea); }
.map .land path.focus { fill: var(--land); stroke: #7d735f; stroke-width: .9; }
.map .land path.other { fill: var(--land-2); stroke: #b3a88f; stroke-width: .7; }
.map .era-indochina path { fill: none; stroke: #3f3f3f; stroke-width: 2.2; stroke-dasharray: 2 5; stroke-linecap: round; }
.map .line17 line { stroke: #111; stroke-width: 3; stroke-dasharray: 9 5; }
.map text { font-family: var(--sans); }
.map .l17 { font-size: 15px; font-weight: 700; fill: #111; paint-order: stroke; stroke: var(--sea); stroke-width: 4px; }
.map .l17.small { font-size: 13px; font-weight: 400; font-style: italic; }
.map .country { font-size: 16px; letter-spacing: .14em; fill: #3f392f; font-weight: 600; paint-order: stroke; stroke: var(--land); stroke-width: 3px; }
.map .country.sub { font-size: 13px; letter-spacing: .06em; font-weight: 500; }
.map .country.minor { font-size: 13px; fill: #6d6555; font-weight: 500; stroke: var(--land-2); }
.map .country.small { font-size: 14px; }
.map .water { font-size: 14px; font-style: italic; fill: #4a6570; letter-spacing: .04em; }
.map .city circle { fill: #111; stroke: #fff; stroke-width: 1.5; }
.map .city-label { font-size: 14px; fill: #111; paint-order: stroke; stroke: #fbf8f1; stroke-width: 3.5px; stroke-linejoin: round; }
.map .era-label rect { fill: rgba(251, 248, 241, .94); stroke: var(--rule-2); }
.map .era-label text { font-size: 18px; font-weight: 600; fill: var(--ink); }
.map .inset-frame { fill: #f8f4ea; stroke: #6d6555; stroke-width: 1.2; }
.map .inset-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; fill: #3f392f; }
.map .inset-note { font-size: 11px; font-style: italic; fill: #6d6555; }
.map .usa { fill: var(--land); stroke: #7d735f; stroke-width: .8; }
.map .hl-tag { stroke: #fff; stroke-width: 1.5; }
html[data-motion="on"] .map .hl path, html[data-motion="on"] .map .hl circle { animation: fadeIn .35s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Two nights ---------- */
.two-nights { padding: 0 16px; }
.lens { border: 0; margin: 0 0 8px; padding: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--sans); }
.lens legend { float: left; font-weight: 700; font-size: 14px; margin-right: 6px; }
.lens label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px 6px 10px; border: 2px solid var(--ink); border-radius: 99px; background: #fff; cursor: pointer; font-size: 15px; }
.lens label:has(input:checked) { background: var(--ink); color: #fff; font-weight: 650; }
.lens input { width: 16px; height: 16px; margin: 0; accent-color: #fff; }
.nights { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.night { border: 1.5px solid var(--rule-2); background: var(--paper-2); padding: 8px 10px; border-radius: 4px; }
.night.current { border: 3px solid var(--ink); padding: 6.5px 8.5px; }
.night h3 { margin: 0 0 4px; font: 600 15px/1.3 var(--sans); }
.night .date { display: inline-block; padding: 1px 6px; background: var(--ink); color: #fff; border-radius: 3px; margin-right: 4px; }
.night .gulf { display: block; width: 100%; height: auto; max-height: 32vh; }
.night-facts { font-size: 14px; line-height: 1.45; margin: 6px 0 0; }
.two-nights[data-lens="said"] .lens-known, .two-nights[data-lens="known"] .lens-said { display: none; }
html[data-motion="on"] .two-nights .lens-known, html[data-motion="on"] .two-nights .lens-said { animation: fadeIn .45s ease-out; }
.map .mk-label { font-size: 15px; font-weight: 600; fill: #111; paint-order: stroke; stroke: var(--sea); stroke-width: 4px; }
.map .mk-note { font-size: 14px; font-style: italic; fill: #222; paint-order: stroke; stroke: var(--sea); stroke-width: 4px; }
.map .mk-note.strong { font-weight: 700; font-style: normal; }
.map .ship, .map .boat { stroke: #fff; stroke-width: 1.5; }
.map .boat.ghost { opacity: .35; }
.map line.atk { stroke: #a34f00; stroke-width: 3; }
.map line.warn { stroke: #1d4f91; stroke-width: 3; stroke-dasharray: 6 3; }
.map .raid-zone { fill: rgba(14, 117, 96, .12); stroke: #0e7560; stroke-width: 2; stroke-dasharray: 5 4; }
.map .no-attack { stroke: #3a3a3a; stroke-width: 2; stroke-dasharray: 5 4; }

.chain { margin: 14px 0 6px; font-family: var(--sans); }
.chain h3 { margin: 0; font-size: 16px; }
.chain-hint { margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.chain-plot { position: relative; height: 224px; margin: 0 6px; }
.chain-scale { position: absolute; left: 0; right: 0; top: 0; height: 26px; border-bottom: 2px solid var(--ink); }
.chain-scale .day { position: absolute; top: 0; font-size: 12px; text-align: center; color: var(--muted); border-left: 1px solid var(--rule-2); height: 26px; }
.chain-scale .day:nth-child(odd) { background: rgba(0, 0, 0, .035); }
.chain-scale .hr { position: absolute; bottom: -2px; width: 1px; height: 6px; background: var(--ink); }
.chain-scale .hr.major { height: 10px; }
.chain-track { list-style: none; margin: 0; padding: 0; }
.chain-track li { position: absolute; left: 0; right: 0; height: 44px; }
.chain-track li.row1 { top: 32px; } .chain-track li.row2 { top: 80px; } .chain-track li.row3 { top: 128px; } .chain-track li.row4 { top: 176px; }
.span-bar { position: absolute; top: 3px; height: 8px; background: var(--ink); border-radius: 2px; opacity: .8; }
.span-bar.fuzzy { background: repeating-linear-gradient(90deg, var(--ink) 0 6px, transparent 6px 10px); opacity: .7; }
.node { position: absolute; top: 0; transform: translateX(-50%); background: none; border: 0; padding: 14px 4px 2px; cursor: pointer; text-align: center; white-space: nowrap; font-size: 12.5px; line-height: 1.25; border-radius: 4px; }
.node.start { transform: translateX(-10px); text-align: left; }
.node.end { transform: translateX(calc(-100% + 10px)); text-align: right; }
.node-dot { position: absolute; top: 0; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff; border: 2.5px solid var(--ink); }
.node.start .node-dot { left: 10px; } .node.end .node-dot { left: calc(100% - 10px); }
.node .when { display: block; color: var(--muted); }
.node .ttl { font-weight: 600; }
.node[aria-current="step"] .node-dot { background: var(--ink); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.node[aria-current="step"] .ttl { text-decoration: underline 2px; text-underline-offset: 3px; }
.node:hover .ttl { text-decoration: underline; }
.chain-gap { position: absolute; top: 224px; left: 35.2%; width: 20.4%; margin: 0; height: 10px; border: 2px solid #7a2e0e; border-top: 0; font-size: 12px; color: #7a2e0e; }
.chain-gap span { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); text-align: center; background: var(--paper); white-space: nowrap; font-weight: 600; padding: 0 4px; }
.chain-plot:has(.chain-gap:not([hidden])) { height: 262px; }
.chain-nav { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.chain-count { font-size: 13px; color: var(--muted); }
.chain-detail { border: 1.5px solid var(--ink); background: #fff; padding: 10px 14px; border-radius: 4px; font: 15px/1.5 var(--serif); }
.chain-detail .when { margin: 0; font: 13px var(--sans); color: var(--muted); }
.chain-detail h4 { margin: 2px 0 6px; font: 700 17px var(--sans); }
.chain-detail ul { margin: 0; padding-left: 18px; }
.chain-detail li { margin: 0 0 4px; }
.only-known { font-weight: 700; color: #7a2e0e; }
.ledger-note { font: 14px var(--sans); background: #fff6dc; padding: 6px 8px; border-left: 3px solid var(--ink); }
html[data-motion="on"] .chain-detail > * { animation: fadeIn .3s ease-out; }

/* ---------- story ---------- */
.story .kicker { margin: 0; font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.story h2 { margin: 2px 0 10px; font-size: 28px; line-height: 1.15; }
.story h3 { margin: 18px 0 4px; font: 700 15px var(--sans); letter-spacing: .02em; }
.story p { margin: 0 0 10px; }
.story .dek { font-size: 19px; font-style: italic; color: #3a342b; }
.story .howto { padding-left: 18px; font-size: 16px; }
.story .howto li { margin-bottom: 6px; }
.src-sample { font: 11px var(--sans); border: 1px solid var(--rule-2); border-radius: 99px; padding: 0 6px; background: #fffaf0; }
.chapter-pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--rule); }
.photo { margin: 8px 0 12px; }
.photo img { display: block; width: 100%; height: auto; border: 1px solid var(--rule-2); background: #ddd; }
.photo.small img { max-width: 260px; }
.photo figcaption { font: 13px/1.4 var(--sans); color: #3a342b; margin-top: 4px; }
.photo .credit { color: var(--muted); }
.ext { font-size: .85em; }

/* inline sources and terms */
.src { font: 600 11px/1.5 var(--sans); padding: 0 7px; margin: 0 1px; border: 1px solid #7d735f; border-radius: 99px; background: #fffaf0; color: #3a342b; cursor: pointer; vertical-align: 1px; white-space: nowrap; }
.src:hover { background: #f2e5c4; }
.term { background: none; border: 0; padding: 0; font: inherit; color: inherit; border-bottom: 2px dotted #3a342b; cursor: help; }
.term:hover { background: #f2e5c4; }
.differs { display: inline; background: #f6ecd6; box-shadow: 0 0 0 2px #f6ecd6; }
.differs strong { font-family: var(--sans); font-size: .82em; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- actors ---------- */
.actors h2 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; }
.actors .hint { margin: 2px 0 8px; color: var(--muted); font-size: 13px; }
.chips, .chips ul { list-style: none; margin: 0; padding: 0; }
.chips > li { margin-bottom: 4px; }
.chip-group { border: 1px solid var(--rule); border-radius: 5px; padding: 4px; margin: 6px 0 !important; }
.chip-group ul li { margin-bottom: 3px; }
.group-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 4px 2px; }
.chip { width: 100%; display: flex; align-items: center; gap: 8px; padding: 5px 8px; min-height: 32px; border: 1.5px solid var(--c); border-radius: 4px; background: #fff; cursor: pointer; text-align: left; font-size: 14px; }
.chip .shape { flex: none; }
.chip-name { flex: 1; }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 14%, #fff); box-shadow: inset 5px 0 0 var(--c); font-weight: 700; }
.chip[aria-pressed="true"] .chip-name::after { content: " ✓"; }
.lit-badge { display: none; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 5px; border-radius: 3px; background: var(--ink); color: #fff; }
.chip.lit { border-width: 3px; padding: 3.5px 6.5px; }
.chip.lit .lit-badge { display: inline-block; }
html[data-motion="on"] .chip.lit { animation: fadeIn .4s ease-out; }
.actor-detail { margin-top: 10px; font-family: var(--serif); font-size: 15px; }
.actor-detail:empty { display: none; }
.actor-detail h3 { font: 700 15px var(--sans); margin: 0 0 4px; display: flex; gap: 6px; align-items: center; }
.actor-detail .where { margin: 0 0 6px; }
.actor-facts { padding-left: 16px; margin: 0 0 8px; }
.actor-facts li { margin-bottom: 6px; }
.actor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actor-actions .btn { font-size: 13px; padding: 4px 8px; }

/* ---------- timeline rail ---------- */
.rail-row { display: flex; align-items: center; gap: 10px; }
.rail-btn { min-width: 36px; justify-content: center; }
.rail-main { flex: 1; min-width: 0; }
.rail-track { position: relative; height: 38px; }
.rail-track .tick { position: absolute; top: 0; transform: translateX(-50%); font-size: 11px; color: var(--muted); }
.rail-track .stub { position: absolute; top: 16px; height: 12px; font-size: 0; }
.rail-track .stub.pre { left: 0; width: 7%; background: repeating-linear-gradient(135deg, #8a7f6a 0 2px, transparent 2px 6px); }
.rail-track .stub.post { right: 0; width: 7%; background: repeating-linear-gradient(45deg, #8a7f6a 0 2px, transparent 2px 6px); }
.rail-bar { position: absolute; left: 0; right: 0; top: 14px; height: 16px; cursor: pointer; touch-action: none; }
.rail-bar::before { content: ""; position: absolute; left: 7%; right: 7%; top: 5px; height: 6px; background: var(--ink); border-radius: 3px; }
.rail-thumb { position: absolute; top: -5px; width: 16px; height: 26px; margin-left: -8px; background: #fff; border: 3px solid var(--ink); border-radius: 4px; cursor: grab; }
html[data-motion="on"] .rail-thumb { transition: left .2s ease-out; }
.rail-events { list-style: none; margin: 0; padding: 0; position: relative; height: 24px; }
.rail-ev { position: absolute; top: 0; transform: translateX(-50%); width: 24px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer; }
.rail-ev .ev-dot { display: block; width: 12px; height: 12px; margin: 6px auto; transform: rotate(45deg); background: #fff; border: 2px solid var(--ink); }
.rail-ev.current .ev-dot { background: var(--ink); }
.rail-ev .ev-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.rail-ev:hover .ev-label, .rail-ev:focus-visible .ev-label { clip: auto; width: auto; height: auto; overflow: visible; bottom: 26px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; background: var(--ink); color: #fff; padding: 2px 6px; border-radius: 3px; }
.rail-readout { margin: 2px 0 0; font: 14px/1.45 var(--serif); min-height: 1.45em; max-height: 4.4em; overflow: auto; }
.rail-readout strong { font-family: var(--sans); }

/* ---------- drawers and popover ---------- */
.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(460px, 100vw); max-width: 100vw; border: 0; border-left: 2px solid var(--ink); padding: 0; background: var(--paper-2); color: var(--ink); }
.drawer::backdrop { background: rgba(20, 16, 10, .35); }
html[data-motion="on"] .drawer[open] { animation: slideIn .25s ease-out; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--paper-2); border-bottom: 1px solid var(--rule); }
.drawer-head h2 { margin: 0; font-size: 20px; }
.drawer-intro { margin: 10px 16px 0; font: 14px var(--sans); color: var(--muted); }
.drawer-body { padding: 8px 16px 30px; }
.glossary .g-item { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.glossary dt { font: 700 15px var(--sans); }
.glossary dd { margin: 2px 0 0; font-size: 15px; }
.g-item.flash { background: #fff1c2; }
.source-list { margin: 6px 0; padding-left: 18px; font: 13px/1.4 var(--sans); }
.source-list li { margin-bottom: 4px; }
.card { border: 2px solid var(--ink); background: #fff; padding: 10px 14px; margin: 10px 0; border-radius: 4px; }
.card-n { margin: 0; font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.card h3 { margin: 2px 0 6px; font-size: 19px; }
.card h4 { margin: 8px 0 2px; font: 700 13px var(--sans); text-transform: uppercase; letter-spacing: .04em; }
.card ul { margin: 0; padding-left: 18px; font-size: 15px; }
.sealed { display: flex; gap: 6px; align-items: center; margin: 2px 0; padding: 8px; background: repeating-linear-gradient(135deg, #efe6d0 0 6px, #f8f2e2 6px 12px); border: 1.5px dashed var(--ink); font: 14px var(--sans); }
#pop { position: fixed; inset: auto; margin: 0; max-height: 60vh; overflow: auto; padding: 12px 16px 10px; border: 1.5px solid var(--ink); border-radius: 5px; background: #fffdf7; color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font: 15px/1.5 var(--serif); }
#pop .pop-title { margin: 0 28px 4px 0; font: 700 15px var(--sans); }
#pop .pop-close { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border: 1px solid var(--rule-2); background: #fff; border-radius: 4px; cursor: pointer; font-size: 18px; line-height: 1; }
#pop .pop-status { margin: 6px 0 0; font: 12px var(--sans); color: var(--muted); }
#pop p { margin: 4px 0; }

/* ---------- one-column layout ---------- */
@media (max-width: 900px) {
  body { height: auto; display: block; font-size: 16px; }
  .top { gap: 8px 12px; padding: 8px 12px; }
  .brand h1 { font-size: 21px; }
  .tools { margin-left: 0; flex-wrap: wrap; }
  #chapterNav { width: 100%; order: 3; }
  .layout { display: block; }
  .stage, .story, .actors { overflow: visible; border-right: 0; }
  .view-region { min-height: 0; }
  .view-region .map { height: auto; }
  .nights { grid-template-columns: 1fr; }
  .night .gulf { max-height: none; }
  .rail { padding: 6px 8px; }
  .rail-readout { max-height: 3em; font-size: 13px; }
  .story { padding: 16px; border-top: 2px solid var(--ink); }
  .actors { border-top: 1px solid var(--rule); }
  .chips { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .chips > li { margin: 0; }
  .chip-group { grid-column: 1 / -1; }
  .node { font-size: 11px; white-space: normal; width: 92px; }
  .node.start, .node.end { width: 92px; }
  .drawer { margin: auto 0 0; width: 100vw; height: 85vh; max-height: 85vh; border-left: 0; border-top: 2px solid var(--ink); border-radius: 10px 10px 0 0; }
  html[data-motion="on"] .drawer[open] { animation-name: sheetIn; }
  @keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) { html:not([data-motion="on"]) * { animation: none !important; transition: none !important; } }
html[data-motion="off"] * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

/* Region map is drawn in a 1000-unit viewBox and usually shown at ~600px, so its type is set larger. */
[hidden] { display: none !important; }
#regionMap .country { font-size: 25px; stroke-width: 4px; }
#regionMap .country.sub { font-size: 19px; }
#regionMap .country.minor { font-size: 19px; }
#regionMap .water { font-size: 21px; }
#regionMap .city-label { font-size: 21px; stroke-width: 5px; }
#regionMap .city circle { r: 5.5; }
#regionMap .l17 { font-size: 21px; stroke-width: 5px; }
#regionMap .l17.small { font-size: 18px; }
#regionMap .era-label text { font-size: 24px; }
#regionMap .inset-title { font-size: 17px; }
#regionMap .inset-note { font-size: 15px; }
.map .line17-label .leader { stroke: #111; stroke-width: 1.5; }
h2[tabindex="-1"]:focus { outline: none; box-shadow: none; }
@media (max-width: 900px) {
  .rail-events { display: flex; gap: 6px; height: auto; overflow-x: auto; padding: 4px 0 6px; }
  .rail-events li { flex: none; }
  .rail-ev { position: static; transform: none; width: auto; height: auto; min-height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border: 1.5px solid var(--ink); border-radius: 4px; background: #fff; font-size: 13px; }
  .rail-ev .ev-dot { margin: 0; width: 10px; height: 10px; }
  .rail-ev .ev-label, .rail-ev:hover .ev-label, .rail-ev:focus-visible .ev-label { position: static; clip: auto; width: auto; height: auto; overflow: visible; transform: none; background: none; color: inherit; padding: 0; font-size: 13px; }
  .rail-ev.current { background: var(--ink); color: #fff; }
  .rail-ev.current .ev-dot { background: #fff; }
}
/* Small screens: the chain keeps its hour scale; step names move to the detail box below it. */
@media (max-width: 700px) {
  .chain-plot { height: 124px; margin: 0 10px; }
  .chain-plot:has(.chain-gap:not([hidden])) { height: 150px; }
  .chain-scale .day { font-size: 10px; white-space: nowrap; overflow: hidden; }
  .chain-track li { height: 24px; }
  .chain-track li.row1 { top: 32px; } .chain-track li.row2 { top: 54px; } .chain-track li.row3 { top: 76px; } .chain-track li.row4 { top: 98px; }
  .node, .node.start, .node.end { width: 28px; height: 22px; padding: 0; transform: translateX(-50%); }
  .node .node-dot, .node.start .node-dot, .node.end .node-dot { left: 50%; top: -3px; }
  .node .when, .node .ttl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .span-bar { top: 1px; }
  .chain-gap { top: 124px; }
  .chain-gap span { left: 50%; right: auto; transform: translateX(-50%); white-space: nowrap; font-size: 11px; }
}
.two-nights[data-lens="said"] .chain-plot { height: 128px; }
@media (max-width: 700px) { .two-nights[data-lens="said"] .chain-plot { height: 80px; } }

/* ================= Stage 2 ================= */
/* chapter menu */
.chapter-menu { position: relative; font-family: var(--sans); font-size: 14px; }
.chapter-menu > summary { list-style: none; cursor: pointer; padding: 6px 12px; border: 1.5px solid var(--ink); border-radius: 4px; background: #fff; display: inline-flex; gap: 6px; align-items: center; min-height: 32px; }
.chapter-menu > summary::-webkit-details-marker { display: none; }
.chapter-menu > summary::after { content: "▾"; }
.chapter-menu .cm-label { font-weight: 700; }
.chapter-menu nav { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: min(420px, 92vw); max-height: 75vh; overflow: auto; background: #fffdf7; border: 1.5px solid var(--ink); border-radius: 5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 8px 12px; }
#chapterList, #chapterList ol { list-style: none; margin: 0; padding: 0; }
#chapterList > li { margin-bottom: 6px; }
.menu-group { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 4px 0 2px; }
#chapterList a { display: block; padding: 4px 8px; border-radius: 3px; color: var(--ink); text-decoration: none; }
#chapterList a:hover { background: #f1ead9; }
#chapterList a[aria-current="page"] { font-weight: 700; background: var(--ink); color: #fff; }

/* generic stepper */
.stepper { display: flex; align-items: flex-start; gap: 6px; margin: 8px 0; font-family: var(--sans); }
.st-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.st-btn { font: 13px/1.25 var(--sans); padding: 5px 9px; border: 1.5px solid var(--rule-2); border-radius: 4px; background: #fff; cursor: pointer; text-align: left; min-height: 32px; }
.st-btn .st-n { display: inline-block; min-width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 50%; border: 1.5px solid var(--ink); font-size: 11px; font-weight: 700; margin-right: 2px; }
.st-btn[aria-current="step"] { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 650; }
.st-btn[aria-current="step"] .st-n { background: #fff; color: var(--ink); }
.stepper .btn { min-width: 36px; justify-content: center; }
.step-h { margin: 0 0 4px; font: 700 15px var(--sans); }
.fig-detail, .map-step-detail { border: 1.5px solid var(--ink); background: #fff; padding: 10px 14px; border-radius: 4px; font: 15px/1.5 var(--serif); margin: 6px 0; }
.map-steps { padding: 0 2px; }
.map-step-detail { margin: 0 2px 8px; }
.fact-list { margin: 0; padding-left: 18px; }
.fact-list li { margin: 0 0 5px; }
.view-region .map { min-height: 300px; }
.map .line17.solid line { stroke-dasharray: none; stroke-width: 4; }
.map .ballot rect { fill: #fffdf7; stroke: #111; stroke-width: 2; }
.map .ballot text { font: 700 18px var(--sans); fill: #111; }
.map .ballot.struck rect { fill: #fff1c2; stroke-dasharray: 5 3; }
.map .zone-text, .map .mark-text { font: 700 19px var(--sans); fill: #111; paint-order: stroke; stroke: #fbf8f1; stroke-width: 5px; stroke-linejoin: round; }
.map .ov-arrow { fill: none; stroke-width: 3.5; stroke-dasharray: 10 5; }
.map .arrow-text { font: 700 18px var(--sans); fill: #111; paint-order: stroke; stroke: #fbf8f1; stroke-width: 5px; stroke-linejoin: round; }
#regionMap .inset .mark-text { font-size: 15px; }
.troop-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font: 14px var(--sans); margin: 0 0 6px; }
.tb-track { flex: 1; min-width: 120px; height: 12px; background: #efe6d0; border: 1px solid var(--rule-2); position: relative; }
.tb-fill { position: absolute; inset: 0 auto 0 0; background: #1d4f91; }
html[data-motion="on"] .tb-fill, html[data-motion="on"] .bar-fill, html[data-motion="on"] .beam { transition: width .35s ease-out, transform .35s ease-out; }
.view-fig { padding: 4px 16px 8px; font-family: var(--sans); }

/* figures: shared */
.fig-block { margin: 6px 0 14px; }
.fig-h { font: 700 15px var(--sans); margin: 4px 0 6px; }
.fig-note { font: 12.5px/1.45 var(--sans); color: var(--muted); margin: 4px 0; }
.muted { color: var(--muted); }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 34%) 1fr minmax(90px, 26%); gap: 8px; align-items: center; font-size: 13.5px; }
.bar-row[hidden] { display: none; }
.bar-row.on .bar-label { font-weight: 700; }
.bar-label { line-height: 1.3; }
.bar-track { position: relative; height: 18px; background: #efe6d0; border: 1px solid var(--rule-2); border-radius: 2px; }
.bar-fill { position: absolute; top: 0; bottom: 0; left: 0; background: #3a342b; }
.bar-fill.planned, .bar-fill.ind, .bar-fill.cur, .bar-fill.you { background: repeating-linear-gradient(135deg, #3a342b 0 4px, #efe6d0 4px 8px); border-right: 2px solid #3a342b; }
.bar-fill.atleast::after { content: ""; position: absolute; right: -9px; top: 1px; border-left: 9px solid #3a342b; border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.bar-fill.open { background: linear-gradient(90deg, #3a342b 0 70%, rgba(58,52,43,.15)); }
.bar-fill.open::before { content: "possibly far more →"; position: absolute; left: 100%; margin-left: 12px; white-space: nowrap; font-size: 11.5px; color: #3a342b; top: 1px; }
.bar-fill.range { background: #3a342b; }
.bar-fill.dashed { background: repeating-linear-gradient(90deg, #3a342b 0 5px, transparent 5px 9px); }
.bar-value { font-variant-numeric: tabular-nums; line-height: 1.3; }
.ax { position: relative; height: 18px; border-bottom: 1.5px solid var(--ink); margin: 0 0 4px; font-size: 11px; color: var(--muted); }
.bars .ax { grid-column: 2; }
.ax-tick { position: absolute; bottom: 2px; transform: translateX(-50%); white-space: nowrap; }
.toggle { border: 0; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.toggle legend { float: left; font-weight: 700; font-size: 14px; margin-right: 6px; }
.toggle label { display: inline-flex; gap: 6px; align-items: center; padding: 5px 12px 5px 8px; border: 2px solid var(--ink); border-radius: 99px; background: #fff; cursor: pointer; font-size: 14px; }
.toggle label:has(input:checked) { background: var(--ink); color: #fff; font-weight: 650; }
.toggle input { margin: 0; accent-color: #fff; }

/* timelines with numbered markers */
.tl { position: relative; margin: 4px 8px 6px; }
.tl-lane { display: grid; grid-template-columns: 110px 1fr; align-items: center; min-height: 34px; border-bottom: 1px dotted var(--rule); }
.tl-lane:has(.tl-lane-label:empty), .tl > .tl-lane:only-of-type { grid-template-columns: 0 1fr; }
.tl-lane-label { font-size: 12px; font-weight: 700; color: var(--muted); padding-right: 6px; }
.tl .ax { margin-left: 110px; }
.tl:not(:has(.tl-lane-label)) .ax { margin-left: 0; }
.tl-track { position: relative; height: 30px; }
.tl-pt { position: absolute; top: 4px; transform: translateX(-50%); }
.tl-span { position: absolute; top: 9px; height: 12px; background: repeating-linear-gradient(90deg, #3a342b 0 6px, #cfc4ad 6px 9px); border-radius: 2px; }
.tl-span .tl-n { position: absolute; left: 0; top: -5px; transform: translateX(-50%); }
.tl-n { display: inline-block; width: 22px; height: 22px; line-height: 19px; text-align: center; border-radius: 50%; background: #fff; border: 2px solid var(--ink); font-size: 11px; font-weight: 700; }
.tl .on .tl-n, .pin.on .tl-n { background: var(--ink); color: #fff; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.tl-span.on { outline: 2px solid var(--ink); outline-offset: 2px; }

/* start pins */
.pins { margin: 6px 10px 8px; }
.pin-track { position: relative; height: 56px; }
.pin { position: absolute; top: 4px; transform: translateX(-50%); }
.pin-span { position: absolute; top: 34px; height: 14px; background: repeating-linear-gradient(135deg, #1d4f91 0 5px, #dbe4f1 5px 10px); border: 2px solid #1d4f91; }
html[data-motion="on"] .pin-span { transition: left .3s, width .3s; }
.span-readout { margin: 0 0 6px; font-family: var(--sans); }

/* scale strip */
.strip-row { display: grid; grid-template-columns: minmax(150px, 30%) 1fr; gap: 4px 10px; padding: 6px 0; border-bottom: 1px dotted var(--rule); font-size: 13.5px; }
.strip-value { grid-column: 2; font-variant-numeric: tabular-nums; }
.squares { display: flex; flex-wrap: wrap; gap: 2px; }
.squares i { display: block; width: 10px; height: 10px; background: var(--c); }
.squares i.part { opacity: .55; }

/* draft */
.pair { display: grid; gap: 5px; }
.pair-row { display: grid; grid-template-columns: 44px 1fr minmax(120px, 30%); gap: 8px; align-items: center; font-size: 12.5px; }
.pair-bars { display: grid; gap: 2px; }
.pair-bars .bar-track { height: 11px; }
.lottery-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; font-size: 14px; }
.lottery-controls input[type=range] { width: min(280px, 60vw); }
.lottery-controls output { font-weight: 700; }
.lookup { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0 8px; font-size: 14px; }
.lookup select { font: inherit; padding: 3px 4px; }
.grid-wrap { overflow-x: auto; }
table.lottery { font: 11px/1.2 var(--sans); width: auto; border-collapse: collapse; }
table.lottery th, table.lottery td { padding: 2px 4px; text-align: right; border: 1px solid #e3dac5; min-width: 26px; }
table.lottery td.called { background: #d8c9a6; font-weight: 700; }
table.lottery td.called::after { content: "✓"; font-size: 8px; vertical-align: top; margin-left: 1px; }
table.lottery td.found { outline: 3px solid #111; outline-offset: -2px; background: #fff1c2; }
table.lottery td.nd { background: repeating-linear-gradient(135deg, #eee 0 3px, #fff 3px 6px); }

/* Tet */
.two-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel { border: 1.5px solid var(--rule-2); background: var(--paper-2); padding: 8px 10px; border-radius: 4px; font-family: var(--serif); font-size: 14.5px; }
.panel .field { font: 700 13px var(--sans); text-transform: uppercase; letter-spacing: .04em; color: var(--accent); margin: 4px 0; }
.pgrid { margin: 0 0 8px; font-family: var(--sans); }
.pgrid-label { margin: 0 0 3px; font-size: 13px; }
.pcells { display: flex; flex-wrap: wrap; gap: 2px; }
.pcells i { width: 9px; height: 9px; border: 1.5px solid #6f6200; background: #fff; }
.pcells i.hit { background: #6f6200; }

/* parallel cards */
.parallel { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pcard { border: 2px solid var(--ink); border-top: 6px solid var(--c); background: #fff; padding: 10px 12px; border-radius: 4px; font-size: 14px; }
.pcard h3 { margin: 0 0 6px; font: 700 17px var(--sans); }
.pcard h4 { margin: 10px 0 4px; font: 700 12px var(--sans); text-transform: uppercase; letter-spacing: .05em; }
.pcard dl { margin: 0; }
.pcard dl > div { padding: 4px 0; border-bottom: 1px dotted var(--rule); }
.pcard dt { font: 700 12px var(--sans); color: var(--muted); }
.pcard dd { margin: 0; font-family: var(--serif); }
.pcard .bar-row { grid-template-columns: 38% 1fr 22%; font-size: 12px; }
.lane-list { margin: 0; padding-left: 20px; font-size: 13px; }

/* promise meter */
.meter { display: grid; grid-template-columns: 1fr 120px 1fr; gap: 8px; align-items: start; margin: 6px 0; }
.pan { border: 2px solid var(--ink); background: #fff; padding: 8px 10px; border-radius: 4px; font-size: 14px; min-height: 90px; }
.pan-h { margin: 0 0 4px; font-weight: 700; }
.pan-body { margin: 0; font-family: var(--serif); }
.weights { margin: 0; padding-left: 18px; }
.beam-wrap { position: relative; height: 90px; }
.beam { position: absolute; left: 0; right: 0; top: 30px; height: 6px; background: var(--ink); border-radius: 3px; transform-origin: 50% 50%; }
.fulcrum { position: absolute; left: 50%; top: 36px; margin-left: -14px; border-left: 14px solid transparent; border-right: 14px solid transparent; border-bottom: 30px solid var(--ink); }

/* debate */
.debate-card { border: 2px dashed var(--ink); background: #fffdf7; padding: 8px 12px; border-radius: 4px; margin: 6px 0; }
.debate-intro { font: 13px var(--sans); color: var(--muted); }
.debate-pos h4 { font: 700 14px var(--sans); margin: 8px 0 2px; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.school { border: 2px solid var(--ink); background: #fff; padding: 8px 10px; border-radius: 4px; font-size: 14px; }
.school h3 { margin: 0 0 6px; font: 700 15px var(--sans); }
.school h4 { font: 700 12px var(--sans); text-transform: uppercase; margin: 8px 0 2px; }
.school .fact-list { font-family: var(--serif); }

/* range ruler */
.ruler { margin: 4px 0; }
.ruler .ax { margin-left: 44%; }
.ruler-row { display: grid; grid-template-columns: 44% 1fr; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dotted var(--rule); font-size: 13px; }
.ruler-track { position: relative; height: 14px; background: #f3ecdb; }
.ruler-bar { position: absolute; top: 2px; height: 10px; background: #3a342b; border-radius: 2px; }
.ruler-bar.dashed { background: repeating-linear-gradient(90deg, #3a342b 0 5px, transparent 5px 9px); }
.ruler-group { margin: 8px 0 0; font-weight: 700; text-transform: uppercase; font-size: 12px; color: var(--accent); }
.study { border-bottom: 1px dotted var(--rule); padding-bottom: 6px; }
.cost-def { font-family: var(--serif); font-size: 15px; }

/* gates */
.gate { border: 2px solid #7a2e0e; background: #fff6ee; padding: 10px 12px; border-radius: 4px; margin: 8px 0; font-family: var(--sans); font-size: 14px; }
.gate-warn { margin: 0 0 4px; }
.gate-title { margin: 0 0 8px; font-style: italic; }
.gate-actions { display: flex; gap: 8px; }
.gate-actions .btn { flex: 1; justify-content: center; }
.gate.skipped { background: #f6f1e6; border-style: dashed; }
.gate-dialog { font-size: 16px; }

/* finale */
.round { border-top: 3px solid var(--ink); padding: 8px 0 14px; }
.round-h { font: 700 17px var(--sans); margin: 4px 0; }
.opinion { display: grid; gap: 10px; }
.op-plot { position: relative; height: 200px; margin: 10px 30px 4px; border-left: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); background: linear-gradient(to top, transparent calc(50% - 1px), #b9ac8f calc(50% - 1px), #b9ac8f 50%, transparent 50%); }
.op-50 { position: absolute; left: -30px; bottom: calc(50% - 8px); font-size: 11px; }
.op-tet { position: absolute; top: 0; bottom: 0; border-left: 2px dashed #7a2e0e; font-size: 11px; color: #7a2e0e; padding-left: 3px; }
.op-you, .op-real { position: absolute; width: 14px; height: 14px; margin: 0 0 -7px -7px; }
.op-you { border: 3px solid var(--ink); background: #fff; border-radius: 50%; }
.op-real { background: #1d4f91; transform: rotate(45deg); }
.op-inputs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.op-in { display: grid; gap: 2px; font-size: 12.5px; text-align: center; }
.op-in output { font-weight: 700; }
.r2-grid { display: grid; gap: 4px; }
.r2-row { display: grid; grid-template-columns: 44px 90px 1fr 110px; gap: 8px; align-items: center; font-size: 13px; }
.r2-row input { font: inherit; width: 90px; padding: 2px 4px; }
.r2-row .bar-track { height: 16px; }
.r2-row .bar-fill.you { height: 50%; }
.r2-row .bar-fill.real { top: 50%; background: #1d4f91; }
.r2-troops { color: var(--muted); font-size: 12px; }
.r3-cards { display: grid; gap: 12px; }
.r3-card { border: 2px solid var(--ink); background: #fff; padding: 10px 12px; border-radius: 4px; font-size: 14px; }
.r3-card h4 { margin: 0 0 4px; font: 700 17px var(--serif); }
.r3-card h5 { margin: 8px 0 2px; font: 700 12px var(--sans); text-transform: uppercase; letter-spacing: .04em; }
.r3-card .fact-list { font-family: var(--serif); }
.r3-card fieldset { border: 1px solid var(--rule); border-radius: 4px; margin: 8px 0; padding: 6px 10px; }
.r3-card fieldset label { margin-right: 12px; display: inline-flex; gap: 4px; align-items: center; min-height: 28px; }
.r3-actors { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.r3-why { display: grid; gap: 3px; font-size: 13px; }
.r3-why textarea { font: 14px var(--serif); }
.r3-card.revealed { border-color: #1d4f91; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: #f7f2e6; padding: 8px; border-radius: 4px; }
.three-col h5 { margin-top: 0; }

/* chain legend (small screens), numbers in claim-chain dots */
.chain-legend { display: none; }
.node-dot { width: 20px; height: 20px; margin-left: -10px; font: 700 11px/15px var(--sans); text-align: center; color: var(--ink); }
.node.start .node-dot { left: 10px; }
.node[aria-current="step"] .node-dot { color: #fff; }
.node { padding-top: 22px; }
.chain-track li.row1 { top: 32px; } .chain-track li.row2 { top: 90px; } .chain-track li.row3 { top: 148px; } .chain-track li.row4 { top: 206px; }
.chain-plot { height: 262px; }
.chain-gap { top: 262px; }
.chain-plot:has(.chain-gap:not([hidden])) { height: 300px; }
.two-nights[data-lens="said"] .chain-plot { height: 150px; }
.chain-count { font-weight: 600; color: var(--ink); }

/* rail lanes */
.rail-lanes { position: relative; }
.lane { position: relative; height: 16px; margin-top: 2px; border-bottom: 1px solid var(--rule); }
.lane-label { position: absolute; left: 0; top: 0; font-size: 10px; color: var(--muted); background: var(--paper-2); padding-right: 4px; z-index: 1; }
.lane-bar { position: absolute; bottom: 0; width: 2.4%; background: #1d4f91; opacity: .75; }
.lane[data-lane="inductions"] .lane-bar { background: repeating-linear-gradient(135deg, #3a342b 0 2px, transparent 2px 4px); opacity: 1; }
.lane[data-lane="deaths"] .lane-bar { background: #7a2e0e; }
.rail-go { font-family: var(--sans); font-size: 13px; }
.footnote { font-size: 14px; color: #3a342b; border-top: 1px solid var(--rule); padding-top: 6px; }

@media (max-width: 900px) {
  .two-panels, .parallel, .board { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
  .meter { grid-template-columns: 1fr; }
  .beam-wrap { height: 60px; }
  .view-fig { padding: 4px 10px 8px; }
}
@media (max-width: 700px) {
  .bar-row { grid-template-columns: 1fr; gap: 2px; }
  .bars .ax { grid-column: 1; }
  .strip-row, .ruler-row { grid-template-columns: 1fr; }
  .strip-value { grid-column: 1; }
  .ruler .ax { margin-left: 0; }
  .op-inputs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .op-in input { width: 100%; }
  .op-plot { margin: 10px 8px 4px 30px; height: 160px; }
  .r2-row { grid-template-columns: 40px 80px 1fr; }
  .r2-troops { grid-column: 3; }
  .tl-lane { grid-template-columns: 70px 1fr; }
  .tl .ax { margin-left: 70px; }
  .chain-legend { display: block; list-style: none; padding: 0; margin: 4px 0 0; font-size: 12.5px; }
  .chain-legend li { margin: 2px 0; }
  .lg-n { display: inline-block; width: 18px; height: 18px; line-height: 15px; text-align: center; border: 1.5px solid var(--ink); border-radius: 50%; font-size: 10px; font-weight: 700; }
  .node .node-dot, .node.start .node-dot, .node.end .node-dot { width: 20px; height: 20px; margin-left: -10px; top: -5px; }
  .chain-track li.row1 { top: 32px; } .chain-track li.row2 { top: 56px; } .chain-track li.row3 { top: 80px; } .chain-track li.row4 { top: 104px; }
  .chain-plot { height: 132px; }
  .chain-gap { top: 132px; }
  .chain-plot:has(.chain-gap:not([hidden])) { height: 160px; }
  .two-nights[data-lens="said"] .chain-plot { height: 84px; }
}
/* Region view: steps on top; map and step detail side by side on wide screens. */
.view-region { flex: none; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; padding: 0 12px; }
.view-region .map-wrap { min-width: 0; }
.view-region .map { display: block; width: 100%; height: max(300px, calc(100dvh - 370px)); min-height: 0; }
.view-region:has(.map-step-detail:not([hidden])) .map { height: max(300px, calc(100dvh - 430px)); }
@media (min-width: 1200px) {
  .view-region:has(.map-step-detail:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(240px, 36%); }
  .view-region:has(.map-step-detail:not([hidden])) .map-steps { grid-column: 1 / -1; }
  .view-region .map-step-detail:not([hidden]) { max-height: calc(100dvh - 430px); overflow: auto; margin-top: 6px; }
}
@media (max-width: 900px) { .view-region .map, .view-region:has(.map-step-detail:not([hidden])) .map { height: auto; } }
.rail-lanes .lane-bar { width: 2.4%; }
.tl-track { height: 60px; }
.tl-lane { min-height: 62px; }
.pin-track { height: 76px; }
.pin-span { top: 50px; }
.ax-row .ax { grid-column: auto; margin: 0; }

/* ================= Fix round ================= */
.story-head .block:first-of-type { margin-top: 0; }
.preview-banner { margin: 0 16px 8px; padding: 8px 12px; border: 2px dashed #7a2e0e; background: #fff6ee; font: 14px var(--sans); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.preview-banner .btn { font-size: 13px; }
.tl.nolabel .tl-lane { grid-template-columns: 0 1fr; }
.tl.nolabel .ax { margin-left: 0; }
.pres-lane { height: 18px; }
.pres { position: absolute; top: 1px; height: 15px; border: 1px solid #1d4f91; background: #e4ebf5; font-size: 10px; line-height: 13px; color: #1d4f91; padding: 0 3px; overflow: hidden; white-space: nowrap; text-overflow: clip; box-sizing: border-box; }
.pres:nth-child(odd) { background: #fff; }
.lottery-note { font-size: 14px; margin: 4px 0 8px; }
.hint-line { font-style: italic; color: #3a342b; }
.r2-warn { color: #7a2e0e; font-weight: 600; min-height: 1.2em; margin: 0 0 4px; font-size: 13px; }
.r2-row input[aria-invalid="true"] { outline: 2px solid #7a2e0e; }
@media (max-width: 900px) {
  /* One column: the chapter's opening text and instructions come before the figure. */
  .layout { display: flex; flex-direction: column; }
  .story, .story-article { display: contents; }
  .story-head { order: 0; padding: 16px 16px 4px; background: var(--paper-2); }
  .stage { order: 1; }
  .rail { order: 2; }
  .story-body { order: 3; padding: 8px 16px 24px; background: var(--paper-2); border-top: 2px solid var(--ink); }
  .actors { order: 4; }
  .op-inputs { grid-template-columns: 1fr; }
  .op-in { grid-template-columns: 76px 1fr 44px; align-items: center; text-align: left; gap: 8px; }
  .op-in input { width: 100%; height: 32px; }
  .pres { font-size: 8px; padding: 0 1px; }
}
.brand .sub { max-width: 640px; font-size: 12.5px; }
