:root {
  --ink: #0b1f3a;
  --ink-2: #44546a;
  --ink-3: #7a8798;
  --line: #e4e8ee;
  --bg: #ffffff;
  --bg-2: #f4f6f9;
  --accent: #ffc629;
  --live: #10a35a;
  --late: #d64545;
  --early: #c27c0e;
  --shadow: 0 6px 24px rgba(11, 31, 58, .16), 0 1px 3px rgba(11, 31, 58, .12);
  --radius: 16px;
  --top: max(12px, env(safe-area-inset-top));
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #e9edf2; color: var(--ink); font: 15px/1.4 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; }

/* ---------- top bar ---------- */
.topbar { position: fixed; z-index: 20; top: var(--top); left: 12px; width: min(420px, calc(100vw - 24px)); display: flex; gap: 8px; align-items: center; }
.brand { flex: none; width: 46px; height: 46px; border: 0; border-radius: 13px; background: #0b1f3a; color: var(--accent); display: grid; place-items: center; box-shadow: var(--shadow); cursor: pointer; }
.search { position: relative; flex: 1; min-width: 0; }
.search input { width: 100%; height: 46px; border: 0; border-radius: 13px; padding: 0 14px 0 40px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); font: inherit; font-size: 16px; outline: none; -webkit-appearance: none; }
.search input:focus { box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
.search-ico { position: absolute; left: 13px; top: 14px; color: var(--ink-3); pointer-events: none; }
.icon-btn { flex: none; width: 46px; height: 46px; border: 0; border-radius: 13px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: #1d6fe0; }
.icon-btn.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.results { position: absolute; top: 52px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--bg); border-radius: 13px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
.results li { padding: 10px; border-radius: 9px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.results li[aria-selected="true"], .results li:hover { background: var(--bg-2); }
.results .num { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; }
.results .nm { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .empty { color: var(--ink-3); cursor: default; }

.banner { position: fixed; z-index: 21; top: calc(var(--top) + 56px); left: 12px; width: min(420px, calc(100vw - 24px)); background: #fff4d1; color: #5c4300; border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 14px; }
.zoomhint { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: 24px; background: rgba(11,31,58,.85); color: #fff; padding: 7px 14px; border-radius: 99px; font-size: 13px; pointer-events: none; }

/* ---------- panel ---------- */
.panel { position: fixed; z-index: 19; left: 12px; top: calc(var(--top) + 58px); bottom: 12px; width: min(420px, calc(100vw - 24px)); background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.grab { display: none; }
#panel-body { overflow: auto; flex: 1; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.stop-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 1; }
.stop-head .row { display: flex; gap: 8px; align-items: flex-start; }
.stop-head h1 { font-size: 18px; line-height: 1.25; margin: 0; font-weight: 700; }
.stop-num { margin-top: 3px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.round { flex: none; border: 0; background: var(--bg-2); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.round.on { color: #e0a100; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.updated { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); margin-top: 10px; min-height: 16px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(16,163,90,.6); } 70% { box-shadow: 0 0 0 7px rgba(16,163,90,0); } 100% { box-shadow: 0 0 0 0 rgba(16,163,90,0); } }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 24px; padding: 0 7px; border-radius: 6px; font-weight: 800; font-size: 13px; border: 1.5px solid transparent; white-space: nowrap; }
.badge.lg { min-width: 48px; height: 34px; font-size: 15px; border-radius: 9px; }

.deps { list-style: none; margin: 0; padding: 6px 8px 12px; }
.dep { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 8px; border-radius: 12px; cursor: pointer; border: 1.5px solid transparent; }
.dep:hover { background: var(--bg-2); }
.dep.sel { border-color: var(--accent); background: #fffaf0; }
.dep.cancelled { opacity: .55; }
.dep .dest { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep .meta { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.dep .when { text-align: right; font-variant-numeric: tabular-nums; }
.dep .mins { font-size: 21px; font-weight: 800; line-height: 1; }
.dep .mins small { font-size: 12px; font-weight: 600; margin-left: 2px; }
.dep .clock { font-size: 12px; color: var(--ink-3); margin-top: 3px; min-height: 15px; }
.st-live { color: var(--live); font-weight: 600; }
.st-late { color: var(--late); font-weight: 600; }
.st-early { color: var(--early); font-weight: 600; }
.st-sched { color: var(--ink-3); }
.st-cancel { color: var(--late); font-weight: 700; }
.wave { display: inline-block; width: 12px; height: 10px; vertical-align: -1px; }
.away.boarding { color: var(--live); font-weight: 700; }

.msg { padding: 28px 20px; color: var(--ink-2); text-align: center; }
.msg h2 { color: var(--ink); font-size: 17px; margin: 0 0 6px; }
.skeleton { height: 56px; margin: 8px 16px; border-radius: 12px; background: linear-gradient(90deg, var(--bg-2), var(--line), var(--bg-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.welcome { padding: 20px 18px; }
.welcome h1 { font-size: 21px; margin: 0 0 6px; }
.welcome h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 22px 0 6px; }
.welcome p { color: var(--ink-2); margin: 0 0 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stop-list { list-style: none; padding: 0; margin: 0; }
.stop-list li { padding: 10px 8px; border-radius: 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.stop-list li:hover { background: var(--bg-2); }
.stop-list .nm { font-weight: 600; font-size: 14px; }
.stop-list .d { margin-left: auto; color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.stop-list .chips { margin-top: 4px; }
.stop-list .chips .badge { height: 20px; min-width: 28px; font-size: 11.5px; }
.numtag { flex: none; background: #0b1f3a; color: #fff; font-weight: 700; font-size: 12px; border-radius: 7px; padding: 4px 7px; font-variant-numeric: tabular-nums; }
.btn { border: 0; background: #0b1f3a; color: #fff; padding: 11px 15px; border-radius: 11px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; }
.btn.alt { background: var(--accent); color: #0b1f3a; }
.tip { font-size: 13px; color: var(--ink-2); background: var(--bg-2); border-radius: 10px; padding: 10px 12px; margin-top: 14px; }
.foot { font-size: 11.5px; color: var(--ink-3); padding: 10px 16px 14px; border-top: 1px solid var(--line); }

/* ---------- map markers ---------- */
.stop-pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; background: #0b1f3a; transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.35); display: grid; place-items: center; }
.stop-pin span { transform: rotate(45deg); width: 10px; height: 10px; background: var(--accent); border-radius: 2px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1d6fe0; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(29,111,224,.2), 0 2px 6px rgba(0,0,0,.3); }

.bus { position: relative; width: 44px; height: 44px; cursor: pointer; }
.bus .arrow { position: absolute; inset: 0; }
.bus .arrow::before { content: ""; position: absolute; left: 50%; top: -2px; margin-left: -7px; border: 7px solid transparent; border-bottom: 10px solid var(--c, #0b1f3a); border-top: 0; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.bus .body { position: absolute; z-index: 1; left: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%; background: var(--c, #0b1f3a); color: var(--t, #fff); border: 2.5px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.35); display: grid; place-items: center; font-weight: 800; font-size: 11.5px; letter-spacing: -.02em; }
.bus.sel .body { width: 38px; height: 38px; left: 3px; top: 3px; font-size: 13px; box-shadow: 0 0 0 4px rgba(255,198,41,.9), 0 3px 12px rgba(0,0,0,.4); }
.bus.waiting .body { border-style: dashed; opacity: .8; }
.bus.moving::after { content: ""; position: absolute; left: 6px; top: 6px; width: 32px; height: 32px; border-radius: 50%; background: var(--c, #0b1f3a); animation: ring 1.6s ease-out infinite; }
.bus.sel.moving::after { left: 3px; top: 3px; width: 38px; height: 38px; }
@keyframes ring { from { transform: scale(1); opacity: .45; } to { transform: scale(2.3); opacity: 0; } }
.bus .lbl { position: absolute; z-index: 2; top: 44px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: #0b1f3a; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.bus .lbl:empty { display: none; }
.bus.stopped .lbl { background: var(--live); }

.maplibregl-popup-content { font: 13px Inter, system-ui, sans-serif; border-radius: 10px; padding: 7px 10px; box-shadow: var(--shadow); color: var(--ink); }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ---------- follow chip ---------- */
.follow { position: fixed; z-index: 21; right: 12px; top: var(--top); display: flex; align-items: center; gap: 8px; background: var(--bg); color: var(--ink); border-radius: 99px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow); font-size: 13px; font-weight: 600; }
.follow .badge { height: 20px; min-width: 28px; font-size: 12px; }
.follow button { border: 0; background: var(--bg-2); border-radius: 99px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 12px; }

/* ---------- phone ---------- */
@media (max-width: 720px) {
  .panel { left: 0; right: 0; width: 100%; top: auto; bottom: 0; height: 52vh; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); transition: height .25s ease; }
  .panel.collapsed { height: 128px; }
  .panel.welcome-mode { height: 44vh; }
  .grab { display: block; flex: none; border: 0; background: none; padding: 10px 0 2px; cursor: pointer; }
  .grab::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: #cfd6df; margin: 0 auto; }
  .stop-head { padding-top: 6px; }
  .follow { right: auto; left: 50%; transform: translateX(-50%); top: calc(var(--top) + 56px); white-space: nowrap; }
  .zoomhint { bottom: calc(44vh + 14px); }
}

[hidden] { display: none !important; }

/* ---------- map / satellite switch ---------- */
.layers { position: fixed; z-index: 18; right: 14px; bottom: 34px; width: 66px; height: 66px; border-radius: 14px; border: 3px solid #fff; padding: 0; cursor: pointer; box-shadow: var(--shadow); background-size: cover; background-position: center; display: flex; align-items: flex-end; overflow: hidden; }
.layers span { width: 100%; background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; font-size: 11.5px; font-weight: 700; padding: 10px 0 4px; text-align: center; }
.layers.show-sat { background-image: url("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/15/11169/7540"); }
.layers.show-map { background-color: #f2f1ee; background-image:
  linear-gradient(115deg, transparent 44%, #fbd38d 44%, #fbd38d 54%, transparent 54%),
  linear-gradient(20deg, transparent 60%, #fff 60%, #fff 66%, transparent 66%),
  linear-gradient(160deg, #9cd1f7 0 22%, transparent 22%),
  radial-gradient(circle at 75% 80%, #c5e8c1 0 22%, transparent 23%); }
.deps .dep:first-child .mins { font-size: 27px; }
@media (max-width: 720px) {
  .layers { top: calc(var(--top) + 58px); bottom: auto; right: 12px; width: 54px; height: 54px; border-radius: 12px; }
  .follow { top: calc(var(--top) + 118px); }
}

/* ---------- home tabs, live buses, alerts, fares ---------- */
.tabs { display: flex; gap: 4px; background: var(--bg-2); border-radius: 14px; padding: 4px; margin: 4px 0 12px; }
.tab { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 11px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.tab.on { background: var(--ink); color: #fff; }
.alert-chip, .adv-banner { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: #fdecea; color: #8c1d18; border-radius: 12px; padding: 9px 12px; font-weight: 600; font-size: 13px; text-align: left; cursor: pointer; margin-bottom: 10px; }
.alert-chip span, .adv-banner span { margin-left: auto; font-size: 16px; }
.adv-banner { margin: 10px 0 0; }
.range-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 4px 8px; }
.range-row .count { color: var(--ink-2); font-size: 14px; }
.stepper { display: flex; align-items: center; background: var(--bg-2); border-radius: 12px; padding: 3px; }
.stepper button { width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--bg); font-size: 18px; font-weight: 700; cursor: pointer; color: var(--ink); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper .val { min-width: 58px; text-align: center; line-height: 1.1; }
.stepper .val small { display: block; font-size: 10px; color: var(--ink-3); }
.bus-list, .next-stops { list-style: none; margin: 0; padding: 0; }
.bus-list li { display: flex; gap: 12px; align-items: center; padding: 10px 8px; border-radius: 12px; cursor: pointer; }
.bus-list li:hover, .next-stops li:hover { background: var(--bg-2); }
.bus-list .nm { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bus-list .sub { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.bus-list .d, .next-stops .d { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.next-stops li { display: flex; gap: 10px; align-items: center; padding: 9px 6px; border-radius: 10px; cursor: pointer; }
.next-stops i { width: 12px; height: 12px; border-radius: 50%; border: 3px solid; background: #fff; flex: none; }
.next-stops span:nth-child(2) { flex: 1; }
.fare-btn { background: var(--accent); color: var(--ink); }
.legal, .muted { color: var(--ink-3); font-size: 12px; line-height: 1.45; }
.small { font-size: 12px; }
#sheet { position: fixed; inset: 0; z-index: 50; background: rgba(11,31,58,.45); display: flex; justify-content: center; align-items: flex-end; }
#sheet[hidden] { display: none; }
.sheet-card { background: var(--bg-2); width: min(560px, 100vw); max-height: 92vh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
@media (min-width: 721px) { #sheet { align-items: center; } .sheet-card { border-radius: 20px; max-height: 88vh; } }
.sheet-card header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.sheet-card header h1 { font-size: 18px; margin: 0; }
.sheet-card header span { width: 36px; }
.sheet-body { overflow: auto; padding: 16px; }
.sheet-body h2 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 18px 4px 8px; }
.sheet-card footer { background: var(--bg); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(11,31,58,.08); }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--bg); border-radius: 99px; padding: 8px 14px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.notice { background: #fff4d1; color: #5c4300; border-radius: 14px; padding: 11px 13px; font-size: 13.5px; margin-top: 4px; }
.table { background: var(--bg); border-radius: 16px; padding: 0 14px; }
.tr { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.tr:first-child { border-top: 0; }
.tr small { display: block; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.tr span { font-weight: 600; }
.tr.na, .tr.na b { color: var(--ink-3); font-weight: 400; }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.amt { border: 1.5px solid transparent; background: var(--bg); border-radius: 14px; padding: 13px 0; font-weight: 700; font-size: 16px; color: var(--ink-2); cursor: pointer; }
.amt.on { border-color: var(--ink); color: var(--ink); }
.pass { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; border: 1.5px solid transparent; background: var(--bg); border-radius: 16px; padding: 14px; margin-bottom: 8px; cursor: pointer; text-align: left; font-size: 15px; color: var(--ink); }
.pass small { display: block; color: var(--ink-2); font-size: 12.5px; font-weight: 400; margin-top: 2px; }
.pass.on { border-color: var(--ink); }
.card-input { width: 100%; height: 52px; border: 1.5px solid var(--line); border-radius: 14px; padding: 0 14px; font-size: 16px; letter-spacing: 1px; background: var(--bg); color: var(--ink); }
.methods { background: var(--bg); border-radius: 16px; padding: 0 14px; opacity: .6; }
.method { padding: 13px 0; border-top: 1px solid var(--line); font-weight: 600; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.method:first-child { border-top: 0; }
.brands { display: flex; gap: 5px; }
.brands i { font-style: normal; color: #fff; font-size: 10.5px; font-weight: 800; border-radius: 4px; padding: 2px 6px; }
.total { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--ink-2); }
.total b { color: var(--ink); font-size: 18px; }
.btn.wide { display: flex; justify-content: center; width: 100%; text-decoration: none; padding: 14px; border-radius: 14px; }
details.adv { background: var(--bg); border-radius: 16px; padding: 14px; margin-bottom: 10px; border-left: 4px solid var(--early); }
details.adv.urgent { border-left-color: var(--late); }
details.adv summary { cursor: pointer; list-style: none; }
details.adv summary b { display: block; font-size: 15px; }
details.adv summary small { color: var(--ink-3); font-size: 12px; }
details.adv summary .chips { display: flex; gap: 4px; margin-top: 6px; }
details.adv p { margin: 6px 0; color: var(--ink-2); font-size: 14px; }
details.adv p.lvl1 { padding-left: 8px; }
details.adv p.lvl2 { padding-left: 24px; }
