:root {
  --paper: #eef1f4;
  --card: #ffffff;
  --ink: #17212b;
  --ink-2: #4a5866;
  --ink-3: #6f7c89;
  --rule: #d8dee5;
  --accent: #2462a3;
  --accent-soft: #dce8f5;
  --muted-line: #98a3ae;
  --board: #16212c;
  --board-row: #1e2b38;
  --board-ink: #ffcf4a;
  --board-dim: #8a9aab;
  --good: #23764a;  --good-bg: #e2f1e8;
  --watch: #9a6408; --watch-bg: #f8edd5;
  --bad: #a83c27;   --bad-bg: #f7e2dc;
  --neutral: #4f5f70; --neutral-bg: #e5eaef;
  --radius: 10px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --flap: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f151b; --card: #18212a; --ink: #e7ecf1; --ink-2: #b3bfcb; --ink-3: #8996a3;
    --rule: #2a3642; --accent: #6ea6e4; --accent-soft: #1d3149; --muted-line: #6b7886;
    --board: #0a1017; --board-row: #131c26;
    --good: #5fc28a; --good-bg: #173326; --watch: #e3ad4f; --watch-bg: #3a2c12;
    --bad: #ef8a72; --bad-bg: #3d1f18; --neutral: #a8b6c4; --neutral-bg: #24303c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f151b; --card: #18212a; --ink: #e7ecf1; --ink-2: #b3bfcb; --ink-3: #8996a3;
  --rule: #2a3642; --accent: #6ea6e4; --accent-soft: #1d3149; --muted-line: #6b7886;
  --board: #0a1017; --board-row: #131c26;
  --good: #5fc28a; --good-bg: #173326; --watch: #e3ad4f; --watch-bg: #3a2c12;
  --bad: #ef8a72; --bad-bg: #3d1f18; --neutral: #a8b6c4; --neutral-bg: #24303c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--sans); font-variant-numeric: tabular-nums;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

/* header */
.top { background: var(--board); color: #e9eef3; padding-top: env(safe-area-inset-top); }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; letter-spacing: .01em; font-size: 17px; }
.brand svg { color: var(--board-ink); }
.updated { font-size: 13px; color: var(--board-dim); }

/* type */
h1 { font-size: 26px; line-height: 1.2; margin: 24px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 19px; line-height: 1.3; margin: 32px 0 10px; }
h3 { font-size: 16px; margin: 0 0 4px; }
p { margin: 0 0 12px; }
.lede { color: var(--ink-2); margin-bottom: 16px; }
.small { font-size: 14px; color: var(--ink-2); }
.tiny { font-size: 13px; color: var(--ink-3); }

/* departures board — the one loud thing */
.board { background: var(--board); color: var(--board-ink); border-radius: 0 0 14px 14px; margin: 0 -16px; padding: 6px 16px 18px; font-family: var(--flap); }
.board-head, .board-row { display: grid; grid-template-columns: 2.4em 1fr 6.2em 5.6em; gap: 10px; align-items: center; }
.board-head { color: var(--board-dim); font-size: 11px; letter-spacing: .08em; padding: 8px 0 6px; }
.board-row { background: var(--board-row); border-radius: 6px; padding: 12px 10px; margin-bottom: 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; }
.board-row .flt { font-size: 22px; font-weight: 700; }
.board-row .dest small { display: block; color: var(--board-dim); font-size: 11px; letter-spacing: .06em; }
.board-row .st { font-size: 12px; text-align: right; font-weight: 700; }
.st-good { color: #7be2a4; } .st-watch { color: var(--board-ink); } .st-bad { color: #ff9b82; } .st-neutral { color: #c5d2df; }
.flap { display: inline-block; }
.flap span { display: inline-block; animation: flip .5s steps(4) both; }
@keyframes flip { 0% { transform: scaleY(.1); opacity: .2 } 100% { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .flap span { animation: none; } }
.board-note { color: #c7d3df; font-family: var(--sans); font-size: 14px; margin: 10px 2px 0; }
@media (max-width: 520px) {
  .board-head, .board-row { grid-template-columns: 2em 1fr auto; }
  .board-head .c-in { display: none; }
  .board-row { grid-template-areas: "flt dest when" "flt st st"; row-gap: 6px; }
  .board-row .flt { grid-area: flt; align-self: start; }
  .board-row .dest { grid-area: dest; font-size: 13px; }
  .board-row .when { grid-area: when; align-self: start; }
  .board-row .st { grid-area: st; text-align: left; font-size: 14px; }
}

/* status list */
.checks { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--radius); border: 1px solid var(--rule); }
.checks li + li { border-top: 1px solid var(--rule); }
.checks a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 16px; color: inherit; text-decoration: none; }
.checks a:hover { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.checks .what { font-weight: 600; }
.checks .detail { grid-column: 1 / -1; font-size: 14px; color: var(--ink-2); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 2px 10px 2px 8px; border-radius: 999px; white-space: nowrap; height: fit-content; }
.pill svg { width: 14px; height: 14px; }
.p-good { color: var(--good); background: var(--good-bg); }
.p-watch { color: var(--watch); background: var(--watch-bg); }
.p-bad { color: var(--bad); background: var(--bad-bg); }
.p-neutral { color: var(--neutral); background: var(--neutral-bg); }

/* panels */
.panel { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.hero-num { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin: 12px 0; }
.facts > div { background: var(--card); padding: 12px 14px; }
.facts b { display: block; font-size: 20px; }
.facts span { font-size: 13px; color: var(--ink-2); }
.bar { height: 10px; background: var(--neutral-bg); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* segmented controls */
.seg { display: inline-flex; background: var(--neutral-bg); border-radius: 8px; padding: 3px; gap: 2px; margin: 0 8px 8px 0; }
.seg button { border: 0; background: transparent; padding: 6px 10px; border-radius: 6px; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* compare table */
.cmp { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; font-size: 15px; }
.cmp th, .cmp td { padding: 12px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--rule); }
.cmp thead th { border-top: 0; background: var(--board); color: var(--board-ink); font-family: var(--flap); font-size: 18px; }
.cmp thead th:first-child { color: var(--board-dim); font-size: 12px; font-family: var(--sans); }
.cmp th[scope="row"] { font-weight: 600; width: 34%; color: var(--ink-2); font-size: 14px; }
.cmp td small { display: block; color: var(--ink-3); font-size: 13px; }
.cmp td.win { background: color-mix(in srgb, var(--good-bg) 70%, transparent); }

.diffs { list-style: none; padding: 0; margin: 0; counter-reset: d; }
.diffs li { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; padding: 14px 0; border-top: 1px solid var(--rule); }
.diffs li:first-child { border-top: 0; }
.diffs li::before { counter-increment: d; content: counter(d); width: 24px; height: 24px; border-radius: 50%; background: var(--board); color: var(--board-ink); font: 700 13px/24px var(--flap); text-align: center; }
.diffs .amt { font-weight: 700; white-space: nowrap; }
.diffs p { grid-column: 2 / -1; margin: 0; font-size: 14px; color: var(--ink-2); }

/* timeline, lists */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--rule); }
.timeline li { position: relative; padding: 0 0 16px 14px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2px solid var(--muted-line); }
.timeline li.past::before { background: var(--muted-line); }
.timeline li.key::before { border-color: var(--accent); background: var(--accent); }
.timeline time { font-size: 13px; color: var(--ink-3); display: block; }

.todo { list-style: none; padding: 0; margin: 0; }
.todo li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; padding: 12px 0; border-top: 1px solid var(--rule); }
.todo li:first-child { border-top: 0; }
.todo.plain li { grid-template-columns: 1fr; }
.todo input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.todo .done label { text-decoration: line-through; color: var(--ink-3); }
.lumps { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.lumps > div { border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.lumps b { display: block; }
.lumps .done { background: var(--good-bg); border-color: transparent; }
.lumps .missed { background: var(--bad-bg); border-color: transparent; }
.lumps .due { background: var(--watch-bg); border-color: transparent; }
dl.kv { display: grid; grid-template-columns: 1fr auto; margin: 0; }
dl.kv dt, dl.kv dd { margin: 0; padding: 8px 0; border-top: 1px solid var(--rule); }
dl.kv dt { color: var(--ink-2); font-size: 14px; }
dl.kv dd { text-align: right; font-weight: 600; }
dl.kv dt:first-of-type, dl.kv dd:first-of-type { border-top: 0; }
.callout { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 12px 0; color: var(--ink-2); font-size: 15px; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--rule); stroke-width: 1; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; }
.chart .lbl { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin: 4px 0 8px; }
.legend i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--card); color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.15); max-width: 220px; }
.tip b { display: block; }

details.table-view summary { cursor: pointer; font-size: 14px; color: var(--accent); margin-top: 6px; }
details.table-view table { width: 100%; font-size: 13px; border-collapse: collapse; margin-top: 6px; }
details.table-view td, details.table-view th { padding: 4px 6px; border-top: 1px solid var(--rule); text-align: right; }
details.table-view th:first-child, details.table-view td:first-child { text-align: left; }

/* tab bar */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.tabs a { flex: 1; max-width: 144px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; font-size: 12px; color: var(--ink-3); text-decoration: none; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.foot { margin: 32px 0 8px; font-size: 13px; color: var(--ink-3); }
