/* Bus Tracker - mobile-first transit UI.
   Layout: full-screen map; a bottom sheet (phones) / side panel (desktop) holds the boards.
   Palette: dark navy + white, amber accent taken from German station departure displays.
   Theme: data-theme on <html> is always set (by js/theme-boot.js), dark is the default. */
:root {
  --bg: #0b1b36;          /* navy */
  --bg-2: #11254a;        /* surfaces */
  --bg-3: #19325f;        /* raised / pressed */
  --fg: #f3f6fb;
  --muted: #9fb1cf;
  --line: #233a63;
  --accent: #f2b33d;      /* departure-board amber */
  --accent-fg: #1b1300;
  --live: #5fd39a;
  --late: #ff8a7a;
  --early: #5fd39a;
  --warn-bg: #3a2f12;
  --warn-fg: #f6d98a;
  --danger: #ff8a7a;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --radius: 14px;
  --panel-w: 400px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  color-scheme: dark;
  font-family: var(--font);
}
:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-2: #ffffff;
  --bg-3: #e8eef7;
  --fg: #0b1b36;
  --muted: #56667f;
  --line: #d9e1ed;
  --accent: #a96d00;
  --accent-fg: #ffffff;
  --live: #1f7a43;
  --late: #c62828;
  --early: #1f7a43;
  --warn-bg: #fff3d1;
  --warn-fg: #6b4b00;
  --danger: #c62828;
  --shadow: 0 6px 24px rgba(11, 27, 54, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* component display rules must not override hidden */
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: var(--s3) var(--s4); }
.pad-s { padding: var(--s2) 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-fg); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

#map { position: absolute; inset: 0 0 0 var(--panel-w); background: var(--bg-3); }

/* ---------- buttons */
.btn-primary { border: 0; background: var(--accent); color: var(--accent-fg); font-weight: 700; padding: 12px 18px; min-height: 44px; border-radius: 12px; }
.btn-primary.small { padding: 8px 12px; min-height: 36px; font-size: 14px; }
.btn-ghost, .btn-clear { border: 1px solid var(--line); background: var(--bg-2); padding: 8px 14px; min-height: 40px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.btn-ghost[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn-ghost.danger { color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.icon-btn { border: 0; background: transparent; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); flex: none; }
.icon-btn:hover:not(:disabled) { background: var(--bg-3); color: var(--fg); }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.kbd { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-3); font-size: 13px; }

/* ---------- panel (desktop: side panel) */
.panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: var(--panel-w);
  background: var(--bg); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 5;
  padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px);
}
.sheet-handle { display: none; }
.panel-head { padding: var(--s3) var(--s4) var(--s2); }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s3); }
.brand-icon { border-radius: 8px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 17px; letter-spacing: .2px; }
.brand-text .muted { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-pill { margin-left: auto; font-size: 12px; padding: 4px 10px; border-radius: 20px; background: var(--bg-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.mode-pill.lines { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 700; }

.search-wrap { position: relative; }
#search, #stop-search {
  width: 100%; padding: 11px 14px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--fg); font-size: 16px; outline: none;
}
#search:focus, #stop-search:focus { border-color: var(--accent); }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); max-height: 50vh; overflow: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 20;
}
.result { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; min-height: 48px; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--line); }
.result:last-child { border-bottom: 0; }
.result:hover, .result.active { background: var(--bg-3); }
.result .ln { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .cnt { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.result-msg { padding: 12px 14px; color: var(--muted); font-size: 14px; }
.result.selected .badge::after { content: " ✓"; }

.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 26px; padding: 0 7px;
  border-radius: 6px; font-weight: 800; font-size: 14px; letter-spacing: .2px; white-space: nowrap; flex: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); font-variant-numeric: tabular-nums;
}
.badge.sm { min-width: 36px; height: 24px; font-size: 13.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s2); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); }
.chip button { border: 0; background: none; padding: 0 8px; min-height: 36px; font-size: 18px; line-height: 1; color: var(--muted); }
.chip .chip-name { padding: 0 2px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 var(--s1); }
.tabs button {
  flex: 1; min-height: 54px; padding: 6px 2px; border: 0; background: none; border-bottom: 3px solid transparent;
  color: var(--muted); font-weight: 600; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabs button svg { width: 21px; height: 21px; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tab-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.panel-foot { padding: var(--s2) var(--s4); border-top: 1px solid var(--line); font-size: 12px; }

/* ---------- my stops */
.stop-search-wrap { position: relative; padding: var(--s3) var(--s4); }
.stop-search-wrap .search-results { left: var(--s4); right: var(--s4); }
.mine-head { display: flex; justify-content: space-between; align-items: center; padding: 0 var(--s4) var(--s2); font-size: 13px; }
.station { border-top: 1px solid var(--line); padding: var(--s3) var(--s4); }
.st-head { display: flex; align-items: center; gap: var(--s2); }
.st-head h3 { margin: 0; font-size: 17px; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-wrap: balance; }
.st-meta { font-size: 12.5px; margin: 0 0 var(--s2); }
.fresh { color: var(--live); }
.stale { color: var(--warn-fg); background: var(--warn-bg); padding: 2px 8px; border-radius: 6px; font-weight: 600; display: inline-block; }
.def-badge { font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--accent-fg); background: var(--accent); padding: 2px 6px; border-radius: 5px; }
.star { border: 0; background: none; font-size: 20px; line-height: 1; padding: 4px; min-width: 36px; min-height: 36px; color: var(--muted); }
.star.on { color: var(--accent); }

.bdep {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; width: 100%;
  border: 0; background: none; padding: 10px 0; min-height: 56px; text-align: left; font-size: 14px; border-top: 1px solid var(--line);
}
.station .bdep:first-of-type { border-top: 0; }
button.bdep:hover:not([disabled]) { background: var(--bg-2); }
.bdep .bm { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bdep .hs { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bdep .bsub { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.bdep .bt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.bdep .cd { font-size: 20px; font-weight: 800; letter-spacing: -.2px; }
.chip-d { font-size: 12.5px; font-weight: 700; }
.src-live { color: var(--live); font-weight: 650; }
.bdep.st-gone { opacity: .5; }
.bdep.st-gone .hs { font-weight: 450; }
.bdep.st-cancelled .hs { text-decoration: line-through; color: var(--muted); }
.bdep.st-unknown .sched { font-weight: 700; font-size: 15px; }
.bdep.cached .bt b { font-size: 17px; }
.bdep.passed { opacity: .5; }
.maybe { display: inline-block; font-size: 11.5px; font-weight: 800; color: var(--warn-fg); background: var(--warn-bg); border-radius: 6px; padding: 1px 6px; }
.typical { color: var(--muted); font-style: italic; }
.gps { display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .4px; color: var(--accent-fg); background: var(--accent); border-radius: 5px; padding: 0 5px; }
.legend { font-size: 12px; padding: var(--s3) var(--s4); }
details.alerts summary { cursor: pointer; font-size: 13px; color: var(--warn-fg); font-weight: 700; padding: 2px 0 6px; min-height: 32px; }
.alert { background: var(--warn-bg); color: var(--warn-fg); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 6px 0; }

.station.editing { display: flex; flex-direction: column; gap: var(--s2); }
.label-input { width: 100%; padding: 10px 12px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); font-size: 16px; }
.edit-row { display: flex; flex-wrap: wrap; gap: 6px; }

.empty { padding: var(--s4); }
.empty-title { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.legend-list { margin: var(--s3) 0 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }

/* skeleton loading */
.skeleton .sk { display: block; background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2)); background-size: 200% 100%; border-radius: 6px; animation: shimmer 1.4s ease infinite; }
.sk-badge { width: 38px; height: 24px; }
.sk-line { height: 12px; width: 70%; }
.sk-line.short { width: 40%; }
.sk-time { width: 44px; height: 20px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.install-hint { margin: 0 var(--s4) var(--s3); padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.install-hint > div { flex: 1; min-width: 0; }

/* ---------- lines / line info (existing views) */
.filters { padding: 10px var(--s4); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.cat-toggle { border: 1px solid var(--line); background: var(--bg-2); padding: 6px 10px 6px 8px; min-height: 36px; border-radius: 18px; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.cat-toggle .dot { width: 10px; height: 10px; border-radius: 50%; }
.cat-toggle[aria-pressed="false"] { opacity: .45; }
.cat-toggle[aria-pressed="false"] .dot { background: var(--muted) !important; }
.switch { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; min-height: 36px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.stat { width: 100%; font-size: 12px; }
.recent { padding: 8px var(--s4) 0; font-size: 13px; }
.recent button { border: 1px dashed var(--line); background: none; border-radius: 8px; padding: 8px 10px; }
.browse { padding: 4px 0 12px; }
.cat-group summary { padding: 12px var(--s4); font-weight: 700; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.cat-group summary::-webkit-details-marker { display: none; }
.cat-group summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.cat-group[open] summary::before { transform: rotate(90deg); }
.cat-group summary .muted { font-weight: 400; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; padding: 0 var(--s4) 8px; }
.grid button { border: 0; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 44px; }
.grid button .badge { width: 100%; }
.grid button small { font-size: 11px; color: var(--muted); }
.grid button.selected .badge { outline: 2px solid var(--fg); outline-offset: 1px; }
.line-card { border-bottom: 1px solid var(--line); padding: var(--s3) var(--s4); }
.line-card h3 { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; font-size: 16px; }
.line-card h3 .ln { font-weight: 650; flex: 1; min-width: 0; }
.line-card .meta { font-size: 13px; margin: 6px 0; }
.dir-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 6px 0; max-width: 100%; }
.dir-toggle button { border: 0; background: var(--bg-2); padding: 8px 10px; min-height: 38px; font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.empty-note { background: var(--bg-2); border-radius: 10px; padding: 10px; font-size: 13.5px; margin: 6px 0; }
.mynear { font-size: 13.5px; margin: 6px 0; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--bg-2); border-radius: 0 10px 10px 0; }
.schematic { margin: 8px 0 0; }
.schematic h4 { margin: 10px 0 4px; font-size: 13.5px; }
.sch-list { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.sch-list li { position: relative; padding: 3px 0 3px 22px; font-size: 13.5px; min-height: 24px; }
.sch-list li::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 4px; background: var(--lc, #888); }
.sch-list li:first-child::before { top: 50%; }
.sch-list li:last-child::before { bottom: 50%; }
.sch-list li.stop::after { content: ""; position: absolute; left: 3px; top: 50%; margin-top: -6px; width: 8px; height: 8px; border-radius: 50%; background: var(--bg); border: 2px solid var(--lc, #888); }
.sch-list li.veh { color: var(--muted); font-size: 12.5px; min-height: 20px; cursor: pointer; }
.sch-list li.veh::after { content: ""; position: absolute; left: 1px; top: 50%; margin-top: -8px; width: 16px; height: 16px; border-radius: 50%; background: var(--lc, #888); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--lc); }
.sch-list li.near-me { font-weight: 700; }

/* near me */
.station h3 { margin: 0 0 6px; font-size: 15px; display: flex; gap: 8px; align-items: baseline; }
.station h3 .muted { font-weight: 400; font-size: 12px; margin-left: auto; white-space: nowrap; }
.dep { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 8px 0; min-height: 44px; text-align: left; font-size: 14px; }
.dep:hover { background: var(--bg-2); }
.dep .hs { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep .tm { white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.dep.canceled .hs, .dep.canceled .tm { text-decoration: line-through; color: var(--muted); }
.late { color: var(--late); font-weight: 700; }
.early { color: var(--early); font-weight: 700; }
.ontime { color: var(--early); }
.tt { color: var(--muted); font-size: 11px; }

/* trip view */
.trip-head { padding: var(--s3) var(--s4) 0; }
.trip-list { list-style: none; margin: 10px 0 0; padding: 0 0 0 4px; }
.trip-list li { position: relative; padding: 6px 0 6px 22px; font-size: 14px; display: flex; gap: 8px; justify-content: space-between; }
.trip-list li::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 4px; background: var(--lc, #888); }
.trip-list li.stop::after { content: ""; position: absolute; left: 3px; top: 50%; margin-top: -6px; width: 8px; height: 8px; border-radius: 50%; background: var(--bg); border: 2px solid var(--lc, #888); }
.trip-list li.passed { color: var(--muted); }
.trip-list li.passed::before { opacity: .4; }
.trip-list li.mine { background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 8px; font-weight: 700; }
.trip-list li.veh-here { color: var(--accent); font-weight: 700; font-size: 13px; }
.trip-list li.veh-here::after { content: ""; position: absolute; left: 1px; top: 50%; margin-top: -8px; width: 16px; height: 16px; border-radius: 50%; background: var(--lc); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--lc); }
.trip-list .tt2 { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* settings */
#settings { padding: var(--s2) var(--s4) var(--s5); }
.set-group { padding: var(--s3) 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s2); }
.set-group h2 { margin: 0; font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.set-group p { margin: 0; line-height: 1.45; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); min-height: 40px; font-size: 14.5px; }
.set-row select { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 40px; }
.seg { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg-opt { flex: 1; position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; }
.seg-opt span { display: block; text-align: center; padding: 8px; min-height: 38px; border-radius: 9px; font-weight: 650; font-size: 14px; }
.seg-opt input:checked + span { background: var(--accent); color: var(--accent-fg); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }

/* ---------- login */
.login { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; place-items: center; padding: calc(var(--s4) + env(safe-area-inset-top, 0px)) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom, 0px)); }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: var(--s3); text-align: center; }
.login-card h1 { margin: 0; font-size: 26px; }
.login-card p { margin: 0; }
.login-icon { margin: 0 auto; border-radius: 18px; box-shadow: var(--shadow); }
.login-card input { width: 100%; padding: 13px 14px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); font-size: 17px; }
.login-card input:focus { border-color: var(--accent); outline: none; }
.login-error { color: var(--danger); font-weight: 600; font-size: 14px; }
.fatal { position: fixed; left: var(--s4); right: var(--s4); top: calc(var(--s4) + env(safe-area-inset-top, 0px)); z-index: 70; background: var(--warn-bg); color: var(--warn-fg); padding: var(--s3) var(--s4); border-radius: 12px; box-shadow: var(--shadow); }

/* ---------- map overlays */
.map-buttons { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 10px; z-index: 4; }
.map-btn { width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-2); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--fg); }
.map-btn[aria-pressed="true"], .map-btn.active { color: var(--accent); }
.banner, .offline-bar {
  position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: calc(var(--panel-w) + 12px); right: 70px; margin: 0 auto; max-width: 520px; z-index: 6;
  background: var(--warn-bg); color: var(--warn-fg); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600;
}
.offline-bar { z-index: 7; }
.banner.down { background: var(--warn-bg); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 80; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
.toast-action { display: flex; align-items: center; gap: 12px; width: max-content; }
.toast-action span { white-space: nowrap; }
.toast-action button { border: 0; background: var(--accent); color: var(--accent-fg); font-weight: 700; border-radius: 8px; padding: 6px 12px; min-height: 36px; }

.maplibregl-popup-content { background: var(--bg-2); color: var(--fg); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); min-width: 220px; }
.maplibregl-popup-tip { border-top-color: var(--bg-2) !important; border-bottom-color: var(--bg-2) !important; }
.maplibregl-popup-close-button { font-size: 20px; color: var(--muted); width: 32px; height: 32px; }
.maplibregl-ctrl-group { background: var(--bg-2) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: var(--ctrl-filter, none); }
:root:not([data-theme="light"]) { --ctrl-filter: invert(1); }
.pop h4 { margin: 0 0 6px; display: flex; gap: 6px; align-items: center; font-size: 15px; padding-right: 18px; }
.pop .row { font-size: 13.5px; margin: 4px 0; }
.pop .src { display: inline-block; font-size: 11.5px; padding: 2px 7px; border-radius: 8px; margin-top: 4px; font-weight: 700; }
.pop .src.live { background: color-mix(in srgb, var(--live) 20%, transparent); color: var(--live); }
.pop .src.tt { background: var(--bg-3); color: var(--muted); }
.pop button.primary { margin-top: 8px; width: 100%; border: 0; background: var(--accent); color: var(--accent-fg); padding: 9px; min-height: 40px; border-radius: 10px; font-weight: 700; }
.pop .deps { max-height: 240px; overflow: auto; }

/* ---------- desktop: map always visible, so no Map tab */
@media (min-width: 768px) { .tabs .tab-map { display: none; } }

/* ---------- phones: native-style layout
   header on top, tab bar fixed at the bottom, one full screen in between: either a list or
   the map (Map tab). No floating sheet, so map gestures and list scrolling never compete. */
@media (max-width: 767px) {
  :root { --head-h: 128px; --tabs-h: 64px; }
  button, a, input, select, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .panel {
    inset: 0; width: auto; height: auto; border: 0; border-radius: 0; box-shadow: none; transform: none; transition: none;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
    background: var(--bg);
  }
  .sheet-handle { display: none; }
  .panel-head { padding: 10px var(--s4) 8px; border-bottom: 1px solid var(--line); background: var(--bg); }
  .brand { margin-bottom: var(--s2); }
  .tab-body { padding-bottom: calc(var(--tabs-h) + 8px); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--bg-2); border-top: 1px solid var(--line); border-bottom: 0;
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }
  .tabs button { min-height: 58px; border-bottom: 0; border-top: 3px solid transparent; font-size: 11.5px; }
  .tabs button[aria-selected="true"] { border-top-color: var(--accent); color: var(--accent); }
  .tabs .tab-info { display: none; }
  .panel-foot { display: none; }
  /* the map lives between header and tab bar, only on the Map tab */
  #map { inset: var(--head-h) 0 var(--tabs-h) 0; visibility: hidden; z-index: 6; }
  body[data-view="map"] #map { visibility: visible; }
  body[data-view="map"] .tab-body { display: none !important; }
  .map-buttons { display: none; top: calc(var(--head-h) + 12px); z-index: 7; }
  body[data-view="map"] .map-buttons { display: flex; }
  .banner, .offline-bar { position: fixed; top: calc(var(--head-h) + 8px); left: 12px; right: 12px; max-width: none; z-index: 20; }
  body[data-view="map"] .banner, body[data-view="map"] .offline-bar { right: 70px; }
  .search-results { max-height: 45vh; max-height: 45dvh; }
  .toast { bottom: calc(var(--tabs-h) + 12px); }
  /* one search per screen: the line search only where lines matter (Map, Lines, line details) */
  body:not([data-view="map"]):not([data-view="lines"]):not([data-view="info"]) .panel-head .search-wrap,
  body:not([data-view="map"]):not([data-view="lines"]):not([data-view="info"]) #chips { display: none; }
  /* more room for the map: no app title on the Map screen */
  body[data-view="map"] .brand { display: none; }
  /* map controls/credits only when the map is on screen */
  body:not([data-view="map"]) .maplibregl-control-container { display: none; }
  .maplibregl-ctrl-bottom-right { margin-bottom: 8px; }
}
