/* =========================================================
   BuzzCloud Maps — Apple Maps-inspired iOS interface
   ========================================================= */

:root {
  /* iOS system colors */
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --gray-fill: rgba(120, 120, 128, 0.12);
  --gray-fill-strong: rgba(120, 120, 128, 0.2);

  --label: #000000;
  --label-secondary: rgba(60, 60, 67, 0.6);
  --label-tertiary: rgba(60, 60, 67, 0.3);

  --sheet-bg: rgba(249, 249, 249, 0.94);
  --card-bg: rgba(255, 255, 255, 0.92);
  --ctrl-bg: rgba(255, 255, 255, 0.86);
  --separator: rgba(60, 60, 67, 0.13);

  --shadow-sheet: 0 -1px 20px rgba(0, 0, 0, 0.14);
  --shadow-ctrl: 0 1px 6px rgba(0, 0, 0, 0.18);
  --nav-banner-bg: rgba(24, 34, 44, 0.95);
  --nav-then-bg: rgba(38, 50, 62, 0.95);
  --nav-top-h: 106px;   /* set from JS: the top stack's bottom edge */

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", Roboto, system-ui, sans-serif;

  --sheet-peek: 210px;   /* collapsed height */
  --sheet-full: 88vh;    /* expanded height */
}

@media (prefers-color-scheme: dark) {
  :root {
    --label: #ffffff;
    --label-secondary: rgba(235, 235, 245, 0.6);
    --label-tertiary: rgba(235, 235, 245, 0.3);

    --gray-fill: rgba(118, 118, 128, 0.24);
    --gray-fill-strong: rgba(118, 118, 128, 0.36);

    --sheet-bg: rgba(28, 28, 30, 0.94);
    --card-bg: rgba(44, 44, 46, 0.92);
    --ctrl-bg: rgba(44, 44, 46, 0.88);
    --separator: rgba(84, 84, 88, 0.6);

    --shadow-sheet: 0 -1px 20px rgba(0, 0, 0, 0.5);
    --shadow-ctrl: 0 1px 6px rgba(0, 0, 0, 0.4);
    --nav-banner-bg: rgba(16, 23, 30, 0.96);
    --nav-then-bg: rgba(30, 40, 50, 0.96);
  }
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--label);
  overscroll-behavior: none;
}

#map { position: absolute; inset: 0; }

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* =========================================================
   Floating map controls (right edge)
   ========================================================= */
.map-controls {
  position: absolute;
  right: 12px;
  top: 60px;
  transition: top 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: 11px;
  overflow: hidden;
  box-shadow: var(--shadow-ctrl);
}
.map-ctrl-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--ctrl-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-ctrl-btn:active { background: var(--gray-fill-strong); }
.map-ctrl-btn.is-off { color: var(--label-secondary); }
/* The navigation banner is far taller than the search pill, so the control
   stack drops below it rather than hiding underneath. */
.map-controls.nav-shift { top: calc(var(--nav-top-h) + 12px); }
@media (min-width: 700px) {
  .map-controls.nav-shift { top: calc(var(--nav-top-h) + 12px); }
}

/* Road you're on, pinned under the puck. */
.road-pill {
  position: absolute;
  left: 50%;
  top: calc(72% + 34px);
  transform: translateX(-50%);
  z-index: 24;
  pointer-events: none;
  padding: 5px 13px;
  border-radius: 13px;
  background: var(--ctrl-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-ctrl);
  color: var(--blue);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================
   Bottom sheet
   ========================================================= */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: var(--sheet-peek);
  display: flex;
  flex-direction: column;
  background: var(--sheet-bg);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow-sheet);
  transition: height 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet.expanded { height: var(--sheet-full); }

/* Desktop: float the sheet as a left-hand panel, like Maps on iPad/Mac */
@media (min-width: 700px) {
  .sheet {
    left: 12px;
    bottom: 12px;
    width: 370px;
    right: auto;
    border-radius: 12px;
    height: 460px;
  }
  .sheet.expanded { height: calc(100vh - 24px); }
  .map-controls { top: 12px; }
}

/* Big invisible drag target — the visible pill is just the affordance. */
.sheet-handle-area {
  flex-shrink: 0;
  padding: 10px 0 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.sheet-handle-area:active { cursor: grabbing; }
.sheet-grabber {
  width: 40px;
  height: 5px;
  border-radius: 2.5px;
  background: var(--label-tertiary);
  pointer-events: none;
}

/* --- Search row --- */
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 10px;
  flex-shrink: 0;
}
.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--gray-fill);
  min-width: 0;
}
.search-icon { color: var(--label-secondary); flex-shrink: 0; }
#search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 17px;
  color: var(--label);
  min-width: 0;
}
#search-input::placeholder { color: var(--label-secondary); }
.clear-btn {
  border: none;
  background: transparent;
  color: var(--label-secondary);
  padding: 0;
  display: flex;
  flex-shrink: 0;
}
.cancel-btn {
  border: none;
  background: transparent;
  color: var(--blue);
  font-size: 17px;
  padding: 0 2px;
  flex-shrink: 0;
}

/* --- Sheet scrolling body --- */
.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 16px;
}
.pane { animation: fade-in 0.22s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--label-secondary);
  text-transform: none;
  margin: 14px 4px 8px;
  letter-spacing: -0.01em;
}

/* =========================================================
   Search results — grouped inset list, Apple style
   ========================================================= */
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: var(--card-bg);
  border-bottom: 0.5px solid var(--separator);
}
.result-list li:first-child { border-radius: 11px 11px 0 0; }
.result-list li:last-child { border-radius: 0 0 11px 11px; border-bottom: none; }
.result-list li:only-child { border-radius: 11px; }
.result-list li:active { background: var(--gray-fill-strong); }

.result-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.result-icon.cat-food { background: var(--orange); }
.result-icon.cat-park { background: var(--green); }
.result-icon.cat-shop { background: #ff9500; }
.result-icon.cat-road { background: #8e8e93; }
.result-icon.cat-fuel { background: #5856d6; }
.result-icon.cat-hotel { background: #af52de; }
.result-icon.cat-health { background: #ff2d55; }

.result-text { flex: 1; min-width: 0; }
.result-name {
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-sub {
  font-size: 13px;
  color: var(--label-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.result-dist {
  font-size: 13px;
  color: var(--label-secondary);
  flex-shrink: 0;
}

/* --- Category shortcut chips --- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: none;
  border-radius: 16px;
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 500;
  background: var(--card-bg);
  color: var(--label);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.chip:active { background: var(--gray-fill-strong); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 14px 4px 8px;
}
.section-head .section-label { margin: 0; }

/* --- Settings row (e.g. Rude Mode toggle) --- */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  background: var(--card-bg);
  border-radius: 11px;
}
.settings-row-text .result-sub { margin-top: 1px; }

.toggle-switch {
  position: relative;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  border: none;
  background: var(--gray-fill-strong);
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s ease;
}
.toggle-switch.is-on { background: var(--green); }
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}
.toggle-switch.is-on .toggle-knob { transform: translateX(20px); }
.link-btn {
  border: none;
  background: transparent;
  color: var(--blue);
  font-size: 14px;
  padding: 0;
}

.empty-state { padding: 6px 4px; }
.empty-hint { font-size: 14px; color: var(--label-secondary); margin-top: 2px; }

/* =========================================================
   Place detail
   ========================================================= */

/* Cover photo — the earliest photo uploaded for this place, bled edge-to-edge
   at the top of the sheet with the title/category pulled up to overlay its
   fade, like a Google-Maps place-page header. Hidden (no height at all)
   until a place actually has a photo. */
.place-cover {
  position: relative;
  height: 176px;
  margin: 0 -12px;
  overflow: hidden;
}
.place-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.place-cover-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.68) 100%);
}

.place-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 0;
}
/* Pulled up into the cover's fade zone — see place-cover-fade above, sized to
   match. Text goes white/shadowed here regardless of light/dark theme, since
   it's sitting on a photo rather than the app background. */
.place-head.over-cover {
  position: relative;
  z-index: 2;
  margin-top: -66px;
  padding: 0 12px;
}
.place-head.over-cover .place-title,
.place-head.over-cover .place-category {
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.place-head.over-cover .close-round {
  background: rgba(0, 0, 0, 0.38);
  color: #fff;
}
.place-head-text { flex: 1; min-width: 0; }
.place-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
}
.place-category {
  font-size: 14px;
  color: var(--label-secondary);
  margin-top: 3px;
}
.close-round {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--gray-fill);
  color: var(--label-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.close-round:active { background: var(--gray-fill-strong); }

/* Travel mode segmented control (drive / bike / walk) */
.mode-row {
  display: flex;
  gap: 4px;
  margin: 12px 0 0;
  padding: 3px;
  background: var(--gray-fill);
  border-radius: 10px;
}
.mode-btn {
  flex: 1;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--label-secondary);
}
.mode-btn.is-active {
  background: var(--card-bg);
  color: var(--blue);
  box-shadow: var(--shadow-ctrl);
}
.mode-btn:active { filter: brightness(0.92); }
.mode-btn:disabled { opacity: 0.4; }

/* Route options strip (Apple-Maps-style alternate route picker) */
.route-options {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.route-options::-webkit-scrollbar { display: none; }
.route-option {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 8px 14px;
  border: none;
  border-radius: 12px;
  background: var(--gray-fill);
  color: var(--label);
  text-align: left;
}
.route-option:active { filter: brightness(0.92); }
.route-option.is-active {
  background: var(--blue);
  color: #fff;
}
.route-option-time { font-size: 15px; font-weight: 600; }
.route-option-sub { font-size: 12px; color: var(--label-secondary); margin-top: 1px; }
.route-option.is-active .route-option-sub { color: rgba(255, 255, 255, 0.85); }

/* Action row */
.action-row {
  display: flex;
  gap: 8px;
  margin: 14px 0 4px;
}
.action-btn {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.action-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.action-primary { background: var(--blue); color: #fff; }
.action-go { background: var(--green); color: #fff; font-size: 17px; }
.action-tinted { background: var(--gray-fill); color: var(--blue); }
.action-btn:active { filter: brightness(0.92); }
.action-btn:disabled { opacity: 0.5; }

/* Icon-only voice button stays narrow next to the wider text actions */
.voice-btn { flex: 0 0 46px; }

/* Selected voice row gets a checkmark tint */
.voice-row-selected .result-name { color: var(--blue); font-weight: 600; }
.voice-check { color: var(--blue); flex-shrink: 0; }

.detail-card {
  margin-top: 14px;
  border-radius: 11px;
  background: var(--card-bg);
  overflow: hidden;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 0.5px solid var(--separator);
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--label-secondary); flex-shrink: 0; }
.detail-val { text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* =========================================================
   Location photos
   ========================================================= */
.photos-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scrollbar-width: none;
}
.photos-strip::-webkit-scrollbar { display: none; }

.add-photo-tile,
.photo-thumb {
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  border-radius: 11px;
  border: none;
  overflow: hidden;
  position: relative;
  /* These are <button> elements — without resetting the UA default padding
     and background, the browser's own button chrome shows through around
     the image as odd white side borders. */
  padding: 0;
  margin: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
}
.add-photo-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: var(--gray-fill);
  color: var(--blue);
  border: 1.5px dashed var(--gray-fill-strong);
  font-size: 11px;
  font-weight: 600;
}
.add-photo-tile:active { background: var(--gray-fill-strong); }

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb:active img { filter: brightness(0.85); }

.photo-review {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--card-bg);
}
.photo-review img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 9px;
  display: block;
}
.photo-caption-input {
  width: 100%;
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  border: none;
  background: var(--gray-fill);
  color: var(--label);
  font-size: 14px;
  font-family: inherit;
}
.photo-caption-input::placeholder { color: var(--label-tertiary); }

/* Full-screen photo lightbox */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img {
  max-width: 94vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  padding: 0 16px;
}
.lightbox-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  background: rgba(120, 120, 128, 0.32);
  color: #fff;
}
.lightbox-delete {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  background: rgba(120, 120, 128, 0.32);
  color: #fff;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(120, 120, 128, 0.32);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }

/* =========================================================
   Route preview
   ========================================================= */
.route-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 0;
}
.route-eta {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--green);
}
.route-sub { font-size: 14px; color: var(--label-secondary); margin-top: 2px; }

.steps-list { list-style: none; margin: 0; padding: 0; }
.steps-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--card-bg);
  border-bottom: 0.5px solid var(--separator);
  font-size: 15px;
  line-height: 1.35;
}
.steps-list li:first-child { border-radius: 11px 11px 0 0; }
.steps-list li:last-child { border-radius: 0 0 11px 11px; border-bottom: none; }
.step-index {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gray-fill);
  color: var(--label-secondary);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.step-text { flex: 1; min-width: 0; }
.step-dist { font-size: 13px; color: var(--label-secondary); margin-top: 2px; }

/* Step currently being flown through / driven */
.steps-list li.step-active {
  background: rgba(0, 122, 255, 0.12);
}
.steps-list li.step-active .step-index {
  background: var(--blue);
  color: #fff;
}
.steps-list li.step-active .step-text { font-weight: 600; }

/* Spinner for in-flight actions */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.action-tinted .spinner {
  border-color: rgba(0, 122, 255, 0.3);
  border-top-color: var(--blue);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   User location puck — ONE definition, used both on the map and
   while navigating, so the two can never drift out of sync.
   ========================================================= */
.puck {
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.puck-beam {
  position: absolute;
  bottom: 50%;
  width: 120px;
  height: 120px;
  background: linear-gradient(to top, rgba(0, 122, 255, 0.32), rgba(0, 122, 255, 0));
  clip-path: polygon(50% 100%, 6% 0%, 94% 0%);
  /* MapLibre owns the root element's transform, so the zoom scale is applied
     to the children. Scaled from the dot outwards so the beam stays attached. */
  transform: translateY(4px) scale(var(--puck-scale, 1));
  transform-origin: bottom center;
  transition: transform 0.12s linear;
}
.puck-dot {
  position: relative;
  transform: scale(var(--puck-scale, 1));
  transform-origin: center;
  transition: transform 0.12s linear;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #007aff;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Soft accuracy halo, matching the old map-layer look. */
.puck-dot::before {
  content: "";
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 122, 255, 0.16);
}
/* Hidden until we actually have a heading to point. */
.puck.no-heading .puck-beam,
.puck.no-heading .puck-chevron { display: none; }

/* Shown when the fix is too far from any mapped road to trust a snap to it —
   off-roading, on the water, or on a road OSM simply hasn't mapped yet. */
.puck.off-road .puck-dot { background: #8e8e93; }
.puck.off-road .puck-dot::before { background: rgba(142, 142, 147, 0.16); }
.puck.off-road .puck-beam {
  background: linear-gradient(to top, rgba(142, 142, 147, 0.32), rgba(142, 142, 147, 0));
}

/* While navigating the map itself rotates to your heading, so the beam would
   only repeat what the whole view already says. The chevron is enough. */
.nav-puck .puck-beam { display: none; }

/* Navigation variant: pinned to a fixed screen point, map moves beneath. */
.nav-puck {
  position: absolute;
  left: 50%;
  /* Below centre so most of the screen shows the road ahead.
     Must stay in sync with NAV_PUCK_SCREEN_BIAS in main.js. */
  top: 72%;
  transform: translate(-50%, -50%);
  z-index: 25;
}

/* =========================================================
   Live navigation banner — distance leads, street confirms
   ========================================================= */
.nav-top {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 10px;
  right: 10px;
  z-index: 40;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.nav-top > * { pointer-events: auto; }

.nav-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px 18px;
  border-radius: 20px;
  background: var(--nav-banner-bg);
  color: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}
.nav-glyph {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.nav-text { flex: 1; min-width: 0; }
.nav-distance {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.nav-street {
  font-size: 17px;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.nav-end-btn {
  border: none;
  background: rgba(255, 59, 48, 0.14);
  color: #ff3b30;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 15px;
  border-radius: 14px;
  flex-shrink: 0;
  align-self: center;
}
.nav-end-btn:active { background: rgba(255, 59, 48, 0.24); }

/* --- "Then" secondary maneuver, tucked beneath the banner --- */
.nav-then {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-radius: 14px;
  background: var(--nav-then-bg);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.nav-then-label {
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-then-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Trip progress bar (arrival / time left / distance left) --- */
.trip-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 38;
  max-width: 380px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 12px 12px 16px;
  border-radius: 16px;
  background: var(--sheet-bg);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  box-shadow: var(--shadow-sheet);
}
@media (min-width: 700px) {
  .trip-bar { left: 12px; right: auto; width: 370px; margin: 0; }
}
.trip-stat { text-align: center; min-width: 0; flex: 0 1 auto; padding: 0 2px; }
.trip-stat-value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.trip-stat-value.trip-eta { color: var(--green); transition: color 0.3s ease; }
.trip-stat-value.trip-eta.behind { color: var(--red); }
.trip-stat-label {
  font-size: 11px;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 1px;
}

/* =========================================================
   Misc overlays
   ========================================================= */
.skip-preview {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  z-index: 35;
  border: none;
  border-radius: 18px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--ctrl-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  color: var(--blue);
  box-shadow: var(--shadow-ctrl);
}

.toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--sheet-peek) + 16px);
  z-index: 50;
  max-width: 88vw;
  width: max-content;
  padding: 11px 18px;
  border-radius: 14px;
  background: rgba(28, 28, 30, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}
@media (min-width: 700px) {
  .toast { bottom: 24px; }
}

/* MapLibre's default controls are replaced by our own */
.maplibregl-ctrl-top-right,
.maplibregl-ctrl-bottom-left { display: none; }
.maplibregl-ctrl-bottom-right { bottom: 4px; right: 4px; opacity: 0.55; }
.maplibregl-popup-content {
  border-radius: 12px;
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
}

/* Marks a search result that can be shown but not routed to. */
.result-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--gray-fill-strong);
  color: var(--label-secondary);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

/* =========================================================
   Speed limit sign + live speed
   ========================================================= */
.speed-cluster {
  position: absolute;
  left: 12px;
  top: calc(var(--nav-top-h) + 12px);
  z-index: 37;
  display: flex;
  align-items: stretch;
  gap: 7px;
}

/* US regulatory sign: white field, black border, stacked legend. */
.speed-sign {
  width: 54px;
  border-radius: 6px;
  background: #fff;
  border: 2.5px solid #1c1c1e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  padding: 3px 0 4px;
  text-align: center;
  font-family: var(--font);
}
.speed-sign-label {
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: #1c1c1e;
}
.speed-sign-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.05;
  color: #1c1c1e;
  font-variant-numeric: tabular-nums;
}

.current-speed {
  min-width: 54px;
  border-radius: 12px;
  padding: 7px 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--sheet-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-ctrl);
  color: var(--label);
}
.current-speed-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.current-speed-unit {
  font-size: 10px;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1px;
}

/* Over the posted limit: the readout goes red, the sign pulses. */
.current-speed.over .current-speed-value { color: #ff3b30; }
.current-speed.over { box-shadow: 0 0 0 2px rgba(255, 59, 48, 0.55), var(--shadow-ctrl); }
.speed-sign.over { animation: speed-pulse 1.4s ease-in-out infinite; }
@keyframes speed-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
  50%      { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(255, 59, 48, 0.45); }
}
@media (prefers-reduced-motion: reduce) {
  .speed-sign.over { animation: none; box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.6); }
}
