/* HALA: minimalist navigation. One accent, three themes (light, dark, high contrast). */

:root {
  --accent: #2b59ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(43, 89, 255, 0.1);
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #0b0d12;
  --muted: #667085;
  --line: #e6e8ee;
  --chip: #f2f4f7;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.06);
  --radius: 22px;
  --ui-bottom: 0px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --accent: #5c82ff;
  --accent-soft: rgba(92, 130, 255, 0.16);
  --bg: #0e1014;
  --surface: #16191f;
  --ink: #f1f3f7;
  --muted: #9aa3b2;
  --line: #262a33;
  --chip: #1f232b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

:root[data-theme="contrast"] {
  --accent: #0a3bff;
  --accent-soft: rgba(10, 59, 255, 0.12);
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #000000;
  --muted: #1f1f1f;
  --line: #000000;
  --chip: #ffffff;
  --shadow: 0 0 0 2px #000;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#map { position: fixed; inset: 0; background: var(--bg); }

/* ---------- top chrome ---------- */
.brand {
  position: fixed; z-index: 5; top: calc(12px + var(--safe-t)); left: 12px;
  display: flex; align-items: baseline; gap: 8px;
  padding: 9px 14px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow);
}
.wordmark {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--ink); text-decoration: none;
  font-weight: 850; letter-spacing: 0.2em; font-size: 15px;
}
.wordmark .drop {
  width: 11px; height: 11px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--accent);
}
.by { color: var(--muted); font-size: 12px; text-decoration: none; }
.by:hover { color: var(--accent); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 48px; height: 48px; padding: 0 14px; border: 0; border-radius: 999px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  font-weight: 650; font-size: 14px;
}
.icon-btn svg { width: 20px; height: 20px; }
.settings-btn { position: fixed; z-index: 5; top: calc(8px + var(--safe-t)); right: 12px; width: 48px; padding: 0; }
.locate-btn {
  position: fixed; z-index: 4; right: 12px; bottom: calc(var(--ui-bottom) + 14px);
  color: var(--accent);
}

/* ---------- sheets ---------- */
.sheet {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0;
  display: none;
  max-height: min(74vh, 640px); overflow-y: auto;
  padding: 22px 18px calc(18px + var(--safe-b));
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 30px rgba(16, 24, 40, 0.1);
}
body[data-screen="home"] #home,
body[data-screen="overview"] #overview,
body[data-screen="settings"] #settings,
body[data-screen="floodwatch"] #floodwatch,
body[data-screen="arrived"] #arrived { display: block; }

.ask { margin: 0 0 14px; font-size: 30px; line-height: 1.1; font-weight: 820; letter-spacing: -0.02em; }

/* From and To: two stacked boxes, joined on the left by a dot, a dotted line and a pin,
   with the swap button beside them. Each box is captioned, so it is clear which one is which. */
.ends { display: flex; align-items: center; gap: 8px; }
.ends-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ends-marks {
  flex: none; align-self: stretch; width: 14px; padding: 24px 0;
  display: flex; flex-direction: column; align-items: center;
}
.end-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 3px var(--ink); }
.end-line { flex: 1; width: 0; margin: 4px 0; border-left: 2px dotted var(--muted); }
.end-pin { width: 12px; height: 12px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); }
.swap-btn {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: var(--chip); color: var(--ink);
}
.swap-btn svg { width: 22px; height: 22px; }
.swap-btn:disabled { opacity: 0.4; cursor: default; }
.swap-btn.spin svg { animation: swap-spin var(--dur-3) var(--ease-out); }
@keyframes swap-spin { from { transform: rotate(-180deg); } }

.row-tag { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.field { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: text; }
.field .row-tag { font-size: 11px; line-height: 14px; }
.field input { flex: none; width: 100%; }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  min-height: 60px; padding: 8px 8px 8px 14px; border-radius: 16px;
  background: var(--bg); box-shadow: inset 0 0 0 2px var(--line);
}
.searchbox:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.searchbox input {
  flex: 1; min-width: 0; height: 30px; padding: 0; border: 0; outline: none; background: transparent;
  color: var(--ink); font: inherit; font-size: 17px; text-overflow: ellipsis;
}
.searchbox input::placeholder { color: var(--muted); }
.searchbox input::-webkit-search-cancel-button { display: none; }
/* From shows My location in the accent until a place is chosen; picking a start outlines it. */
body.pick-origin .from-box { box-shadow: inset 0 0 0 2px var(--accent); }
.from-box input:placeholder-shown { font-weight: 600; }
.from-box input::placeholder { color: var(--accent); }
.paste-btn {
  height: 44px; padding: 0 16px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.hint { min-height: 0; margin: 8px 2px 0; color: var(--muted); font-size: 14px; }
.hint:empty { display: none; }

.results, .recents ul, .trip { list-style: none; margin: 0; padding: 0; }
.results { margin-top: 8px; }
.place {
  display: flex; flex-direction: column; gap: 2px; width: 100%;
  padding: 12px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left;
  min-height: 56px;
}
.place:active { background: var(--chip); }
.place-title { font-weight: 650; font-size: 16px; }
.place-sub { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recents { margin-top: 18px; }
.recents h2 { margin: 0 0 2px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.recents:has(ul:empty) { display: none; }
.results:not(:empty) + .recents { display: none; }

/* overview */
.summary { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.sum-time { font-size: 32px; font-weight: 820; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sum-meta { color: var(--muted); font-size: 15px; }
.trip { margin-bottom: 12px; }
.trip li {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line);
}
.trip .pin {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  background: var(--accent); color: var(--accent-ink);
}
.trip .pin.origin { background: var(--chip); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.trip .txt { flex: 1; min-width: 0; }
.trip .tag { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.trip .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip .rm { border: 0; background: none; color: var(--muted); font-size: 22px; width: 44px; height: 44px; }

.row-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modes { display: flex; width: 100%; margin-bottom: 8px; }
.modes button { flex: 1; }
.tip { margin: 16px 2px 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }

/* settings */
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 26px; font-weight: 820; letter-spacing: -0.02em; }
.setting { padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting-label { font-weight: 700; margin-bottom: 8px; }
.setting .seg { display: flex; flex-wrap: wrap; width: 100%; }
.setting .seg button { flex: 1 1 auto; }
.setting-hint { margin: 8px 2px 0; color: var(--muted); font-size: 13px; }
.setting-hint:empty { display: none; }
.help-title { margin: 18px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.help { margin: 0; padding-left: 20px; color: var(--ink); font-size: 14.5px; line-height: 1.5; }
.help li { margin: 4px 0; }
.ghost-btn { height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--chip); font-weight: 650; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--chip); }
.seg button { height: 38px; padding: 0 12px; border: 0; border-radius: 9px; background: none; font-weight: 650; font-size: 14px; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.go-row { display: flex; gap: 10px; }
.go-btn {
  flex: 1; height: 58px; border: 0; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 19px; font-weight: 800; letter-spacing: 0.04em;
}
.go-btn:disabled { opacity: 0.45; }
.sim-btn { height: 58px; padding: 0 20px; border: 0; border-radius: 16px; background: var(--chip); font-weight: 700; font-size: 16px; }
.back-link { display: block; margin: 12px auto 0; border: 0; background: none; color: var(--muted); font-weight: 600; min-height: 44px; }

.arrived { text-align: center; }
.arrived-title { font-size: 34px; font-weight: 850; letter-spacing: -0.02em; }
.arrived-sub { color: var(--muted); margin: 6px 0 18px; }

/* ---------- navigation ---------- */
.nav { display: none; }
body[data-screen="nav"] .nav { display: block; }
body[data-screen="nav"] .brand,
body[data-screen="nav"] .settings-btn,
body[data-screen="nav"] .flood-btn,
body[data-screen="nav"] .locate-btn { display: none; }

.card {
  position: fixed; z-index: 6; top: calc(10px + var(--safe-t)); left: 10px; right: 10px;
  display: grid; grid-template-columns: 108px 1fr; column-gap: 14px; align-items: center;
  padding: 14px 16px 14px 14px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.m-icon {
  width: 108px; height: 108px; border-radius: 24px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; --icon-bg: var(--accent);
}
.m-icon svg { width: 84px; height: 84px; }
.m-icon:empty { visibility: hidden; }
.m-body { min-width: 0; }
.m-dist { font-size: 50px; line-height: 0.95; font-weight: 880; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.m-text { margin-top: 4px; font-size: 21px; line-height: 1.18; font-weight: 750; }
.m-road { margin-top: 2px; font-size: 16px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-road:empty, .m-then:empty { display: none; }
.m-then {
  grid-column: 1 / -1; justify-self: start;
  margin-top: 10px; padding: 4px 10px; border-radius: 8px;
  background: var(--chip); font-size: 14px; font-weight: 650;
}

.recenter-btn {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-b)); display: none; color: var(--accent);
}
body.free .recenter-btn { display: inline-flex; }

.navbar {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 6px;
  min-height: 78px; padding: 10px 10px calc(10px + var(--safe-b)) 16px;
  background: var(--surface); box-shadow: 0 -6px 24px rgba(16, 24, 40, 0.08);
}
.eta { flex: 1; min-width: 0; }
.eta-time { font-size: 21px; font-weight: 820; font-variant-numeric: tabular-nums; white-space: nowrap; }
.eta-meta { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.navbar .icon-btn { box-shadow: none; background: var(--chip); min-width: 46px; height: 46px; padding: 0 10px; }
.vehicle-btn { color: var(--accent); }
.vehicle-btn svg { width: 30px; height: 30px; }

/* quick marker picker, just above the bar */
.picker {
  position: fixed; z-index: 7; left: 10px; right: 10px; bottom: calc(88px + var(--safe-b));
  display: none; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 8px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
body.picking .picker { display: grid; }
.picker button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 84px; padding: 8px 4px; border: 0; border-radius: 14px; background: none;
  font-size: 13px; font-weight: 650;
}
.picker button svg { width: 44px; height: 44px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25)); }
.picker button[aria-checked="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.sim-speed { display: none !important; }
body.sim .sim-speed { display: inline-flex !important; }
.voice-btn[aria-pressed="false"] .wave { opacity: 0.2; }
.end-btn { height: 46px; padding: 0 15px; border: 0; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 750; }

.toast {
  position: fixed; z-index: 20; left: 50%; top: calc(14px + var(--safe-t));
  transform: translate(-50%, -150%); opacity: 0;
  max-width: calc(100vw - 24px); padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 650; font-size: 15px;
  transition: transform 0.25s ease, opacity 0.25s ease; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
body[data-screen="nav"] .toast.show { transform: translate(-50%, 140px); }

/* rider puck */
.puck { width: 78px; height: 78px; }
.puck[data-vehicle="arrow"] { width: 60px; height: 60px; }
.puck svg { width: 100%; height: 100%; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35)); }
.stop-pin {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--accent); box-shadow: 0 0 0 3px var(--surface), 0 3px 8px rgba(0, 0, 0, 0.25);
  display: grid; place-items: center;
}
.stop-pin span { transform: rotate(45deg); color: #fff; font-weight: 800; font-size: 13px; }

/* map attribution sits above whatever panel is open */
.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: 0; }
.maplibregl-ctrl-attrib { font-family: var(--font); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib { background: rgba(22, 25, 31, 0.8); color: #9aa3b2; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib a { color: #c5cbd6; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }

/* high contrast: heavier type and outlines for direct sunlight */
:root[data-theme="contrast"] .m-dist { font-size: 54px; font-weight: 900; }
:root[data-theme="contrast"] .m-text { font-weight: 800; }
:root[data-theme="contrast"] .m-icon { background: #000; --icon-bg: #000; }
:root[data-theme="contrast"] .m-road { color: #000; font-weight: 750; }
:root[data-theme="contrast"] .card,
:root[data-theme="contrast"] .navbar,
:root[data-theme="contrast"] .sheet { border: 3px solid #000; box-shadow: none; }
:root[data-theme="contrast"] .brand,
:root[data-theme="contrast"] .icon-btn { box-shadow: 0 0 0 2px #000; }
:root[data-theme="contrast"] .place { border-bottom: 2px solid #000; }
:root[data-theme="contrast"] .eta-time { font-size: 22px; }

/* ---------- wide screens: panels float on the left ---------- */
@media (min-width: 900px) {
  .sheet {
    left: 20px; right: auto; top: 78px; bottom: auto; width: 400px;
    max-height: calc(100vh - 100px); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .card { left: 20px; right: auto; width: 440px; top: 20px; }
  .navbar { left: 50%; right: auto; width: 560px; transform: translateX(-50%); bottom: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
  .recenter-btn { bottom: 110px; }
  body[data-screen="nav"] .toast.show { transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- intro: the wordmark assembles while a route draws across a faint grid ---------- */
#intro {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--bg); color: var(--ink);
  --k: 1;
  animation: intro-out calc(0.35s * var(--k)) ease forwards calc(1.9s * var(--k));
}
.intro-short #intro { --k: 0.38; }
.intro-short .intro-skip { display: none; }
.intro-map { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--line); }
.intro-grid { opacity: 0; animation: intro-fade calc(0.5s * var(--k)) ease forwards; }
.intro-street { fill: none; stroke: var(--line); stroke-width: 9; stroke-linecap: round; opacity: 0; animation: intro-fade calc(0.6s * var(--k)) ease forwards calc(0.1s * var(--k)); }
.intro-route {
  fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: intro-draw calc(1.1s * var(--k)) cubic-bezier(0.6, 0, 0.2, 1) forwards calc(0.15s * var(--k));
}
.intro-pin {
  fill: var(--accent); transform-box: fill-box; transform-origin: center; transform: scale(0);
  animation: intro-pop calc(0.32s * var(--k)) cubic-bezier(0.3, 1.6, 0.5, 1) forwards calc(1.2s * var(--k));
}
.intro-mark {
  position: relative; display: flex; align-items: center; gap: 0.16em;
  padding: 10px 18px; border-radius: 18px; background: var(--bg);
  font-weight: 850; font-size: 46px; letter-spacing: 0.14em;
}
.intro-mark .drop {
  width: 22px; height: 22px; margin-right: 0.15em; border-radius: 50% 50% 50% 0; background: var(--accent);
  transform: rotate(-45deg) scale(0);
  animation: intro-drop calc(0.4s * var(--k)) cubic-bezier(0.3, 1.5, 0.5, 1) forwards calc(0.25s * var(--k));
}
.intro-mark .l { display: inline-block; opacity: 0; transform: translateY(18px); animation: intro-rise calc(0.45s * var(--k)) cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.intro-mark .l:nth-child(2) { animation-delay: calc(0.38s * var(--k)); }
.intro-mark .l:nth-child(3) { animation-delay: calc(0.46s * var(--k)); }
.intro-mark .l:nth-child(4) { animation-delay: calc(0.54s * var(--k)); }
.intro-mark .l:nth-child(5) { animation-delay: calc(0.62s * var(--k)); }
.intro-by {
  position: absolute; bottom: calc(70px + var(--safe-b));
  color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: 0.08em;
  opacity: 0; animation: intro-fade calc(0.4s * var(--k)) ease forwards calc(1s * var(--k));
}
.intro-skip {
  position: absolute; bottom: calc(34px + var(--safe-b)); color: var(--muted); font-size: 12px;
  opacity: 0; animation: intro-fade 0.3s ease forwards 0.7s;
}
.intro-reduced #intro { animation: intro-out 0.3s ease forwards 0.5s; }
.intro-reduced #intro * { animation: none !important; opacity: 1 !important; stroke-dashoffset: 0 !important; }
.intro-reduced .intro-mark .l { transform: none; }
.intro-reduced .intro-mark .drop { transform: rotate(-45deg); }
.intro-reduced .intro-pin { transform: none; }
.intro-reduced .intro-skip { display: none; }
.intro-skipped #intro { animation: intro-out 0.15s ease forwards !important; }
@keyframes intro-fade { to { opacity: 1; } }
@keyframes intro-draw { to { stroke-dashoffset: 0; } }
@keyframes intro-pop { to { transform: scale(1); } }
@keyframes intro-drop { to { transform: rotate(-45deg) scale(1); } }
@keyframes intro-rise { to { opacity: 1; transform: none; } }
@keyframes intro-out { to { opacity: 0; visibility: hidden; } }

/* ---------- saved places ---------- */
body[data-screen="place"] #place { display: block; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.chip {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px;
  border: 0; border-radius: 14px; background: var(--chip); text-align: left;
}
.chip-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; flex: none; }
.chip-icon svg { width: 20px; height: 20px; }
.chip.unset .chip-icon { background: var(--surface); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.chip-text { display: flex; flex-direction: column; min-width: 0; }
.chip-text b { font-size: 15px; }
.chip-text small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.pick-save .to-box { box-shadow: inset 0 0 0 2px var(--accent); }
.saved { margin-top: 16px; }
.saved-head { display: flex; align-items: center; gap: 8px; }
.saved-head h2 { flex: 1; margin: 0; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 650; font-size: 14px; min-height: 40px; padding: 0 4px; }
.link-btn[hidden] { display: none; }
.saved-list { list-style: none; margin: 4px 0 0; padding: 0; }
.saved-item { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.s-go { display: flex; align-items: center; gap: 12px; flex: 1; min-height: 56px; padding: 8px 4px; border: 0; background: none; text-align: left; }
.s-icon { width: 36px; height: 36px; display: grid; place-items: center; font-size: 20px; border-radius: 10px; background: var(--chip); border: 0; flex: none; }
.s-txt { display: flex; flex-direction: column; min-width: 0; }
.s-txt small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-name { flex: 1; min-width: 0; height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--chip); color: var(--ink); font: inherit; }
.s-btn { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--chip); font-size: 18px; }
.s-btn:disabled { opacity: 0.35; }
.s-del { color: #d93036; }
.results li { display: flex; align-items: stretch; }
.results .place { flex: 1; }
.place-save { width: 48px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--accent); font-size: 22px; }

/* place card */
.place-head { min-width: 0; }
.place-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.place-sub-line { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
#place .go-row { margin: 12px 0; }
#place-add[hidden] { display: none; }
.place-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.place-actions .ghost-btn { flex: 1 1 auto; }
.bm-form { display: none; margin-top: 12px; }
body.bm-open .bm-form { display: block; }
#bm-name { width: 100%; height: 48px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--chip); color: var(--ink); font: inherit; font-size: 16px; }
.bm-icons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0; }
.bm-icons button { height: 44px; border: 0; border-radius: 10px; background: var(--chip); font-size: 20px; }
.bm-icons button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }

.saved-pin {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); background: var(--surface); box-shadow: 0 0 0 2px var(--accent), 0 3px 8px rgba(0, 0, 0, 0.25);
  font-size: 17px;
}
.saved-pin > * , .saved-pin { line-height: 1; }
.saved-pin.svg { background: var(--accent); color: #fff; }
.saved-pin svg { width: 18px; height: 18px; transform: rotate(45deg); }
.saved-pin.emoji { text-indent: 0; }
body[data-screen="nav"] .saved-pin { display: none; }

/* settings: privacy and data */
.privacy-intro { margin: 6px 0; font-size: 14px; line-height: 1.45; }
.privacy-list { margin: 0 0 6px; padding-left: 18px; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }
.file-btn input { display: none; }
.danger-btn { height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: #fde8e8; color: #b42318; font-weight: 700; }
:root[data-theme="dark"] .danger-btn { background: #3a1d1d; color: #ff9b94; }

/* ---------- alerts and reports on the nav screen ---------- */
.alert {
  position: fixed; z-index: 6; left: 10px; right: 10px; top: calc(176px + var(--safe-t));
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 16px; background: #1b1f27; color: #fff; box-shadow: var(--shadow);
  font-weight: 750; font-size: 17px;
}
body.alerting .alert { display: flex; }
.alert-icon { width: 34px; height: 34px; border-radius: 9px; background: #e5484d; flex: none; position: relative; }
.alert-icon::after { content: ""; position: absolute; inset: 9px 7px; border-radius: 4px; background: #fff; }
.alert[data-kind="jam"] .alert-icon { background: #f59e0b; }
.alert[data-kind="roadblock"] .alert-icon, .alert[data-kind="accident"] .alert-icon { background: #e5484d; }
.alert[data-kind="hazard"] .alert-icon { background: #eab308; }
.alert-text { flex: 1; min-width: 0; }
.alert-speed:not(:empty) {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: #fff; color: #000; border: 4px solid #e5484d; font-size: 16px; font-weight: 900;
}
.alert-votes { display: none; gap: 6px; width: 100%; }
.alert:not([data-kind="camera"]) .alert-votes { display: flex; }
.alert-votes button { flex: 1; height: 40px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 700; }
.demo-badge { display: none; padding: 2px 8px; border-radius: 6px; background: #f59e0b; color: #000; font-size: 11px; font-weight: 900; letter-spacing: 0.06em; }
body.demo-reports .demo-badge { display: inline-block; }
.alert[data-kind="camera"] .demo-badge { display: none; }
.report-btn {
  position: fixed; z-index: 6; right: 12px; bottom: calc(100px + var(--safe-b));
  display: none; height: 56px; padding: 0 20px; border: 0; border-radius: 999px;
  background: #f59e0b; color: #000; font-weight: 850; font-size: 16px; box-shadow: var(--shadow);
}
body.can-report .report-btn { display: inline-flex; align-items: center; }
.report-menu {
  position: fixed; z-index: 8; left: 10px; right: 10px; bottom: calc(90px + var(--safe-b));
  display: none; padding: 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
body.reporting .report-menu { display: block; }
.report-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 18px; }
.report-types { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.report-types button {
  display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 0 14px;
  border: 0; border-radius: 14px; background: var(--chip); font-weight: 750; font-size: 16px; text-align: left;
}
.r-dot { width: 18px; height: 18px; border-radius: 50%; background: #e5484d; flex: none; }
.report-types [data-kind="jam"] .r-dot { background: #f59e0b; }
.report-types [data-kind="hazard"] .r-dot { background: #eab308; }
.report-types [data-kind="speedtrap"] .r-dot { background: #6366f1; }
#report-cancel { width: 100%; }

/* ==========================================================================
   Motion and layout stability
   One set of timings; only transform and opacity animate; panels have fixed
   heights so loading content never moves what is under the rider's finger.
   ========================================================================== */
:root {
  --dur-1: 160ms;   /* presses, small fades */
  --dur-2: 220ms;   /* banners, menus, enter */
  --dur-3: 320ms;   /* sheets, controls that follow a sheet */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-sheet: cubic-bezier(0.22, 1.15, 0.36, 1); /* a soft, spring-like settle */
}

/* Sheets keep one height per screen and scroll inside, and slide in on entry. */
.sheet { max-height: none; animation: sheet-in var(--dur-3) var(--ease-sheet) both; }
#home { height: min(60vh, 560px); }
#overview { height: min(64vh, 540px); }
body.has-jx #overview { height: min(78vh, 680px); overflow-y: auto; }
body.has-jx #overview .trip { flex: none; max-height: none; overflow: visible; }
body.has-jx #overview .go-row { position: sticky; bottom: 0; z-index: 1; background: var(--surface); }
#floodwatch { height: min(76vh, 660px); }
#settings { height: min(86vh, 760px); }
#place { max-height: min(74vh, 640px); }
@keyframes sheet-in { from { transform: translateY(28px); opacity: 0; } }
@keyframes rise-in { from { transform: translateY(10px); opacity: 0; } }

/* Overview: the trip list scrolls, Go stays pinned at the bottom of the sheet. */
body[data-screen="overview"] #overview { display: flex; flex-direction: column; }
#overview .trip { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#overview .go-row { margin-top: auto; padding-top: 8px; }
#overview .back-link { margin-top: 4px; }

/* Summary placeholder while the route is calculated: same size as the answer. */
.sum-time { min-width: 3.2ch; min-height: 1.15em; }
.sum-meta { min-height: 1.2em; }

/* Search: the hint line keeps its space; while a query is typed, results own the sheet. */
.hint { min-height: 1.35em; }
.hint:empty { display: block; visibility: hidden; }
#saved-empty:empty { display: none; }
body.searching #home .chips,
body.searching #home .saved,
body.searching #home .recents,
body.searching #home .tip { display: none; }
.results .place, .results li { animation: rise-in var(--dur-2) var(--ease-out) both; }
.results .skeleton { display: block; height: 56px; border-bottom: 1px solid var(--line); animation: none; }
.results .skeleton span {
  display: block; height: 12px; margin: 14px 6px 8px; width: 55%; border-radius: 6px;
  background: linear-gradient(90deg, var(--chip) 0%, var(--line) 50%, var(--chip) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
.results .skeleton:nth-child(2) span { width: 40%; }
.results .skeleton:nth-child(3) span { width: 65%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Controls that sit on top of a sheet move with it, by transform. */
.locate-btn { bottom: 14px; transform: translateY(calc(-1 * var(--ui-bottom))); transition: transform var(--dur-3) var(--ease-out); }
.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left {
  bottom: 0; transform: translateY(calc(-1 * var(--ui-bottom))); transition: transform var(--dur-3) var(--ease-out);
}

/* Presses: a small, quick scale; nothing changes size. */
button { transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-1) ease, opacity var(--dur-1) ease, box-shadow var(--dur-1) ease; }
button:active:not(:disabled) { transform: scale(0.97); }
.recenter-btn:active { transform: translateX(-50%) scale(0.97); }
.go-btn:disabled, .sim-btn:disabled { opacity: 0.45; }

/* Navigation card: a fixed size whatever the instruction, so nothing below it jumps. */
.card { height: 136px; animation: rise-in var(--dur-3) var(--ease-sheet) both; }
.m-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-road:empty { display: block; visibility: hidden; }
.m-road { min-height: 1.3em; }
.m-then {
  position: absolute; left: 14px; top: calc(100% + 6px); margin: 0;
  box-shadow: var(--shadow); background: var(--surface);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.m-then:empty { display: block; opacity: 0; transform: translateY(-6px); pointer-events: none; }
.navbar { animation: rise-in var(--dur-3) var(--ease-sheet) both; }

/* Banners and menus fade and slide instead of popping; they never push anything. */
.alert {
  display: flex; top: calc(196px + var(--safe-t));
  visibility: hidden; opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2);
}
body.alerting .alert { visibility: visible; opacity: 1; transform: none; pointer-events: auto; transition-delay: 0s; }
.picker, .report-menu {
  visibility: hidden; opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2);
}
.picker { display: grid; }
.report-menu { display: block; }
body.picking .picker, body.reporting .report-menu { visibility: visible; opacity: 1; transform: none; pointer-events: auto; transition-delay: 0s; }
.recenter-btn {
  display: inline-flex; visibility: hidden; opacity: 0; transform: translateX(-50%) translateY(8px);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2);
}
body.free .recenter-btn { visibility: visible; opacity: 1; transform: translateX(-50%); transition-delay: 0s; }
.toast { transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-2) var(--ease-out); }

@media (min-width: 900px) {
  #home, #overview, #settings, #place { height: auto; max-height: calc(100vh - 100px); }
  #overview .trip { flex: 0 1 auto; }
  .alert { left: 20px; right: auto; width: 440px; top: 196px; }
  .navbar { animation: none; } /* it is centred with a transform here */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0s !important; }
  button:active:not(:disabled) { transform: none; }
}

/* The control corner keeps its height, so the credit button appearing moves nothing. */
.maplibregl-ctrl-bottom-right { min-height: 44px; min-width: 44px; }
@media (max-width: 640px) {
  /* Until MapLibre makes it compact, the credit stays out of the layout instead of flashing open. */
  .maplibregl-ctrl-attrib:not(.maplibregl-compact) { display: none; }
}
/* Start where the home sheet will be, so nothing slides on first paint. */
@media (max-width: 899px) { :root { --ui-bottom: min(60vh, 560px); } }


/* ---------- flood watch ---------- */
.flood-btn { position: fixed; z-index: 5; top: calc(64px + var(--safe-t)); right: 12px; width: 48px; padding: 0; }
.flood-dot { position: absolute; top: 8px; right: 8px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); background: transparent; display: none; }
.flood-btn[data-sev] .flood-dot { display: block; }
.flood-btn[data-sev="rising"] .flood-dot, .flood-btn[data-sev="alert"] .flood-dot { background: #f59e0b; }
.flood-btn[data-sev="warning"] .flood-dot { background: #ea580c; }
.flood-btn[data-sev="danger"] .flood-dot { background: #e5484d; }
.flood-head { margin: 4px 0; font-size: 19px; font-weight: 780; line-height: 1.25; }
.flood-meta { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.flood-warn { padding: 10px 12px; border-radius: 12px; background: rgba(245, 158, 11, 0.14); margin-bottom: 8px; font-size: 14px; line-height: 1.35; }
.flood-warn b { display: block; margin-bottom: 3px; }
.flood-list { list-style: none; margin: 0 0 12px; padding: 0; }
.flood-list button { display: grid; grid-template-columns: 12px 1fr auto; gap: 2px 10px; width: 100%; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line, rgba(127,127,127,0.18)); background: none; color: inherit; font: inherit; text-align: left; }
.flood-list .sev-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; grid-row: span 2; }
.sev-dot[data-sev="rising"], .sev-dot[data-sev="alert"] { background: #f59e0b; }
.sev-dot[data-sev="warning"] { background: #ea580c; }
.sev-dot[data-sev="danger"] { background: #e5484d; }
.flood-list .fl-name { font-weight: 700; }
.flood-list .fl-sev { font-weight: 750; font-size: 14px; }
.flood-list .fl-sub { grid-column: 2 / 4; color: var(--muted); font-size: 13px; }

/* The notice that the route has changed: above everything else on the nav screen. */
.sum-divert { margin: 6px 0 2px; padding: 9px 12px; border-radius: 12px; font-weight: 720; font-size: 14.5px; line-height: 1.3; background: rgba(234, 88, 12, 0.14); color: #b4400a; }
.sum-divert[data-level="stuck"] { background: #e5484d; color: #fff; }
.sum-divert[data-level="watch"] { background: rgba(245, 158, 11, 0.16); color: #8a5a00; }
[data-theme="dark"] .sum-divert:not([data-level="stuck"]) { color: #ffc48f; }
.divert {
  position: fixed; z-index: 9; left: 10px; right: 10px; top: calc(156px + var(--safe-t));
  display: none; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: #c2410c; color: #fff; box-shadow: var(--shadow);
  animation: rise-in var(--dur-3) var(--ease-sheet) both;
}
.divert[data-level="stuck"] { background: #d92d32; }
body.diverting .divert { display: flex; }
.divert-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); position: relative; }
.divert-icon::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 20px; }
.divert-body { display: flex; flex-direction: column; min-width: 0; font-size: 14.5px; line-height: 1.25; }
.divert-body b { font-size: 17px; font-weight: 800; }
.alert[data-kind="flood"] .alert-icon, .alert[data-kind="gauge"] .alert-icon { background: #2563eb; }
.alert[data-kind="gauge"] .alert-votes, .alert[data-kind="gauge"] .demo-badge { display: none; }

/* ---------- junction guide ---------- */
.jx { margin: 8px 0; flex: none; }
.jx[hidden] { display: none; }
.jx-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 6px; }
.jx-head b { font-size: 15px; font-weight: 800; }
.jx-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.jx-tabs { display: flex; gap: 4px; margin-left: auto; }
.jx-tabs button { height: 32px; padding: 0 10px; border: 0; border-radius: 9px; background: rgba(127, 127, 127, 0.13); color: inherit; font: inherit; font-size: 12.5px; font-weight: 650; }
.jx-tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.jx-view { position: relative; height: clamp(150px, 24vh, 220px); border-radius: 14px; overflow: hidden; background: rgba(127, 127, 127, 0.12); }
.jx-view iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.skeleton-fill { position: absolute; inset: 0; background: linear-gradient(100deg, rgba(127,127,127,0.1) 30%, rgba(127,127,127,0.22) 50%, rgba(127,127,127,0.1) 70%); background-size: 220% 100%; animation: jx-shimmer 1.3s linear infinite; }
@keyframes jx-shimmer { to { background-position: -220% 0; } }
.jx-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.jx-nav { flex: none; width: 40px; height: 48px; border: 0; border-radius: 12px; background: rgba(127, 127, 127, 0.13); color: inherit; font-size: 24px; line-height: 1; }
.jx-nav:disabled { opacity: 0.35; }
.jx-diagram { flex: none; width: 52px; height: 52px; }
.jx-map { display: block; width: 100%; height: 100%; }
.jx-say { flex: 1; min-width: 0; }
.jx-text { font-weight: 720; font-size: 14.5px; line-height: 1.25; }
.jx-open { font-size: 12.5px; color: var(--accent); font-weight: 650; }
.lanes { display: flex; gap: 2px; margin: 3px 0; }
.lanes:empty { display: none; }
.lane { width: 22px; height: 22px; padding: 2px; border-radius: 5px; color: var(--muted); opacity: 0.5; }
.lane.on { color: #fff; background: var(--accent); opacity: 1; }
.nav-jx {
  position: fixed; z-index: 6; left: 10px; right: 10px; top: calc(156px + var(--safe-t));
  display: flex; gap: 8px; height: 148px; padding: 6px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow);
}
.nav-jx[hidden] { display: none; }
body.alerting .nav-jx { top: calc(232px + var(--safe-t)); }
.nav-jx-side { flex: none; width: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.nav-jx-side .lanes { flex-wrap: wrap; justify-content: center; }
.nav-jx-side > div:first-child { width: 72px; height: 72px; }
.nav-jx iframe { flex: 1; min-width: 0; border: 0; border-radius: 11px; pointer-events: none; background: rgba(127, 127, 127, 0.12); }
.google-row a { display: block; padding: 10px 2px; color: var(--accent); font-weight: 700; text-decoration: none; }
.google-row small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; margin-top: 2px; }
@media (min-width: 900px) {
  .divert, .nav-jx { right: auto; width: 420px; }
}
