:root {
  --bg: #0d0f0a;
  --panel: #15180f;
  --panel-2: #1b1f13;
  --line: #2c3120;
  --brass: #c9a24a;
  --brass-dim: #8a7136;
  --amber: #ffb627;
  --amber-glow: rgba(255, 182, 39, 0.45);
  --green: #9be15d;
  --text: #e8e2cc;
  --muted: #8d8a78;
  --red: #ff6b4a;
  --led: "Consolas", "SFMono-Regular", "Menlo", "Noto Sans Mono CJK TC", monospace;
  --cjk: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(ellipse at top, #1a1e12 0%, var(--bg) 60%) fixed;
  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: 2px solid var(--brass-dim);
  background: linear-gradient(#1c2014, #12150d);
}

.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark {
  font-size: 26px; font-weight: 800; letter-spacing: 4px;
  color: var(--brass);
  text-shadow: 0 0 8px rgba(201, 162, 74, 0.35);
}
.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: #262b19; }
.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: 6px;
}
.station-names h1 { margin: 0; font-size: 44px; letter-spacing: 6px; color: #f5ecd0; }
.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 10px var(--amber-glow);
  border: 1px solid var(--brass-dim); padding: 2px 10px; border-radius: 4px;
}
.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: #23281a; color: var(--brass); border: 1px solid var(--line);
}

.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);
  border: 1px dashed var(--line); border-radius: 4px;
}
.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: #3d5a24; }
.flag.warn { color: var(--amber); border-color: var(--brass-dim); }
.flag.bad { color: var(--red); border-color: #6b2a1d; }

.error {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 4px;
  background: #2a130d; border: 1px solid #6b2a1d; color: #ffb4a0; font-size: 14px;
}

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

.platform {
  background: #090a06;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}
.platform-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(#2a2614, #1b1a0e);
  border-bottom: 2px solid var(--brass-dim);
}
.platform-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brass); color: #16140a;
  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; }

.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-route { width: 80px; }
.rows th.col-cars { width: 90px; }
.rows th.col-time { width: 150px; text-align: right; }
.rows td {
  padding: 12px 14px; border-bottom: 1px solid #1a1d12;
  font-family: var(--led); vertical-align: middle;
}
.rows tr:last-child td { border-bottom: none; }
.rows .route {
  display: inline-block; min-width: 56px; text-align: center;
  font-size: 22px; font-weight: 800; color: #111;
  background: var(--amber); border-radius: 4px; padding: 2px 6px;
  box-shadow: 0 0 10px var(--amber-glow);
}
.rows .dest-ch { font-family: var(--cjk); font-size: 22px; color: var(--amber); text-shadow: 0 0 8px var(--amber-glow); }
.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 8px var(--amber-glow); }
.rows .time-en { font-size: 12px; color: var(--brass); margin-top: 2px; }
.rows .cars { white-space: nowrap; color: var(--muted); font-size: 12px; }
.car {
  display: inline-block; width: 18px; height: 10px; margin-right: 2px;
  border: 1px solid var(--amber); border-radius: 2px; background: rgba(255, 182, 39, 0.25);
  vertical-align: middle;
}
.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: #3d5a24; }
.tag.stop { color: var(--red); border-color: #6b2a1d; }

/* Train at / about to leave the platform ("-", Arriving, Departing) */
tr.imminent td { background: rgba(155, 225, 93, 0.06); }
tr.imminent .time-ch, tr.imminent .dest-ch { color: var(--green); text-shadow: 0 0 10px rgba(155, 225, 93, 0.55); }
tr.imminent .time-ch { animation: blink 1.1s steps(2, start) infinite; }
tr.imminent .route { background: var(--green); box-shadow: 0 0 12px rgba(155, 225, 93, 0.55); }
tr.stopped td { opacity: 0.6; }
tr.stopped .time-ch { color: var(--red); text-shadow: none; }

@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: 6px;
  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: var(--muted); font-size: 12px; line-height: 1.6;
}
.foot code { color: var(--brass); }

@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: #16140a;
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 10px var(--amber-glow);
  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-route { width: 64px; }
  .rows th.col-cars { width: 64px; }
  .rows th.col-time { width: 104px; }
  .rows th, .rows td { padding-left: 8px; padding-right: 8px; }
  .rows td { overflow-wrap: anywhere; }
  .rows .route { 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 .route { 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 .route { 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);
}
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-route { width: 56px; }
body.layout-duo .rows th.col-cars { 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 .route { 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 .cars { font-size: 11px; white-space: normal; }
body.layout-duo .car { width: 12px; height: 9px; margin-right: 1px; }

/* —— 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: linear-gradient(180deg, #1c2014 0%, #12150d 100%);
  border-right: 2px solid var(--brass-dim);
}
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: 10px;
  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: #262b19; border-color: var(--brass); }
.platform-nav-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.platform-nav-btn.is-active {
  color: #16140a;
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 12px var(--amber-glow);
}
.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: #16140a; 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: 2px solid var(--brass-dim);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
}
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: 999px;
}
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-route { width: 50px; }
  body.layout-duo .rows th.col-cars { width: 42px; }
  body.layout-duo .rows th.col-time { width: 86px; }
  body.layout-duo .rows .route { font-size: 16px; }
  body.layout-duo .rows .dest-ch { font-size: 18px; }
  body.layout-duo .rows .time-ch { font-size: 18px; }
  body.layout-duo .rows .cars .car-count { display: none; } /* icons still show length */
  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; }
}
