:root {
  /* Persona-blue tool palette: flat electric blue, hard black/white, mid-gray cel edges.
     --brass* / --amber* keep their old names: brass = white ink, amber = electric cyan. */
  --bg: #17adf5;
  --cel: #0b6fa4;
  --ink: #000000;
  --panel: #0a0a0a;
  --panel-2: #161616;
  --line: #6e6e6e;
  --brass: #ffffff;
  --brass-dim: #8c8c8c;
  --amber: #4fd6ff;
  --amber-glow: rgba(79, 214, 255, 0.35);
  --green: #5cff8a;
  --text: #f5f5f5;
  --muted: #a0a0a0;
  --red: #ff4d5e;
  --led: "Consolas", "SFMono-Regular", "Menlo", "Noto Sans Mono CJK TC", monospace;
  --cjk: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  /* Per-line accent; app.js sets --line-c inline from known MTR line colours. */
  --line-c: var(--amber);
  --line-t: var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: linear-gradient(118deg, var(--ink) 0 16%, transparent calc(16% + 1px)) fixed, var(--bg);
  color: var(--text);
  font-family: var(--cjk);
  min-height: 100%;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 3px solid var(--brass);
  background: var(--ink);
}

.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark {
  font-size: 26px; font-weight: 800; letter-spacing: 4px;
  color: var(--brass);
  text-shadow: 3px 3px 0 var(--bg);
}
.brand-sub { color: var(--muted); font-size: 13px; letter-spacing: 1px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls input, .controls select, .controls button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--brass-dim);
  border-radius: 4px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}
.controls input { width: 240px; }
.controls select { min-width: 260px; max-width: 360px; }
.controls button { cursor: pointer; color: var(--brass); font-weight: 700; }
.controls button:hover { background: #2a2a2a; }
.controls button:disabled { opacity: 0.5; cursor: progress; }
.controls input:focus, .controls select:focus, .controls button:focus-visible {
  outline: 2px solid var(--amber); outline-offset: 1px;
}

main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 8px; }

.station-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding: 18px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 6px solid var(--brass);
  border-radius: 2px;
  box-shadow: 6px 6px 0 var(--cel);
}
.station-names h1 { margin: 0; font-size: 44px; letter-spacing: 6px; color: #ffffff; }
.station-names .en { color: var(--brass); font-size: 18px; letter-spacing: 1px; margin-top: 2px; }
.station-meta { text-align: right; }
.station-meta .code {
  font-family: var(--led); font-size: 26px; font-weight: 700;
  color: var(--amber); text-shadow: 0 0 6px var(--amber-glow);
  border: 1px solid var(--brass-dim); padding: 2px 10px; border-radius: 2px;
}
.station-meta .sid { color: var(--muted); font-size: 13px; margin-left: 8px; }
.lines { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.lines span {
  font-family: var(--led); font-size: 12px; padding: 2px 6px; border-radius: 3px;
  background: #1f1f1f; color: var(--brass); border: 1px solid var(--line);
  border-left: 4px solid var(--line-c);
}

.status-strip {
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center;
  margin: 12px 0; padding: 8px 14px;
  font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 2px;
}
.status-strip b { font-family: var(--led); color: var(--text); font-weight: 600; }
.flag { margin-left: auto; padding: 2px 8px; border-radius: 3px; border: 1px solid var(--line); }
.flag.ok { color: var(--green); border-color: #2f7a45; }
.flag.warn { color: var(--amber); border-color: var(--brass-dim); }
.flag.bad { color: var(--red); border-color: #8a2230; }
.flag.delay { color: var(--ink); background: var(--amber); border-color: var(--amber); }

.error {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 4px;
  background: var(--ink); border: 1px solid var(--red); color: #ffb3bb; font-size: 14px;
}
/* Partial data (one line failed / upstream status ≠ 1 / delay flag) — not fatal. */
.notice {
  margin: 0 0 12px; padding: 8px 14px; border-radius: 4px;
  background: var(--ink); border: 1px solid var(--amber); color: var(--amber); font-size: 13px;
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 16px;
}

.platform {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 6px 6px 0 var(--cel);
}
.platform-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: #1c1c1c;
  border-bottom: 2px solid var(--brass);
}
.platform-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 0;
  clip-path: polygon(18% 0, 100% 0, 82% 100%, 0 100%);
  background: var(--brass); color: var(--ink);
  font-family: var(--led); font-weight: 800; font-size: 20px;
}
.platform-title { font-size: 18px; font-weight: 700; letter-spacing: 2px; }
.platform-title small { display: block; font-size: 12px; color: var(--muted); letter-spacing: 1px; font-weight: 400; }
.platform-lines { margin-left: auto; display: flex; gap: 4px; }
.platform-lines span {
  font-family: var(--led); font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 2px;
  background: var(--line-c); color: var(--line-t);
}

.rows { width: 100%; border-collapse: collapse; }
.rows th {
  text-align: left; font-weight: 400; font-size: 11px; color: var(--muted);
  padding: 6px 14px; border-bottom: 1px solid var(--line); letter-spacing: 1px;
}
.rows th.col-line { width: 80px; }
.rows th.col-clock { width: 100px; }
.rows th.col-time { width: 150px; text-align: right; }
.rows td {
  padding: 12px 14px; border-bottom: 1px solid #262626;
  font-family: var(--led); vertical-align: middle;
}
.rows tr:last-child td { border-bottom: none; }
.rows .line-badge {
  display: inline-block; min-width: 56px; text-align: center;
  font-size: 18px; font-weight: 800; color: var(--line-t);
  background: var(--line-c); border-radius: 2px; padding: 3px 6px;
  box-shadow: 2px 2px 0 var(--brass);
}
.rows .dest-ch { font-family: var(--cjk); font-size: 22px; color: var(--text); }
.rows .dest-en { font-size: 12px; color: var(--brass); margin-top: 2px; }
.rows .time { text-align: right; white-space: nowrap; }
.rows .time-ch { font-family: var(--cjk); font-size: 22px; color: var(--amber); text-shadow: 0 0 6px var(--amber-glow); }
.rows .time-en { font-size: 12px; color: var(--brass); margin-top: 2px; }
.rows .clock { white-space: nowrap; color: var(--text); font-size: 18px; }
.rows .remark { font-family: var(--cjk); font-size: 12px; color: var(--muted); margin-top: 4px; }

.tag {
  display: inline-block; margin-top: 4px; padding: 1px 6px; border-radius: 3px;
  font-family: var(--cjk); font-size: 11px; letter-spacing: 1px; border: 1px solid;
}
.tag.arr { color: var(--brass); border-color: var(--brass-dim); }
.tag.dep { color: var(--green); border-color: #2f7a45; }
.tag.stop { color: var(--red); border-color: #8a2230; }
.tag.via { color: var(--amber); border-color: var(--brass-dim); }

/* Train arriving now (ttnt 0 / blank) */
tr.imminent td { background: rgba(92, 255, 138, 0.08); }
tr.imminent .time-ch, tr.imminent .dest-ch { color: var(--green); text-shadow: none; }
tr.imminent .time-ch { animation: blink 1.1s steps(2, start) infinite; }

@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { tr.imminent .time-ch { animation: none; } }

.empty {
  padding: 40px; text-align: center; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--line); border-radius: 2px;
  box-shadow: 6px 6px 0 var(--cel);
  grid-column: 1 / -1;
}
.empty .big { font-size: 22px; color: var(--amber); margin-bottom: 6px; }

.board.stale .platform { opacity: 0.55; filter: grayscale(0.4); }

.foot {
  max-width: 1280px; margin: 16px auto 24px; padding: 0 24px;
  color: #00263b; font-size: 12px; line-height: 1.6;
}
.foot code { color: var(--ink); font-weight: 700; }

@media (max-width: 720px) {
  .board { grid-template-columns: 1fr; }
  .station-names h1 { font-size: 32px; }
  .controls input, .controls select { width: 100%; min-width: 0; max-width: none; }
  .controls { width: 100%; }
  .station-meta { text-align: left; }
  .lines { justify-content: flex-start; }
}

/* —— Duo toggle button (visible in every layout) —— */
.controls .duo-toggle {
  min-width: 52px;
  padding: 8px 10px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  opacity: 0.85;
}
.controls .duo-toggle[aria-pressed="true"],
body.layout-duo .controls .duo-toggle {
  color: var(--ink);
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 3px 3px 0 var(--brass);
  opacity: 1;
}

/* —— Safe areas: only what the browser actually reports via env() ——
   Horizontal/bottom insets are applied once, on the element that touches that
   edge (topbar / main / footer), never on <body> as well. */
body { padding-top: env(safe-area-inset-top, 0px); }
.topbar {
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
}
main {
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
}
.foot {
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

/* Narrow phones: fixed table layout so the ETA column is never pushed past the card edge. */
@media (max-width: 520px) {
  .rows { table-layout: fixed; }
  .rows th.col-line { width: 64px; }
  .rows th.col-clock { width: 64px; }
  .rows th.col-time { width: 104px; }
  .rows th, .rows td { padding-left: 8px; padding-right: 8px; }
  .rows td { overflow-wrap: anywhere; }
  .rows .line-badge { min-width: 0; width: 100%; }
  .rows .time { white-space: normal; }
}

/* The platform rail only exists in Duo mode. */
.platform-nav { display: none; }

/* —— Default layout on compact / short screens (not Duo-specific) —— */

/* Outer cover–ish: compact portrait (~5.4", ~466×678 pt) */
@media (max-width: 480px) and (max-height: 720px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    gap: 8px;
    padding: 8px 12px;
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
  }
  .brand-sub { display: none; }
  .brand-mark { font-size: 18px; letter-spacing: 2px; }
  .controls { width: 100%; gap: 6px; }
  .controls input,
  .controls select { width: 100%; min-width: 0; max-width: none; }
  .controls input, .controls select, .controls button {
    padding: 6px 8px; font-size: 13px;
  }
  main {
    padding: 8px 10px 4px;
    padding-left: calc(10px + env(safe-area-inset-left, 0px));
    padding-right: calc(10px + env(safe-area-inset-right, 0px));
  }
  .station-head { padding: 8px 12px; gap: 6px; }
  .station-names h1 { font-size: 26px; letter-spacing: 2px; }
  .station-names .en { font-size: 12px; }
  .station-meta { text-align: left; }
  .station-meta .code { font-size: 16px; }
  .station-meta .sid { display: none; }
  .lines { justify-content: flex-start; margin-top: 4px; }
  .status-strip {
    margin: 6px 0; padding: 4px 8px; gap: 4px 10px; font-size: 11px;
  }
  .board { grid-template-columns: 1fr; gap: 8px; }
  .platform-head { padding: 6px 10px; }
  .platform-no { width: 28px; height: 28px; font-size: 15px; }
  .platform-title { font-size: 14px; }
  .platform-title small { display: none; }
  .rows th { padding: 3px 8px; }
  .rows td { padding: 8px; }
  .rows .line-badge { min-width: 40px; font-size: 18px; }
  .rows .dest-ch { font-size: 20px; }
  .rows .time-ch { font-size: 24px; }
  body.layout-duo .rows .dest-en,
  body.layout-duo .rows .time-en,
  .rows .dest-en,
  .rows .time-en { display: none; }
  .foot { margin: 6px auto 10px; font-size: 10px; padding: 0 10px; }
}

/* Inner unfolded–ish: wide + short landscape (~7.6", ~951×669 pt) */
@media (min-width: 700px) and (max-height: 780px) and (orientation: landscape) {
  .topbar {
    gap: 8px;
    padding-top: 6px;
    padding-bottom: 6px;
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
  }
  .brand-sub { display: none; }
  .brand-mark { font-size: 18px; }
  .controls input { width: 140px; }
  .controls select { min-width: 160px; max-width: 220px; }
  .controls input, .controls select, .controls button {
    padding: 5px 8px; font-size: 12px;
  }
  main {
    max-width: none;
    padding-top: 8px;
    padding-bottom: 2px;
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
  }
  .station-head {
    padding: 6px 12px;
    gap: 8px;
    align-items: center;
  }
  .station-names h1 { font-size: 24px; letter-spacing: 2px; }
  .station-names .en { font-size: 12px; }
  .station-meta .code { font-size: 16px; }
  .station-meta .sid { display: none; }
  .lines { margin-top: 4px; }
  .status-strip {
    margin: 6px 0;
    padding: 3px 10px;
    gap: 4px 14px;
    font-size: 11px;
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
  }
  .board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .platform-head { padding: 5px 10px; gap: 8px; }
  .platform-no { width: 28px; height: 28px; font-size: 15px; }
  .platform-title { font-size: 14px; }
  .platform-title small { display: none; }
  .rows th { padding: 3px 8px; font-size: 10px; }
  .rows td { padding: 6px 8px; }
  .rows .line-badge { min-width: 40px; font-size: 16px; }
  .rows .dest-ch { font-size: 18px; }
  .rows .time-ch { font-size: 20px; }
  .rows .dest-en,
  .rows .time-en { display: none; }
  .foot {
    margin: 4px auto 8px;
    font-size: 10px;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
  }
}


/* ======================================================================
   iPhone Duo layout  (body.layout-duo)

   Body becomes a two-column grid:  [ rail | content ]  (LEFT / leading rail).
   Safari on Duo draws its system chrome (clock / back / tabs) over the
   trailing (right) edge of the webview, and a web page can never put tappable
   controls there — taps get eaten and the rail looks clipped. So the platform
   rail lives on the LEADING edge, absorbing env(safe-area-inset-left); the
   content column runs to the right edge and pads only by the real
   env(safe-area-inset-right). No guessed chrome widths anywhere.

   Every platform is always shown (1 column when narrow, more when the
   content column has room). The rail is navigation only: tapping a button
   highlights that platform and scrolls it under the sticky topbar.

   Bottom: Safari's floating URL bar overlaps the page. --vv-bottom is set by
   JS from visualViewport (with a small cushion on iPhone Safari) and combined
   with env(safe-area-inset-bottom) via max() so they never double up.
   ====================================================================== */
:root {
  --rail-w: 64px;
  --vv-bottom: 0px;
  --duo-gutter: 10px;
  --duo-bottom: max(env(safe-area-inset-bottom, 0px), var(--vv-bottom));
}

body.layout-duo {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "top" "main";
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  overflow-x: clip; /* belt-and-braces: nothing may widen the layout viewport */
}
body.layout-duo.has-platform-nav:not(.platform-nav-chips) {
  /* [ rail | content ] — rail on the leading (left) edge, spanning both rows. */
  grid-template-columns: calc(var(--rail-w) + env(safe-area-inset-left, 0px)) minmax(0, 1fr);
  grid-template-areas: "rail top" "rail main";
}
body.layout-duo .foot { display: none; } /* would sit under the floating URL bar */

/* —— Dense topbar: brand · station select · reload · Duo —— */
body.layout-duo .topbar {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 20;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 8px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) var(--duo-gutter) 6px;
  padding-left: calc(var(--duo-gutter) + env(safe-area-inset-left, 0px));
  /* Content always reaches the trailing edge: honour the real inset only. */
  padding-right: calc(var(--duo-gutter) + env(safe-area-inset-right, 0px));
}
/* With the left rail, the rail already absorbs the leading inset. */
body.layout-duo.has-platform-nav:not(.platform-nav-chips) .topbar {
  padding-left: var(--duo-gutter);
}
body.layout-duo .brand { flex: none; }
body.layout-duo .brand-sub { display: none; }
body.layout-duo .brand-mark { font-size: 17px; letter-spacing: 2px; white-space: nowrap; }
body.layout-duo .controls {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  flex-wrap: nowrap;
  gap: 6px;
}
body.layout-duo .controls #stationSearch { display: none; }
body.layout-duo .controls select,
body.layout-duo .controls button {
  min-height: 44px;
  padding: 4px 8px;
  font-size: 13px;
}
body.layout-duo .controls select {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
}
body.layout-duo .controls button { flex: none; min-width: 44px; }
body.layout-duo .reload-label-long { display: none; }

/* —— Content column —— */
body.layout-duo main {
  grid-area: main;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 8px var(--duo-gutter) calc(16px + var(--duo-bottom));
  padding-left: calc(var(--duo-gutter) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--duo-gutter) + env(safe-area-inset-right, 0px));
}
body.layout-duo.has-platform-nav:not(.platform-nav-chips) main {
  padding-left: var(--duo-gutter);
}
body.layout-duo .station-head {
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-left-width: 4px;
}
body.layout-duo .station-names { min-width: 0; }
body.layout-duo .station-names h1 {
  font-size: 24px;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.layout-duo .station-names .en { font-size: 12px; }
body.layout-duo .station-meta { flex: none; text-align: right; }
body.layout-duo .station-meta .code { font-size: 16px; padding: 1px 8px; }
body.layout-duo .station-meta .sid { display: none; }
body.layout-duo .lines { margin-top: 4px; justify-content: flex-end; }

body.layout-duo .status-strip {
  min-width: 0;
  margin: 6px 0;
  padding: 3px 8px;
  gap: 4px 12px;
  font-size: 11px;
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
}
body.layout-duo .status-strip > span:first-child { display: none; } /* system time */

/* All platforms are shown: one column when narrow, two+ when each card
   can keep at least ~340px. The rail only highlights / scrolls. */
body.layout-duo .board {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 10px;
  align-items: start;
}
body.layout-duo .platform {
  min-width: 0;
  scroll-margin-top: 64px; /* clear the sticky topbar (JS also offsets) */
  border-color: var(--brass-dim);
}
body.layout-duo .platform.is-active {
  border-color: var(--brass);
  box-shadow: 0 0 0 2px var(--brass), 6px 6px 0 var(--cel);
}
body.layout-duo .platform-head { padding: 6px 10px; gap: 8px; }
body.layout-duo .platform-no { width: 28px; height: 28px; font-size: 15px; }
body.layout-duo .platform-title { font-size: 15px; letter-spacing: 1px; }
body.layout-duo .platform-title small { display: none; }

/* Fixed table layout: columns can never push the ETA past the card edge. */
body.layout-duo .rows { table-layout: fixed; }
body.layout-duo .rows th.col-line { width: 56px; }
body.layout-duo .rows th.col-clock { width: 64px; }
body.layout-duo .rows th.col-time { width: 96px; }
body.layout-duo .rows th { padding: 4px 6px; font-size: 10px; }
body.layout-duo .rows td { padding: 8px 6px; overflow-wrap: anywhere; }
body.layout-duo .rows .line-badge { min-width: 0; width: 100%; font-size: 17px; padding: 2px 2px; }
body.layout-duo .rows .dest-ch { font-size: 19px; }
body.layout-duo .rows .dest-en,
body.layout-duo .rows .time-en,
body.layout-duo .rows .tag-en { display: none; }
body.layout-duo .rows .time { white-space: normal; padding-right: 8px; }
body.layout-duo .rows .time-ch { font-size: 19px; line-height: 1.15; }
body.layout-duo .rows .clock { font-size: 14px; white-space: normal; }
body.layout-duo .platform-lines span { font-size: 11px; padding: 1px 4px; }
body.layout-duo 
/* —— Platform rail (scroll-to navigation) — leading/left edge —— */
body.layout-duo.has-platform-nav .platform-nav {
  grid-area: rail;
  grid-row: 1 / -1;
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 30;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 6px calc(12px + var(--duo-bottom));
  padding-left: calc(6px + env(safe-area-inset-left, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--ink);
  border-right: 3px solid var(--brass);
}
body.layout-duo.has-platform-nav .platform-nav::before {
  content: "月台";
  display: block;
  text-align: center;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
}

.platform-nav-btn {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  min-height: 56px;
  padding: 6px 2px;
  margin: 0;
  flex-shrink: 0;
  border: 1px solid var(--brass-dim);
  border-radius: 3px;
  background: var(--panel-2);
  color: var(--brass);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.platform-nav-btn:hover { background: #2a2a2a; border-color: var(--brass); }
.platform-nav-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.platform-nav-btn.is-active {
  color: var(--ink);
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 3px 3px 0 var(--brass);
}
.platform-nav-no {
  font-family: var(--led);
  font-weight: 800;
  font-size: 20px;
  line-height: 1;
}
.platform-nav-eta {
  font-family: var(--cjk);
  font-size: 11px;
  line-height: 1.15;
  max-width: 100%;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  opacity: 0.9;
}
.platform-nav-btn.is-active .platform-nav-eta { color: var(--ink); opacity: 0.85; }

/* —— Very narrow Duo (< 360px, set by JS): bottom chip bar instead of rail —— */
body.layout-duo.has-platform-nav.platform-nav-chips .platform-nav {
  position: fixed;
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  height: auto;
  flex-direction: row;
  gap: 8px;
  padding: 8px calc(var(--duo-gutter) + env(safe-area-inset-right, 0px)) calc(8px + var(--duo-bottom)) calc(var(--duo-gutter) + env(safe-area-inset-left, 0px));
  overflow-x: auto;
  overflow-y: hidden;
  border-right: none;
  border-top: 3px solid var(--brass);
  box-shadow: 0 -4px 0 var(--cel);
}
body.layout-duo.platform-nav-chips .platform-nav::before { display: none; }
body.layout-duo.platform-nav-chips .platform-nav-btn {
  width: auto;
  min-width: 64px;
  min-height: 44px;
  flex-direction: row;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 3px;
}
body.layout-duo.platform-nav-chips main {
  padding-bottom: calc(76px + var(--duo-bottom));
}

/* —— Compact outer screen —— */
@media (max-width: 480px) {
  :root { --rail-w: 60px; --duo-gutter: 8px; }
  body.layout-duo .rows th.col-line { width: 50px; }
  body.layout-duo .rows th.col-clock { width: 52px; }
  body.layout-duo .rows th.col-time { width: 86px; }
  body.layout-duo .rows .line-badge { font-size: 13px; }
  body.layout-duo .rows .dest-ch { font-size: 18px; }
  body.layout-duo .rows .time-ch { font-size: 18px; }
  body.layout-duo .station-names h1 { font-size: 22px; }
}
@media (max-width: 380px) {
  body.layout-duo .brand { display: none; }
  body.layout-duo .lines { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .platform-nav-btn { transition: none; }
}
