:root {
  --ink: #0d0c0a;
  --paper: #ebe4d4;
  --foam: #f3efe6;
  --dim: rgba(243, 239, 230, 0.62);
  --faint: rgba(243, 239, 230, 0.28);
  --rule: rgba(243, 239, 230, 0.22);
  --halo: rgba(10, 9, 8, 0.8);
  --accent: #c8a774;
  --seal: #d0573c;
  --fg: var(--foam);
  --display: "Gap Sans", system-ui, sans-serif;
  --smallcaps: "Gap Sans", system-ui, sans-serif;
  --text: "Gap Sans", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .1, 1);
}
/* Gap Sans by Interstices (a fork of Sani Trixie Sans), SIL OFL 1.1, served from fonts/. It has no italic, so none is faked. */
@font-face { font-family: "Gap Sans"; src: url("fonts/gapsans-webfont.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Gap Sans"; src: url("fonts/gapsansbold-webfont.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Gap Sans"; src: url("fonts/gapsansblack-webfont.woff2") format("woff2"); font-weight: 900; font-style: normal; font-display: swap; }
html { font-synthesis: none; }

/* ——— type set. Default: Gap Sans. Trial sets with ?font=0…6 (loaded on demand by app.js; 0 is v1's IM Fell + EB Garamond) ——— */
:root { --sc-case: uppercase; --sc-caps: normal; --sc-size: .8; --display-w: 400; --display-track: -.02em; --hero-scale: .92; }
.font-0 { --display: "IM Fell English", Georgia, serif; --text: "EB Garamond", Georgia, serif; --smallcaps: "IM Fell English SC", "IM Fell English", Georgia, serif; --sc-case: none; --sc-size: 1; --display-track: -.005em; --hero-scale: 1; }
.font-1, .font-2, .font-3, .font-4, .font-5, .font-6 { --sc-size: 1; --sc-case: none; --display-w: 400; --display-track: -.005em; --hero-scale: 1; }
.font-1 { --display: "Ibarra Real Nova", Georgia, serif; --text: "Ibarra Real Nova", Georgia, serif; --smallcaps: "Fragment Mono", ui-monospace, monospace; --sc-case: uppercase; --display-track: -.015em; }
.font-2 { --display: "Imbue", Georgia, serif; --text: "Piazzolla", Georgia, serif; --smallcaps: "Piazzolla", Georgia, serif; --sc-caps: all-small-caps; --display-w: 300; --display-track: 0; --hero-scale: 1.35; }
.font-3 { --display: "Brygada 1918", Georgia, serif; --text: "Brygada 1918", Georgia, serif; --smallcaps: "Brygada 1918", Georgia, serif; --sc-caps: all-small-caps; --display-track: -.02em; --hero-scale: .9; }
.font-4 { --display: "Syne", system-ui, sans-serif; --text: "Schibsted Grotesk", system-ui, sans-serif; --smallcaps: "Syne", system-ui, sans-serif; --sc-case: uppercase; --display-w: 600; --display-track: -.03em; --hero-scale: .78; }
.font-5 { --display: "Familjen Grotesk", system-ui, sans-serif; --text: "Familjen Grotesk", system-ui, sans-serif; --smallcaps: "Fragment Mono", ui-monospace, monospace; --sc-case: uppercase; --display-w: 500; --display-track: -.035em; --hero-scale: .88; }
.font-6 { --display: "Funnel Display", system-ui, sans-serif; --text: "Funnel Sans", system-ui, sans-serif; --smallcaps: "Funnel Sans", system-ui, sans-serif; --sc-case: uppercase; --display-w: 300; --display-track: -.03em; --hero-scale: .9; }
.font-1, .font-4, .font-5, .font-6 { --sc-size: .82; }
[class*="font-"] { font-family: var(--text); }
.sc, .kicker, .gauge a, .pile-label small, .layout-switch button, .codec, .scroll-cue, #notes dt, .specimen span:last-child {
  text-transform: var(--sc-case); font-variant-caps: var(--sc-caps);
}
h1, h2, .finish-name, .pile-label span, .numeral, .tally b, .codec .z, .finishes button, .specimen b {
  font-weight: var(--display-w); letter-spacing: var(--display-track);
}

body.theme-paper {
  --fg: #1a1714;
  --dim: rgba(26, 23, 20, 0.66);
  --faint: rgba(26, 23, 20, 0.32);
  --rule: rgba(26, 23, 20, 0.22);
  --halo: rgba(236, 229, 213, 0.9);
  --accent: #8a5a2b;
}

* { box-sizing: border-box; }
html { background: var(--ink); scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--fg);
  font: 400 19px/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
  transition: color .9s var(--ease);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; }
em { font-style: italic; color: var(--accent); transition: color .9s; }
.sc { font-family: var(--smallcaps); letter-spacing: .06em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: pan-y; cursor: grab; }
/* mouse drag moves through the story (app.js) */
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
@media (hover: hover) { .chapter-copy { cursor: grab; } }
#track { position: relative; height: 1300vh; pointer-events: none; }
#track section { position: absolute; left: 0; width: 1px; height: 1px; }

/* paper grain + vignette sit above the canvas but below the type */
.grain {
  /* only a small margin around the screen: the drift below moves it at most ±4.5% of the viewport.
     (it was 200% each way, which made the browser blend four screens of grain over the canvas every frame) */
  position: fixed; inset: -6%; pointer-events: none; z-index: 2; opacity: .2; mix-blend-mode: overlay; will-change: transform;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.1s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -4%); }
  60% { transform: translate(-4%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}
.vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0,0,0,.55) 100%); transition: opacity 1s; }
body.theme-paper .vignette { opacity: .35; }

/* ——— masthead ——— */
.masthead {
  position: fixed; z-index: 10; top: 0; left: 0; right: 0;
  display: flex; align-items: baseline; gap: 2rem; padding: 22px 32px;
  font-size: 15px; letter-spacing: .02em;
}
.wordmark { text-decoration: none; font-size: 17px; letter-spacing: .16em; }
.tally { margin-left: auto; color: var(--dim); font-variant-numeric: oldstyle-nums tabular-nums; }
.tally b { color: var(--fg); font-weight: 400; font-family: var(--display); font-size: 20px; }
.link-btn { font-family: var(--text); font-style: italic; color: var(--dim); border-bottom: 1px solid var(--rule); padding-bottom: 1px; transition: color .3s, border-color .3s; }
.link-btn:hover, .link-btn:focus-visible { color: var(--fg); border-color: var(--fg); }

/* ——— tide gauge ——— */
.gauge {
  position: fixed; z-index: 10; right: 30px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 24px; padding-right: 18px; /* clear of the line, where the scrub knob runs */
}
.gauge::before { content: ""; position: absolute; right: 3px; top: 4px; bottom: 4px; width: 1px; background: var(--rule); }
/* the fill and the knob move by transform only (set from app.js), so scrolling never re-lays out the page */
.gauge-fill { position: absolute; right: 3px; top: 4px; width: 1px; height: calc(100% - 8px); background: var(--fg); transform-origin: 50% 0; transform: scaleY(0); }
/* drag the knob, or press anywhere on the line, to move through the story */
.gauge-track { position: absolute; right: -11px; top: 0; bottom: 0; width: 29px; cursor: grab; touch-action: none; }
.gauge-knob {
  position: absolute; right: -2px; top: 4px; width: 11px; height: 11px; margin-top: -5.5px; border-radius: 50%;
  background: var(--fg); box-shadow: 0 0 0 3px var(--ink); cursor: grab; touch-action: none; z-index: 2;
  transition: width .2s, height .2s, margin .2s, right .2s;
}
body.theme-paper .gauge-knob { box-shadow: 0 0 0 3px var(--paper); }
.gauge-knob:hover, .gauge-knob:focus-visible, body.scrubbing .gauge-knob { width: 15px; height: 15px; margin-top: -7.5px; right: -4px; }
body.scrubbing, body.scrubbing * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
body.scrubbing .gauge a.current span { opacity: 1; transform: none; }
.gauge a { position: relative; z-index: 1; display: flex; align-items: center; justify-content: flex-end; gap: 12px; text-decoration: none; font-family: var(--smallcaps); font-size: 13px; letter-spacing: .08em; color: var(--faint); transition: color .4s; }
.gauge a span { opacity: 0; transform: translateX(6px); transition: opacity .4s, transform .4s var(--ease); white-space: nowrap; }
.gauge a i { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; background: var(--ink); position: relative; z-index: 1; transition: background .4s; }
body.theme-paper .gauge a i { background: var(--paper); }
.gauge a.on { color: var(--fg); }
.gauge a.on i { background: var(--fg); }
.gauge a.current span, .gauge:hover a span { opacity: 1; transform: none; }

/* ——— chapter copy ——— */
.chapter-copy {
  position: fixed; z-index: 5; left: clamp(24px, 6vw, 96px); bottom: clamp(56px, 11vh, 120px);
  width: min(400px, calc(100vw - 48px));
  opacity: 0; transform: translateY(18px); pointer-events: none;
  transition: opacity .9s var(--ease), transform 1.1s var(--ease);
  text-shadow: 0 1px 18px rgba(0,0,0,.55);
}
body.theme-paper .chapter-copy { text-shadow: 0 1px 14px rgba(235,228,212,.9); }
/* a soft pool of shade behind the copy so it stays legible */
.chapter-copy::before {
  content: ""; position: absolute; z-index: -1; inset: -90px -120px -70px -140px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(10,9,8,.82), rgba(10,9,8,.55) 55%, transparent);
  transition: background .9s;
}
body.theme-paper .chapter-copy::before { background: radial-gradient(closest-side, rgba(233,226,210,.85), rgba(233,226,210,.5) 55%, transparent); }
.chapter-copy.on { opacity: 1; transform: none; pointer-events: auto; }
.chapter-copy p { margin: 0 0 .8em; }
.chapter-copy h2 { font: 400 clamp(40px, 5vw, 60px)/1 var(--display); margin: 0 0 .45em; letter-spacing: -.005em; }
.numeral { font: italic 400 22px/1 var(--display); color: var(--accent); margin-bottom: .6em !important; transition: color .9s; }
.fine { font-size: 14px; color: var(--faint); font-style: italic; border-top: 1px solid var(--rule); padding-top: .7em; margin-top: 1em !important; }

.hero { left: 50%; top: 50%; bottom: auto; width: auto; transform: translate(-50%, -46%); text-align: center; }
.hero.on { transform: translate(-50%, -50%); }
.hero::before { inset: -120px -200px; background: radial-gradient(closest-side, rgba(10,9,8,.6), transparent); }
.hero h1 { margin: 0; font: 400 calc(clamp(64px, 11vw, 168px) * var(--hero-scale))/.9 var(--display); letter-spacing: -.01em; }
.kicker { font-family: var(--smallcaps); font-size: 14px; letter-spacing: .22em; color: var(--dim); margin-bottom: 2.2em !important; }
.lede { font-style: italic; font-size: 20px; margin-top: 2.2em !important; color: var(--fg); }
.scroll-cue { margin-top: 3.2em !important; display: flex; flex-direction: column; align-items: center; gap: 12px; font-family: var(--smallcaps); font-size: 13px; letter-spacing: .2em; color: var(--faint); }
.scroll-cue i { width: 1px; height: 48px; background: linear-gradient(var(--fg), transparent); animation: cue 2.6s var(--ease) infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); opacity: 1; } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }

/* autoencoder glyph: two hand-cut wedges around a narrow neck */
.codec { display: flex; align-items: center; gap: 10px; margin: 1.1em 0 1.2em; font-family: var(--smallcaps); font-size: 14px; letter-spacing: .06em; color: var(--dim); }
.codec .z { color: var(--fg); font-family: var(--display); font-size: 20px; }
.wedge { display: block; width: 64px; height: 34px; background: var(--fg); opacity: .8; }
.wedge.in { clip-path: polygon(0 0, 100% 38%, 100% 62%, 0 100%); }
.wedge.out { clip-path: polygon(0 38%, 100% 0, 100% 100%, 0 62%); }

/* chapter III: the held-out shells and the error curve */
.held { color: var(--seal); font-style: italic; }
.curve { margin: .2em 0 0; }
.curve svg { display: block; width: 100%; max-width: 320px; height: auto; overflow: visible; }
.curve .ax { fill: none; stroke: var(--rule); stroke-width: 1; }
.curve .tr { fill: none; stroke: var(--dim); stroke-width: 1.2; }
.curve .va { fill: none; stroke: var(--seal); stroke-width: 1.4; }
.curve .best { stroke: var(--faint); stroke-dasharray: 2 3; }
.curve text { font: italic 11px var(--text); fill: var(--faint); }
.curve .k-va { fill: var(--seal); }
.curve figcaption { font-size: 14px; color: var(--dim); font-style: italic; margin-top: .3em; }
.curve figcaption b { font-weight: 400; color: var(--fg); font-style: normal; }

/* free / grid switch */
.layout-switch { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 3px; margin: .4em 0 .2em; }
.layout-switch button { padding: 6px 18px; border-radius: 999px; font-family: var(--smallcaps); font-size: 14px; letter-spacing: .1em; color: var(--dim); transition: background .4s, color .4s; }
.layout-switch button[aria-pressed="true"] { background: var(--fg); color: var(--ink); }
body.theme-paper .layout-switch button[aria-pressed="true"] { color: var(--paper); }

.finish-copy { bottom: auto; top: clamp(90px, 16vh, 160px); }
.finish-name { font: italic 400 30px/1.1 var(--display); margin-bottom: .5em !important; }
#finish-text { min-height: 3.2em; font-style: italic; color: var(--dim); }

/* cluster pile labels, positioned from 3D each frame */
.pile-labels { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.pile-label { position: absolute; transform: translate(-50%, 0); text-align: center; opacity: 0; transition: opacity .6s; white-space: nowrap; }
.pile-label.on { opacity: 1; }
.pile-label b { display: block; font: italic 400 16px/1 var(--display); color: var(--accent); }
.pile-label span { display: block; font: 400 22px/1.15 var(--display); }
.pile-label small { display: block; font-family: var(--smallcaps); font-size: 12px; letter-spacing: .12em; color: var(--dim); }
.scan-label b { font: 400 26px/1 var(--display); color: var(--fg); font-style: normal; }

/* the archipelago's names, an old chart's lettering, shown at the bench; placed from 3D each frame */
.isle {
  position: absolute; left: 0; top: 0; padding: 4px 10px; text-align: center; white-space: nowrap;
  opacity: 0; transition: opacity .7s var(--ease); cursor: default;
  text-shadow: 0 0 3px var(--halo), 0 0 8px var(--halo), 0 0 16px var(--halo);
  background: radial-gradient(closest-side, var(--halo), transparent);
}
.isle.on { opacity: 1; pointer-events: auto; }
.isle b { display: block; font: 400 11px/1 var(--display); letter-spacing: .3em; color: var(--accent); margin-bottom: 4px; }
.isle span { display: block; font: 400 15px/1.1 var(--display); letter-spacing: .22em; text-transform: uppercase; }
/* the land's description unfolds under its name on hover, or on a tap */
.isle em {
  position: absolute; left: 50%; top: 100%; width: 240px; margin-left: -120px; padding: 8px 12px 9px;
  font-style: normal; font-size: 13px; line-height: 1.4; white-space: normal; color: var(--fg); text-shadow: none;
  background: var(--halo); opacity: 0; transform: translateY(-4px); transition: opacity .3s, transform .3s; pointer-events: none;
}
.isle em small { display: block; margin-top: 4px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.isle:hover em, .isle.open em { opacity: 1; transform: none; }
.isle:hover, .isle.open { z-index: 2; }
.isle.minor span { font-size: 12px; }
.isles-leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.isles-leaders line { stroke: var(--fg); stroke-width: 1; opacity: .5; }
.isles-leaders circle { fill: none; stroke: var(--fg); stroke-width: 1; opacity: .8; }
#isle-names[aria-pressed="false"] { opacity: .6; }

/* specimen tag on hover, like a museum label tied with string */
.specimen {
  position: fixed; z-index: 9; pointer-events: none; left: 0; top: 0;
  padding: 9px 14px 10px; background: #e8dfcb; color: #1b1712;
  font-size: 14px; line-height: 1.3; box-shadow: 0 6px 22px rgba(0,0,0,.35);
  opacity: 0; transform: translate(14px, 14px) rotate(-1.2deg); transition: opacity .2s;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 9px 100%, 0 calc(100% - 9px));
}
.specimen.on { opacity: 1; }
.specimen b { font: 400 18px var(--display); }
.specimen em { display: block; color: #1b1712; font-size: 16px; }
.specimen span:last-child { display: block; font-family: var(--smallcaps); font-size: 12px; letter-spacing: .08em; color: #6b5a44; }

/* final work bench */
.bench {
  position: fixed; z-index: 6; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
  width: min(760px, calc(100vw - 32px)); opacity: 0; pointer-events: none;
  transition: opacity .8s var(--ease), transform .9s var(--ease);
}
.bench.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.bench-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 12px; }
.views { display: flex; gap: 1.2rem; font-size: 16px; }
.finishes { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.finishes button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; font: 400 16px/1 var(--display); color: var(--dim); position: relative; transition: color .3s; }
.finishes button[aria-pressed="true"], .finishes button:hover { color: var(--fg); }
.finishes button[aria-pressed="true"]::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: -1px; height: 2px; background: var(--fg); }
.sw { width: 26px; height: 26px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1px var(--rule); }
.sw.fossil { background: radial-gradient(circle at 40% 40%, #a29d8a 28%, #2d2a25 32%, #24221e 70%); }
.sw.rubbing { background: radial-gradient(circle at 50% 50%, #1f3b54 38%, #ece7dc 40%); }
.sw.line { background: #efe8d8 repeating-linear-gradient(35deg, transparent 0 4px, #4a3322 4px 5px); }
.sw.contour { background: #12110f repeating-radial-gradient(circle at 40% 40%, transparent 0 3px, #e9e1cf 3px 4px); }
.sw.cast { background: radial-gradient(circle at 35% 30%, #fffdf8, #bdb6aa 80%); }
.sw.nacre { background: conic-gradient(from 30deg, #9fd3c9, #c6b3e6, #f1d6b5, #9fc0e8, #c9e6c2, #9fd3c9); }
.hint { margin: 10px 0 0; text-align: center; font-size: 14px; font-style: italic; color: var(--faint); }

.tide-btn { position: fixed; z-index: 10; left: 32px; bottom: 22px; font-size: 14px; }
body.at-bench .tide-btn, body.past-shore .tide-btn { display: none; }

/* field notes */
dialog#notes {
  width: min(620px, calc(100vw - 32px)); max-height: 86vh; overflow: auto; padding: 42px 44px 34px;
  background: #ece5d5; color: #1a1714; border: 0; box-shadow: 0 30px 90px rgba(0,0,0,.55);
  font-size: 17px;
}
dialog#notes::backdrop { background: rgba(8,7,6,.7); backdrop-filter: blur(3px); }
#notes h2 { font: 400 46px/1 var(--display); margin: .1em 0 .6em; }
#notes .kicker { margin-bottom: 0 !important; color: #6b5a44; }
#notes dl { margin: 1.4em 0; }
#notes dt { font-family: var(--smallcaps); letter-spacing: .1em; font-size: 14px; color: #8a5a2b; margin-top: 1em; }
#notes dd { margin: .2em 0 0; }
#notes .fine { color: #6b5a44; border-color: rgba(0,0,0,.15); }
#notes .close { position: absolute; top: 14px; right: 20px; font-size: 30px; line-height: 1; color: #6b5a44; }

#veil { position: fixed; inset: 0; z-index: 50; background: var(--ink); display: grid; place-content: center; text-align: center; transition: opacity 1.4s var(--ease), visibility 1.4s; }
#veil .sc { font-size: 26px; letter-spacing: .3em; margin: 0; }
#veil .veil-sub { font-style: italic; color: var(--dim); margin: .4em 0 0; }
body.ready #veil { opacity: 0; visibility: hidden; }
.nojs { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; background: var(--ink); }

:focus-visible { outline: 1px dashed var(--accent); outline-offset: 4px; }

@media (max-width: 720px) {
  body { font-size: 17px; }
  .masthead { padding: 16px; gap: 1rem; }
  .wordmark { display: none; }
  .gauge { right: 12px; gap: 18px; }
  .gauge a span { display: none; }
  .chapter-copy { left: 16px; bottom: 28px; width: calc(100vw - 52px); }
  .hero { width: calc(100vw - 32px); left: 50%; }
  .hero h1 { font-size: calc(15vw * var(--hero-scale)); }
  .lede { font-size: 18px; }
  .chapter-copy h2 { font-size: 40px; }
  .chapter-copy p { margin-bottom: .6em; }
  .chapter-copy[data-ch="3"] .codec, .chapter-copy[data-ch="3"] .curve, .chapter-copy[data-ch="3"] .fine, .chapter-copy[data-ch="4"] .fine { display: none; }
  .codec { margin: .6em 0 .7em; }
  .wedge { width: 44px; height: 26px; }
  .pile-label span { font-size: 17px; }
  .pile-label b { font-size: 13px; }
  .pile-label small { font-size: 11px; }
  .isle span { font-size: 11px; letter-spacing: .14em; }
  .isle b { display: none; }
  .isle em { width: 190px; margin-left: -95px; font-size: 12px; }
  .finish-copy p:not(.finish-name):not(.numeral) { display: none; }
  .finish-copy h2 { font-size: 32px; margin-bottom: .25em; }
  .finish-name { font-size: 24px; }
  .chapter-copy::before { inset: -60px -40px -40px -40px; }
  body.at-bench .gauge { opacity: 0; pointer-events: none; }
  .finish-copy { top: 72px; }
  .finishes { grid-template-columns: repeat(3, 1fr); }
  .bench { bottom: 12px; }
  .bench-row { flex-wrap: wrap; }
  .views { gap: .9rem; font-size: 14px; }
  .tide-btn { left: 16px; bottom: 10px; }
  .chapter-copy[data-ch="1"] .fine, .chapter-copy[data-ch="2"] .fine { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .scroll-cue i { animation: none; }
}

/* ——— 中文 ———
   Titles and labels in Fusion Pixel (缝合像素), text in Glow Sans (未来荧黑); Latin letters and figures stay in
   Gap Sans, which comes first in every stack. Both Chinese fonts are subset to the site's own characters
   (_build/subset_zh.py) and are only downloaded once Chinese is shown. The pixel font is drawn at whole
   multiples of its 12 px grid so it stays crisp. */
@font-face { font-family: "Fusion Pixel ZH"; src: url("fonts/fusion-pixel-zh.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Glow Sans ZH"; src: url("fonts/glow-sans-zh-light.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Glow Sans ZH"; src: url("fonts/glow-sans-zh-regular.woff2") format("woff2"); font-weight: 700; font-display: swap; }

.mast-links { display: flex; align-items: baseline; gap: 1.4rem; }
.lang-btn { font-family: "Gap Sans", "Fusion Pixel ZH", system-ui, sans-serif; font-style: normal; font-size: 12px; letter-spacing: .14em; }
body.lang-zh .lang-btn { font-size: 13px; letter-spacing: .08em; }

body.lang-zh {
  --display: "Gap Sans", "Fusion Pixel ZH", system-ui, sans-serif;
  --smallcaps: "Gap Sans", "Fusion Pixel ZH", system-ui, sans-serif;
  --text: "Gap Sans", "Glow Sans ZH", system-ui, sans-serif;
}
body.lang-zh em, body.lang-zh .lede, body.lang-zh .link-btn, body.lang-zh .fine, body.lang-zh .hint, body.lang-zh #finish-text { font-style: normal; }
body.lang-zh .chapter-copy p, body.lang-zh #notes p, body.lang-zh #notes dd { line-height: 1.85; letter-spacing: .02em; text-wrap: pretty; /* no lone character on the last line */ }
body.lang-zh .fine { line-height: 1.7; }

/* pixel titles on the 12 px grid */
body.lang-zh .hero h1 { font-size: 144px; line-height: 1; letter-spacing: .06em; }
body.lang-zh .chapter-copy h2, body.lang-zh #notes h2 { font-size: 48px; line-height: 1.1; letter-spacing: .04em; }
body.lang-zh .finish-name { font-size: 36px; letter-spacing: .04em; }
body.lang-zh .pile-label span { font-size: 24px; letter-spacing: .06em; }
body.lang-zh .wordmark.sc { font-size: 24px; letter-spacing: .12em; }
body.lang-zh #veil .sc { font-size: 24px; letter-spacing: .3em; }
body.lang-zh .lede { font-size: 22px; letter-spacing: .04em; }

/* pixel labels at their native 12 px */
body.lang-zh .sc, body.lang-zh .kicker, body.lang-zh .scroll-cue, body.lang-zh .gauge a, body.lang-zh .layout-switch button,
body.lang-zh .finishes button, body.lang-zh .pile-label small, body.lang-zh #notes dt, body.lang-zh .specimen span:last-child,
body.lang-zh .isle span, body.lang-zh .isle.minor span { font-size: 12px; }
body.lang-zh .kicker, body.lang-zh .scroll-cue { letter-spacing: .3em; }
body.lang-zh .gauge a { letter-spacing: .1em; }
body.lang-zh .isle span { letter-spacing: .24em; }
body.lang-zh .layout-switch button { letter-spacing: .2em; }
body.lang-zh .finishes button { letter-spacing: .12em; }
body.lang-zh .isle em { font-size: 13px; line-height: 1.6; }

@media (max-width: 720px) {
  body.lang-zh .hero h1 { font-size: 72px; }
  body.lang-zh .chapter-copy h2, body.lang-zh #notes h2 { font-size: 36px; }
  body.lang-zh .finish-name { font-size: 24px; }
  body.lang-zh .pile-label span { font-size: 12px; }
  body.lang-zh .lede { font-size: 18px; }
  .mast-links { gap: 1rem; }
}
.nw { white-space: nowrap; }
