/* ============================================================
   WayPointe — design system
   Light/dark, translucent "liquid glass", iOS-flavored motion.
   ============================================================ */

:root {
  /* brand + semantic (from the Design Bible) */
  --blue: #1677ff;
  --blue-deep: #0b57d0;
  --green: #2dbe60;
  --amber: #f2b134;
  --orange: #f07c22;
  --red: #e53935;
  --darkred: #8e1b18;
  --yellow: #f5c542;
  --alpr: #8b5cf6;

  /* light theme */
  --bg: #f7f7f5;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --glass-border: rgba(255, 255, 255, 0.55);
  --hairline: rgba(17, 17, 17, 0.08);
  --text: #111111;
  --text2: #626262;
  --text3: #9a9a9a;
  --shadow-soft: 0 10px 30px rgba(17, 24, 39, 0.14);
  --shadow-pop: 0 16px 44px rgba(17, 24, 39, 0.22);
  --fill: rgba(17, 17, 17, 0.06);
  --fill-strong: rgba(17, 17, 17, 0.12);

  /* shape */
  --r-card: 22px;
  --r-control: 16px;
  --r-pill: 999px;

  /* motion */
  --spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --ease: cubic-bezier(0.32, 0.72, 0.24, 1);

  /* safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

[data-theme="dark"] {
  --bg: #111315;
  --surface: rgba(28, 28, 30, 0.8);
  --surface-solid: #1c1c1e;
  --glass: rgba(28, 28, 30, 0.62);
  --glass-strong: rgba(28, 28, 30, 0.88);
  --glass-border: rgba(255, 255, 255, 0.12);
  --hairline: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --text2: #a1a1a6;
  --text3: #6f6f74;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 16px 44px rgba(0, 0, 0, 0.6);
  --fill: rgba(255, 255, 255, 0.08);
  --fill-strong: rgba(255, 255, 255, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  position: fixed; inset: 0;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }

.hidden { display: none !important; }
.muted { color: var(--text2); }
.small { font-size: 13px; }
.error-text { color: var(--red); font-size: 14px; margin: 8px 0 0; }
.scrollable { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.scrollable::-webkit-scrollbar, .chip-bar::-webkit-scrollbar { display: none; }

/* ---------- map ---------- */
#map { position: absolute; inset: 0; background: var(--bg); z-index: 0; }
.mapboxgl-ctrl-attrib {
  font: 10px/14px -apple-system, sans-serif !important;
  background: var(--glass) !important;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 10px 0 0 0;
  color: var(--text2) !important;
}
.mapboxgl-ctrl-attrib a { color: var(--text2) !important; }
.mapboxgl-ctrl-logo { opacity: 0.55; }

/* ---------- glass primitives ---------- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
}
.pill { border-radius: var(--r-pill); }
.icon-btn {
  width: 44px; height: 44px; min-width: 44px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  transition: transform 0.18s var(--spring), background 0.2s var(--ease);
}
.icon-btn:active { transform: scale(0.9); }
.mini-btn {
  width: 30px; height: 30px; border-radius: var(--r-pill);
  background: var(--fill); display: grid; place-items: center;
  font-size: 15px; font-weight: 600;
  transition: transform 0.18s var(--spring);
}
.mini-btn:active { transform: scale(0.88); }
.text-btn { color: var(--blue); font-size: 16px; font-weight: 500; padding: 8px 6px; }
.text-btn:active { opacity: 0.5; }
.primary-btn {
  width: 100%; height: 54px; border-radius: var(--r-control);
  background: linear-gradient(180deg, #3c93ff, var(--blue-deep));
  color: #fff; font-size: 17px; font-weight: 600; letter-spacing: 0.2px;
  box-shadow: 0 10px 22px rgba(22, 119, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.2s var(--spring), box-shadow 0.2s var(--ease);
}
.primary-btn:active { transform: scale(0.97); box-shadow: 0 6px 14px rgba(22, 119, 255, 0.3); }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; z-index: 30;
  top: calc(var(--safe-top) + 10px);
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-right) + 12px);
  display: flex; gap: 10px; align-items: center;
  transition: opacity 0.3s var(--ease), transform 0.35s var(--spring);
}
.brand {
  display: flex; align-items: center; gap: 7px;
  height: 44px; padding: 0 14px 0 10px;
  font-weight: 700; font-size: 16px; letter-spacing: -0.2px;
}
.brand-mark { color: var(--blue); display: grid; place-items: center; }
.search-pill {
  flex: 1; display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 16px; border-radius: var(--r-pill);
  color: var(--text2); font-size: 16px;
  justify-content: flex-start;
  transition: transform 0.2s var(--spring);
}
.search-pill:active { transform: scale(0.97); }

/* ---------- fabs ---------- */
#fabStack {
  position: fixed; z-index: 31;
  right: calc(var(--safe-right) + 12px);
  bottom: calc(var(--safe-bottom) + 118px);
  display: flex; flex-direction: column; gap: 10px;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--spring);
}
.fab {
  width: 48px; height: 48px; border-radius: var(--r-pill);
  display: grid; place-items: center;
  transition: transform 0.2s var(--spring);
}
.fab:active { transform: scale(0.88); }
.fab.active { background: var(--blue); color: #fff; border-color: transparent; }

/* ---------- report fab + bubble menu ---------- */
#reportFabWrap {
  position: fixed; z-index: 32;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 24px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--spring);
}
.report-fab {
  width: 60px; height: 60px; border-radius: var(--r-pill);
  background: linear-gradient(180deg, #3c93ff, var(--blue-deep));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 12px 28px rgba(22, 119, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.25s var(--spring), background 0.25s var(--ease);
}
.report-fab:active { transform: scale(0.9); }
.report-fab.open { transform: rotate(45deg); background: var(--fill-strong); color: var(--text); box-shadow: var(--shadow-soft); }
.bubble-menu {
  position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: 12px;
  pointer-events: none;
}
.bubble-menu .bubble {
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 16px 0 8px;
  border-radius: var(--r-pill);
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  font-size: 15px; font-weight: 600; white-space: nowrap;
  opacity: 0; transform: translateY(18px) scale(0.7);
  transition: opacity 0.24s var(--ease), transform 0.32s var(--spring);
}
.bubble-menu.open { pointer-events: auto; }
.bubble-menu.open .bubble { opacity: 1; transform: translateY(0) scale(1); }
.bubble-menu.open .bubble:nth-child(1) { transition-delay: 0.02s; }
.bubble-menu.open .bubble:nth-child(2) { transition-delay: 0.05s; }
.bubble-menu.open .bubble:nth-child(3) { transition-delay: 0.08s; }
.bubble-menu.open .bubble:nth-child(4) { transition-delay: 0.11s; }
.bubble-menu.open .bubble:nth-child(5) { transition-delay: 0.14s; }
.bubble-menu.open .bubble:nth-child(6) { transition-delay: 0.17s; }
.bubble-menu.open .bubble:nth-child(7) { transition-delay: 0.2s; }
.bubble-menu.open .bubble:nth-child(8) { transition-delay: 0.23s; }
.bubble-icon {
  width: 34px; height: 34px; border-radius: var(--r-pill);
  display: grid; place-items: center; color: #fff; font-size: 17px;
}

/* ---------- sheets ---------- */
.sheet {
  position: fixed; z-index: 40;
  left: 0; right: 0; bottom: 0;
  margin: 0 auto; max-width: 560px;
  background: var(--surface-solid);
  border-radius: var(--r-card) var(--r-card) 0 0;
  box-shadow: var(--shadow-pop);
  padding: 6px 16px calc(var(--safe-bottom) + 14px);
  transform: translateY(105%);
  transition: transform 0.45s var(--spring);
  max-height: 82dvh;
  display: flex; flex-direction: column;
  will-change: transform;
}
[data-theme="dark"] .sheet { background: #1c1c1e; }
.sheet.open { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-tall { height: min(88dvh, 760px); }
.sheet-handle {
  width: 38px; height: 5px; border-radius: 3px;
  background: var(--fill-strong);
  margin: 6px auto 8px; flex: 0 0 auto;
  touch-action: none;
}
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 10px; }
.sheet-title-row h2 { margin: 0; font-size: 22px; letter-spacing: -0.4px; }

/* ---------- search ---------- */
.search-head { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; }
.search-field {
  flex: 1; display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 12px; border-radius: var(--r-control);
  color: var(--text2);
}
.search-field input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 17px; color: var(--text); min-width: 0;
}
.search-field input::placeholder { color: var(--text3); }
.search-mode {
  margin: 2px 0 10px; padding: 9px 12px;
  background: rgba(22, 119, 255, 0.12); color: var(--blue);
  border-radius: 12px; font-size: 14px; font-weight: 600;
}
.chip-bar {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px;
  flex: 0 0 auto;
}
.chip {
  flex: 0 0 auto; height: 36px; padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--fill); font-size: 14.5px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  transition: transform 0.18s var(--spring), background 0.2s;
}
.chip:active { transform: scale(0.93); }
.chip.active { background: var(--blue); color: #fff; }

/* ---------- lists / rows ---------- */
.list { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; }
.list-section {
  font-size: 13px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 14px 4px 6px;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 8px; border-radius: 14px;
  transition: background 0.15s var(--ease), transform 0.15s var(--spring);
  text-align: left; width: 100%;
}
.row:active { background: var(--fill); transform: scale(0.985); }
.row-icon {
  width: 40px; height: 40px; min-width: 40px; border-radius: var(--r-pill);
  background: var(--fill); display: grid; place-items: center;
  font-size: 18px; color: var(--blue);
}
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13.5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row-meta { font-size: 13px; color: var(--text3); text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; }

.empty-state { text-align: center; color: var(--text3); padding: 36px 20px; font-size: 15px; }
.empty-state .big { font-size: 34px; margin-bottom: 10px; }

.star-btn { color: var(--text3); font-size: 20px; padding: 6px; transition: transform 0.2s var(--spring), color 0.2s; }
.star-btn:active { transform: scale(0.8); }
.star-btn.on { color: var(--yellow); }

/* ---------- place card ---------- */
.place-hero { padding: 4px 0 2px; }
.place-title { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.place-sub { color: var(--text2); font-size: 15px; margin-top: 3px; }
.place-actions { display: flex; gap: 10px; padding: 14px 2px 6px; overflow-x: auto; }
.action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 66px; padding: 10px 6px; border-radius: var(--r-control);
  background: var(--fill); font-size: 12.5px; font-weight: 600;
  transition: transform 0.18s var(--spring), background 0.2s;
}
.action-btn:active { transform: scale(0.92); }
.action-btn .ico { font-size: 21px; color: var(--blue); }
.action-btn.dim .ico { color: var(--text2); }

/* ---------- route sheet ---------- */
.route-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 0 6px; }
.route-dest { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; }
.route-dest-sub { font-size: 13.5px; color: var(--text2); margin-top: 1px; }
.pref-chips { display: flex; gap: 8px; padding: 10px 0 4px; overflow-x: auto; }
.alt-scroll { display: flex; gap: 10px; overflow-x: auto; padding: 10px 2px 12px; scroll-snap-type: x mandatory; }
.alt-card {
  flex: 0 0 78%; max-width: 300px; scroll-snap-align: start;
  background: var(--fill); border-radius: var(--r-card);
  padding: 14px; border: 2px solid transparent;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--spring), background 0.2s;
}
.alt-card.selected { border-color: var(--blue); background: rgba(22, 119, 255, 0.1); }
.alt-card:active { transform: scale(0.97); }
.alt-tag { font-size: 12px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: 0.5px; }
.alt-main { font-size: 22px; font-weight: 700; margin-top: 4px; }
.alt-sub { font-size: 14px; color: var(--text2); margin-top: 2px; }
.alt-badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.badge {
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: var(--r-pill);
  background: var(--fill-strong); color: var(--text2);
}
.badge.toll { background: rgba(240, 124, 34, 0.16); color: var(--orange); }
.badge.tollfree { background: rgba(45, 190, 96, 0.15); color: var(--green); }
.badge.traffic { background: rgba(229, 57, 53, 0.14); color: var(--red); }
.route-steps { padding: 4px 0 8px; }
.step-row { display: flex; gap: 12px; padding: 10px 6px; align-items: center; }
.step-ico { width: 30px; color: var(--blue); display: grid; place-items: center; }
.step-txt { flex: 1; font-size: 14.5px; }
.step-dist { font-size: 13px; color: var(--text3); }
.route-actions { display: flex; gap: 10px; align-items: center; padding-top: 6px; }
.route-actions .primary-btn { flex: 1; }

/* ---------- saved / settings / layers ---------- */
.segmented {
  display: flex; background: var(--fill); border-radius: 12px; padding: 3px; gap: 3px;
  margin-bottom: 10px; flex: 0 0 auto;
}
.segmented button {
  flex: 1; height: 36px; border-radius: 10px; font-size: 14px; font-weight: 600;
  color: var(--text2); transition: background 0.2s var(--ease), color 0.2s, transform 0.2s var(--spring);
}
.segmented button.active { background: var(--surface-solid); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
[data-theme="dark"] .segmented button.active { background: #3a3a3c; }
.segmented button:active { transform: scale(0.96); }

.settings-group { padding: 8px 0 4px; }
.settings-group h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text3); margin: 14px 6px 6px;
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 6px; border-bottom: 1px solid var(--hairline);
}
.setting-row:last-child { border-bottom: 0; }
.setting-label { font-size: 15.5px; }
.setting-desc { font-size: 12.5px; color: var(--text3); margin-top: 2px; }
.setting-control { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }

/* iOS switch */
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--r-pill);
  background: var(--fill-strong); transition: background 0.25s var(--ease);
  pointer-events: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: var(--r-pill);
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s var(--spring);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(20px); }

.select {
  height: 36px; border-radius: 10px; border: 1px solid var(--hairline);
  background: var(--fill); color: var(--text); font-size: 14.5px; padding: 0 10px;
  -webkit-appearance: none; appearance: none;
}
.input-glass {
  height: 40px; border-radius: 12px; border: 1px solid var(--hairline);
  background: var(--fill); color: var(--text); font-size: 15px; padding: 0 12px; width: 100%;
  outline: none;
}
.input-glass:focus { border-color: var(--blue); }
.button-soft {
  height: 38px; padding: 0 14px; border-radius: 12px;
  background: var(--fill); font-size: 14.5px; font-weight: 600;
  transition: transform 0.18s var(--spring);
}
.button-soft:active { transform: scale(0.94); }
.button-soft.danger { color: var(--red); }

/* ---------- nav HUD ---------- */
.nav-banner {
  position: fixed; z-index: 35;
  top: calc(var(--safe-top) + 10px);
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-right) + 12px);
  max-width: 560px; margin: 0 auto;
  display: flex; gap: 12px; align-items: center;
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-pop);
  padding: 12px 14px;
  animation: dropIn 0.45s var(--spring);
}
.turn-icon {
  width: 54px; height: 54px; min-width: 54px; border-radius: var(--r-control);
  background: var(--blue); color: #fff;
  display: grid; place-items: center;
}
.turn-icon svg { width: 34px; height: 34px; }
.turn-body { flex: 1; min-width: 0; }
.turn-top { display: flex; justify-content: space-between; align-items: baseline; }
#turnDist { font-size: 26px; font-weight: 800; letter-spacing: -0.6px; }
.turn-eta { font-size: 13px; color: var(--text2); font-weight: 600; }
.turn-street { font-size: 16.5px; font-weight: 600; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-next { font-size: 13px; color: var(--text2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lanes { display: flex; gap: 5px; margin-top: 7px; }
.lane {
  width: 26px; height: 30px; border-radius: 7px;
  border: 1.5px solid var(--hairline);
  display: grid; place-items: center; color: var(--text3);
}
.lane.valid { color: var(--text); border-color: var(--text3); background: var(--fill); }
.lane svg { width: 17px; height: 17px; }

.alert-banner {
  position: fixed; z-index: 36;
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-right) + 12px);
  top: calc(var(--safe-top) + 10px);
  max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  background: rgba(245, 197, 66, 0.94);
  color: #3b2c00;
  border-radius: var(--r-control);
  box-shadow: var(--shadow-pop);
  padding: 12px 14px;
  font-weight: 650; font-size: 15.5px;
  animation: dropIn 0.4s var(--spring);
}
.alert-banner.danger { background: rgba(229, 57, 53, 0.95); color: #fff; }
.alert-banner .alert-ico { font-size: 22px; }
body.navigating .alert-banner { top: calc(var(--safe-top) + 104px); }

.nav-footer {
  position: fixed; z-index: 35;
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-right) + 12px);
  bottom: calc(var(--safe-bottom) + 12px);
  max-width: 560px; margin: 0 auto;
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: riseIn 0.45s var(--spring);
}
.nav-progress { height: 4px; background: var(--fill); }
.nav-progress i { display: block; height: 100%; width: 0%; background: var(--blue); border-radius: 0 4px 4px 0; transition: width 0.6s var(--ease); }
.nav-bottom-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.nav-end {
  height: 44px; padding: 0 18px; border-radius: var(--r-pill);
  background: rgba(229, 57, 53, 0.14); color: var(--red);
  font-size: 16px; font-weight: 700;
  transition: transform 0.18s var(--spring);
}
.nav-end:active { transform: scale(0.93); }
.nav-stats { flex: 1; display: flex; flex-direction: column; }
#navEta { font-size: 17px; font-weight: 700; }
#navRemain { font-size: 13.5px; color: var(--text2); }
.nav-actions { display: flex; gap: 8px; }
.mini-fab {
  width: 40px; height: 40px; border-radius: var(--r-pill);
  background: var(--fill); display: grid; place-items: center;
  font-size: 17px;
  transition: transform 0.18s var(--spring), background 0.2s;
}
.mini-fab:active { transform: scale(0.88); }
.mini-fab.on { background: var(--blue); color: #fff; }

.sim-bar {
  position: fixed; z-index: 34;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 112px);
  display: flex; align-items: center; gap: 12px;
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-soft);
  padding: 8px 14px;
  font-size: 13.5px; font-weight: 600;
  animation: riseIn 0.4s var(--spring);
}
.sim-controls { display: flex; align-items: center; gap: 8px; }
.sim-label { color: var(--blue); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; z-index: 60;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 96px);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 90vw;
}
.toast {
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-pop);
  padding: 11px 18px;
  font-size: 14.5px; font-weight: 600;
  animation: popIn 0.35s var(--spring);
}
.toast.leaving { animation: fadeOut 0.3s var(--ease) forwards; }

/* ---------- offline ---------- */
.offline-banner {
  position: fixed; z-index: 65;
  top: calc(var(--safe-top) + 8px); left: 50%; transform: translateX(-50%);
  background: rgba(229, 57, 53, 0.95); color: #fff;
  border-radius: var(--r-pill); padding: 9px 16px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: dropIn 0.4s var(--spring);
}

/* ---------- onboarding / loading ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(22, 119, 255, 0.35), transparent 60%),
    var(--bg);
  padding: 24px;
}
.onboard-card {
  width: 100%; max-width: 420px;
  background: var(--glass-strong);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  box-shadow: var(--shadow-pop);
  padding: 26px 22px;
  animation: popIn 0.5s var(--spring);
}
.onboard-logo {
  width: 62px; height: 62px; border-radius: 18px;
  background: linear-gradient(180deg, #3c93ff, var(--blue-deep));
  display: grid; place-items: center; margin-bottom: 16px;
  box-shadow: 0 10px 24px rgba(22, 119, 255, 0.35);
}
.onboard-card h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.6px; }
.onboard-card p { margin: 0 0 16px; line-height: 1.45; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.onboard-card input {
  width: 100%; height: 50px; border-radius: var(--r-control);
  border: 1px solid var(--hairline); background: var(--fill);
  color: var(--text); font-size: 15px; padding: 0 14px; margin-bottom: 14px;
  outline: none; -webkit-appearance: none;
}
.onboard-card input:focus { border-color: var(--blue); }
.onboard-card a { color: var(--blue); }

.loading {
  position: fixed; z-index: 68;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 12px;
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-pop);
  padding: 14px 22px;
  font-size: 15px; font-weight: 600;
  animation: popIn 0.3s var(--spring);
}
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--fill-strong); border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}

/* ---------- navigating mode ---------- */
body.navigating #topbar,
body.navigating #fabStack,
body.navigating #reportFabWrap,
body.navigating .sheet { opacity: 0; pointer-events: none; transform: translateY(20px); }
body.navigating #navBanner,
body.navigating #navFooter { display: flex !important; }

/* ---------- desktop ---------- */
@media (min-width: 768px) {
  .sheet { border-radius: var(--r-card); bottom: 20px; max-width: 480px; }
  #reportFabWrap { left: auto; right: calc(var(--safe-right) + 12px); transform: none; bottom: calc(var(--safe-bottom) + 34px); }
  #fabStack { bottom: calc(var(--safe-bottom) + 156px); }
  .bubble-menu { left: auto; right: 4px; transform: none; }
  .bubble { flex-direction: row-reverse; padding: 0 8px 0 16px; }
}

/* ---------- keyframes ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.86); } to { opacity: 1; transform: scale(1); } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-14px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(8px) scale(0.96); } }
@keyframes pulseRing {
  0% { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* location puck (HTML marker) */
.puck { position: relative; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; }
.puck::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--blue); border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(22, 119, 255, 0.55);
  z-index: 2;
}
.puck::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  background: rgba(22, 119, 255, 0.35);
  animation: pulseRing 2.2s var(--ease) infinite;
  z-index: 1;
}
.puck .heading {
  position: relative; z-index: 3;
  width: 16px; height: 16px;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}
.puck .heading.hidden { display: none; }

.dest-pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px;
  background: linear-gradient(160deg, #3c93ff, var(--blue-deep));
  transform: rotate(-45deg);
  border: 2.5px solid #fff;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.35);
}
.dest-pin::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%;
  background: #fff;
}
.stop-pin {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-solid); border: 2.5px solid var(--blue);
  color: var(--blue); font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: var(--shadow-soft);
}

/* map popup */
.mapboxgl-popup-content {
  background: var(--glass-strong) !important;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 16px !important;
  box-shadow: var(--shadow-pop) !important;
  color: var(--text) !important;
  padding: 12px 14px !important;
  font: 14px -apple-system, sans-serif !important;
}
.mapboxgl-popup-tip { display: none !important; }
.mapboxgl-popup-close-button { font-size: 18px; color: var(--text2) !important; padding: 2px 8px !important; }

/* ---------- theme toggle ---------- */
#themeBtn svg { display: block; }

/* ---------- route sheet: from row ---------- */
.from-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 6px; margin: 0 0 6px; background: transparent; border: 0;
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
  border-radius: var(--r-control);
}
.from-row:active { background: rgba(127, 127, 127, 0.12); }
.from-row .from-label { font-size: 11px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text3); }
.from-row .from-name { flex: 1; font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.from-row .from-edit { color: var(--blue); font-weight: 700; font-size: 13px; }

/* ---------- speed HUD ---------- */
.speed-hud {
  position: fixed; z-index: 34;
  left: calc(var(--safe-left) + 14px);
  bottom: calc(var(--safe-bottom) + 108px);
  display: none; align-items: flex-end; gap: 10px;
  transition: opacity 0.3s var(--ease);
}
body.navigating .speed-hud { display: flex; }
.speed-main {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#speedNow { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.speed-unit { font-size: 11px; font-weight: 700; color: var(--text2); margin-top: 2px; }
.speed-limit {
  min-width: 52px; height: 62px; padding: 0 8px;
  background: #fff; border: 3.5px solid #111; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #111; box-shadow: var(--shadow-soft);
}
.speed-limit span { font-size: 23px; font-weight: 800; line-height: 1; }
.speed-limit small { font-size: 7px; font-weight: 800; letter-spacing: 1.2px; margin-top: 1px; }

/* ---------- puck variants ---------- */
.puck.dot .heading { display: none; }
.puck .car { position: absolute; inset: 2.5px; z-index: 3; }
.puck.car::before { background: #1c1c1e; border-color: rgba(255,255,255,0.85); }

/* ---------- Apple-style destination pin ---------- */
.dest-pin {
  width: 36px; height: 36px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(160deg, #ff5f4d, #d21f1f);
  transform: rotate(-45deg);
  border: 3px solid #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}
.dest-pin::after { inset: 10px; }
