/* The MTR, in section — site stylesheet. Tokens follow design-system.md. */
@layer reset, tokens, base, layout, components, utilities;

/* ---------- fonts ---------- */
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("../fonts/plexmono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("../fonts/plexmono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
/* Metric-matched fallbacks so the swap does not reflow */
@font-face {
  font-family: "Archivo Fallback";
  src: local("Arial"), local("ArialMT"), local("Helvetica Neue"), local("Helvetica");
  size-adjust: 98%;
  ascent-override: 89.6%;
  descent-override: 21.4%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Plex Mono Fallback";
  src: local("Courier New"), local("CourierNewPSMT");
  size-adjust: 100%;
  ascent-override: 102.5%;
  descent-override: 27.5%;
  line-gap-override: 0%;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ol, ul { margin: 0; }
  ol[class], ul[class] { list-style: none; padding: 0; }
  img, svg { display: block; max-width: 100%; }
  button, input, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
}

@layer tokens {
  :root {
    color-scheme: light dark;

    --paper: #f5f4f0;
    --paper-2: #ebe9e2;
    --paper-3: #e1ded5;
    --ink: #15171c;
    --graphite: #474c57;
    --rule: #cfccc2;
    --rule-strong: #6b6f78;
    --navy: #1f3a5f;
    --navy-ink: #f5f4f0;
    --focus: #1f3a5f;

    /* strata tints (used inside SVG patterns) */
    --stratum-fill: #dcd6c6;
    --stratum-clay: #cbc6b6;
    --stratum-weathered: #d8d2c2;
    --stratum-rock: #c3bfb3;
    --water: #c9d4de;
    --water-line: #8ea3b8;

    /* the projection room: always dark, both themes */
    --stage: #0e1726;
    --stage-2: #142036;
    --stage-ink: #ebe9e2;
    --stage-graphite: #a7b0bf;
    --stage-rule: #2b3c57;
    --signal: #e8c35a;          /* film only: the active step, sweep, struts, lift, focus on the stage */
    --stage-concrete: #3a4a63;  /* film only: concrete in section */

    /* MTR line identifiers (values checked in data.js) */
    --ktl: #00ab4e;
    --twl: #ed1d24;
    --isl: #007dc5;
    --sil: #bac429;
    --tkl: #7d499d;
    --tcl: #f7943e;
    --ael: #00888a;
    --drl: #f173ac;
    --eal: #53b7e8;
    --tml: #923011;

    /* level encoding: diverging around street level (validated, see design-system.md) */
    --lv-up: #c4581c;
    --lv-mid: #7d838d;
    --lv-down: #1f5aa6;

    --font-sans: "Archivo", "Archivo Fallback", sans-serif;
    --font-mono: "Plex Mono", "Plex Mono Fallback", ui-monospace, monospace;

    --step--2: clamp(0.72rem, 0.70rem + 0.10vw, 0.78rem);
    --step--1: clamp(0.83rem, 0.80rem + 0.15vw, 0.92rem);
    --step-0: clamp(1rem, 0.96rem + 0.20vw, 1.125rem);
    --step-1: clamp(1.2rem, 1.12rem + 0.38vw, 1.45rem);
    --step-2: clamp(1.44rem, 1.30rem + 0.68vw, 1.9rem);
    --step-3: clamp(1.73rem, 1.48rem + 1.2vw, 2.6rem);
    --step-4: clamp(2.07rem, 1.65rem + 2.1vw, 3.6rem);
    --step-5: clamp(2.5rem, 1.8rem + 3.5vw, 5.2rem);
    --step-6: clamp(3rem, 1.9rem + 5.6vw, 7.5rem);

    --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem;
    --s-6: 2rem; --s-7: 3rem; --s-8: 4rem; --s-9: 6rem; --s-10: 8rem; --s-11: 12rem;

    --sheet-max: 88rem;
    --gutter: 16px;
    --measure: 66ch;

    --ease-draft: cubic-bezier(.65, 0, .35, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --t-fast: 160ms;
    --t-mid: 320ms;
    --t-slow: 640ms;

    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  @media (min-width: 481px) { :root { --gutter: 24px; } }
  @media (min-width: 1025px) { :root { --gutter: 40px; } }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --paper: #0e1726;
      --paper-2: #142036;
      --paper-3: #1a2942;
      --ink: #ebe9e2;
      --graphite: #aab2c0;
      --rule: #26364f;
      --rule-strong: #8a96a8;
      --navy: #a9c3e6;
      --navy-ink: #0e1726;
      --focus: #a9c3e6;
      --stratum-fill: #24324a;
      --stratum-clay: #1f2c42;
      --stratum-weathered: #22304a;
      --stratum-rock: #2a3953;
      --water: #16294a;
      --water-line: #4b6a93;
      --stage: #0a121f;
      --stage-2: #101b2e;
      --lv-up: #c9692f;
      --lv-mid: #8a929e;
      --lv-down: #4a82cf;
    }
  }
  :root[data-theme="dark"] {
    --paper: #0e1726;
    --paper-2: #142036;
    --paper-3: #1a2942;
    --ink: #ebe9e2;
    --graphite: #aab2c0;
    --rule: #26364f;
    --rule-strong: #8a96a8;
    --navy: #a9c3e6;
    --navy-ink: #0e1726;
    --focus: #a9c3e6;
    --stratum-fill: #24324a;
    --stratum-clay: #1f2c42;
    --stratum-weathered: #22304a;
    --stratum-rock: #2a3953;
    --water: #16294a;
    --water-line: #4b6a93;
    --stage: #0a121f;
    --stage-2: #101b2e;
    --lv-up: #c9692f;
    --lv-mid: #8a929e;
    --lv-down: #4a82cf;
  }
}

@layer base {
  html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  body {
    background-color: var(--paper);
    background-image: var(--grain);
    background-size: 160px 160px;
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--step-0);
    font-weight: 400;
    font-stretch: 100%;
    line-height: 1.55;
    font-variant-numeric: lining-nums;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
  }

  h1, h2, h3, h4 { line-height: 1.04; font-weight: 800; text-wrap: balance; }
  p { text-wrap: pretty; }

  a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
  a:hover { text-decoration-thickness: 2px; }

  :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 1px; }

  ::selection { background: var(--navy); color: var(--navy-ink); }

  .mono, code, kbd, time, .tabular {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums slashed-zero;
  }
}

@layer layout {
  .wrap {
    width: 100%;
    max-width: var(--sheet-max);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  /* the drawing-sheet frame: hairlines left and right of the content */
  .sheet-frame {
    position: relative;
  }
  @media (min-width: 1025px) {
    .sheet-frame::before, .sheet-frame::after {
      content: "";
      position: absolute;
      inset-block: 0;
      width: 1px;
      background: var(--rule);
      pointer-events: none;
    }
    .sheet-frame::before { left: calc(var(--gutter) / 2); }
    .sheet-frame::after { right: calc(var(--gutter) / 2); }
  }

  .grid-12 {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--s-5);
  }
}

@layer components {
  /* ---------- skip link ---------- */
  .skip {
    position: absolute;
    left: var(--s-4);
    top: -10rem;
    z-index: 100;
    background: var(--ink);
    color: var(--paper);
    padding: var(--s-3) var(--s-4);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    text-decoration: none;
  }
  .skip:focus { top: var(--s-4); }

  /* ---------- mono label ---------- */
  .label {
    font-family: var(--font-mono);
    font-size: var(--step--2);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--graphite);
    line-height: 1.3;
  }

  /* ---------- masthead ---------- */
  .masthead {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 50;
    background: color-mix(in oklab, var(--paper) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.2) blur(10px);
    backdrop-filter: saturate(1.2) blur(10px);
    border-bottom: 1px solid var(--rule);
  }
  .masthead .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    min-height: 3.5rem;
  }
  .mark {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--ink);
    text-decoration: none;
    font-weight: 800;
    font-stretch: 62%;
    font-size: 1.125rem;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    line-height: 1;
    min-height: 44px;
  }
  .mark svg { width: 26px; height: 26px; flex: none; }
  .mark span { font-weight: 200; font-stretch: 125%; text-transform: none; letter-spacing: 0; }

  .nav-toggle {
    display: none;
    align-items: center;
    gap: var(--s-2);
    min-height: 44px;
    padding: 0 var(--s-3);
    border: 1px solid var(--rule-strong);
    border-radius: 2px;
    background: transparent;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .nav-toggle svg { width: 14px; height: 14px; transition: transform var(--t-fast) var(--ease-out); }
  .nav-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

  .nav ol { display: flex; gap: var(--s-1); list-style: none; margin: 0; padding: 0; }
  .nav a {
    display: inline-flex;
    align-items: baseline;
    gap: 0.45em;
    min-height: 44px;
    align-items: center;
    padding: 0 var(--s-3);
    color: var(--ink);
    text-decoration: none;
    font-size: var(--step--1);
    font-weight: 500;
    border-radius: 2px;
  }
  .nav a .no { font-family: var(--font-mono); font-size: var(--step--2); color: var(--graphite); }
  .nav a:hover { background: var(--paper-2); }
  .nav a[aria-current="true"] { box-shadow: inset 0 -2px 0 var(--ink); }

  @media (max-width: 860px) {
    .nav-toggle { display: inline-flex; }
    .nav {
      position: absolute;
      inset-inline: 0;
      top: 100%;
      background: var(--paper);
      border-bottom: 1px solid var(--rule);
      display: none;
    }
    .nav.is-open { display: block; }
    .nav ol { flex-direction: column; padding: var(--s-2) var(--gutter) var(--s-4); gap: 0; }
    .nav a { width: 100%; font-size: var(--step-0); border-bottom: 1px solid var(--rule); border-radius: 0; padding-inline: 0; }
    .nav a[aria-current="true"] { box-shadow: inset 3px 0 0 var(--ink); padding-left: var(--s-3); }
  }

  /* ---------- buttons ---------- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-3);
    min-height: 48px;
    padding: 0 var(--s-5);
    border: 1.5px solid var(--ink);
    border-radius: 2px;
    font-family: var(--font-sans);
    font-size: var(--step-0);
    font-weight: 600;
    text-decoration: none;
    color: var(--ink);
    background: transparent;
    transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
  }
  .btn:hover { background: var(--paper-2); text-decoration: none; }
  .btn:active { transform: translateY(1px); }
  .btn--solid { background: var(--ink); color: var(--paper); }
  .btn--solid:hover { background: var(--navy); border-color: var(--navy); color: var(--navy-ink); }
  .btn .meta { font-family: var(--font-mono); font-size: var(--step--2); font-weight: 400; opacity: 0.8; letter-spacing: 0.04em; }
  .btn svg { width: 16px; height: 16px; flex: none; }

  /* ---------- hero ---------- */
  .hero { padding-block: var(--s-7) var(--s-8); }
  .hero .grid-12 { row-gap: var(--s-6); align-items: start; }
  .hero-copy { grid-column: 1 / span 5; padding-top: var(--s-6); }
  .hero-fig { grid-column: 6 / -1; margin-right: calc(var(--gutter) * -0.5); }

  .kicker { margin-bottom: var(--s-5); display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
  .kicker span:not(:last-child)::after { content: "·"; margin-left: var(--s-4); color: var(--rule-strong); }

  h1 {
    font-size: var(--step-6);
    letter-spacing: -0.01em;
    margin-bottom: var(--s-5);
  }
  h1 .h1-a { display: block; font-weight: 850; font-stretch: 62%; text-transform: uppercase; letter-spacing: -0.005em; }
  h1 .h1-b { display: block; font-weight: 200; font-stretch: 125%; letter-spacing: -0.035em; font-size: 0.62em; margin-top: 0.08em; }

  .standfirst { font-size: var(--step-1); line-height: 1.45; max-width: 34ch; color: var(--ink); }
  .standfirst + p { margin-top: var(--s-4); color: var(--graphite); max-width: 44ch; }
  .actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-6); }

  @media (max-width: 1024px) {
    .hero-copy { grid-column: 1 / -1; padding-top: 0; }
    .hero-fig { grid-column: 1 / -1; margin-right: 0; }
    .standfirst { max-width: 44ch; }
  }

  /* ---------- figures & drawings ---------- */
  .drawing {
    position: relative;
    background-color: var(--paper);
    border: 1px solid var(--rule);
  }
  .drawing svg { width: 100%; height: auto; overflow: visible; }
  .drawing-grid {
    background-image:
      linear-gradient(to right, color-mix(in oklab, var(--rule) 45%, transparent) 1px, transparent 1px),
      linear-gradient(to bottom, color-mix(in oklab, var(--rule) 45%, transparent) 1px, transparent 1px);
    background-size: 8px 8px;
  }
  figcaption, .figcap {
    display: flex;
    gap: var(--s-3);
    margin-top: var(--s-3);
    font-size: var(--step--1);
    color: var(--graphite);
    line-height: 1.45;
  }
  .figcap .fig-no, figcaption .fig-no { font-family: var(--font-mono); font-size: var(--step--2); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); white-space: nowrap; padding-top: 0.15em; }

  /* drawing primitives (SVG) */
  .ink-line { stroke: var(--ink); fill: none; }
  .ink-fill { fill: var(--ink); }
  .paper-fill { fill: var(--paper); }
  .graphite-fill { fill: var(--graphite); }
  .rule-line { stroke: var(--rule-strong); fill: none; }
  .hair { stroke: var(--rule); fill: none; }
  .svg-label { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.04em; fill: var(--ink); font-variant-numeric: tabular-nums; }
  .svg-label--muted { fill: var(--graphite); }
  .svg-title { font-family: var(--font-sans); font-weight: 800; font-stretch: 62%; text-transform: uppercase; fill: var(--ink); letter-spacing: 0.01em; }
  .svg-sans { font-family: var(--font-sans); fill: var(--ink); }

  .pat-line { stroke: var(--graphite); stroke-width: 0.7; fill: none; opacity: 0.55; }
  .pat-dot { fill: var(--graphite); opacity: 0.45; }
  .pat-water { stroke: var(--water-line); stroke-width: 0.8; fill: none; }
  .stratum-fill { fill: var(--stratum-fill); }
  .stratum-clay { fill: var(--stratum-clay); }
  .stratum-weathered { fill: var(--stratum-weathered); }
  .stratum-rock { fill: var(--stratum-rock); }
  .water-fill { fill: var(--water); }

  /* ---------- cut legend (hero) ---------- */
  .cut-legend {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--ink);
    margin-top: var(--s-4);
  }
  .cut-legend li {
    padding: var(--s-3) var(--s-3) var(--s-3) 0;
    border-right: 1px solid var(--rule);
    display: grid;
    gap: 0.2rem;
    align-content: start;
  }
  .cut-legend li + li { padding-left: var(--s-3); }
  .cut-legend li:last-child { border-right: 0; }
  .cut-legend .swatch { display: inline-block; width: 1.75rem; height: 0.5rem; border: 1px solid var(--ink); background: var(--c); vertical-align: middle; margin-right: 0.4rem; }
  .cut-legend .yr { font-family: var(--font-mono); font-size: var(--step-1); font-weight: 500; line-height: 1.1; }
  .cut-legend .nm { font-weight: 600; font-size: var(--step--1); line-height: 1.25; }
  .cut-legend .dp { font-family: var(--font-mono); font-size: var(--step--2); color: var(--graphite); }
  @media (max-width: 640px) {
    .cut-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cut-legend li:nth-child(2) { border-right: 0; }
    .cut-legend li:nth-child(3) { padding-left: 0; }
    .cut-legend li:nth-child(n+3) { border-top: 1px solid var(--rule); }
  }

  /* ---------- sheets (sections) ---------- */
  .sheet { padding-block: var(--s-9) var(--s-8); border-top: 1px solid var(--ink); }
  .sheet-head {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr) minmax(0, 17rem);
    border: 1px solid var(--ink);
    margin-bottom: var(--s-7);
  }
  .sheet-head > * { padding: var(--s-4) var(--s-5); }
  .sheet-head > * + * { border-left: 1px solid var(--ink); }
  .sheet-no { display: grid; align-content: space-between; gap: var(--s-4); }
  .sheet-no b { font-family: var(--font-mono); font-weight: 500; font-size: var(--step-4); line-height: 1; letter-spacing: -0.02em; }
  .sheet-title h2 { font-size: var(--step-4); font-stretch: 62%; text-transform: uppercase; letter-spacing: -0.005em; }
  .sheet-title h2 .thin { font-weight: 200; font-stretch: 125%; text-transform: none; letter-spacing: -0.03em; font-size: 0.8em; display: block; margin-top: 0.12em; }
  .sheet-title p { margin-top: var(--s-4); max-width: 60ch; color: var(--graphite); }
  .sheet-meta { display: grid; align-content: start; gap: var(--s-3); }
  .sheet-meta div { display: grid; gap: 0.1rem; align-content: start; }
  .sheet-meta dd { font-size: var(--step--1); line-height: 1.35; }

  @media (max-width: 860px) {
    .sheet { padding-block: var(--s-8) var(--s-7); }
    .sheet-head { grid-template-columns: 5.5rem minmax(0, 1fr); }
    .sheet-meta { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--ink); grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
    .sheet-no b { font-size: var(--step-3); }
  }
  @media (max-width: 480px) {
    .sheet-head { grid-template-columns: minmax(0, 1fr); }
    .sheet-head > * + * { border-left: 0; border-top: 1px solid var(--ink); }
    .sheet-no { grid-auto-flow: column; justify-content: space-between; align-items: end; }
    .sheet-head > * { padding: var(--s-3) var(--s-4); }
  }

  .prose { max-width: var(--measure); }
  .prose p + p { margin-top: var(--s-4); }
  .prose h3 { font-size: var(--step-2); font-stretch: 62%; text-transform: uppercase; margin: var(--s-6) 0 var(--s-3); }

  /* ---------- film (the projection room) ---------- */
  .film {
    --ink: var(--stage-ink);
    --graphite: var(--stage-graphite);
    --rule: var(--stage-rule);
    --rule-strong: #8a96a8;
    --paper: var(--stage);
    --paper-2: var(--stage-2);
    --focus: var(--signal);
    --stratum-fill: #1d2a40;
    --stratum-clay: #192538;
    --stratum-weathered: #1f2d45;
    --stratum-rock: #26354f;
    --water: #13284a;
    --water-line: #3f5f8a;
    background: var(--stage);
    color: var(--stage-ink);
    border: 1px solid var(--stage-rule);
  }
  /* the stage shrinks so stage, caption and controls fit one screen */
  .film-stage {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--stage);
    width: min(100%, calc((100svh - 17.5rem) * 16 / 9));
    min-width: min(100%, 36rem);
    margin-inline: auto;
  }
  .film-frame { background: var(--stage); border-bottom: 1px solid var(--stage-rule); }
  .film-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
  .film-stage { cursor: pointer; }
  /* year stamps stay legible over drawings by knocking out the ink behind
     each glyph, never by covering the drawing with a plate */
  .f-stamp text { paint-order: stroke; stroke: var(--stage); stroke-width: 10px; stroke-linejoin: round; }
  .film-poster {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--s-4);
    background: color-mix(in oklab, var(--stage) 58%, transparent);
    border: 0;
    color: var(--stage-ink);
    text-align: center;
    padding: var(--s-5);
    transition: opacity var(--t-mid) var(--ease-out);
  }
  .film-poster[hidden] { display: none; }
  .film-poster .ring {
    width: clamp(64px, 9vw, 104px);
    aspect-ratio: 1;
    border-radius: 999px;
    border: 1.5px solid currentColor;
    display: grid;
    place-items: center;
    transition: transform var(--t-mid) var(--ease-out), background var(--t-mid) var(--ease-out);
  }
  .film-poster .ring svg { position: static; width: 32%; height: 32%; margin-left: 8%; }
  .film-poster:hover .ring { transform: scale(1.06); background: color-mix(in oklab, var(--stage-ink) 12%, transparent); }
  .film-poster .t { font-weight: 800; font-stretch: 62%; text-transform: uppercase; font-size: var(--step-3); line-height: 1; }
  .film-poster .m { font-family: var(--font-mono); font-size: var(--step--1); color: var(--stage-graphite); letter-spacing: 0.04em; }

  .film-cap {
    min-height: calc(3 * 1.4em + 2 * var(--s-4));
    padding: var(--s-4) var(--s-6);
    border-top: 1px solid var(--stage-rule);
    font-size: var(--step-1);
    line-height: 1.4;
    font-weight: 400;
    max-width: none;
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: var(--s-5);
    align-items: start;
  }
  .film-cap .when { font-family: var(--font-mono); font-size: var(--step--1); color: var(--stage-graphite); padding-top: 0.45em; letter-spacing: 0.04em; text-transform: uppercase; }
  .film-cap .txt { max-width: 64ch; text-wrap: pretty; }
  .film-cap .txt b { font-weight: 700; }

  .film-bar {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-3) var(--s-6) var(--s-4);
    border-top: 1px solid var(--stage-rule);
  }
  .icon-btn {
    width: 44px; height: 44px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--stage-rule);
    border-radius: 2px;
    background: transparent;
    color: var(--stage-ink);
  }
  .icon-btn:hover { background: var(--stage-2); border-color: var(--stage-graphite); }
  .icon-btn svg { width: 18px; height: 18px; }
  .film-time { font-family: var(--font-mono); font-size: var(--step--1); color: var(--stage-graphite); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .film-time b { color: var(--stage-ink); font-weight: 500; }

  .scrub { position: relative; height: 44px; display: grid; align-items: center; }
  .scrub input { width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; height: 44px; position: relative; z-index: 2; }
  .scrub input::-webkit-slider-runnable-track { height: 2px; background: transparent; }
  .scrub input::-moz-range-track { height: 2px; background: transparent; }
  .scrub input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 999px; background: var(--stage-ink); border: 3px solid var(--stage); box-shadow: 0 0 0 1px var(--stage-ink); }
  .scrub input::-moz-range-thumb { width: 12px; height: 12px; border-radius: 999px; background: var(--stage-ink); border: 3px solid var(--stage); box-shadow: 0 0 0 1px var(--stage-ink); }
  .scrub input:focus-visible { outline: none; }
  .scrub input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--stage-ink), 0 0 0 4px var(--focus); }
  .scrub input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--stage-ink), 0 0 0 4px var(--focus); }
  .scrub .track { position: absolute; inset-inline: 0; top: 50%; height: 2px; translate: 0 -50%; background: var(--stage-rule); }
  .scrub .fill { position: absolute; left: 0; top: 50%; height: 2px; translate: 0 -50%; background: var(--stage-ink); width: var(--p, 0%); }
  .scrub .tick { position: absolute; top: calc(50% - 6px); width: 1px; height: 12px; background: var(--stage-graphite); }

  .film-chapters { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); border-top: 1px solid var(--stage-rule); }
  .film-chapters li + li { border-left: 1px solid var(--stage-rule); }
  @media (max-width: 1100px) {
    .film-chapters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .film-chapters li:nth-child(3n+1) { border-left: 0; }
    .film-chapters li:nth-child(n+4) { border-top: 1px solid var(--stage-rule); }
  }
  .film-chapters li { display: flex; }
  .film-chapters button {
    width: 100%;
    height: 100%;
    min-height: 64px;
    text-align: left;
    background: transparent;
    border: 0;
    padding: var(--s-3) var(--s-3);
    display: grid;
    gap: 0.15rem;
    color: var(--stage-graphite);
    position: relative;
  }
  .film-chapters button:hover { background: var(--stage-2); color: var(--stage-ink); }
  .film-chapters button .y { font-family: var(--font-mono); font-size: var(--step--2); letter-spacing: 0.06em; }
  .film-chapters button .n { font-weight: 600; font-size: var(--step--1); color: var(--stage-ink); line-height: 1.25; }
  .film-chapters button[aria-current="true"] { color: var(--stage-ink); background: var(--stage-2); }
  .film-chapters button[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--stage-ink); }

  .transcript { border-top: 1px solid var(--stage-rule); }
  .transcript summary {
    cursor: pointer;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 0 var(--s-6);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    list-style: none;
  }
  .transcript summary::-webkit-details-marker { display: none; }
  .transcript summary::before { content: "+"; width: 1em; font-size: 1.2em; }
  .transcript[open] summary::before { content: "−"; }
  .transcript summary:hover { background: var(--stage-2); }
  .transcript-body { padding: var(--s-2) var(--s-6) var(--s-6); columns: 2 30ch; column-gap: var(--s-7); }
  .transcript-body section { break-inside: avoid; margin-bottom: var(--s-5); }
  .transcript-body h3 { font-size: var(--step-0); font-weight: 700; margin-bottom: var(--s-2); }
  .transcript-body h3 .y { font-family: var(--font-mono); font-weight: 400; color: var(--stage-graphite); font-size: var(--step--1); margin-right: var(--s-2); }
  .transcript-body p { color: var(--stage-ink); font-size: var(--step--1); line-height: 1.55; }
  .transcript-body p + p { margin-top: var(--s-2); }

  @media (max-width: 860px) {
    .film-cap { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); padding: var(--s-4) var(--s-4); font-size: var(--step-1); min-height: calc(4 * 1.35em + 2 * var(--s-4) + 1.5em); }
    .film-cap .when { padding-top: 0; }
    .film-bar { padding: var(--s-2) var(--s-4) var(--s-3); gap: var(--s-2) var(--s-3); grid-template-columns: auto auto minmax(0, 1fr); }
    .film-bar .film-time { grid-column: 1 / -1; grid-row: 2; }
    .film-chapters button { padding: var(--s-3) var(--s-4); min-height: 56px; }
    .transcript summary { padding-inline: var(--s-4); }
    .transcript-body { padding-inline: var(--s-4); columns: 1; }
    .film { margin-inline: calc(var(--gutter) * -1); border-inline: 0; }
    .film-stage { width: 100%; min-width: 0; }
  }

  /* ---------- network ---------- */
  .net { border: 1px solid var(--ink); }
  .net-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "year year" "stats ctl";
    gap: var(--s-4) var(--s-6);
    align-items: end;
    padding: var(--s-4) var(--s-5) var(--s-4);
    border-bottom: 1px solid var(--ink);
  }
  .year-ctl { grid-area: year; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-1) var(--s-5); align-items: center; }
  .year-ctl label { grid-column: 1 / -1; }
  .year-out { font-family: var(--font-mono); font-weight: 500; font-size: var(--step-4); line-height: 1; letter-spacing: -0.03em; min-width: 4ch; font-variant-numeric: tabular-nums; }
  .year-range { position: relative; }
  .year-range input { width: 100%; margin: 0; -webkit-appearance: none; appearance: none; background: transparent; height: 44px; position: relative; z-index: 1; cursor: pointer; }
  .year-range input::-webkit-slider-runnable-track { height: 2px; background: var(--ink); }
  .year-range input::-moz-range-track { height: 2px; background: var(--ink); }
  .year-range input::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -10px; border-radius: 999px; background: var(--paper); border: 2px solid var(--ink); }
  .year-range input::-moz-range-thumb { width: 18px; height: 18px; border-radius: 999px; background: var(--paper); border: 2px solid var(--ink); }
  .year-range input:focus-visible { outline: none; }
  .year-range input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--focus); }
  .year-range input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--focus); }
  .year-ticks { position: relative; height: 1.2em; font-family: var(--font-mono); font-size: var(--step--2); color: var(--graphite); margin-top: -6px; pointer-events: none; }
  .year-ticks span { position: absolute; top: 0; left: calc(11px + var(--p) * (100% - 22px)); translate: -50% 0; white-space: nowrap; }
  .year-ticks span:first-child { translate: -11px 0; }
  .year-ticks span:last-child { translate: calc(-100% + 11px) 0; }

  .net-stats { grid-area: stats; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-6); margin: 0; }
  .net-stats div { display: grid; gap: 0.15rem; }
  .net-stats dd { margin: 0; font-family: var(--font-mono); font-size: var(--step-2); font-weight: 500; line-height: 1.05; font-variant-numeric: tabular-nums; }
  .net-stats dt { order: 2; }

  .ctl-row { grid-area: ctl; display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: end; justify-content: flex-end; }
  .seg-wrap { border: 0; padding: 0; margin: 0; display: grid; gap: var(--s-2); min-width: 0; }
  .seg-wrap legend { padding: 0; margin-bottom: var(--s-2); }
  .seg { display: inline-grid; grid-auto-flow: column; border: 1px solid var(--rule-strong); border-radius: 2px; }
  .seg label { position: relative; display: grid; }
  .seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
  .seg span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-4); font-size: var(--step--1); font-weight: 600; white-space: nowrap; }
  .seg label + label span { border-left: 1px solid var(--rule-strong); }
  .seg input:checked + span { background: var(--ink); color: var(--paper); }
  .seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; position: relative; z-index: 1; }
  .seg input:not(:checked):hover + span { background: var(--paper-2); }
  .btn--compact { min-height: 46px; font-size: var(--step--1); padding: 0 var(--s-4); }

  .net-map { position: relative; min-width: 0; border-bottom: 1px solid var(--ink); }
  .net-map .scroller { overflow: auto; overscroll-behavior-x: contain; }
  .net-map .scroller > svg { width: 100%; height: auto; min-width: 760px; display: block; }
  @media (max-width: 1100px) { .net-map .scroller > svg { min-width: 1150px; } .net-map .scroller { max-height: 82vh; } }
  .net-hint { display: none; }
  @media (max-width: 1100px) { .net-hint { display: block; padding: var(--s-2) var(--s-4); font-size: var(--step--2); color: var(--graphite); border-bottom: 1px solid var(--rule); } }
  .net-legend svg { width: 16px; height: 16px; flex: none; }
  .net-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--rule); font-size: var(--step--2); }
  .net-legend li { display: inline-flex; align-items: center; gap: 0.45rem; }
  .net-legend .sw { width: 1.4rem; height: 0.42rem; border: 1px solid var(--ink); background: var(--c); }

  .net-detail { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; }
  .station-card { padding: var(--s-5); display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: var(--s-3) var(--s-6); align-content: start; min-height: 15rem; border-right: 1px solid var(--ink); }
  .station-card > .empty { grid-column: 1 / -1; align-self: center; }
  .sc-a, .sc-b { display: grid; gap: var(--s-3); align-content: start; }
  .station-card h3 { font-size: var(--step-3); font-stretch: 62%; text-transform: uppercase; }
  .station-card .lines { display: flex; flex-wrap: wrap; gap: var(--s-2); }
  .chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--step--2); font-weight: 600; border: 1px solid var(--rule-strong); padding: 0.2rem 0.5rem; border-radius: 2px; line-height: 1.2; }
  .chip i { width: 0.7rem; height: 0.7rem; background: var(--c); border: 1px solid var(--ink); display: inline-block; }
  .station-card dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-1) var(--s-4); font-size: var(--step--1); margin: 0; }
  .station-card dt { color: var(--graphite); }
  .station-card dd { margin: 0; font-variant-numeric: tabular-nums; }
  .station-card .note { font-size: var(--step--1); color: var(--ink); border-left: 2px solid var(--rule-strong); padding-left: var(--s-3); max-width: 60ch; }
  .station-card .empty { color: var(--graphite); font-size: var(--step--1); }
  .level-glyph { width: 100%; max-width: 22rem; height: auto; border: 1px solid var(--rule); background: var(--paper-2); }

  .station-pick { display: grid; gap: var(--s-2); padding: var(--s-5); align-content: start; }
  .station-pick select { min-height: 44px; border: 1px solid var(--rule-strong); border-radius: 2px; padding: 0 var(--s-3); background: var(--paper); width: 100%; }
  .pick-note { font-size: var(--step--2); color: var(--graphite); margin-top: var(--s-3); line-height: 1.5; }

  /* map marks */
  .m-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
  .m-case { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
  .m-stn { cursor: pointer; }
  .m-stn .hit { fill: transparent; }
  .m-stn .dot { fill: var(--paper); stroke: var(--ink); stroke-width: 2; transition: fill var(--t-fast); }
  .m-stn text { font-family: var(--font-sans); font-size: 12.5px; font-weight: 500; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 3.5px; stroke-linejoin: round; }
  .m-stn.is-x text { font-weight: 700; }
  .m-stn .ring { fill: none; stroke: transparent; }
  .m-stn:hover .dot { fill: var(--paper-3); }
  .m-stn:hover .ring { stroke: var(--rule-strong); stroke-width: 1.5; }
  .m-stn.is-sel .ring { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 3 3; }
  .m-stn.is-off { pointer-events: none; }
  .m-stn.is-off text, .m-stn.is-off .dot, .m-stn.is-off .lvl, .m-stn.is-off .ring { opacity: 0; }
  .m-water { fill: var(--water); }
  .m-coast { fill: none; stroke: var(--water-line); stroke-width: 1; }
  .m-place { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; fill: var(--graphite); }
  .m-call rect { fill: var(--ink); }
  .m-call text { fill: var(--paper); font-family: var(--font-sans); font-size: 13px; }
  .m-call .t { font-weight: 700; font-size: 14px; }
  .m-call path { fill: var(--ink); }

  @media (max-width: 1100px) {
    .net-controls { grid-template-columns: minmax(0, 1fr); grid-template-areas: "year" "stats" "ctl"; }
    .ctl-row { justify-content: flex-start; }
    .net-detail { grid-template-columns: minmax(0, 1fr); }
    .station-card { border-right: 0; border-bottom: 1px solid var(--rule); }
  }
  @media (max-width: 640px) {
    .net-controls { padding: var(--s-4); }
    .station-card { grid-template-columns: minmax(0, 1fr); padding: var(--s-4); }
    .station-pick { padding: var(--s-4); }
    .net-stats { gap: var(--s-2) var(--s-4); }
    .net-stats dd { font-size: var(--step-1); }
    .net { margin-inline: calc(var(--gutter) * -1); border-inline: 0; }
  }

  /* ---------- interchanges (stacks) ---------- */
  .stacks { display: grid; grid-template-columns: 16rem minmax(0, 1fr); border: 1px solid var(--ink); }
  .stack-tabs { display: grid; align-content: start; border-right: 1px solid var(--ink); }
  .stack-tabs button {
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--rule);
    padding: var(--s-3) var(--s-4);
    min-height: 56px;
    display: grid;
    gap: 0.15rem;
    position: relative;
  }
  .stack-tabs button:hover { background: var(--paper-2); }
  .stack-tabs button .n { font-weight: 700; font-size: var(--step-0); line-height: 1.2; }
  .stack-tabs button .k { display: flex; gap: 3px; }
  .stack-tabs button .k i { width: 14px; height: 6px; background: var(--c); border: 1px solid var(--ink); }
  .stack-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
  .stack-tabs button[aria-selected="true"] .k i { border-color: var(--paper); }
  .stack-panel { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); min-width: 0; }
  .stack-panel:focus-visible { outline-offset: -4px; }
  .stack-fig { padding: var(--s-4); border-right: 1px solid var(--rule); min-width: 0; }
  .stack-fig svg { width: 100%; height: auto; }
  .stack-text { padding: var(--s-5); display: grid; align-content: start; gap: var(--s-4); }
  .stack-text h3 { font-size: var(--step-3); font-stretch: 62%; text-transform: uppercase; }
  .stack-text .levels { display: grid; gap: 0; border-top: 1px solid var(--ink); }
  .stack-text .levels li { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr); gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--rule); font-size: var(--step--1); }
  .stack-text .levels .lv { font-family: var(--font-mono); font-weight: 500; }
  .stack-text p { font-size: var(--step--1); color: var(--graphite); }
  .stack-text p strong { color: var(--ink); }

  @media (max-width: 1100px) {
    .stack-panel { grid-template-columns: minmax(0, 1fr); }
    .stack-fig { border-right: 0; border-bottom: 1px solid var(--rule); }
  }
  @media (max-width: 1100px) {
    .stacks { grid-template-columns: minmax(0, 1fr); }
    .stack-tabs { grid-auto-flow: column; grid-auto-columns: minmax(9.5rem, 1fr); overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--ink); scroll-snap-type: x mandatory; }
    .stack-tabs button { border-bottom: 0; border-right: 1px solid var(--rule); scroll-snap-align: start; }
    .stack-text { padding: var(--s-4); }
  }

  /* ---------- methods ---------- */
  .method-list { border-top: 1px solid var(--ink); counter-reset: m; }
  .method {
    display: grid;
    grid-template-columns: 4rem minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--s-5) var(--s-6);
    padding-block: var(--s-6);
    border-bottom: 1px solid var(--rule);
    align-items: start;
  }
  .method .no { font-family: var(--font-mono); font-size: var(--step-2); font-weight: 500; line-height: 1; }
  .method h3 { font-size: var(--step-3); font-stretch: 62%; text-transform: uppercase; margin-bottom: var(--s-3); }
  .method h3 .thin { font-weight: 200; font-stretch: 125%; text-transform: none; letter-spacing: -0.03em; font-size: 0.72em; display: block; margin-top: 0.1em; }
  .method p { color: var(--ink); max-width: 56ch; }
  .method p + p { margin-top: var(--s-3); }
  .method .used { margin-top: var(--s-4); display: grid; gap: var(--s-1); font-size: var(--step--1); }
  .method .used .label { margin-bottom: 0.2rem; }
  .method .refs { margin-top: var(--s-3); font-size: var(--step--2); color: var(--graphite); }
  .method .used li { display: grid; grid-template-columns: 8ch minmax(0, 1fr); gap: var(--s-3); align-items: baseline; }
  .method .used .y { font-family: var(--font-mono); font-size: var(--step--2); color: var(--graphite); white-space: nowrap; }
  .method-fig { border: 1px solid var(--rule); background: var(--paper); }
  .method-fig svg { width: 100%; height: auto; }
  @media (max-width: 960px) {
    .method { grid-template-columns: 3rem minmax(0, 1fr); }
    .method-fig { grid-column: 2; }
  }
  @media (max-width: 480px) {
    .method { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
    .method-fig { grid-column: auto; }
  }

  /* ---------- sources ---------- */
  .sources { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-6) var(--s-7); }
  .sources h3 { font-size: var(--step-1); font-stretch: 62%; text-transform: uppercase; margin-bottom: var(--s-3); }
  .src-list { display: grid; gap: var(--s-3); font-size: var(--step--1); }
  .src-list li { display: grid; grid-template-columns: 3rem minmax(0, 1fr); scroll-margin-top: 5rem; }
  .src-id { font-family: var(--font-mono); color: var(--graphite); font-size: var(--step--2); padding-top: 0.2em; }
  .src-list li:target { background: var(--paper-2); outline: 1px solid var(--rule-strong); outline-offset: 4px; }
  .ref { font-family: var(--font-mono); font-size: 0.85em; color: var(--graphite); white-space: nowrap; }
  .ref a { color: inherit; }
  .card-ref { white-space: normal; font-size: var(--step--2); line-height: 1.5; }
  .film .f-dest { fill: var(--stage-graphite); font-weight: 400; }
  .src-list a { overflow-wrap: anywhere; }
  .notes p { font-size: var(--step--1); max-width: 60ch; }
  .notes p + p { margin-top: var(--s-3); }
  @media (max-width: 860px) { .sources { grid-template-columns: minmax(0, 1fr); } }

  /* ---------- footer ---------- */
  .site-foot { border-top: 1px solid var(--ink); padding-block: var(--s-6) var(--s-7); font-size: var(--step--1); color: var(--graphite); }
  .site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-4); }
  .site-foot p { max-width: 62ch; }
}

@layer utilities {
  .sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .nowrap { white-space: nowrap; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  }
}

/* ================= drawings: the opening cut ================= */
@layer components {
  .c-train-body { stroke: var(--ink); stroke-width: 1.6; }
  .c-train-win { fill: var(--paper); stroke: var(--ink); stroke-width: 1; }
  .c-year { font-family: var(--font-mono); font-weight: 500; font-size: 22px; fill: var(--ink); letter-spacing: 0.02em; }
  .c-box { fill: color-mix(in oklab, var(--paper) 88%, transparent); }
  .js .cut-legend li { transition: opacity var(--t-slow) var(--ease-out); }
  .js .cut-legend li:not(.is-on) { opacity: 0.28; }

  /* ================= the film ================= */
  .film svg text { font-variant-numeric: tabular-nums; }
  .f-ink { stroke: var(--stage-ink); fill: none; }
  .f-ink-fill { fill: var(--stage-ink); }
  .f-rule { stroke: var(--stage-rule); fill: none; }
  .f-hair { stroke: var(--stage-graphite); stroke-width: 1; fill: none; opacity: 0.6; }
  .f-hill { stroke: var(--stage-graphite); stroke-width: 1.5; fill: none; opacity: 0.7; }
  .f-label { font-family: var(--font-mono); font-size: 20px; letter-spacing: 0.08em; text-transform: uppercase; fill: var(--stage-graphite); }
  .f-tick { font-family: var(--font-mono); font-size: 18px; fill: var(--stage-graphite); }
  .f-anno { font-family: var(--font-sans); font-weight: 700; font-size: 26px; fill: var(--stage-ink); }
  .f-name { font-family: var(--font-sans); font-weight: 600; font-stretch: 87%; font-size: 22px; fill: var(--stage-ink); paint-order: stroke; stroke: var(--stage); stroke-width: 6px; stroke-linejoin: round; }
  .f-place { font-family: var(--font-mono); font-size: 18px; letter-spacing: 0.22em; text-transform: uppercase; fill: var(--stage-graphite); }
  .f-year { font-family: var(--font-mono); font-weight: 500; font-size: 96px; fill: var(--stage-ink); letter-spacing: -0.04em; }
  .f-year-sm { font-family: var(--font-mono); font-weight: 500; font-size: 40px; fill: var(--stage-ink); }
  .f-title { font-family: var(--font-sans); font-weight: 850; font-stretch: 62%; font-size: 72px; text-transform: uppercase; fill: var(--stage-ink); }
  .f-level { font-family: var(--font-mono); font-weight: 500; font-size: 36px; fill: var(--stage-ink); }
  .f-count { font-family: var(--font-mono); font-weight: 500; font-size: 88px; fill: var(--stage-ink); }
  .f-step { font-family: var(--font-mono); font-size: 20px; letter-spacing: 0.08em; text-transform: uppercase; fill: var(--stage-graphite); transition: fill 200ms; }
  .f-step.is-on { fill: var(--signal); }
  .f-end { font-family: var(--font-sans); font-weight: 700; font-size: 34px; fill: var(--stage-ink); }
  .f-band-label { font-family: var(--font-sans); font-weight: 600; font-size: 24px; fill: var(--stage-ink); }
  .f-band-a { fill: var(--stage-2); }
  .f-band-b { fill: var(--stage); }
  .f-mark { stroke: var(--stage-ink); stroke-width: 2.5; }
  .f-mark-label { font-family: var(--font-sans); font-weight: 600; font-size: 19px; fill: var(--stage-ink); paint-order: stroke; stroke: var(--stage); stroke-width: 5px; stroke-linejoin: round; }
  .f-sweep { stroke: var(--signal); stroke-width: 2; stroke-dasharray: 6 6; }
  .f-bldg-body { fill: var(--stage); stroke: var(--stage-ink); stroke-width: 1.4; }
  .f-winline { stroke: var(--stage-graphite); stroke-width: 1.2; stroke-dasharray: 9 7; opacity: 0.55; }
  .f-sign { fill: var(--stage-2); stroke: var(--stage-graphite); stroke-width: 1.4; }
  .f-train-body { fill: var(--stage-2); stroke: var(--stage-ink); stroke-width: 2; }
  .f-train-stripe { stroke: none; }
  .f-window { fill: var(--stage-graphite); opacity: 0.55; }
  .f-wheel { fill: var(--stage); stroke: var(--stage-ink); stroke-width: 2; }
  .f-person { stroke: var(--stage-ink); stroke-width: 2.4; stroke-linecap: round; opacity: 0.8; }
  .f-person-head { fill: var(--stage-ink); }
  .f-dash { fill: none; stroke: var(--signal); stroke-width: 2.5; stroke-dasharray: 12 9; }
  .f-void { fill: var(--stage); }
  .f-wall { fill: var(--stage-ink); }
  .f-strut { stroke: var(--signal); stroke-width: 5; }
  .f-deck { fill: var(--stage-2); stroke: var(--stage-ink); stroke-width: 2; }
  .f-concrete { fill: var(--stage-concrete); stroke: var(--stage-ink); stroke-width: 1.5; }
  .f-slab { fill: var(--stage-concrete); stroke: var(--stage-ink); stroke-width: 1.5; }
  .f-pile { stroke: var(--stage-graphite); stroke-width: 3; opacity: 0.8; }
  .f-track { fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
  .f-col { stroke: var(--stage-ink); stroke-width: 4; }
  .f-shaft { stroke: var(--stage-graphite); stroke-width: 2; stroke-dasharray: 5 5; }
  .f-stn-box { fill: var(--stage-2); stroke: var(--stage-ink); stroke-width: 2; }
  .f-tube { fill: var(--stage-concrete); stroke: var(--stage-ink); stroke-width: 2; }
  .f-approach { fill: none; stroke-width: 10; stroke-linecap: round; }
  .f-arrow { stroke: var(--signal); stroke-width: 4; fill: none; }
  .f-case { stroke: var(--stage-ink); stroke-width: 16; fill: none; stroke-linecap: round; }
  .f-xline { stroke-width: 10; fill: none; stroke-linecap: round; }
  .f-cable { stroke: var(--stage-ink); stroke-width: 4; fill: none; }
  .f-deck-box { fill: var(--stage-2); stroke: var(--stage-ink); stroke-width: 3; }
  .f-cavern { fill: var(--stage); stroke: var(--stage-ink); stroke-width: 3; }
  .f-shaft-box { fill: var(--stage); stroke: var(--stage-ink); stroke-width: 2.5; }
  .f-tower { fill: var(--stage-2); stroke: var(--stage-ink); stroke-width: 2.5; }
  .f-lift { fill: var(--signal); stroke: var(--stage); stroke-width: 2; }
  .f-bore { fill: var(--stage); stroke-width: 6; }
  .f-lining { fill: none; stroke: var(--stage-ink); stroke-width: 1.5; }
  .f-bore-tint { opacity: 0.25; }
  .f-none { display: none; }

  /* the film's chapter strip: one row on desktop */

  /* ================= the network ================= */
  .m-stn .lvl { display: none; }
  .is-level .m-stn .lvl { display: inline; }
  .is-level .m-stn .dot { opacity: 0; }
  .is-level .m-line { stroke: var(--paper-3) !important; }
  .is-level .m-case { stroke: var(--rule-strong); }
  .lv-shape { stroke: var(--ink); stroke-width: 1.3; }
  .net-legend li svg { flex: none; }
  .m-stn .hit { pointer-events: all; }
}

@layer components {
  /* ================= interchange stacks ================= */
  .stk-title { font-family: var(--font-sans); font-weight: 800; font-stretch: 62%; font-size: 24px; text-transform: uppercase; fill: var(--ink); }
  .stk-lv { font-family: var(--font-mono); font-weight: 500; font-size: 17px; fill: var(--ink); }
  .stk-hall { fill: var(--paper-2); stroke: var(--rule-strong); stroke-width: 1; stroke-dasharray: 4 3; }
  .stk-box { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
  .stk-track { stroke: var(--ink); stroke-width: 1.2; }
  .stk-plat { fill: var(--paper-3); stroke: var(--ink); stroke-width: 1.2; }
  .stk-line { font-family: var(--font-sans); font-weight: 700; font-size: 17px; fill: var(--ink); }
  .stk-dest { font-family: var(--font-sans); font-size: 16px; fill: var(--graphite); }
  .stk-street { stroke: var(--ink); stroke-width: 2.5; }
  .stack-fig svg .svg-label { font-size: 14px; }
  @media (max-width: 760px) {
    .stk-line { font-size: 22px; }
    .stk-dest { font-size: 20px; }
    .stk-lv { font-size: 21px; }
    .stack-fig svg .svg-label { font-size: 19px; }
  }
  .stack-fig { margin: 0; }
  .stack-fig svg { max-width: 640px; margin-inline: auto; }
  .stack-text .opened { display: flex; flex-wrap: wrap; gap: var(--s-2); }
  .stack-text .lede { font-size: var(--step-0); color: var(--ink); }

  /* ================= sources ================= */
  .src-groups { display: grid; gap: var(--s-6); }
  .notes h3 { margin-bottom: var(--s-3); }

  /* station chips in the stacks use the same chip style */
  .stack-text .chip { font-size: var(--step--2); }
}

@layer components {
  /* phones: the opening cut keeps its key labels and drops the fine print,
     which the legend and caption repeat */
  @media (max-width: 640px) {
    [data-cut] .c-minor { display: none; }
    [data-cut] .c-key { font-size: 26px; }
    /* larger year stamps sit a little lower, clear of the slabs */
    [data-cut] .c-year { font-size: 28px; translate: 0 8px; }
    .film-cap { min-height: calc(5 * 1.4em + 2 * var(--s-4) + 1.4em); }
  }
  .stk-note { font-weight: 500; }

  /* Film labels follow the stage's own width, not the viewport's, so a small
     stage (a phone, upright or sideways) gets the large, simplified labels. */
  .film-stage { container: stage / inline-size; }
  .film .sm { display: none; }
  @container stage (max-width: 640px) {
    .film .f-label, .film .f-tick, .film .f-place { display: none; }
    .film .f-anno { font-size: 40px; }
    .film .f-name { font-size: 40px; }
    .film .f-mark-label { font-size: 40px; }
    .film .f-band-label { font-size: 40px; }
    .film .f-step { font-size: 40px; }
    .film .f-level { font-size: 44px; }
    .film .f-year-sm { font-size: 48px; }
    .film .f-end { font-size: 48px; }
    .film .lg { display: none; }
    .film .sm { display: inline; }
  }

  /* phones held sideways: the whole player fits the short screen */
  @media (max-height: 520px) and (min-aspect-ratio: 4/3) {
    .masthead { position: relative; }
    html { scroll-padding-top: 0.5rem; }
    .film-stage { width: min(100%, calc((100svh - 8.75rem) * 16 / 9)); min-width: 0; }
    .film-cap { font-size: var(--step--1); min-height: calc(3 * 1.4em + 12px); padding: 6px var(--s-4); grid-template-columns: 5rem minmax(0, 1fr); gap: var(--s-3); }
    .film-cap .when { padding-top: 0.2em; }
    .film-bar { padding: 4px var(--s-4); grid-template-columns: auto auto minmax(0, 1fr) auto; }
    .film-bar .film-time { grid-column: auto; grid-row: auto; }
  }
}

/* ================= Sheet 03: the network in three dimensions ================= */
@layer components {
  .m3 { border: 1px solid var(--ink); }
  .m3-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: var(--s-4) var(--s-6); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--ink); }
  .m3-views { display: flex; flex-wrap: wrap; border: 1px solid var(--rule-strong); border-radius: 2px; }
  .m3-views button { min-height: 44px; padding: 0 var(--s-4); background: transparent; border: 0; font-size: var(--step--1); font-weight: 600; white-space: nowrap; }
  .m3-views button + button { border-left: 1px solid var(--rule-strong); }
  .m3-views button:hover { background: var(--paper-2); }
  .m3-views button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
  .m3-views button:focus-visible { outline-offset: -3px; }
  .m3-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5); }
  .m3-exag { display: grid; grid-template-columns: auto 10rem 5.5rem; align-items: center; gap: var(--s-1) var(--s-3); }
  .m3-exag input { width: 100%; accent-color: var(--ink); min-height: 44px; margin: 0; }
  .m3-exag output { font-family: var(--font-mono); font-size: var(--step--1); font-variant-numeric: tabular-nums; }
  .m3-check { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; font-size: var(--step--1); font-weight: 600; cursor: pointer; }
  .m3-check input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }

  .m3-body { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; grid-template-rows: min(70svh, 720px); }
  .m3-stage {
    position: relative;
    height: 100%;
    min-height: 22rem;
    border-right: 1px solid var(--ink);
    background: var(--paper);
    touch-action: pan-y;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
  }
  .m3-stage:active { cursor: grabbing; }
  .m3-stage:focus-visible { outline: 2px solid var(--focus); outline-offset: -4px; }
  .m3-stage canvas { display: block; }
  .m3-loading { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-mono); font-size: var(--step--1); color: var(--graphite); }
  .m3-loading[hidden] { display: none; }
  .m3-hint { position: absolute; left: 50%; top: var(--s-4); translate: -50% 0; background: var(--ink); color: var(--paper); padding: var(--s-2) var(--s-4); font-size: var(--step--1); border-radius: 2px; pointer-events: none; }
  .m3-hint[hidden] { display: none; }
  .m3-nav { position: absolute; right: var(--s-3); bottom: var(--s-3); display: grid; grid-template-columns: repeat(3, 44px); gap: 4px; }
  .m3-nav .icon-btn { background: var(--paper); border-color: var(--rule-strong); color: var(--ink); }
  .m3-nav .icon-btn:hover { background: var(--paper-2); border-color: var(--ink); }

  .m3-side { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; overscroll-behavior: contain; }
  .m3-side > * { flex: none; }
  .m3-card { padding: var(--s-4) var(--s-4) var(--s-5); display: grid; gap: var(--s-3); border-bottom: 1px solid var(--rule); min-height: 12rem; align-content: start; }
  .m3-card h3 { font-size: var(--step-3); font-stretch: 62%; text-transform: uppercase; }
  .m3-card .empty { color: var(--graphite); font-size: var(--step--1); }
  .m3-levels { display: grid; gap: var(--s-3); font-size: var(--step--1); }
  .m3-levels li { display: grid; gap: 0.3rem; justify-items: start; }
  .m3-card-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
  .m3-clear { min-height: 44px; padding: 0 var(--s-3); background: transparent; border: 1px solid var(--rule-strong); border-radius: 2px; font-size: var(--step--1); font-weight: 600; }
  .m3-clear:hover { background: var(--paper-2); }
  .m3-ent { font-size: var(--step--1); border-left: 2px solid var(--rule-strong); padding-left: var(--s-3); }
  .for-touch { display: none; }
  @media (hover: none) and (pointer: coarse) { .for-pointer { display: none; } .for-touch { display: inline; } }
  .m3-pick { display: grid; gap: var(--s-2); padding: var(--s-4); border-bottom: 1px solid var(--rule); }
  .m3-pick select { min-height: 44px; border: 1px solid var(--rule-strong); border-radius: 2px; padding: 0 var(--s-3); background: var(--paper); width: 100%; }
  .m3-filter { padding: var(--s-4); display: grid; gap: var(--s-2); }
  .m3-lines { display: grid; gap: 2px; }
  .m3-lines button { width: 100%; min-height: 32px; display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-2); background: transparent; border: 1px solid transparent; border-radius: 2px; font-size: var(--step--1); text-align: left; }
  .m3-lines button:hover { background: var(--paper-2); }
  .m3-lines button[aria-pressed="true"] { border-color: var(--ink); font-weight: 700; }
  .m3-lines .sw { width: 1.4rem; height: 0.42rem; border: 1px solid var(--ink); background: var(--c); flex: none; }
  .m3-all { justify-self: start; min-height: 36px; padding: 0 var(--s-3); background: transparent; border: 1px solid var(--rule-strong); border-radius: 2px; font-size: var(--step--1); font-weight: 600; }
  .m3-all:disabled { opacity: 0.45; cursor: default; }
  .m3-help { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--ink); font-size: var(--step--2); color: var(--graphite); }

  @media (max-width: 1100px) {
    .m3-body { grid-template-columns: minmax(0, 1fr); }
    .m3-body { grid-template-rows: min(70svh, 640px) auto; }
    .m3-stage { border-right: 0; border-bottom: 1px solid var(--ink); }
    .m3-side { overflow: visible; }
    .m3-side { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-content: start; }
    .m3-card { grid-row: span 2; border-right: 1px solid var(--rule); border-bottom: 0; }
    .m3-card.is-empty { grid-column: 1 / -1; grid-row: auto; min-height: 0; border-right: 0; border-bottom: 1px solid var(--rule); }
    .m3-side { align-items: start; }
    .m3-pick { align-content: start; align-self: start; border-bottom: 0; }
    .m3-filter { border-top: 1px solid var(--rule); }
    .m3-lines { grid-template-columns: minmax(0, 1fr); }
  }
  @media (max-width: 640px) {
    .m3 { margin-inline: calc(var(--gutter) * -1); border-inline: 0; }
    .m3-bar { padding: var(--s-3) var(--s-4); }
    .m3-views { width: 100%; }
    .m3-views button { flex: 1 1 auto; padding: 0 var(--s-3); }
    .m3-views button + button { border-left: 0; }
    .m3-views { gap: 1px; background: var(--rule-strong); }
    .m3-views button { background: var(--paper); }
    .m3-exag { grid-template-columns: auto minmax(0, 1fr) 5rem; width: 100%; }
    .m3-body { grid-template-rows: max(62svh, 22rem) auto; }
    .m3-card.is-empty { min-height: 0; }
    .m3-nav { top: var(--s-3); bottom: auto; }
    .m3-side { grid-template-columns: minmax(0, 1fr); }
    .m3-card { grid-row: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
    .m3-help { padding: var(--s-3) var(--s-4); }
  }
}
