/* Tracks On Time — mobile-first design system
   ---------------------------------------------------------------------- */
:root {
  --brand: #0b3d91;
  --brand-2: #1652f0;
  --brand-ink: #ffffff;
  --bg: #f3f5f9;
  --card: #ffffff;
  --card-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --board: #ffffff;
  --board-bg: #15803d;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .18);
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #8fb4ff;
    --brand-2: #6c9bff;
    --brand-ink: #0b1220;
    --bg: #0b1220;
    --card: #131c2e;
    --card-2: #182338;
    --ink: #e8eef8;
    --ink-2: #c4cfdf;
    --muted: #8b9bb3;
    --line: #233149;
    --line-2: #31425f;
    --ok: #4ade80;
    --ok-bg: rgba(34, 197, 94, .16);
    --warn: #fbbf24;
    --warn-bg: rgba(245, 158, 11, .16);
    --bad: #f87171;
    --bad-bg: rgba(239, 68, 68, .16);
    --info: #93c5fd;
    --info-bg: rgba(59, 130, 246, .18);
    --board: #052e16;
    --board-bg: #4ade80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-sm { width: 18px; height: 18px; }
.ic-xs { width: 15px; height: 15px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- layout */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
main { display: block; min-height: 60vh; }
.stack > * + * { margin-top: 16px; }
.section { margin-top: 24px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 10px; }
.sec-h h2 { font-size: 1.05rem; }
.sec-h a { font-size: .9rem; font-weight: 600; }

/* -------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 8px 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; letter-spacing: -.01em; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; }
.topnav { display: none; margin-left: 16px; gap: 4px; }
.topnav a { padding: 8px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: .95rem; }
.topnav a:hover { background: var(--card); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--brand-2); background: var(--card); }
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  border: 0; background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--card); }
.search-pill {
  display: none; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px; min-width: 240px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--muted);
}

/* -------------------------------------------------------------- tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .72rem; font-weight: 600; position: relative;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--brand-2); }
.tabbar a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; width: 32px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand-2);
}
.tabbar .badge { position: absolute; top: 8px; left: calc(50% + 6px); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center;
}

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .topnav { display: flex; }
  .search-pill { display: flex; }
  .topbar .icon-btn.search-btn { display: none; }
  .topbar { padding: 0 24px; }
}

/* --------------------------------------------------------------- cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.card-pad { padding: 16px; }
.card + .card { margin-top: 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.row-link {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px; color: var(--ink);
}
.row-link:hover { text-decoration: none; background: var(--card-2); }
.row-link .grow { flex: 1; min-width: 0; }
.row-link .chev { color: var(--line-2); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  height: 22px; padding: 0 7px; border-radius: 6px;
  background: var(--c, #475569); color: var(--t, #fff);
  font-size: .7rem; font-weight: 800; letter-spacing: .02em; white-space: nowrap; flex: none;
}
.chip-lg { height: 28px; padding: 0 10px; font-size: .8rem; border-radius: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chip-scroll::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-weight: 600; font-size: .88rem;
}
.filter-chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #475569); flex: none; }

/* ------------------------------------------------------- status pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap;
  background: var(--card-2); color: var(--muted);
}
.k-ok { color: var(--ok); }
.k-warn { color: var(--warn); }
.k-bad { color: var(--bad); }
.k-info { color: var(--info); }
.k-muted { color: var(--muted); }
.pill.k-ok { background: var(--ok-bg); }
.pill.k-warn { background: var(--warn-bg); }
.pill.k-bad { background: var(--bad-bg); }
.pill.k-info { background: var(--info-bg); }
.pill.k-board { background: var(--board-bg); color: var(--board); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); animation: pulse 2s infinite; flex: none; }
.live-dot.stale { background: var(--warn); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); } 70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot, .pulse-ring { animation: none !important; } }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 700; font-size: .95rem;
}
.btn:hover { text-decoration: none; background: var(--card-2); }
.btn-primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand-2) 88%, black); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0b1220; } }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.fav-btn[aria-pressed="true"] { color: #f59e0b; }
.fav-btn[aria-pressed="true"] .ic { fill: #f59e0b; stroke: #f59e0b; }

/* --------------------------------------------------- segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: color-mix(in srgb, var(--line) 70%, transparent); }
.seg a, .seg button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; border-radius: 10px; border: 0; background: transparent;
  color: var(--ink-2); font-weight: 700; font-size: .95rem;
}
.seg a:hover { text-decoration: none; }
.seg [aria-current="page"], .seg [aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---------------------------------------------------------- page hero */
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin: 14px 2px 8px; }
.crumbs a { color: var(--muted); }
.crumbs span[aria-hidden] { opacity: .6; }
.hero { display: flex; align-items: flex-start; gap: 12px; margin: 4px 0 12px; }
.hero .grow { flex: 1; min-width: 0; }
.hero h1 { font-size: 1.55rem; }
.hero .sub { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sticky-tools { position: sticky; top: var(--topbar-h); z-index: 20; background: var(--bg); padding: 8px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.toolbar .grow { flex: 1; min-width: 0; }
.select {
  width: 100%; height: 40px; padding: 0 34px 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none; -webkit-appearance: none; font-size: .92rem; font-weight: 600; color: var(--ink);
}

/* Typeable filter (station page "Stops at") */
.combo { position: relative; }
.combo-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: flex; color: var(--muted); pointer-events: none; }
.combo-input {
  width: 100%; height: 40px; padding: 0 40px 0 36px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: .92rem; font-weight: 600; color: var(--ink);
  text-overflow: ellipsis;
}
.combo-input::placeholder { color: var(--muted); font-weight: 500; }
.combo.has-value .combo-input { border-color: var(--brand-2); color: var(--brand-2); }
.combo.has-value .combo-ic { color: var(--brand-2); }
.combo-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px;
  display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.combo-clear:hover { background: var(--card-2); color: var(--ink); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; margin: 0; padding: 6px; list-style: none;
  max-height: min(50vh, 360px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.combo-opt { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.combo-opt .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-opt .sub { display: flex; gap: 4px; flex: none; }
.combo-opt mark { background: transparent; color: var(--brand-2); }
.combo-opt.is-active, .combo-opt:hover { background: var(--card-2); }
.combo-opt.combo-all { color: var(--muted); border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; margin-bottom: 4px; }
.combo-empty { padding: 14px 12px; color: var(--muted); font-size: .9rem; }
.updated { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* -------------------------------------------------------------- notices */
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; font-size: .9rem; background: var(--info-bg); color: var(--ink); }
.notice .ic { color: var(--info); margin-top: 1px; }
.notice.warn { background: var(--warn-bg); }
.notice.warn .ic { color: var(--warn); }
.notice.bad { background: var(--bad-bg); }
.notice.bad .ic { color: var(--bad); }
.notice + .notice { margin-top: 8px; }
.notice p { margin: 0; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }

/* ------------------------------------------------------ departures rows */
.board { list-style: none; margin: 0; padding: 0; }
.board > li + li { border-top: 1px solid var(--line); }
.dep {
  display: grid; grid-template-columns: 74px 1fr auto; gap: 4px 12px; align-items: center;
  padding: 12px 14px 12px 12px; color: var(--ink); min-height: 72px; position: relative;
}
.dep:hover { text-decoration: none; background: var(--card-2); }
.dep-time { grid-row: span 2; align-self: start; text-align: left; }
.dep-time .t { display: block; font-size: 1.02rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.dep-time .t.late { color: var(--bad); }
.dep-time .was { display: block; font-size: .78rem; color: var(--muted); text-decoration: line-through; font-variant-numeric: tabular-nums; }
.dep-time .cd { display: block; font-size: .8rem; font-weight: 700; color: var(--brand-2); margin-top: 2px; }
.dep-main { min-width: 0; }
.dep-dest { font-weight: 750; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: .82rem; color: var(--muted); min-width: 0; flex-wrap: wrap; }
.dep-status { grid-column: 2 / 4; display: flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 650; min-width: 0; }
.dep-status .next { color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trk { grid-row: 1; grid-column: 3; text-align: center; min-width: 52px; }
.trk .lbl { display: block; font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.trk .num { display: block; font-size: 1.45rem; font-weight: 850; line-height: 1.1; font-variant-numeric: tabular-nums; }
.trk.tba .num { font-size: .9rem; font-weight: 700; color: var(--muted); padding-top: 4px; }
.dep.is-boarding { background: color-mix(in srgb, var(--ok-bg) 70%, var(--card)); }
.dep.is-boarding::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--ok); }
.dep.is-boarding .trk .num { color: var(--ok); }
.dep.is-departed { opacity: .55; }
.dep.is-cancelled .dep-dest, .dep.is-cancelled .dep-time .t { text-decoration: line-through; color: var(--muted); }
.flag { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.board-foot { padding: 12px 16px; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); }
.divider-now { display: flex; align-items: center; gap: 10px; padding: 6px 14px; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-2); background: var(--card-2); }
.divider-now::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .35; }
.board-sec { padding: 10px 14px 6px; font-size: .75rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); background: var(--card-2); border-top: 1px solid var(--line); }
.board-sec:first-child { border-top: 0; border-radius: var(--radius) var(--radius) 0 0; }
.compact .dep { min-height: 60px; padding-top: 10px; padding-bottom: 10px; }

/* -------------------------------------------------------- arrivals rows */
.arr { display: grid; grid-template-columns: 74px 1fr auto; gap: 2px 12px; align-items: center; padding: 12px 14px 12px 12px; color: var(--ink); min-height: 66px; }
.arr:hover { text-decoration: none; background: var(--card-2); }
.arr .when { text-align: right; }
.arr .when .t { display: block; font-weight: 800; font-variant-numeric: tabular-nums; }
.arr .when .s { display: block; font-size: .8rem; font-weight: 650; }
.arr.is-arrived .dep-time .t { color: var(--muted); font-weight: 650; }
.arr.is-approaching { background: color-mix(in srgb, var(--info-bg) 60%, var(--card)); }
.approx { color: var(--muted); font-weight: 600; }

/* ------------------------------------------------------------- timeline */
.tl { list-style: none; margin: 0; padding: 8px 0; }
.tl li { position: relative; display: grid; grid-template-columns: 34px 1fr auto; gap: 0 10px; align-items: start; padding: 9px 16px 9px 8px; }
.tl li::before { content: ""; position: absolute; left: 24px; top: 0; bottom: 0; width: 4px; background: var(--c, var(--brand-2)); opacity: .9; }
.tl li:first-child::before { top: 18px; }
.tl li:last-child::before { bottom: calc(100% - 18px); }
.tl li.passed::before { background: var(--line-2); opacity: 1; }
.tl li.is-next::before { background: linear-gradient(var(--line-2) 0 18px, var(--c, var(--brand-2)) 18px); }
.tl .node { position: relative; z-index: 1; width: 16px; height: 16px; margin: 2px 0 0 10px; border-radius: 50%; background: var(--card); border: 4px solid var(--c, var(--brand-2)); }
.tl li.passed .node { border-color: var(--line-2); background: var(--line-2); width: 12px; height: 12px; margin: 4px 0 0 12px; border-width: 0; }
.tl li.is-next .node { width: 22px; height: 22px; margin: -1px 0 0 7px; background: var(--c, var(--brand-2)); border-color: var(--card); box-shadow: 0 0 0 3px var(--c, var(--brand-2)); }
.tl li.is-next .node::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 2px solid var(--c, var(--brand-2)); animation: ring 1.8s ease-out infinite; }
@keyframes ring { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.3); opacity: 0; } }
.tl .nm { font-weight: 650; color: var(--ink); }
.tl li.passed .nm { color: var(--muted); font-weight: 500; }
.tl li.is-next .nm { font-weight: 800; }
.tl .note { display: block; font-size: .78rem; color: var(--muted); }
.tl .tm { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.tl .tm .sch { display: block; font-size: .76rem; color: var(--muted); font-weight: 500; }
.tl li.passed .tm { color: var(--muted); font-weight: 600; }
.tl li.cancelled .nm { text-decoration: line-through; }

/* ------------------------------------------------------------- train page */
.train-head { border-radius: var(--radius); padding: 18px 16px; color: var(--t, #fff); background: var(--c, var(--brand)); position: relative; overflow: hidden; }
.train-head::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.train-head .eyebrow { font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: .9; }
.train-head h1 { font-size: 1.5rem; margin-top: 4px; color: inherit; }
.train-head .route { margin-top: 6px; font-size: .92rem; opacity: .95; }
.status-card { padding: 16px; }
.status-big { font-size: 1.5rem; font-weight: 850; letter-spacing: -.01em; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 14px; }
.kv div { background: var(--card-2); border-radius: 12px; padding: 10px 12px; }
.kv .k { display: block; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kv .v { display: block; font-weight: 750; margin-top: 2px; }
.cars { display: flex; gap: 3px; margin-top: 6px; }
.cars span { flex: 1; height: 12px; border-radius: 3px; background: var(--c); }

/* ---------------------------------------------------------------- trip */
.trip-form { padding: 14px; }
.od { position: relative; display: grid; gap: 8px; }
.od-field {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 56px 8px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card-2); text-align: left;
}
.od-field .lbl { display: block; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.od-field .val { display: block; font-weight: 700; font-size: 1rem; }
.od-field .val.placeholder { color: var(--muted); font-weight: 600; }
.od-field .pin { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--brand-2); flex: none; }
.od-field.to .pin { border-radius: 3px; background: var(--brand-2); }
.swap-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; box-shadow: var(--shadow); }
.when-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.input { width: 100%; height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); font-weight: 600; }
.itin { display: block; padding: 14px 16px; color: var(--ink); }
.itin:hover { text-decoration: none; background: var(--card-2); }
.itin-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.itin-times { font-size: 1.15rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.itin-dur { font-weight: 700; color: var(--muted); white-space: nowrap; }
.itin-legs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: .85rem; color: var(--ink-2); }
.itin-legs .arrow { color: var(--muted); }
.itin-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; font-size: .84rem; }
.leg-list { margin-top: 10px; border-left: 3px solid var(--line); padding-left: 12px; display: grid; gap: 6px; font-size: .86rem; }

/* -------------------------------------------------------------- alerts */
.alert-item { padding: 14px 16px; }
.alert-item .when { font-size: .78rem; color: var(--muted); font-weight: 600; }
.alert-item .ttl { font-weight: 750; margin-top: 4px; }
.alert-item .txt { margin-top: 4px; color: var(--ink-2); font-size: .94rem; }
.alert-item .refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.alert-item .refs a { font-size: .8rem; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); }

/* ------------------------------------------- page headers + station tiles */
.home-hero { padding: 18px 0 6px; }
.home-hero h1 { font-size: 1.45rem; }
.home-hero p { color: var(--muted); margin: 6px 0 14px; font-size: .95rem; }
.station-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.station-tile { display: flex; flex-direction: column; gap: 6px; padding: 12px; min-height: 64px; border-radius: 14px; background: var(--card); border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); color: var(--ink); font-weight: 700; font-size: .92rem; box-shadow: var(--shadow); }
.station-tile:hover { text-decoration: none; background: var(--card-2); }
.station-tile .dots { display: flex; gap: 3px; flex-wrap: wrap; }
.station-tile .dots .dot { width: 8px; height: 8px; }
.faq details { padding: 14px 16px; }
.faq details + details { border-top: 1px solid var(--line); }
.faq summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-weight: 800; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 8px 0 0; color: var(--ink-2); }
.line-list a { display: flex; align-items: center; gap: 12px; }

/* --------------------------------------------------- line + station list */
.stations-filter { position: sticky; top: var(--topbar-h); z-index: 10; padding: 10px 0; background: var(--bg); }
.line-diagram { list-style: none; margin: 0; padding: 6px 0; }
.line-diagram li a { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 10px 14px 10px 8px; color: var(--ink); position: relative; min-height: 48px; }
.line-diagram li a:hover { text-decoration: none; background: var(--card-2); }
.line-diagram li a::before { content: ""; position: absolute; left: 24px; top: 0; bottom: 0; width: 4px; background: var(--c); }
.line-diagram li:first-child a::before { top: 50%; }
.line-diagram li:last-child a::before { bottom: 50%; }
.line-diagram .node { position: relative; z-index: 1; width: 14px; height: 14px; margin-left: 11px; border-radius: 50%; background: var(--card); border: 3px solid var(--c); }

/* --------------------------------------------------------- search sheet */
.search { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; }
.search[hidden] { display: none; }
.search-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--line); background: var(--card); }
.search-field { flex: 1; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 1.05rem; height: 100%; }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-cancel { border: 0; background: transparent; color: var(--brand-2); font-weight: 700; padding: 0 6px; height: 44px; }
.search-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 12px 40px; }
.search-sec { margin: 14px 4px 6px; font-size: .75rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.search-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; min-height: 56px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); text-align: left; }
.search-item:hover, .search-item.is-active { background: var(--card); text-decoration: none; }
.search-item .grow { flex: 1; min-width: 0; }
.search-item .nm { font-weight: 700; }
.search-item .sub { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.search-item .lead { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--card); color: var(--muted); flex: none; border: 1px solid var(--line); }
.search-item mark { background: transparent; color: var(--brand-2); }
@media (min-width: 900px) {
  .search { inset: 64px auto auto 50%; transform: translateX(-50%); width: 560px; max-height: 70vh; border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--line); }
  .search-backdrop { position: fixed; inset: 0; z-index: 59; background: rgba(15, 23, 42, .35); }
}
.search-backdrop[hidden] { display: none; }

/* ----------------------------------------------------------------- toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px); z-index: 70; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 650; font-size: .92rem; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* --------------------------------------------------------------- footer */
.site-foot { margin-top: 40px; padding: 24px 0 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; }
.site-foot nav a { color: var(--ink-2); font-weight: 600; }
.site-foot p { margin: 4px 0; }

/* ------------------------------------------------------------ skeletons */
.skel { position: relative; overflow: hidden; background: var(--card-2); border-radius: 8px; min-height: 14px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--card) 70%, transparent), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.is-loading { opacity: .6; transition: opacity .2s; }

/* ------------------------------------------------------------- prose */
.prose { color: var(--ink-2); font-size: .95rem; }
.prose h2 { color: var(--ink); margin: 22px 0 8px; font-size: 1.1rem; }
.prose ul { padding-left: 20px; margin: 0 0 12px; }
.prose li { margin: 4px 0; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.facts div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.facts .k { display: block; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.facts .v { display: block; font-weight: 750; color: var(--ink); margin-top: 2px; }

/* ------------------------------------------------------- page additions */
[hidden] { display: none !important; }
.inline-ic { display: inline-block; vertical-align: -2px; }
.grow { flex: 1; min-width: 0; }

/* Boards: names must be block-level to ellipsize; compact AM/PM keeps times on one line */
.dep-dest { display: block; }
.ampm { font-size: .66em; font-weight: 750; margin-left: 2px; letter-spacing: .02em; }
.dep-time .t, .arr .when .t { white-space: nowrap; }

/* Compact service-alert block (one line until tapped) */
.alert-box { border-radius: 14px; background: var(--warn-bg); font-size: .9rem; margin-bottom: 10px; }
.alert-box summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; min-height: 48px; }
.alert-box summary::-webkit-details-marker { display: none; }
.alert-box summary > .ic { color: var(--warn); }
.alert-box summary .first { display: block; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.alert-box summary .toggle::after { content: "Show"; color: var(--brand-2); font-weight: 700; font-size: .85rem; }
.alert-box[open] summary .toggle::after { content: "Hide"; }
.alert-box[open] summary .first { display: none; }
.alert-box ul { margin: 0; padding: 0 14px 4px 46px; display: grid; gap: 10px; }
.alert-box li { color: var(--ink); }
.alert-box .all { display: inline-block; margin: 8px 14px 12px 46px; font-weight: 650; }
.board-block > .notice { margin-bottom: 10px; }

/* Train timeline: folded earlier stops */
.tl-early summary { padding: 12px 16px 4px 50px; color: var(--brand-2); font-weight: 700; font-size: .9rem; cursor: pointer; list-style: none; }
.tl-early summary::-webkit-details-marker { display: none; }
.tl-early[open] .when-closed, .tl-early:not([open]) .when-open { display: none; }
.tl.tl-head { padding-bottom: 0; }
.tl.tl-head li:last-child::before { bottom: 0; }
.tl.tl-cont { padding-top: 0; }
.tl.tl-cont li:first-child::before { top: 0; }
.tl.tl-cont li.passed:first-child::before { background: var(--line-2); }

/* Trip planner */
.when-wrap { margin-top: 10px; }
.trip-list .itin-top, .trip-list .itin-legs, .trip-list .itin-foot { display: flex; }
.itin .arrow { color: var(--muted); font-weight: 600; }
.itin .xfer { font-weight: 650; }
.itin.is-departed { opacity: .55; }
.trip-list .leg-list { margin: -4px 16px 14px; }
.leg-list a { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; color: var(--ink); padding: 4px 0; }
.leg-list a:hover { text-decoration: none; }
.leg-list a:hover strong { text-decoration: underline; }
.trip-list.compact .itin { padding: 12px 14px; }
.trip-list.compact .itin-times { font-size: 1.02rem; }

/* Stations A–Z */
.stations-filter .search-field { background: var(--card); }
.az-h { margin: 20px 4px 8px; font-size: .8rem; font-weight: 800; letter-spacing: .08em; color: var(--muted); }

/* Line page diagram: name, then other lines serving the station */
.ld-main { min-width: 0; }
.ld-name { display: block; font-weight: 650; }
.ld-main .chips { margin-top: 4px; gap: 4px; }
.line-diagram .chev { color: var(--line-2); }

/* Search page + error page */
.search-inline { display: flex; gap: 8px; align-items: center; }
.search-inline .search-field { background: var(--card); }
.err-hero { text-align: center; padding: 36px 8px 8px; }
.err-hero h1 { margin-top: 14px; }
.err-hero p { color: var(--muted); margin: 8px auto 0; max-width: 460px; }
.err-icon { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center; background: var(--info-bg); color: var(--info); }
.err-icon .ic { width: 32px; height: 32px; }
.err-hero .btn-row { justify-content: center; max-width: 360px; margin-left: auto; margin-right: auto; }

/* -------------------------------------------------------------- express tag */
.pill.k-express { background: var(--brand); color: var(--brand-ink); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; padding: 1px 7px; }

/* -------------------------------------------------------------- track sniper */
/* Board rows: the button sits in the (empty) track slot, outside the row link. */
.board > li { position: relative; }
.snipe-slot { width: 72px; min-height: 46px; }
.snipe-btn {
  position: absolute; top: 12px; right: 14px; z-index: 1; width: 72px; height: 46px; padding: 0 4px; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 1.5px dashed var(--brand-2); border-radius: 10px; background: var(--info-bg); color: var(--brand-2);
  font-weight: 800; cursor: pointer;
}
.snipe-btn .lbl { font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.snipe-btn .num { display: inline-flex; align-items: center; gap: 3px; font-size: .78rem; }
.snipe-btn:hover { background: color-mix(in srgb, var(--info-bg) 70%, var(--brand-2)); }
.snipe-btn:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
/* Trip cards: small inline button in the bottom-right corner; the card's footer row reserves room for it. */
.itin-wrap { position: relative; }
.snipe-btn.snipe-inline { top: auto; bottom: 14px; right: 14px; width: auto; flex-direction: row; gap: 5px; height: 34px; padding: 0 10px; border-radius: 999px; font-size: .78rem; }
.itin.has-snipe .itin-foot { padding-right: 128px; min-height: 34px; }
.trip-list.compact .snipe-btn { display: none; }

.snipe-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(15, 23, 42, .45); }
.snipe-backdrop[hidden], .snipe[hidden] { display: none; }
.snipe {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 81; max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lg);
}
@media (min-width: 900px) {
  .snipe { left: 50%; right: auto; bottom: auto; top: 80px; width: 460px; transform: translateX(-50%); border-radius: 18px; border: 1px solid var(--line); }
}
.snipe-head { display: flex; align-items: flex-start; gap: 10px; }
.snipe-head h2 { margin: 0; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.snipe-sub { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.snipe-track { margin: 14px 0 10px; padding: 16px; border-radius: 16px; border: 2px dashed var(--line-2, var(--line)); background: var(--card); text-align: center; transition: border-color .3s, background .3s; }
.snipe-track .lbl { display: block; font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.snipe-track .num { display: block; font-size: 3.4rem; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--muted); }
.snipe-track.is-found { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.snipe-track.is-found .num { color: var(--ok); }
.snipe-track.is-over .num { font-size: 1.4rem; padding: 10px 0; }
.snipe-live { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: .8rem; color: var(--muted); }
.snipe-status { margin-top: 4px; font-size: .9rem; font-weight: 650; }
.snipe-sec { padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); margin-top: 10px; font-size: .92rem; }
.snipe-sec h3 { margin: 0 0 6px; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.snipe-sec p { margin: 0; }
.snipe-sec .big { font-size: 1.05rem; font-weight: 800; }
.snipe-sec ul { list-style: none; margin: 0; padding: 0; }
.snipe-sec li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: .88rem; min-width: 0; }
.snipe-sec li:first-child { border-top: 0; }
.snipe-sec .trkno { font-weight: 850; min-width: 64px; font-variant-numeric: tabular-nums; }
.snipe-sec .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.snipe-sec .who .d { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snipe-sec li.same .trkno { color: var(--brand-2); }
.snipe-foot { margin: 12px 2px; }
.snipe .btn { margin-top: 4px; }
