/* Tunnelbanan: an editorial field atlas of the Stockholm metro. Warm paper, hairline rules, serif titles,
   mono captions and soft floating cards. Standalone: no design-system stylesheet loads before this one.
   Every colour is a custom property on :root; nothing below the token blocks names a colour directly,
   except the small illustrations in index.html, which carry their own palette. */

:root {
  color-scheme: light;
  /* Paper and ink */
  --paper: #f6f3e9;
  --panel: #fffcf3;
  --bar: #fbf9f0;
  --ink: #263c35;
  --muted: #626c60;
  --muted-2: #69745f;
  --rule: #cfcfc0;
  --rule-soft: #e2e0d4;
  --green: #36594b;
  --green-hover: #416b58;
  --green-soft: #e9efe1;
  --green-border: #81977b;
  --green-ink: #294e3e;
  --on-green: #fffcf0;
  --rust: #ac4931;
  --hover: #ececdf;
  --warn: #9a6416;
  --error: #ac4931;
  --ok: #4f7a55;

  /* Floating paper: cards, pills, chips */
  --card-border: #c8cbba;
  --pill-bg: rgba(255, 252, 243, 0.92);
  --chip-bg: #fbfaf1;
  --chip-border: #d7d7c9;
  --dash: #c2c7b7;
  --shadow-card: 0 3px 0 rgba(85, 100, 67, 0.04), 0 6px 18px rgba(65, 77, 53, 0.09);
  --shadow-pill: 0 3px 0 rgba(85, 100, 67, 0.04), 0 5px 12px rgba(65, 77, 53, 0.08);
  --shadow-sheet: 0 -6px 22px rgba(65, 77, 53, 0.12);
  --shadow-label: 0 2px 6px rgba(38, 60, 53, 0.12);
  --shadow-dialog: 0 18px 75px rgba(38, 60, 53, 0.22);
  --backdrop: rgba(38, 54, 44, 0.25);

  /* Map furniture */
  --dot: #cbd0bc;
  --vignette: rgba(120, 112, 80, 0.10);
  --mark: #87927e;
  --scale-ink: #7b8575;
  --compass-face: rgba(250, 247, 237, 0.85);
  --compass-ring: #9ba492;
  --needle-n: #a64e35;
  --needle-s: #647967;
  --compass-letter: #364f40;
  --compass-pin: #f9f4e8;
  --compass-pin-ring: #4e6553;
  --live: #699366;
  --live-halo: #e6ebdb;
  --live-warn: #bc8c4e;
  --live-warn-halo: #f0e7d4;

  /* Seasons: the chip glyphs */
  --season-spring: #8b985b;
  --season-spring-fill: #efc9cf;
  --season-summer: #c28b34;
  --season-summer-fill: #f3d492;
  --season-autumn: #b56b38;
  --season-autumn-fill: #eac29b;
  --season-winter: #6a8d9a;

  /* Metro lines: content markers, not accents */
  --line-green: #489763;
  --line-red: #d45546;
  --line-blue: #467dc0;
  --badge-green: #2c6e45;
  --badge-red: #a9382c;
  --badge-blue: #2b5a94;
  --line-on: #fffcf3;
  --signal: #d9822b;

  /* 3D scene, read by js/scene.js */
  --scene-ground: #f2e9d8;
  --scene-skirt: #e6d7bb;
  --scene-water: #85bcba;
  --scene-ink: #5d5064;
  --scene-contour: #dcd2bc;
  --scene-platform: #fbf7ec;
  --scene-shadow: #41538f;
  --scene-label-halo: #fffcf3;

  /* Type */
  --sans: Inter, "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  /* Space, size and motion. js/scene.js reads --dur-slow for camera flights. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --size-target: 44px;
  --dur-instant: 90ms;
  --dur-quick: 160ms;
  --dur-base: 240ms;
  --dur-slow: 400ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-move: cubic-bezier(0.6, 0, 0.4, 1);

  /* Layout */
  --topbar-h: 48px;
  --foot-h: 33px;
  --rail-w: 344px;
  --rail-inset: 14px;
  --rail-clear: calc(var(--rail-w) + 2 * var(--rail-inset)); /* where the map is free of the desktop rail */
  --gutter-left: max(16px, env(safe-area-inset-left, 0px));
  --gutter-right: max(16px, env(safe-area-inset-right, 0px));
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Night: the dark scheme, a forced dark theme, and the Lucia night scene share one twilight palette. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #1e2336; --panel: #252b42; --bar: #1a1f31; --ink: #efeadd; --muted: #b0b7cf; --muted-2: #a2a9c2;
    --rule: #3a4263; --rule-soft: #2e3552; --green: #88b596; --green-hover: #9cc5a8; --green-soft: #2d3e42;
    --green-border: #5b8270; --green-ink: #cfe5d5; --on-green: #1a1f31; --rust: #e28668; --hover: #2d3550;
    --warn: #e2b86b; --error: #e28668; --ok: #88b596;
    --card-border: #3a4263; --pill-bg: rgba(37, 43, 66, 0.92); --chip-bg: #2a3049; --chip-border: #3a4263; --dash: #4a5378;
    --shadow-card: 0 3px 0 rgba(0, 0, 0, 0.10), 0 6px 18px rgba(0, 0, 0, 0.28);
    --shadow-pill: 0 3px 0 rgba(0, 0, 0, 0.10), 0 5px 12px rgba(0, 0, 0, 0.26);
    --shadow-sheet: 0 -6px 22px rgba(0, 0, 0, 0.32); --shadow-label: 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-dialog: 0 18px 75px rgba(0, 0, 0, 0.5); --backdrop: rgba(10, 12, 24, 0.5);
    --dot: #353d5c; --vignette: rgba(0, 0, 0, 0.22); --mark: #6c7597; --scale-ink: #8a92b0;
    --compass-face: rgba(37, 43, 66, 0.85); --compass-ring: #6c7597; --needle-n: #e28668; --needle-s: #88b596;
    --compass-letter: #efeadd; --compass-pin: #252b42; --compass-pin-ring: #b0b7cf;
    --live: #88b596; --live-halo: #2d3e42; --live-warn: #e2b86b; --live-warn-halo: #4a4232;
    --season-spring: #b5c487; --season-summer: #e2b45f; --season-autumn: #e0956a; --season-winter: #9cc0cc;
    --line-on: #fffcf3;
    --scene-ground: #2d3352; --scene-skirt: #222742; --scene-water: #242e52; --scene-ink: #17182b;
    --scene-contour: #3a4263; --scene-platform: #353d60; --scene-shadow: #11152c; --scene-label-halo: #22273e;
  }
}
:root[data-theme="dark"], :root[data-special="lucia"] {
  color-scheme: dark;
  --paper: #1e2336; --panel: #252b42; --bar: #1a1f31; --ink: #efeadd; --muted: #b0b7cf; --muted-2: #a2a9c2;
  --rule: #3a4263; --rule-soft: #2e3552; --green: #88b596; --green-hover: #9cc5a8; --green-soft: #2d3e42;
  --green-border: #5b8270; --green-ink: #cfe5d5; --on-green: #1a1f31; --rust: #e28668; --hover: #2d3550;
  --warn: #e2b86b; --error: #e28668; --ok: #88b596;
  --card-border: #3a4263; --pill-bg: rgba(37, 43, 66, 0.92); --chip-bg: #2a3049; --chip-border: #3a4263; --dash: #4a5378;
  --shadow-card: 0 3px 0 rgba(0, 0, 0, 0.10), 0 6px 18px rgba(0, 0, 0, 0.28);
  --shadow-pill: 0 3px 0 rgba(0, 0, 0, 0.10), 0 5px 12px rgba(0, 0, 0, 0.26);
  --shadow-sheet: 0 -6px 22px rgba(0, 0, 0, 0.32); --shadow-label: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-dialog: 0 18px 75px rgba(0, 0, 0, 0.5); --backdrop: rgba(10, 12, 24, 0.5);
  --dot: #353d5c; --vignette: rgba(0, 0, 0, 0.22); --mark: #6c7597; --scale-ink: #8a92b0;
  --compass-face: rgba(37, 43, 66, 0.85); --compass-ring: #6c7597; --needle-n: #e28668; --needle-s: #88b596;
  --compass-letter: #efeadd; --compass-pin: #252b42; --compass-pin-ring: #b0b7cf;
  --live: #88b596; --live-halo: #2d3e42; --live-warn: #e2b86b; --live-warn-halo: #4a4232;
  --season-spring: #b5c487; --season-summer: #e2b45f; --season-autumn: #e0956a; --season-winter: #9cc0cc;
  --line-on: #fffcf3;
  --scene-ground: #2d3352; --scene-skirt: #222742; --scene-water: #242e52; --scene-ink: #17182b;
  --scene-contour: #3a4263; --scene-platform: #353d60; --scene-shadow: #11152c; --scene-label-halo: #22273e;
}

/* ---------- Page ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; background: var(--paper); }
body {
  height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  background: var(--paper); color: var(--ink); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, table, caption, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, select, input { font: inherit; color: inherit; }
button { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--green); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }
::selection { background: var(--green-soft); color: var(--ink); }
svg { display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* js/app.js reads the sheet's transition time, which drops to 1 ms here */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0ms !important; }
}

.app { position: fixed; inset: 0; height: 100dvh; }

/* ---------- Top bar ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 8; height: calc(var(--topbar-h) + var(--safe-top));
  display: flex; align-items: center; gap: var(--space-3); padding: var(--safe-top) var(--gutter-right) 0 max(12px, env(safe-area-inset-left, 0px));
  background: var(--bar); border-bottom: 1px solid var(--rule);
}
.identity { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-icon svg { width: 34px; height: 34px; }
.wordmark { display: none; white-space: nowrap; font: 700 27px/.95 var(--serif); letter-spacing: -1.4px; color: var(--ink); }
.city-nav {
  position: relative; display: flex; align-items: center; gap: 2px; align-self: stretch; min-width: 0; flex: 0 1 auto; margin-right: auto;
  padding-left: var(--space-2); overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 22px), transparent);
}
.city-nav::-webkit-scrollbar { display: none; }
.city-nav button {
  flex: none; height: 34px; padding: 0 10px; border: 1px solid transparent; border-radius: 7px; background: transparent;
  color: var(--muted); font: 600 12.5px/1 var(--sans); white-space: nowrap;
  transition: background-color var(--dur-quick) var(--ease-out), color var(--dur-quick) var(--ease-out);
}
.city-nav button[aria-current="true"] { background: var(--green-soft); border-color: var(--green-border); color: var(--green-ink); }
.city-nav button:focus-visible { outline-offset: -2px; }
@media (hover: hover) { .city-nav button:not([aria-current="true"]):hover { background: var(--hover); color: var(--ink); } }
.city-nav button:active { transform: translateY(1px); }
.top-actions { display: flex; align-items: center; gap: var(--space-3); flex: none; }
.live-pill { display: none; align-items: center; gap: 8px; color: var(--green-ink); font: 500 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px var(--live-halo); }
.live-pill[data-tone="ok"] i { animation: live-pulse 2.4s var(--ease-out) infinite; }
.live-pill[data-tone="warn"] i { background: var(--live-warn); box-shadow: 0 0 0 3px var(--live-warn-halo); }
.live-pill[data-tone="off"] { color: var(--muted); }
.live-pill[data-tone="off"] i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--live-halo); } 50% { box-shadow: 0 0 0 5px var(--live-halo); } }

/* Paper buttons: Field notes, Change station, Try again */
.button, .gf-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 36px; padding: 0 12px;
  border: 1px solid var(--card-border); border-radius: 7px; background: var(--panel); color: var(--ink);
  font: 600 12.5px/1 var(--sans); white-space: nowrap; text-decoration: none;
  transition: background-color var(--dur-quick) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
.button svg, .gf-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .button:hover, .gf-button:hover { background: var(--hover); } }
.button:active, .gf-button:active { transform: translateY(1px); }
.gf-button:disabled { opacity: .4; transform: none; }
.gf-button--primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
@media (hover: hover) { .gf-button--primary:hover { background: var(--green-hover); } }
.gf-button--primary[aria-pressed="true"] { background: var(--green-soft); border-color: var(--green-border); color: var(--green-ink); }
.gf-button--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.gf-button__mark { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
#notes-open { min-width: var(--size-target); min-height: var(--size-target); padding: 0; border-color: transparent; background: transparent; }
#notes-open span { display: none; }
#notes-open svg { width: 20px; height: 20px; }

/* ---------- Workspace: the map with the rail or sheet over it ---------- */
.workspace { position: absolute; left: 0; right: 0; top: calc(var(--topbar-h) + var(--safe-top)); bottom: 0; isolation: isolate; }
.foot { display: none; }

/* ---------- Stage: the 3D view on dotted paper ---------- */
.stage {
  position: absolute; inset: 0 0 var(--stage-bottom, 0px) 0; overflow: hidden; isolation: isolate;
  background-color: var(--paper);
  background-image: radial-gradient(ellipse at 50% 45%, transparent 55%, var(--vignette)), radial-gradient(var(--dot) .6px, transparent .9px);
  background-size: 100% 100%, 18px 18px;
}
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='192' height='192'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23grain)'/%3E%3C/svg%3E");
}
.stage__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage__canvas:active { cursor: grabbing; }
.stage__canvas:focus-visible { outline: 2px solid var(--rust); outline-offset: -4px; }
.stage__labels { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }

/* Station labels: warm floating map pills. js/scene.js positions them with transform, so none is set here. */
.stage__labels > * {
  position: absolute; left: 0; top: 0; white-space: nowrap; padding: 3px 8px 4px; border: 1px solid var(--card-border); border-radius: 7px;
  background: var(--pill-bg); box-shadow: var(--shadow-label); color: var(--ink);
  font: 600 13px/1.15 var(--serif); letter-spacing: -.1px; text-shadow: none; text-decoration: none;
}
.stage__labels small { display: block; margin-top: 2px; color: var(--muted); font: 500 8.5px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.stage__labels [data-selected] { text-decoration: none; border-color: var(--rust); box-shadow: 0 0 0 1.5px var(--rust), var(--shadow-label); }
.stage__labels [data-selected] > span { text-decoration: none; }

.stage__note {
  position: absolute; z-index: 3; top: 64px; left: var(--gutter-left);
  max-width: min(320px, calc(100% - var(--gutter-left) - 70px)); padding: 10px 14px; /* clear of the compass */
  background: var(--panel); border: 1px solid var(--card-border); border-radius: 10px; box-shadow: var(--shadow-pill);
  font: italic 14px/1.4 var(--serif); color: var(--ink);
}
.stage__note strong { display: block; font: 600 13px/1.4 var(--sans); }

/* Registration marks, the map code and the scale: architectural framing, never in the way */
.mark { position: absolute; z-index: 3; width: 11px; height: 11px; opacity: .46; pointer-events: none; display: none; }
.mark::before, .mark::after { content: ""; position: absolute; background: var(--mark); }
.mark::before { top: 5px; width: 11px; height: 1px; }
.mark::after { left: 5px; width: 1px; height: 11px; }
.mark.tl { top: 14px; left: 14px; }
.mark.tr { top: 14px; right: 14px; }
.mark.bl { bottom: 14px; left: 14px; }
.mark.br { bottom: 14px; right: 14px; }
.map-code {
  position: absolute; z-index: 3; top: 12px; left: 36px; display: none; pointer-events: none;
  color: var(--muted-2); font: 500 9px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
}
/* the scale is drawn straight over the 3D view and keeps a paper halo; the map code and gesture hint sit on paper chips */
.scale { text-shadow: 0 0 2px var(--panel), 0 0 4px var(--panel), 0 0 8px var(--panel); }
.map-code, .gesture {
  padding: 3px 8px; color: var(--muted); border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--card-border) 82%, transparent);
  box-shadow: 0 2px 6px rgba(38, 60, 53, 0.08);
}
.scale i { box-shadow: 0 1px 0 var(--panel); }
.scale { position: absolute; z-index: 3; left: 14px; bottom: 64px; pointer-events: none; color: var(--muted-2); font: 500 9px/1.4 var(--mono); letter-spacing: .05em; }
.scale i { display: block; width: 40px; height: 4px; margin-top: 4px; border: 1px solid var(--scale-ink); border-top: 0; }

/* Map controls: one floating paper pill */
.map-controls {
  position: absolute; z-index: 4; top: 8px; right: max(8px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--pill-bg); border: 1px solid var(--card-border); border-radius: 12px; box-shadow: var(--shadow-pill);
}
.map-controls > button {
  display: grid; place-items: center; width: var(--size-target); height: var(--size-target); padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink);
  transition: background-color var(--dur-quick) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
@media (hover: hover) { .map-controls > button:not(:disabled):hover { background: var(--hover); } }
.map-controls > button:active { transform: translateY(1px); }
.map-controls > button:disabled { opacity: .4; transform: none; }
.map-controls > button[aria-checked="true"] { background: var(--green-soft); color: var(--green-ink); box-shadow: inset 0 0 0 1px var(--green-border); }
.map-controls svg, .tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.map-controls .play { background: var(--green); color: var(--on-green); }
@media (hover: hover) { .map-controls .play:not(:disabled):hover { background: var(--green-hover); } }
.play .icon-pause { stroke-width: 3.2; }
.play .icon-play { fill: currentColor; stroke-width: 1.2; }
.play[aria-pressed="true"] .icon-play, .play[aria-pressed="false"] .icon-pause { display: none; }
.divider { width: 1px; height: 22px; margin: 0 2px; background: var(--rule); flex: none; }
.zoom-pct { min-width: var(--size-target); text-align: center; color: var(--muted); font: 500 10px/1 var(--mono); font-variant-numeric: tabular-nums; }

/* Compass rose: also the north-up button. The needle turns about the dial's centre, in SVG units. */
.compass {
  position: absolute; z-index: 4; top: 66px; right: max(6px, env(safe-area-inset-right, 0px)); width: 50px; height: 54px; padding: 0;
  border: 0; background: transparent; border-radius: 50%;
}
.compass svg { width: 100%; height: 100%; overflow: visible; }
.compass:disabled { opacity: .4; }
.compass__face { fill: var(--compass-face); stroke: var(--compass-ring); stroke-width: .6; }
.compass__ticks { fill: none; stroke: var(--compass-ring); stroke-width: 2; stroke-dasharray: 1 7.64; }
.compass__north { fill: var(--needle-n); }
.compass__south { fill: var(--needle-s); }
.compass__n { fill: var(--compass-letter); font: 700 11px var(--serif); }
.compass__pin { fill: var(--compass-pin); stroke: var(--compass-pin-ring); }
/* no transition: js/app.js writes the bearing as the camera moves, and the camera already eases it */
#compass-needle { transform-box: view-box; transform-origin: 34px 39px; }

/* Bottom of the map: the gesture hint and the camera presets */
.stage-bottom {
  position: absolute; z-index: 4; left: 0; right: 0; bottom: 10px; display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
}
.stage-bottom > * { pointer-events: auto; }
.gesture { display: none; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--muted); font: italic 13px/1.3 var(--serif); }
.gesture svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.gesture--touch { display: none; }
@media (hover: none) { .gesture--pointer { display: none; } .gesture--touch { display: inline; } }
.views {
  display: flex; flex-wrap: nowrap; gap: 2px; max-width: calc(100% - 20px); overflow-x: auto; scrollbar-width: none; padding: 3px;
  background: var(--pill-bg); border: 1px solid var(--card-border); border-radius: 10px; box-shadow: var(--shadow-pill);
}
.views::-webkit-scrollbar { display: none; }
.vbtn {
  flex: none; height: 36px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font: 600 12px/1 var(--sans); white-space: nowrap;
  transition: background-color var(--dur-quick) var(--ease-out), color var(--dur-quick) var(--ease-out);
}
@media (hover: hover) { .vbtn:not([aria-pressed="true"]):hover { background: var(--hover); color: var(--ink); } }
.vbtn[aria-pressed="true"] { background: var(--green); color: var(--on-green); }
.vbtn:focus-visible { outline-offset: -2px; }

/* At the full detent the sheet covers the map on a phone */
.app[data-detent="full"] :is(.map-controls, .compass, .stage-bottom, .scale), .app[data-scene="failed"] :is(.map-controls, .compass, .stage-bottom, .scale, .map-code) { visibility: hidden; }

/* ---------- Sheet (phone) / atlas rail (desktop) ---------- */
.sheet {
  position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; height: calc(100% - var(--space-2));
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--card-border); border-bottom: 0;
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow-sheet);
  transform: translateY(var(--sheet-shift, 50%)); transition: transform var(--dur-slow) var(--ease-out); will-change: transform;
}
.sheet[data-dir="down"] { transition-duration: calc(var(--dur-slow) * .7); }
.sheet[data-dragging="true"] { transition: none; }
/* fills the gap a drag above the top opens under the sheet (js/app.js rubber band) */
.sheet::after { content: ""; position: absolute; left: -1px; right: -1px; top: 100%; height: var(--space-7); background: var(--panel); }
.sheet__head { flex: none; padding: 0 var(--gutter-right) var(--space-3) var(--gutter-left); touch-action: none; }
.sheet__grab { display: grid; place-items: center; width: 100%; height: 40px; padding: 0; background: transparent; border: 0; cursor: grab; touch-action: none; }
.sheet__grab:active { cursor: grabbing; }
.sheet__grab:focus-visible { outline-offset: -4px; }
.sheet__grabber { display: block; width: 38px; height: 4px; border-radius: 2px; background: var(--rule); transition: background-color var(--dur-quick) var(--ease-out); }
@media (hover: hover) { .sheet__grab:hover .sheet__grabber { background: var(--muted); } }

.stamp-line { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); color: var(--rust); font: 500 10px/1.4 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.flag { display: block; width: 21px; height: 13px; flex: none; transform: rotate(-5deg); border-radius: 1px; overflow: hidden; box-shadow: 0 0 0 1px rgba(80, 53, 25, .13); }
.flag svg { width: 100%; height: 100%; }
.sheet__title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-height: var(--size-target); padding-top: 2px; }
/* never narrower than its longest word: the button drops to the next line before a name breaks mid-word */
.sheet__title h1 {
  flex: 1; min-width: min-content; overflow-wrap: break-word; color: var(--ink);
  font: 400 clamp(26px, 2.5vw, 34px)/1.08 var(--serif); letter-spacing: -1.4px;
}
.sheet__title h1:focus-visible { outline-offset: 4px; }
.sheet__title .gf-button { flex: none; }
#picker-open { gap: 0; }
#picker-open .label-wide { margin-left: .28em; }
@media (max-width: 899px) {
  /* the station strip snaps chip by chip and fades at both ends instead of cutting a name off */
  .city-nav { scroll-snap-type: x proximity; scroll-padding-left: 10px; }
  .city-nav button { scroll-snap-align: start; }
  .city-nav {
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 18px), transparent 100%);
  }
}
@media (max-width: 479px) {
  /* all five camera presets fit a 390 px phone */
  .views { gap: 1px; padding: 2px; max-width: calc(100% - 16px); }
  .vbtn { height: 34px; padding: 0 8px; font-size: 11px; }
}
@media (max-width: 479px) { .label-wide { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }
.sheet__lines { display: flex; flex-wrap: wrap; gap: var(--space-1); padding-top: var(--space-2); }
.sheet__body {
  flex: none; height: var(--sheet-body, 40dvh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  padding: 0 var(--gutter-right) calc(var(--safe-bottom) + var(--space-5)) var(--gutter-left); border-top: 1px solid var(--rule-soft);
}

/* Peek strip: the next two departures, shown only at the lowest detent. A visual duplicate of the list. */
.peek { display: none; min-height: var(--space-8); padding-top: var(--space-2); padding-bottom: var(--safe-bottom); }
.app[data-detent="peek"] .peek { display: block; }
.app[data-detent="peek"] .sheet__lines { display: none; }
.peek li { display: flex; align-items: center; gap: var(--space-3); min-height: var(--space-6); }
.peek .peek__dest { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.peek .peek__none { color: var(--muted); font: italic 14px/1.4 var(--serif); }

/* ---------- Desktop: top bar, floating rail, map and footer ---------- */
/* The same query as DESKTOP in js/app.js: desktop, and a phone on its side, where a bottom sheet would leave no map. */
@media (min-width: 900px), (orientation: landscape) and (min-width: 600px) and (max-height: 500px) {
  :root { --topbar-h: 60px; }
  .topbar { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
  .brand-icon svg { width: 40px; height: 40px; }
  .wordmark { display: block; }
  .city-nav { margin-left: var(--space-3); padding-left: var(--space-4); }
  .city-nav::before { content: ""; align-self: center; flex: none; width: 1px; height: 24px; margin-right: 8px; background: var(--rule); }
  .live-pill { display: inline-flex; }
  #notes-open { min-width: 0; min-height: 36px; padding: 0 12px; border-color: var(--card-border); background: var(--panel); }
  #notes-open span { display: inline; }
  #notes-open svg { width: 17px; height: 17px; }

  .workspace { bottom: var(--foot-h); }
  .foot {
    position: absolute; left: 0; right: 0; bottom: 0; height: var(--foot-h); display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    padding: 0 max(24px, env(safe-area-inset-right, 0px)) 0 max(24px, env(safe-area-inset-left, 0px));
    background: var(--bar); border-top: 1px solid var(--rule); color: var(--muted-2); font: 9px/1 var(--mono); letter-spacing: .015em; white-space: nowrap;
  }
  .foot .metric { display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .08em; font-weight: 500; }
  .foot svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  .foot .credits { overflow: hidden; text-overflow: ellipsis; }
  .foot a { color: inherit; text-underline-offset: 2px; }

  .stage { bottom: 0; }
  .mark { display: block; }
  .mark.tl, .mark.bl { left: calc(var(--rail-clear) + 8px); }
  .map-code { display: block; left: calc(var(--rail-clear) + 30px); }
  .scale { left: calc(var(--rail-clear) + 28px); bottom: 12px; }
  .stage__note { top: 36px; left: calc(var(--rail-clear) + 8px); /* under the map code */ max-width: min(360px, calc(100% - var(--rail-clear) - 140px)); }
  .map-controls { top: var(--rail-inset); right: var(--rail-inset); }
  .compass { top: 80px; right: 18px; width: 64px; height: 70px; }
  .stage-bottom { left: var(--rail-clear); bottom: 16px; }
  .gesture { display: flex; }
  .vbtn { height: 34px; padding: 0 12px; font-size: 12.5px; }

  .sheet {
    left: var(--rail-inset); right: auto; top: var(--rail-inset); bottom: var(--rail-inset); width: var(--rail-w); height: auto;
    border: 1px solid var(--card-border); border-radius: 10px; box-shadow: var(--shadow-card); overflow: hidden;
    transform: none; transition: none;
  }
  .sheet::after { display: none; }
  .sheet__head { padding: 18px 18px 14px; touch-action: auto; }
  .sheet__body { flex: 1; height: auto; min-height: 0; padding: 0 18px var(--space-5); }
  .sheet__grab, .app .peek { display: none !important; }
  .sheet__title { padding-top: 8px; }
  .app .sheet__lines { display: flex !important; }
  .app[data-detent="full"]:not([data-scene="failed"]) :is(.map-controls, .compass, .stage-bottom, .scale) { visibility: visible; }
}
/* A phone on its side: a slimmer bar, no footer, a narrower rail */
@media (orientation: landscape) and (min-width: 600px) and (max-height: 500px) {
  :root { --topbar-h: 44px; --rail-w: 300px; --rail-inset: 8px; }
  .workspace { bottom: 0; }
  .foot, .gesture, .map-code { display: none; }
  .brand-icon svg { width: 30px; height: 30px; }
  .wordmark { font-size: 22px; }
  .compass { top: 64px; width: 46px; height: 50px; }
}
@media (min-width: 900px) and (max-width: 1080px) { .live-pill { display: none; } }

/* ---------- Season and atmosphere ---------- */
.season-box { padding: var(--space-4) 0 var(--space-4); border-bottom: 1px solid var(--rule); }
.subhead { margin-bottom: 10px; color: var(--muted); font: 500 10px/1.4 var(--mono); letter-spacing: .095em; text-transform: uppercase; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border: 1px solid var(--chip-border); border-radius: 6px;
  background: var(--chip-bg); color: var(--ink); font: 500 12.5px/1 var(--sans);
  transition: background-color var(--dur-quick) var(--ease-out), border-color var(--dur-quick) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
@media (hover: hover) { .chip:not([aria-pressed="true"]):hover { background: var(--hover); } }
.chip:active { transform: translateY(1px); }
.chip svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.chip[data-season="spring"] svg { color: var(--season-spring); }
.chip[data-season="spring"] .chip__fill { fill: var(--season-spring-fill); stroke-width: 1.1; }
.chip[data-season="spring"] .chip__eye { fill: var(--season-summer); stroke: none; }
.chip[data-season="summer"] svg { color: var(--season-summer); }
.chip[data-season="summer"] .chip__fill { fill: var(--season-summer-fill); }
.chip[data-season="autumn"] svg { color: var(--season-autumn); }
.chip[data-season="autumn"] .chip__fill { fill: var(--season-autumn-fill); }
.chip[data-season="winter"] svg { color: var(--season-winter); }
.chip[aria-pressed="true"] { background: var(--green-soft); border-color: var(--green-border); color: var(--green-ink); font-weight: 650; }
.events { display: flex; gap: 7px; margin-top: 8px; }
.select-wrap { position: relative; flex: 1; display: flex; align-items: center; height: 36px; border: 1px dashed var(--dash); border-radius: 6px; }
.select-wrap:focus-within { border-style: solid; border-color: var(--green-border); }
.select-wrap select {
  width: 100%; height: 100%; padding: 0 26px 0 32px; border: 0; background: transparent; color: var(--ink);
  font: 500 12px/1 var(--sans); appearance: none; -webkit-appearance: none; cursor: pointer;
}
.select-wrap select:focus-visible { outline: none; }
.select-wrap > svg { position: absolute; width: 15px; height: 15px; pointer-events: none; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.select-wrap > svg:first-child { left: 10px; }
.select-wrap > svg:last-of-type { right: 8px; width: 12px; }
.chip--snow { flex: none; height: 36px; padding: 0 10px; font-size: 12px; }
.season-note { margin-top: 12px; color: var(--muted); font: italic 13.5px/1.4 var(--serif); }
.season-note:empty { display: none; }

/* ---------- Sections ---------- */
.section { padding-top: 20px; }
.gf-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); padding-bottom: 7px; border-bottom: 1px solid var(--rule); }
.section h2, .gf-section-head h2 { color: var(--ink); font: 500 11px/1.4 var(--mono); letter-spacing: .09em; text-transform: uppercase; }
.gf-label { font: 500 10px/1.4 var(--mono); letter-spacing: .095em; text-transform: uppercase; }
.section__meta { color: var(--muted); }
.gf-num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.note { padding-top: var(--space-3); color: var(--muted); font-size: 13px; line-height: 1.45; max-width: 640px; }
.note--block { padding: var(--space-4) 0; color: var(--ink); font: italic 15px/1.45 var(--serif); }
.note--block .gf-button { margin-top: var(--space-3); font-style: normal; }
.note--block .note { font-family: var(--sans); font-style: normal; }

/* Where the figures come from */
.source { display: flex; align-items: flex-start; gap: var(--space-2); padding-top: 10px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.source .gf-shape { margin-top: 5px; }
.source[data-tone="warn"] { color: var(--ink); }
.gf-shape { display: inline-block; flex: none; width: 8px; height: 8px; position: relative; vertical-align: middle; }
.gf-shape--state { border-radius: 50%; background: var(--live); box-shadow: 0 0 0 2.5px var(--live-halo); }
.gf-shape--state[data-on="false"] { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.gf-shape--attention { width: 10px; height: 9px; background: var(--warn); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
/* SL's messages for the whole station, in SL's words */
.notices li { margin-top: 10px; padding: 8px 11px; border: 1px solid var(--card-border); border-radius: 7px; background: var(--chip-bg); color: var(--ink); font-size: 12.5px; line-height: 1.45; }

/* ---------- Shared pieces ---------- */
.line-tag {
  display: inline-grid; place-items: center; flex: none; min-width: 28px; height: 21px; padding: 0 5px; border-radius: 5px;
  background: var(--muted); color: var(--panel); font: 500 12px/1 var(--mono); font-variant-numeric: tabular-nums;
}
.line-tag[data-color="green"] { background: var(--badge-green); color: var(--line-on); }
.line-tag[data-color="red"] { background: var(--badge-red); color: var(--line-on); }
.line-tag[data-color="blue"] { background: var(--badge-blue); color: var(--line-on); }
.line-strip { display: inline-block; flex: none; width: 16px; height: 6px; border-radius: 3px; background: var(--muted); }
.line-strip[data-color="green"] { background: var(--line-green); }
.line-strip[data-color="red"] { background: var(--line-red); }
.line-strip[data-color="blue"] { background: var(--line-blue); }
.gf-tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--green-border); border-radius: 4px;
  background: var(--green-soft); color: var(--green-ink); font: 500 9.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
}

/* ---------- Departures ---------- */
.dep { width: 100%; border-collapse: collapse; margin-top: var(--space-4); }
.dep caption { text-align: left; padding-bottom: 5px; border-bottom: 1px solid var(--rule); color: var(--ink); }
.dep caption .dep__towards { display: block; font: 400 16px/1.3 var(--serif); letter-spacing: -.2px; }
.dep th { padding: 0; border: 0; height: 0; line-height: 0; }
.dep td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.dep td:last-child { padding-right: 0; }
.dep .dep__line { width: 38px; }
.dep .dep__dest { font-weight: 500; overflow-wrap: anywhere; }
.dep .dep__dest s { color: var(--muted); font-weight: 400; }
.dep .dep__sub { display: block; font-weight: 400; font-size: 12px; line-height: 1.4; color: var(--muted); }
.dep .dep__sub--warn { color: var(--warn); }
.dep .dep__sub--error { color: var(--error); }
.dep .dep__track { white-space: nowrap; color: var(--muted); font: 400 11px/21px var(--mono); }
.dep .dep__when { white-space: nowrap; text-align: right; font: 500 15px/21px var(--mono); font-variant-numeric: tabular-nums; }
.dep .dep__when small { font: 400 11px/21px var(--mono); color: var(--muted); }
.dep .dep__when[data-cancelled="true"] { color: var(--error); font-size: 12px; font-weight: 400; }
.when { font: 500 15px/21px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.when small { font: 400 11px/21px var(--mono); color: var(--muted); }

/* Loading skeleton: still blocks, no shimmer. Rows match .dep's: 9 px padding, a 21 px line and a 1 px rule. */
.skeleton__group { padding-top: var(--space-4); }
.skeleton__caption { display: block; width: 40%; height: 22px; margin-bottom: 6px; border-radius: 4px; background: var(--hover); }
.skeleton__row { display: block; height: 40px; padding: 9px 0; border-bottom: 1px solid var(--rule-soft); }
.skeleton__row::before { content: ""; display: block; width: 70%; height: 100%; border-radius: 4px; background: var(--hover); }
.skeleton__row:nth-child(odd)::before { width: 85%; }

/* ---------- Facts and lists ---------- */
/* the label column stops at 40%, so a long label wraps instead of squeezing the value at 320 px */
.facts { display: grid; grid-template-columns: fit-content(40%) minmax(0, 1fr); }
.facts dt, .facts dd { padding: 9px 0; border-bottom: 1px solid var(--rule-soft); }
.facts dt { overflow-wrap: anywhere; padding-right: var(--space-3); color: var(--muted); font: 500 9.5px/18px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.facts dd { font-size: 13px; line-height: 18px; }
.facts dd small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.4; }

.ends h3 { padding-top: 18px; font: 400 17px/1.25 var(--serif); letter-spacing: -.2px; }
.ends .ends__hint { padding: 3px 0 7px; color: var(--muted); font: italic 13px/1.4 var(--serif); border-bottom: 1px solid var(--rule); }
.row-button {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: var(--size-target); padding: 7px 6px;
  background: transparent; border: 0; border-bottom: 1px solid var(--rule-soft); border-radius: 0; text-align: left; font-size: 13px;
  transition: background-color var(--dur-quick) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
@media (hover: hover) { .row-button:not(:disabled):hover { background: var(--hover); } }
.row-button:active { transform: translateY(1px); }
.row-button:focus-visible { outline-offset: -2px; }
.row-button:disabled { transform: none; }
.row-button__text { flex: 1; min-width: 0; }
.row-button__text small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; }
.row-button .gf-tag { flex: none; }

/* Atlas key and landmarks */
.field-key { margin-top: 20px; border-top: 1px solid var(--rule); }
.key-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 40px; padding: 0; border: 0; background: transparent;
  color: var(--ink); font: 500 11px/1.4 var(--mono); letter-spacing: .09em; text-transform: uppercase;
}
.key-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-quick) var(--ease-out); }
.key-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.key-lines { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 2px 0 8px; color: var(--muted); font: 500 10px/1.4 var(--mono); letter-spacing: .04em; }
.key-lines li { display: inline-flex; align-items: center; gap: 6px; }
.key-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 3px 5px;
  border: 0; border-radius: 6px; background: transparent; text-align: left;
  transition: background-color var(--dur-quick) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
@media (hover: hover) { .key-row:not(:disabled):hover { background: var(--hover); } }
.key-row:active { transform: translateY(1px); }
.key-row:disabled { opacity: .55; transform: none; }
.key-row svg { width: 32px; height: 32px; fill: none; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
.key-row__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.key-row__text strong { font-size: 12.5px; font-weight: 600; }
.key-row__text small { color: var(--muted); font: 9.5px/1.2 var(--mono); letter-spacing: .02em; }
.key-row__arrow { color: var(--green-border); font-size: 13px; }

.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--rule-soft); font-size: 12px; line-height: 1.45; color: var(--muted); }

/* ---------- Picker ---------- */
.picker { padding-top: var(--space-4); }
.picker__bar { position: sticky; top: 0; z-index: 1; display: flex; gap: var(--space-2); align-items: flex-end; padding-bottom: var(--space-3); background: var(--panel); }
.picker__bar .gf-field { flex: 1; min-width: 0; }
.gf-field { display: flex; flex-direction: column; gap: 6px; }
.gf-field__label { color: var(--muted); font: 500 10px/1.4 var(--mono); letter-spacing: .095em; text-transform: uppercase; }
.gf-input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--card-border); border-radius: 7px; background: var(--chip-bg); color: var(--ink);
  font: 400 16px/1 var(--sans); /* 16 px, so iOS does not zoom the page on focus */
}
.gf-input::placeholder { color: var(--muted); }
.gf-input:focus { outline: 2px solid var(--rust); outline-offset: 0; border-color: var(--green-border); }
.picker__list { border-top: 1px solid var(--rule); }
.picker__list [role="option"] {
  display: flex; align-items: center; gap: var(--space-3); min-height: var(--size-target); padding: var(--space-2) 6px;
  border-bottom: 1px solid var(--rule-soft); cursor: pointer; scroll-margin: var(--space-9) 0 var(--space-4);
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: background-color var(--dur-quick) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
.picker__list [role="option"]:active { transform: translateY(1px); }
@media (hover: hover) { .picker__list [role="option"]:hover { background: var(--hover); } }
.picker__list [role="option"][data-active="true"] { background: var(--green-soft); outline: 1px solid var(--green-border); outline-offset: -1px; border-radius: 6px; }
.picker__list [role="option"][aria-selected="true"] .picker__name { font-weight: 600; }
.picker__name { flex: 1; min-width: 0; font: 400 16px/1.25 var(--serif); }
.picker__name small { display: block; font: 400 10.5px/1.5 var(--mono); color: var(--muted); }
.picker__strips { display: flex; gap: var(--space-1); width: var(--space-8); flex: none; }

/* ---------- Train ---------- */
.train__head { display: flex; align-items: center; gap: var(--space-3); padding-top: 18px; }
.train__head h2 { font: 400 26px/1.1 var(--serif); letter-spacing: -1px; }
.train__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); padding-top: 18px; }

/* ---------- Field notes ---------- */
dialog.notes {
  width: min(500px, calc(100vw - 28px)); max-height: 80dvh; padding: 0; overflow: auto;
  color: var(--ink); background: var(--panel); border: 1px solid var(--card-border); border-radius: 12px; box-shadow: var(--shadow-dialog);
}
dialog.notes::backdrop { background: var(--backdrop); }
.dialog-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 14px 14px 14px 20px; border-bottom: 1px solid var(--rule); background: var(--panel);
}
.dialog-head h2 { font: 400 29px/1.1 var(--serif); letter-spacing: -1px; }
.tool { display: grid; place-items: center; width: var(--size-target); height: var(--size-target); padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); }
@media (hover: hover) { .tool:hover { background: var(--hover); } }
.dialog-body { padding: 4px 20px 18px; font-size: 13px; line-height: 1.5; }
.dialog-body h3 { margin: 16px 0 6px; color: var(--muted); font: 500 10.5px/1.4 var(--mono); letter-spacing: .095em; text-transform: uppercase; }
.notes__lead { margin: 12px 0 4px; font: 16px/1.45 var(--serif); }
.notes__list dt { margin-top: 9px; font-weight: 600; }
.notes__list dd { color: var(--ink); }
.dialog-body a { font-weight: 550; }

/* Touch screens keep :hover on the last thing tapped; the hover rules above are behind (hover: hover). */
/* Phone browsers float a toolbar over the bottom of the page that the safe-area inset does not report: leave room to scroll the last rows clear of it. */
@media (hover: none) and (max-width: 899px) { .sheet__body { padding-bottom: calc(var(--safe-bottom) + 96px); } }
