/* ══════════════════════════════════════════════════════════════
   mybustop — one roadside board
   Red banner + white face; rows are plate · direction · mins.
   ══════════════════════════════════════════════════════════════ */
:root {
  /* Peeks through the banner's rounded top corners + the status-bar inset.
     Follows the phone theme so dark-mode users don't get two white wedges. */
  --page: #ffffff;
  --canvas: #2a2a2c;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #aeaeb2;
  --hairline: #e3e3e6;
  --accent: #007aff;
  --fill: rgba(118,118,128,.12);
  --sep-lt: rgba(60,60,67,.12);
  --arrive: #e4002b;
  --red: #c8102e;
  --eta-hot: #e4002b;
  --eta-warm: #c67a00;
  --eta-calm: #1d1d1f;
  --eta-hot-bg: #fff6f6;
  --eta-hot-bd: #f3c1c3;
  --eta-warm-bg: #fff8ec;
  --eta-warm-bd: #efd3a0;

  --kmb: #e4002b;
  --ctb: #ffd100;
  --gmb: #00994d;
  --nlb: #0069c0;

  --r-lg: 18px;
  --r-md: 12px;
  --spring: cubic-bezier(.32,.72,0,1);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --plate: "Barlow Condensed", "Arial Narrow", "Helvetica Neue",
    "DIN Alternate", "PingFang HK", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root { --page: #000000; }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
  color-scheme: light dark;
  background: var(--page);
}
[hidden] { display: none !important; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "PingFang HK", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: none;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}
body.sheet-open { overflow: hidden; }
::selection { background: rgba(0,122,255,.18); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Full-bleed page; only the red banner is rounded ─────────── */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 0;
  min-height: 0;
}
.sign {
  position: relative;
  flex: 1;
  width: 100%;
  min-width: 0;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 18px 18px 0 0;
}
.sign.is-empty .board { display: none; }

.banner {
  position: relative;
  background: var(--red);
  color: #fff;
  min-height: 38px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}
.ops { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.op {
  height: 18px; padding: 0 5px;
  border-radius: 2px;
  font-family: var(--plate);
  font-size: 10px; font-weight: 800;
  letter-spacing: .04em;
  display: flex; align-items: center; line-height: 1;
}
.op.kmb { background: #fff; color: var(--kmb); }
.op.ctb { background: var(--ctb); color: #111; }
.op.gmb { background: #fff; color: var(--gmb); }
.op.nlb { background: #fff; color: var(--nlb); }
.banner-title {
  flex: 1;
  font-size: 15px; font-weight: 800;
  letter-spacing: -.2px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.title-clock {
  flex-shrink: 0;
  opacity: .78;
  display: block;
}
.credit {
  font-family: var(--plate);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  color: rgba(255,255,255,.42);
  flex-shrink: 0;
}
@media (max-width: 420px) {
  .credit { display: none; }
}
.banner-clock {
  font-family: var(--plate);
  font-size: 16px; font-weight: 800;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.banner-wx {
  font-family: var(--plate);
  font-size: 15px; font-weight: 800;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,.88);
  flex-shrink: 0;
}

.sync-progress {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px; background: transparent;
}
.sync-progress.run::after {
  content: ""; display: block; height: 100%;
  background: rgba(255,255,255,.75);
  transform-origin: left;
  animation: syncbar 30s linear forwards;
}
@keyframes syncbar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.ptr {
  position: absolute;
  top: 100%; left: 0; right: 0;
  height: 0;
  overflow: hidden;
  display: flex; align-items: flex-start; justify-content: center;
  transition: height .22s ease;
  z-index: 9;
}
.ptr .spinner { margin-top: 8px; }

.edit-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff8e6; border-bottom: 1px solid #f2e3b3;
  color: #7a5b00; font-size: 13px; font-weight: 500;
  padding: 10px 16px;
}
.edit-done {
  font-family: inherit; border: none; background: none;
  color: var(--accent); font-size: 15px; font-weight: 600;
  padding: 8px 10px; cursor: pointer; min-height: 44px;
}

.board {
  flex: 1;
  width: 100%;
  padding: 4px 16px 8px;
  background: #fff;
  min-height: 0;
  overflow: auto;
}
@media (min-width: 720px) {
  .banner { padding-left: 20px; padding-right: 20px; }
  .board { padding: 8px 28px 12px; }
}

.capsule {
  position: relative;
  padding: 6px 0 2px;
  animation: cardIn .5s cubic-bezier(.2,.7,.2,1) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.capsule + .capsule { border-top: 1px solid var(--hairline); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
}

.stop-line {
  display: flex;
  align-items: baseline;
  gap: 0;
  padding: 8px 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
.stop-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.2;
  flex-shrink: 0;
}
.dotsep {
  color: #c7c7cc;
  margin: 0 6px;
  font-weight: 500;
  flex-shrink: 0;
}
.stop-en {
  font-family: var(--plate);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink-2);
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stop-street {
  font-size: 12px;
  color: var(--ink-3);
  flex-shrink: 2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.routes { padding-left: 16px; }

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline);
}
.row:last-child { border-bottom: none; }
.row.tap { cursor: pointer; outline: none; box-shadow: none; }
.row.tap .dir-tc::after {
  content: " ›";
  color: rgba(60,60,67,.32);
  font-weight: 400;
}
.row.tap:active { background: #f6f6f7; }
.row.tap:focus,
.row.tap:focus-visible { outline: none; }
body.editing .row.tap { cursor: default; }
body.editing .row.tap .dir-tc::after { content: none; }
body.editing .row.tap:active { background: #fffdf6; }
body.editing .row { grid-template-columns: auto minmax(0, 1fr) auto auto; }
@media (max-width: 480px) {
  body.editing .row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  body.editing .row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding: 0 0 4px;
  }
}

/* roadside plate */
.plate {
  flex-shrink: 0;
  box-sizing: border-box;
  min-width: 56px;
  height: 38px;
  padding: 0 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--plate);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.plate[data-len="4"] { font-size: 22px; min-width: 62px; }
.plate[data-len="5"],
.plate[data-len="6"] { font-size: 18px; min-width: 68px; }
.plate.ctb { background: var(--ctb); color: #111; }
.plate.kmb { background: var(--kmb); color: #fff; }
.plate.gmb { background: var(--gmb); color: #fff; }
.plate.nlb { background: var(--nlb); color: #fff; }

.dir { min-width: 0; }
.row .dir-tc {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .dir-en {
  margin-top: 1px;
  font-family: var(--plate);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.eta-area {
  min-width: 68px;
  text-align: right;
}
.eta { color: var(--ink); }
.eta-next {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
}
.eta-num {
  font-family: var(--plate);
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.9;
}
.eta-unit {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
}
.eta.arriving .eta-num {
  font-size: 18px;
  letter-spacing: 0;
  color: var(--arrive);
}
.eta.hot .eta-num { color: var(--eta-hot); }
.eta.warm .eta-num { color: var(--eta-warm); }
.eta.calm .eta-num { color: var(--eta-calm); }
.eta.muted .eta-num {
  font-size: 22px;
  color: var(--ink-3);
  font-weight: 700;
}
.later {
  margin-top: 2px;
  font-family: var(--plate);
  font-size: 12px;
  font-weight: 700;
  color: #9a9a9e;
  letter-spacing: .02em;
}
.later em { font-style: normal; font-weight: 600; margin-right: 3px; }
.row.flash .eta-num { animation: etaflash .45s ease-out; }
@keyframes etaflash { 0% { opacity: .35; } }

.co-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.co-dot.kmb { background: var(--kmb); }
.co-dot.ctb { background: #c79100; }
.co-dot.gmb { background: var(--gmb); }
.co-dot.nlb { background: var(--nlb); }

@keyframes pulse { 50% { opacity: .3; } }

.sk { border-radius: 6px; background: var(--fill); animation: shimmer 1.4s ease-in-out infinite; }
.sk-eta { height: 28px; width: 44px; margin-left: auto; }
@keyframes shimmer { 50% { opacity: .4; } }

/* ── Thumb dock ───────────────────────────────────────────────── */
.dock {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  border-top: 1px solid #eee;
  background: #fafafa;
  padding: 3px 4px calc(3px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.dock.no-acct { grid-template-columns: 1fr 1fr 1fr; }
.dock button {
  appearance: none; border: 0; background: none;
  font-family: inherit; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 2px 4px 1px; min-height: 0; cursor: pointer;
}
.dock button:active { opacity: .4; }
.dock .ico {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  font-size: 16px; line-height: 1;
}
.dock .lab { font-size: 9px; font-weight: 600; color: #5c5c5c; line-height: 1.15; }
.dock .add .ico {
  width: 26px; height: 26px; border-radius: 50%;
  background: #1d1d1f; color: #fff; font-size: 18px;
}
.dock .add .lab { color: var(--ink); }
body.editing #editBtn .lab { color: var(--accent); }
#accountBtn .ico { position: relative; }
.acct-dot {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #30d158;
  right: 1px; top: 1px;
  border: 1.5px solid #fafafa;
}
#accountBtn.signed .lab {
  color: #0a7a32;
  font-weight: 800;
}
#accountBtn.signed .ico { color: #0a7a32; }

/* ── Edit mode ────────────────────────────────────────────────── */
body.editing .capsule { outline: none; }
body.editing .row { background: #fffdf6; }
.row-actions {
  display: none;
  gap: 6px;
  align-items: center;
}
body.editing .row-actions { display: flex; }
.mini-btn {
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  width: 42px; height: 42px;
  background: var(--card);
  color: var(--ink-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  cursor: pointer;
}
.mini-btn:active { opacity: .4; }
.mini-btn.del { color: #ff3b30; border-color: #f3c1c3; }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 32px;
  text-align: center;
  background: #fff;
  min-height: 0;
}
.empty-art { margin-bottom: 6px; }
.pulse-ring { transform-origin: 60px 60px; animation: ringPulse 2.4s ease-out infinite; }
@keyframes ringPulse { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
.mini-bus { animation: busDrive 4.5s ease-in-out infinite; }
@keyframes busDrive { 0%, 25% { transform: translateX(0); } 55%, 100% { transform: translateX(52px); } }
.empty-title { font-size: 19px; font-weight: 600; letter-spacing: -0.3px; }
.empty-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.empty-cta {
  margin-top: 24px;
  font-family: inherit; font-size: 17px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 14px;
  padding: 14px 36px;
  cursor: pointer; min-height: 54px;
}
.cta-sub { font-size: 11px; font-weight: 400; opacity: .8; }
.empty-cta:active { opacity: .55; }

/* ── Bottom sheet (add-stop wizard) ───────────────────────────── */
/* Never paint a closed <dialog> — any display:flex on .sheet would
   override the UA's dialog:not([open]) { display:none } and leave a
   blank undismissable sheet on the page. */
dialog.sheet:not([open]) { display: none !important; }

.sheet {
  position: fixed;
  top: auto;                    /* beat UA dialog inset:0 */
  left: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 520px;
  margin-left: auto; margin-right: auto;
  max-height: 92dvh;
  border: none;
  border-radius: 20px 20px 0 0;
  background: var(--card);
  color: var(--ink);
  padding: 8px 20px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0,0,0,.14);
  animation: sheetIn .8s cubic-bezier(.22, 1, .36, 1) both;
  overflow: visible;
}
@keyframes sheetIn { from { transform: translateY(100%); } }
.sheet.closing {
  animation: none;
}

/* Add-stop lookup: centered card (beats UA dialog inset + bottom-sheet rules) */
.sheet.as-modal {
  inset: unset;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: min(420px, calc(100vw - 28px));
  max-width: min(420px, calc(100vw - 28px));
  max-height: min(88dvh, 680px);
  height: fit-content;
  margin: 0;
  border-radius: 20px;
  transform: translate(-50%, -50%);
  animation: modalIn .4s var(--spring);
  box-shadow: 0 16px 48px rgba(0,0,0,.22);
  overflow: auto;
  padding: 16px 20px 18px;
}
.sheet.as-modal .sheet-grab { display: none; }
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.96); }
}
.sheet.as-modal.closing { animation: none; }
@keyframes modalOut {
  to { opacity: 0; transform: translate(-50%, -42%) scale(.96); }
}
.sheet::backdrop {
  background: rgba(29,29,31,.4);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: fade .3s ease both;
}
.sheet.closing::backdrop {
  animation: none;
  opacity: 0;
  transition: opacity .7s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.sheet-grab {
  width: 36px; height: 5px; border-radius: 3px;
  background: rgba(60,60,67,.3);
  margin: 4px auto 12px;
}
.sheet-head {
  position: relative;
  display: flex; justify-content: center; align-items: center;
  margin-bottom: 16px;
}
.sheet-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.sheet-close {
  position: absolute; right: 0; top: 50%;
  transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  background: var(--fill); border: none;
  color: var(--ink-2);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
}
.step { animation: stepIn .28s var(--spring); }
@keyframes stepIn { from { opacity: 0; transform: translateX(24px); } }

.field-label {
  display: block;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}
.fl-en { color: var(--ink-3); font-weight: 500; }
.mode-tabs {
  display: flex;
  background: var(--fill);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}
.mode-tab {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 36px;
}
.mode-tab span {
  font-weight: 500;
  color: var(--ink-3);
  font-size: 12px;
}
.mode-tab.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.mode-tab.on span { color: var(--ink-2); }
.route-row { display: flex; gap: 8px; }
.route-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  background: var(--fill);
  border: none;
  border-radius: 11px;
  padding: 12px 14px;
  outline: none;
  text-transform: uppercase;
  transition: box-shadow .18s, background .18s;
}
.route-input:focus { background: #fff; box-shadow: 0 0 0 2px var(--accent); }
.route-input.as-place { text-transform: none; }
.stop-filter {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  background: var(--fill);
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  margin-bottom: 10px;
  -webkit-appearance: none;
  appearance: none;
}
.stop-filter:focus { background: #fff; box-shadow: 0 0 0 2px var(--accent); }
.place-hint {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
  padding: 7px 4px;
}
.place-hits { margin-top: 12px; max-height: 38dvh; }
.s-co {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 3px 6px;
  border-radius: 6px;
  min-width: 36px;
  text-align: center;
}
.s-co.kmb { background: rgba(228,0,43,.12); color: var(--kmb); }
.s-co.ctb { background: rgba(199,145,0,.16); color: #9a6b00; }
.s-co.nlb { background: rgba(0,105,192,.12); color: var(--nlb); }
.s-co.gmb { background: rgba(0,153,77,.12); color: var(--gmb); }
.dir-plate {
  flex-shrink: 0;
  font-family: var(--plate);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .02em;
  min-width: 42px;
  text-align: center;
}
.btn-primary {
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 22px;
  min-width: 92px;
  min-height: 52px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:active { opacity: .55; }
.field-error { color: #e5484d; font-size: 13.5px; margin-top: 10px; font-weight: 500; }

.op-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.op-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  background: var(--canvas);
  border-radius: 9999px; padding: 7px 12px;
}
.op-chip i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.op-chip i.ctb { background: #c79100; }
.op-chip i.kmb { background: var(--kmb); }
.op-chip i.gmb { background: var(--gmb); }
.op-chip i.nlb { background: var(--nlb); }

/* iOS grouped lists for direction + stop picking */
.dir-choices, .stop-list {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow: hidden;
}
.stop-list {
  max-height: 52dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.dir-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: none;
  border-bottom: 1px solid var(--sep-lt);
  padding: 12px 16px;
  min-height: 60px;
  cursor: pointer;
  font-family: inherit;
  position: relative;
}
.dir-btn:last-child { border-bottom: none; }
.dir-btn:active { background: var(--sep-lt); }
.dir-co { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.dir-text { min-width: 0; }
.dir-tc { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.dir-tc small { color: var(--ink-3); font-weight: 400; }
.dir-en {
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dir-btn::after, .stop-item::after {
  content: "›";
  margin-left: auto;
  color: rgba(60,60,67,.3);
  font-size: 21px;
  font-weight: 400;
  padding-left: 6px;
  flex-shrink: 0;
}
.stop-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: none;
  border-bottom: 1px solid var(--sep-lt);
  color: var(--ink);
  font-family: inherit;
  padding: 13px 16px;
  min-height: 56px;
  cursor: pointer;
  font-size: 15.5px;
  font-weight: 500;
}
.stop-item:last-child { border-bottom: none; }
.stop-item:active { background: var(--sep-lt); }
.s-seq {
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  min-width: 22px;
}
.s-en { color: var(--ink-2); font-size: 12.5px; font-weight: 400; }

.sheet-foot {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px;
}
.btn-back {
  background: none; border: none;
  color: var(--accent); font-size: 17px; font-weight: 400;
  cursor: pointer; font-family: inherit;
  padding: 12px 14px 12px 0; min-height: 48px;
}
.btn-back:active { opacity: .35; }
.foot-hint { display: none; }
.loading {
  margin-top: 14px;
  font-size: 14px; color: var(--ink-2); font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ───────────────────────────────────────────────────── */
.toast-zone {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 60; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  background: rgba(29,29,31,.92);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #f5f5f7;
  font-size: 14px; font-weight: 500;
  border-radius: 9999px;
  padding: 12px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: toastIn .32s cubic-bezier(.2,.8,.2,1);
  max-width: 92vw;
}
.toast.out { animation: toastOut .25s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.94); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.96); } }
.toast-action {
  font-family: inherit; border: none; background: none;
  color: #6cb6ff; font-size: 14px; font-weight: 600;
  cursor: pointer; padding: 4px 2px; white-space: nowrap;
}

/* refresh icon spin */
#refreshBtn.spinning .refresh-ico { animation: spin .8s linear infinite; }

/* ── Footer ───────────────────────────────────────────────────── */
.footer {
  text-align: center;
  color: #8e8e93;
  font-size: 11px;
  line-height: 1.45;
  padding: 6px 14px 4px;
  background: #fff;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ── Sign-in reminder (local stops, not signed in) ────────────── */
.login-nudge {
  position: absolute;
  left: 10px; right: 10px;
  bottom: calc(50px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 10px 14px;
  background: #1d1d1f;
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
  animation: toastIn .32s var(--spring);
}
.sign.has-nudge .board { padding-bottom: 72px; }
.nudge-copy { flex: 1; min-width: 0; text-align: left; }
.nudge-copy strong {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -.2px;
}
.nudge-copy span {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.3;
  color: rgba(255,255,255,.62);
}
.nudge-cta {
  flex-shrink: 0;
  border: 0;
  background: #ffd100;
  color: #111;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 36px;
  cursor: pointer;
}
.nudge-cta:active { opacity: .55; }
.nudge-x {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border: 0; background: transparent;
  color: rgba(255,255,255,.5);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.nudge-x:active { opacity: .4; }

/* ── Account / cloud backup ───────────────────────────────────── */
.acct-lead {
  font-size: 15px; line-height: 1.65; color: var(--ink);
  margin: 2px 0 18px;
}
.acct-en { color: var(--ink-2); font-size: 13.5px; }
.g-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 14px;
  font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
}
.g-btn:active { background: var(--canvas); }
.gis-btn {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 44px;
}
.acct-note {
  margin-top: 14px; text-align: center;
  font-size: 12px; color: var(--ink-3); line-height: 1.6;
}
.acct-user { display: flex; align-items: center; gap: 12px; margin: 4px 0 6px; }
.acct-ava {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--fill); object-fit: cover; flex-shrink: 0;
}
.acct-ava-fb {
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600; color: var(--ink-2);
}
.acct-id { min-width: 0; }
.acct-name { font-size: 17px; font-weight: 600; }
.acct-mail {
  font-size: 13px; color: var(--ink-2); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-sync {
  margin-top: 14px; padding: 12px 14px;
  background: var(--canvas); border-radius: 12px;
  font-size: 13.5px; color: var(--ink-2);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.acct-sync .ok {
  width: 8px; height: 8px; border-radius: 50%;
  background: #30d158; flex-shrink: 0;
}
.acct-when { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.acct-signout {
  width: 100%; margin-top: 14px; min-height: 52px;
  border: 1px solid #f3c1c3; color: #ff3b30; background: #fff;
  border-radius: 14px; font-size: 16px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.acct-signout:active { opacity: .4; }

/* ── Route timeline sheet ─────────────────────────────────────── */
.sheet.route-sheet[open] {
  height: min(88dvh, 820px);
  max-height: 92dvh;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: sheetIn .8s cubic-bezier(.22, 1, .36, 1) both;
}
.sheet.route-sheet[open].closing {
  animation: none;
}
.route-hd {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.route-hd .plate { min-width: 58px; height: 40px; font-size: 27px; }
.route-hd-copy { min-width: 0; flex: 1; padding-top: 1px; }
.route-hd-tc {
  font-size: 16px; font-weight: 800; letter-spacing: -.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.route-hd-en {
  font-family: var(--plate); font-size: 13px; font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.route-hd-meta {
  margin-top: 3px;
  font-size: 11px; font-weight: 600; color: var(--ink-3);
}
.route-hd-later {
  margin-top: 2px;
  font-family: var(--plate); font-size: 12px; font-weight: 700;
  color: #9a9a9e;
}
.route-eta {
  display: flex; align-items: baseline; gap: 4px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 10px; padding: 6px 10px 5px;
  flex-shrink: 0;
}
.route-eta b {
  font-family: var(--plate); font-size: 26px; font-weight: 800;
  line-height: .85; color: var(--eta-calm);
}
.route-eta span { font-size: 10px; font-weight: 700; color: var(--ink-3); }
.route-eta.now,
.route-eta.hot {
  background: var(--eta-hot-bg);
  border-color: var(--eta-hot-bd);
}
.route-eta.now b,
.route-eta.hot b { color: var(--eta-hot); }
.route-eta.warm {
  background: var(--eta-warm-bg);
  border-color: var(--eta-warm-bd);
}
.route-eta.warm b { color: var(--eta-warm); }
.route-eta.calm { background: #fff; border-color: var(--hairline); }
.route-eta.calm b { color: var(--eta-calm); }
.route-eta.muted { background: #f4f4f5; border-color: var(--hairline); }
.route-eta.muted b { color: var(--ink-3); font-size: 22px; }
.route-hd .sheet-close { position: static; transform: none; flex-shrink: 0; }
.route-legend {
  display: flex; gap: 12px; padding: 8px 16px 6px;
  font-size: 11px; font-weight: 600; color: var(--ink-2);
  flex-shrink: 0;
}
.route-legend i {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 5px; vertical-align: 0;
}
.route-legend .p { background: #d0d0d4; }
.route-legend .h { background: var(--arrive); box-shadow: 0 0 0 3px rgba(228,0,43,.18); }
.route-legend .r { background: var(--ink); }
.route-tl {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px 16px 16px 14px;
}
.route-load, .route-fail { margin: 8px 16px 4px; flex-shrink: 0; }
.rt-stop {
  display: grid;
  grid-template-columns: 18px 28px minmax(0,1fr) auto;
  gap: 8px;
  align-items: start;
  position: relative;
  min-height: 44px;
  padding: 8px 0;
}
.rt-rail {
  position: relative;
  width: 18px;
  align-self: stretch;
}
.rt-rail::before {
  content: "";
  position: absolute; left: 7px; top: -8px; bottom: -8px;
  width: 2px; background: #e5e5ea;
}
.rt-stop:first-child .rt-rail::before { top: 14px; }
.rt-stop:last-child .rt-rail::before { bottom: auto; height: 14px; }
.rt-stop.remain .rt-rail::before,
.rt-stop.end .rt-rail::before { background: #1d1d1f; }
.rt-stop.here .rt-rail::before {
  background: linear-gradient(#d0d0d4 0 14px, #1d1d1f 14px);
}
.rt-node {
  position: absolute; left: 3px; top: 12px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #d0d0d4;
  box-shadow: 0 0 0 3px #fff;
  z-index: 1;
}
.rt-stop.remain .rt-node,
.rt-stop.end .rt-node { background: #1d1d1f; }
.rt-stop.here .rt-node {
  width: 14px; height: 14px; left: 1px; top: 10px;
  background: #fff;
  border: 3px solid var(--arrive);
  box-shadow: 0 0 0 4px rgba(228,0,43,.14);
}
.rt-stop.end .rt-node { border-radius: 3px; }
.rt-seq {
  font-family: var(--plate); font-size: 12px; font-weight: 700;
  color: var(--ink-3); padding-top: 10px;
}
.rt-nm { min-width: 0; padding-top: 6px; }
.rt-tc { font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.rt-en { font-family: var(--plate); font-size: 12px; font-weight: 600; color: var(--ink-2); }
.rt-mins {
  font-family: var(--plate); font-weight: 800; font-size: 16px;
  padding-top: 8px; color: var(--ink); text-align: right;
  min-width: 44px;
}
.rt-mins small { font-size: 10px; font-weight: 600; color: var(--ink-3); margin-left: 1px; }
.rt-stop.passed { opacity: .38; }
.rt-stop.passed .rt-tc { text-decoration: line-through; text-decoration-thickness: 1px; }
.rt-stop.passed .rt-mins { color: var(--ink-3); font-weight: 600; font-size: 12px; padding-top: 10px; }
.rt-stop.here {
  background: #fff8f8;
  margin: 2px -10px;
  padding-left: 10px; padding-right: 10px;
  border-radius: 12px;
}
.rt-you {
  display: inline-block;
  margin-top: 3px;
  font-size: 10px; font-weight: 800;
  letter-spacing: .04em;
  color: var(--arrive);
  background: #ffe8ea;
  border-radius: 4px;
  padding: 2px 6px;
}
.rt-stop.here .rt-mins { font-size: 20px; }
.rt-stop.here .rt-mins.now,
.rt-stop.here .rt-mins.hot { color: var(--eta-hot); }
.rt-stop.here .rt-mins.warm { color: var(--eta-warm); }
.rt-stop.here .rt-mins.calm { color: var(--eta-calm); }
.rt-stop.end {
  position: sticky;
  bottom: 0;
  background: linear-gradient(#fff0, #fff 18%);
  margin-top: 2px;
  padding-bottom: 10px;
  z-index: 2;
}
.rt-skip {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
  padding: 2px 0;
}
.rt-skip .rt-rail { height: 28px; align-self: auto; }
.rt-skip .rt-rail::before {
  top: 0; bottom: 0;
  background: repeating-linear-gradient(#d0d0d4 0 3px, transparent 3px 6px);
}
.rt-skip.ahead .rt-rail::before {
  background: repeating-linear-gradient(#1d1d1f 0 3px, transparent 3px 6px);
}
.rt-skip-btn {
  justify-self: start;
  font-family: inherit;
  font-size: 11px; font-weight: 700; color: var(--ink-3);
  background: #f2f2f4;
  border: none; border-radius: 999px;
  padding: 6px 10px;
  min-height: 28px;
  cursor: pointer;
}
.rt-skip.ahead .rt-skip-btn { color: var(--ink-2); }
.rt-skip-btn:active { opacity: .55; }
.rt-bus {
  position: relative;
  height: 22px;
  margin: -2px 0;
}
.rt-bus .rt-rail {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 18px;
}
.rt-bus .rt-rail::before { top: 0; bottom: 0; background: #d0d0d4; }
.rt-bus-ico {
  position: absolute; left: -3px; top: 3px;
  width: 24px; height: 16px; border-radius: 4px;
  background: #1d1d1f; color: #fff;
  font-family: var(--plate); font-size: 9px; font-weight: 800;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.16);
  z-index: 2;
}
.rt-bus-ico.ctb { background: var(--ctb); color: #111; }
.rt-bus-ico.kmb { background: var(--kmb); color: #fff; }
.rt-bus-ico.gmb { background: var(--gmb); color: #fff; }
.rt-bus-ico.nlb { background: var(--nlb); color: #fff; }
.rt-bus-lbl {
  position: absolute; left: 28px; top: 3px;
  font-size: 10px; font-weight: 700; color: var(--ink-2);
  white-space: nowrap;
}
.rt-mins .sk { width: 28px; height: 14px; display: inline-block; }
