:root {
  --bg: #ffffff; --fg: #10161b; --muted: #5d6b75; --line: #e3e8ec; --panel: rgba(255,255,255,.97);
  --accent: #1f9d5c; --blue: #2563eb; --shadow: 0 6px 24px rgba(0,0,0,.18);
  --ok: #22a565; --maybe: #e0a100; --down: #d64545; --off: #9aa5ad;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #10161b; --fg: #e8eef2; --muted: #93a1ab; --line: #26313a; --panel: rgba(18,24,30,.97); --shadow: 0 6px 24px rgba(0,0,0,.5); }
}
* { box-sizing: border-box; }
html, body { overscroll-behavior: none; margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.4 -apple-system, system-ui, "Segoe UI", sans-serif; }
body { position: fixed; inset: 0; overflow: hidden; }
#map { position: absolute; inset: 0; }
a { color: var(--blue); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--down); font-weight: 600; }

#bar { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 10px; right: 56px; display: flex; gap: 8px; z-index: 5; }
.pill { border-radius: 999px; font-weight: 600; box-shadow: var(--shadow); padding: 10px 18px; }
.round { width: 42px; height: 42px; border-radius: 50%; padding: 0; box-shadow: var(--shadow); font-weight: 700; }
.maplibregl-ctrl-top-right { top: env(safe-area-inset-top); }

#trip { position: absolute; z-index: 6; top: calc(62px + env(safe-area-inset-top)); left: 10px; right: 10px; max-width: 460px;
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; display: grid; gap: 10px; }
#trip[hidden] { display: none; }
.field { position: relative; display: grid; grid-template-columns: 48px 1fr; align-items: center; }
.field label { color: var(--muted); font-size: 13px; }
.field input, .row input { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px; width: 100%; font-size: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.row input { width: 76px; padding: 8px; }
.sugg { position: absolute; z-index: 7; left: 48px; right: 0; top: 100%; margin: 4px 0 0; padding: 0; list-style: none;
  background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
.sugg:empty { display: none; }
.sugg li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.sub { color: var(--muted); font-size: 13px; display: block; }

/* Phones: a bottom sheet with a fixed height (set by sheet.js to the full-screen height) moved with translateY
   between snap points; its content scrolls only at full height. Wide screens: a fixed side panel. */
#sheet { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; height: 30dvh; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 16px 16px 0 0; box-shadow: var(--shadow); touch-action: none; will-change: transform; }
#sheetBody { flex: 1; min-height: 0; overflow: hidden; overscroll-behavior: contain; padding: 0 14px calc(14px + env(safe-area-inset-bottom)); }
#sheet.full #sheetBody { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
@media (min-width: 760px) {
  #sheet { left: 10px; right: auto; width: 400px; bottom: 10px; top: calc(70px + env(safe-area-inset-top)); height: auto; border-radius: 16px; touch-action: auto; transform: none; }
  #sheetBody { overflow-y: auto; touch-action: auto; }
  #grip { display: none; }
}
#grip { flex: none; height: 26px; cursor: grab; position: relative; }
#grip::before { content: ''; position: absolute; left: 50%; top: 9px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--line); }
.title { font-size: 17px; margin: 4px 0; }
.list { list-style: none; margin: 8px 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li.gap { color: var(--down); font-weight: 600; cursor: default; font-size: 14px; }
.grow { flex: 1; min-width: 0; }
.grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.right { text-align: right; white-space: nowrap; font-size: 14px; }
.toggle { display: block; margin-top: 4px; }

.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--off); }
.dot.verified { background: var(--ok); } .dot.probable { background: var(--maybe); } .dot.down { background: var(--down); }
.card header { display: flex; gap: 10px; align-items: flex-start; }
.card header .dot { margin-top: 7px; }
.card header div { flex: 1; }
.card h2 { font-size: 18px; margin: 0; }
.card .x { border: 0; background: none; font-size: 24px; line-height: 1; padding: 0 4px; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; background: var(--line); }
.badge.verified { background: color-mix(in srgb, var(--ok) 20%, transparent); }
.badge.probable { background: color-mix(in srgb, var(--maybe) 25%, transparent); }
.badge.down { background: color-mix(in srgb, var(--down) 22%, transparent); }
.price { font-size: 20px; font-weight: 700; margin: 8px 0; }
.price .muted { font-size: 13px; font-weight: 400; }
.detour { font-weight: 600; color: var(--blue); }
dl { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; margin: 8px 0; font-size: 14px; }
dt { color: var(--muted); } dd { margin: 0; }
.ev { padding-left: 18px; font-size: 13px; }
.actions { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.btn { text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-weight: 600; }

dialog { border: 0; border-radius: 16px; background: var(--panel); color: var(--fg); max-width: 520px; width: calc(100% - 24px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.4); }

#updPill { position: fixed; left: 50%; transform: translateX(-50%); top: calc(64px + env(safe-area-inset-top)); z-index: 60;
  font-weight: 600; color: #f4efe6; background: rgba(20,22,26,.92); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 12px 18px; }
#updPill b { margin-left: 10px; color: #5fd39a; }
.note { font-size: 14px; margin: 6px 0; }
.dot.inline { display: inline-block; width: 9px; height: 9px; margin-right: 4px; vertical-align: 0; }
#moreStops { width: 100%; margin: 4px 0 8px; }
#grip::after { content: ''; position: absolute; inset: -14px 0 0; } /* a bigger touch target, above the strip too */
#sheet.collapsed #sheetBody { visibility: hidden; }
#sheet { background: var(--bg); }
#sheet.full { z-index: 7; box-shadow: none; } /* full height covers the top buttons; drag it down to get them back */
