/* Darb's driving surface: one action color, quiet map chrome and clear directions. */
body.driving-ui {
  --ink: #182332;
  --muted: #6b7787;
  --blue: #3268f5;
  --aqua: #3268f5;
  --aqua-light: #edf2ff;
  --panel: #fff;
  --surface: #f3f5f8;
  --border: #e5e9ef;
  --shadow: 0 12px 38px #13243a1a;
  --small-shadow: 0 3px 18px #13243a17;
  --darb-top: max(12px, env(safe-area-inset-top));
  --darb-bottom: max(12px, env(safe-area-inset-bottom));
  --darb-bottom-space: 16px;
}
body.driving-ui.dark {
  --ink: #eff4fa;
  --muted: #a4b2c2;
  --panel: #1a2636;
  --surface: #253347;
  --border: #344156;
  --aqua-light: #253c66;
  --shadow: 0 12px 38px #0005;
  --small-shadow: 0 3px 18px #0003;
}
body.driving-ui button { min-height: 48px; }
body.driving-ui .icon-button { width: 48px; height: 48px; }
body.driving-ui .map-vignette { background: linear-gradient(#e9eff833, transparent 120px); }
body.driving-ui.dark .map-vignette { background: linear-gradient(#07122255, transparent 120px); }
body.driving-ui .app-header { top: var(--darb-top); left: 16px; right: 16px; gap: 12px; z-index: 7; }
body.driving-ui .brand { padding: 6px 10px; gap: 8px; border: 0; border-radius: 18px; min-height: 52px; }
body.driving-ui .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
body.driving-ui .brand-copy { min-width: 0; padding: 0; }
body.driving-ui .brand-name { font-size: 25px; letter-spacing: -1px; }
body.driving-ui .brand-dot { color: var(--blue); }
body.driving-ui .brand-tagline,
body.driving-ui .prototype-badge { display: none; }
body.driving-ui .header-actions { gap: 0; padding: 2px; border-radius: 18px; }
body.driving-ui .header-actions .icon-button { width: 48px; height: 48px; border-radius: 15px; }
body.driving-ui .header-actions .icon-button[aria-pressed=true] { color: var(--blue); background: var(--aqua-light); }
body.driving-ui .region-switcher { top: calc(var(--darb-top) + 62px); right: 16px; left: auto; width: 176px; min-height: 48px; gap: 7px; padding: 0 10px; border-radius: 16px; }
body.driving-ui .region-switcher .region-icon { width: 25px; height: 28px; background: none; }
body.driving-ui .region-icon svg { width: 20px; height: 20px; }
body.driving-ui .region-field { flex: 1; min-width: 0; }
body.driving-ui .region-field label,
body.driving-ui .coverage-pill { display: none; }
body.driving-ui .region-field select { min-height: 48px; font-size: 12px; padding-left: 18px; }
body.driving-ui .app-shell .map-context { top: auto; left: 16px; bottom: 16px; transform: none; max-width: min(300px, calc(100% - 420px)); height: 28px; padding: 0 10px; font-size: 10px; border: 0; box-shadow: var(--small-shadow); overflow: hidden; text-overflow: ellipsis; background: var(--panel); color: var(--muted); }
body.driving-ui .map-context #region-label,
body.driving-ui .map-context .context-divider { display: none; }

#planner { top: 140px; bottom: var(--darb-bottom); right: 16px; left: auto; width: 360px; max-height: min(740px, calc(100dvh - 156px)); border-radius: 24px; }
#planner .panel-toggle { display: flex; align-items: center; justify-content: center; width: 100%; height: 48px; min-height: 48px; padding: 0; border: 0; background: none; flex-shrink: 0; cursor: pointer; }
#planner .panel-toggle span { width: 34px; height: 4px; border-radius: 8px; background: #c7d1dd; }
#planner .planner-content { padding: 0 18px 20px; min-height: 0; overflow: auto; }
#planner .planner-heading { margin-bottom: 14px; }
#planner .planner-heading h1 { font-size: 23px; line-height: 1.6; letter-spacing: -.6px; }
#planner .planner-heading .eyebrow,
#planner .heading-illustration { display: none; }
#planner .waypoints { padding: 10px 12px; border: 0; border-radius: 18px; background: var(--surface); }
#planner .waypoint-row { min-height: 60px; gap: 9px; }
#planner .waypoint-field label { font-size: 10px; }
#planner .waypoint-field input { min-height: 36px; font-size: 15px; font-weight: 650; }
#planner .field-button { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 13px; }
#planner .waypoint-actions { gap: 0; }
#planner .swap-button { min-height: 48px; min-width: 48px; }
#planner .route-button { min-height: 54px; border-radius: 17px; font-size: 15px; margin-top: 12px; color: #fff; background: var(--blue); }
#planner .primary-button { color: #fff; background: var(--blue); }
#planner .route-actions .primary-button,
#planner .route-actions .secondary-button { min-height: 52px; border-radius: 15px; }
#planner .route-result { padding-top: 16px; margin-top: 16px; }
#planner .metric.main-metric strong { color: var(--blue); }
#planner .route-alternative { min-height: 48px; border-radius: 13px; font-size: 11px; }
#planner .route-alternative.active,
#planner .route-alternative.selected { border-color: var(--blue); color: var(--blue); background: var(--aqua-light); }
#planner .nearby-section { margin-top: 22px; }
#planner .section-heading h2 { font-size: 13px; }
#planner .quick-places { gap: 8px; }
#planner .quick-place { border: 0; background: var(--surface); border-radius: 15px; min-height: 68px; }
#planner .planner-footer { font-size: 9px; line-height: 1.9; }
#planner .search-results { max-height: min(320px, 42dvh); border-radius: 17px; box-shadow: none; }
#planner .search-results .place-option { min-height: 64px; }
#planner .search-actions button { min-height: 48px; }
.destination-shortcut { display: none; align-items: center; gap: 12px; width: calc(100% - 24px); min-height: 56px; margin: 0 12px 12px; padding: 10px 16px; border: 0; border-radius: 18px; background: var(--surface); color: var(--ink); text-align: right; font-weight: 750; font-size: 19px; }
.destination-shortcut svg { width: 24px; height: 24px; color: var(--blue); flex-shrink: 0; }
.destination-shortcut .destination-shortcut-arrow { margin-right: auto; width: 20px; color: var(--muted); }
.panel-collapsed #planner,
#planner.collapsed { top: auto; height: auto; max-height: none; }
.panel-collapsed #planner .planner-content,
#planner.collapsed .planner-content { display: none; }
.panel-collapsed #destination-shortcut,
#planner.collapsed #destination-shortcut { display: flex; }
.picking #planner { display: none; }
.navigating #planner { display: none; }

body.driving-ui .app-shell .map-tools { left: 16px; bottom: 144px; gap: 8px; }
body.driving-ui .map-tool { width: 48px; height: 48px; border: 0; border-radius: 16px; background: var(--panel); color: var(--ink); }
body.driving-ui .zoom-group { border-radius: 16px; overflow: hidden; }
body.driving-ui .map-tool.locate-button { color: var(--blue); }
body.driving-ui .app-shell .report-button { left: 16px; right: auto; bottom: 66px; width: 56px; height: 60px; border-radius: 19px; background: #ffcc73; color: #634216; }
body.driving-ui .report-button span { font-size: 10px; }
#follow-button { width: auto; min-width: 48px; padding: 0 14px; gap: 8px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; }
#follow-button svg { width: 23px; height: 23px; flex-shrink: 0; }
body.driving-ui .map-pick-banner { top: calc(var(--darb-top) + 122px); left: 50%; right: auto; transform: translateX(-50%); border-radius: 18px; }
body.driving-ui .map-pick-banner button { min-width: 48px; min-height: 48px; }

/* The marker's outer transform belongs to the map adapter. Only the inner
 * vehicle image receives heading rotation from the navigation controller. */
.darb-marker.gps.vehicle-marker { width: 56px; height: 66px; border: 0; background: none; border-radius: 0; box-shadow: none; display: grid; place-items: center; }
.vehicle-marker .vehicle-heading { display: block; width: 48px; height: 60px; object-fit: contain; transform-origin: 50% 50%; filter: drop-shadow(0 3px 4px #10233b66); }

#nav-panel { top: var(--darb-top); bottom: auto; right: 16px; left: auto; width: 360px; max-height: min(260px, 42dvh); overflow: auto; border-radius: 23px; padding: 12px 18px 16px; background: #172a3a; color: #fff; }
body.driving-ui.navigating #nav-panel { background: #172a3a; }
#nav-panel .nav-top { min-height: 22px; font-size: 11px; color: #c7d5e3; }
#nav-panel .nav-mode { display: block; min-width: 0; padding: 0; margin: 0; border: 0; color: #c7d5e3; font-size: 11px; line-height: 1.7; }
#nav-panel .nav-live-dot { background: #83a7ff; box-shadow: none; }
#nav-panel .maneuver { align-items: center; gap: 14px; padding: 8px 0 0; }
#nav-panel .maneuver-icon { width: 62px; height: 72px; color: #fff; }
#nav-panel .maneuver-icon svg { width: 58px; height: 58px; }
#nav-panel .maneuver-copy { flex: 1; }
#nav-panel .maneuver-copy strong { font-size: 34px; font-weight: 850; letter-spacing: -.7px; line-height: 1.25; }
#nav-panel .maneuver-copy p { font-size: 15px; font-weight: 650; margin: 4px 0 0; line-height: 1.7; color: #fff; }
#nav-panel .maneuver-copy small { font-size: 12px; margin-top: 2px; line-height: 1.7; color: #c7d5e3; overflow-wrap: anywhere; }
.trip-summary { position: absolute; right: 16px; bottom: var(--darb-bottom); width: 360px; z-index: 7; padding: 14px 16px 10px; border-radius: 23px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.trip-summary-main { display: flex; align-items: center; gap: 14px; }
.trip-metrics { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 12px; flex: 1; min-width: 0; }
.trip-metric { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.trip-metric strong { max-width: 100%; overflow-wrap: anywhere; font-size: 19px; font-weight: 750; line-height: 1.45; }
.trip-metric span { color: var(--muted); font-size: 10px; }
.trip-time strong { color: var(--blue); font-size: 24px; font-weight: 850; }
.trip-summary .stop-button { margin: 0; min-height: 52px; min-width: 52px; padding: 6px; flex-direction: column; justify-content: center; gap: 0; border: 0; border-radius: 15px; background: var(--surface); color: #a54646; font-size: 10px; }
.trip-summary .stop-button svg { width: 22px; height: 22px; }
.trip-summary-detail { display: flex; align-items: center; gap: 8px; padding-top: 8px; margin-top: 9px; border-top: 1px solid var(--border); min-height: 30px; }
.trip-summary-detail #nav-progress { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.trip-estimate { font-size: 10px; color: var(--muted); }
.trip-summary .speed-indicator { margin-right: auto; border: 0; width: auto; height: auto; flex-direction: row; gap: 5px; border-radius: 0; color: var(--muted); }
.trip-summary .speed-indicator strong { font-size: 14px; color: var(--ink); }
.trip-summary .speed-indicator span { font-size: 9px; color: var(--muted); }
body.driving-ui.navigating .brand,
body.driving-ui.navigating .region-switcher,
body.driving-ui.navigating .map-context,
body.driving-ui.navigating #theme-toggle,
body.driving-ui.navigating #info-button,
body.driving-ui.navigating #report-button,
body.driving-ui.navigating #locate-button { display: none; }
body.driving-ui.navigating .app-header { left: 16px; right: auto; }
body.driving-ui.navigating .app-shell .map-tools { bottom: 154px; }
body.driving-ui.navigating .header-actions { padding: 0; border-radius: 17px; }
body.driving-ui .app-shell .toast { bottom: 56px; left: 50%; right: auto; transform: translateX(-50%); border-radius: 16px; max-width: min(520px, calc(100% - 32px)); font-size: 12px; line-height: 1.8; }
body.driving-ui .leaflet-control-attribution,
body.driving-ui .maplibregl-ctrl-attrib { max-width: calc(100vw - 28px); font-size: 9px !important; line-height: 1.5; white-space: normal; background: #ffffffed; color: #344354; }

@media (max-width: 800px) {
  body.driving-ui { --darb-bottom-space: min(66dvh, 560px); }
  body.driving-ui.panel-collapsed { --darb-bottom-space: calc(142px + env(safe-area-inset-bottom)); }
  body.driving-ui.picking { --darb-bottom-space: max(12px, env(safe-area-inset-bottom)); }
  body.driving-ui.navigating { --darb-bottom-space: calc(142px + env(safe-area-inset-bottom)); }
  body.driving-ui .app-header { left: 12px; right: 12px; gap: 8px; }
  body.driving-ui .region-switcher { right: 12px; width: 164px; }
  #planner { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: var(--darb-bottom-space); border-radius: 26px 26px 0 0; box-shadow: 0 -5px 28px #15294117; }
  #planner .planner-content { padding: 0 16px calc(20px + env(safe-area-inset-bottom)); }
  #planner .waypoint-field input { font-size: 16px; }
  .panel-collapsed #planner,
  #planner.collapsed { left: 12px; right: 12px; bottom: var(--darb-bottom); width: auto; max-height: none; border-radius: 23px; }
  .panel-collapsed #planner .panel-toggle,
  #planner.collapsed .panel-toggle { min-height: 48px; height: 48px; }
  .destination-shortcut { min-height: 54px; font-size: 20px; }
  body.driving-ui .app-shell .map-tools { left: 12px; bottom: calc(var(--darb-bottom-space) + 26px); gap: 8px; }
  body.driving-ui .map-tools .zoom-group,
  body.driving-ui .map-tools .compass-button { display: none; }
  body.driving-ui .app-shell .report-button { left: auto; right: 12px; bottom: calc(var(--darb-bottom-space) + 25px); width: 54px; height: 56px; border-radius: 18px; }
  body.driving-ui .app-shell .map-context { left: 72px; bottom: calc(var(--darb-bottom-space) + 27px); max-width: calc(100% - 148px); height: 26px; font-size: 9px; padding: 0 8px; }
  body.driving-ui .app-shell .maplibregl-ctrl-bottom-left,
  body.driving-ui .app-shell .maplibregl-ctrl-bottom-right,
  body.driving-ui .app-shell .leaflet-bottom { bottom: calc(var(--darb-bottom-space) + 2px) !important; }
  body.driving-ui .app-shell .toast { bottom: calc(var(--darb-bottom-space) + 84px); font-size: 12px; padding: 11px 15px; }
  body.driving-ui .map-pick-banner { top: calc(var(--darb-top) + 122px); left: 12px; right: 12px; transform: none; min-width: 0; max-width: none; padding: 9px 12px; }
  body.driving-ui.picking .app-shell .report-button { display: none; }
  #nav-panel { left: 12px; right: 12px; width: auto; border-radius: 22px; padding: 10px 16px 14px; max-height: min(250px, 38dvh); }
  #nav-panel .maneuver-icon { width: 57px; height: 70px; }
  #nav-panel .maneuver-icon svg { width: 56px; height: 56px; }
  .trip-summary { right: 12px; left: 12px; bottom: var(--darb-bottom); width: auto; padding: 13px 14px 9px; border-radius: 22px; }
  body.driving-ui.navigating .app-header { top: auto; bottom: calc(var(--darb-bottom-space) + 82px); left: 12px; right: auto; }
  body.driving-ui.navigating .app-shell .map-tools { left: 12px; bottom: calc(var(--darb-bottom-space) + 22px); }
  body.driving-ui.navigating .app-shell .toast { bottom: calc(var(--darb-bottom-space) + 82px); }
  #follow-button { min-height: 48px; border-radius: 16px; }
  body.driving-ui .app-dialog { max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  body.driving-ui .brand { padding: 6px 8px; gap: 6px; }
  body.driving-ui .brand-mark { width: 30px; height: 30px; border-radius: 10px; }
  body.driving-ui .brand-name { font-size: 23px; }
  #planner .planner-content { padding-left: 12px; padding-right: 12px; }
  #planner .waypoints { padding: 8px; }
  #planner .waypoint-row { gap: 6px; }
  #planner .waypoint-field input { font-size: 16px; }
  #planner .waypoint-symbol { width: 10px; height: 10px; }
  #nav-panel { padding-left: 12px; padding-right: 12px; }
  #nav-panel .maneuver { gap: 10px; }
  #nav-panel .maneuver-copy strong { font-size: 30px; }
  #nav-panel .maneuver-copy p { font-size: 14px; }
  .trip-summary { padding-left: 12px; padding-right: 12px; }
  .trip-summary-main { gap: 8px; }
  .trip-metrics { gap: 6px; }
  .trip-metric strong { font-size: 16px; }
  .trip-time strong { font-size: 21px; }
}

/* A short viewport can be landscape or the open mobile keyboard. Keep the
 * active form scrollable, with a separate, usable strip of map beside it. */
@media (max-height: 500px) and (min-width: 550px) {
  body.driving-ui { --darb-bottom-space: 12px; }
  body.driving-ui .app-header { left: 12px; right: auto; gap: 8px; }
  body.driving-ui .brand { display: none; }
  body.driving-ui .region-switcher { top: calc(var(--darb-top) + 62px); left: 12px; right: auto; width: 148px; }
  #planner { top: 12px; bottom: var(--darb-bottom); left: auto; right: 12px; width: min(380px, 55vw); max-height: calc(100dvh - 24px - env(safe-area-inset-bottom)); border-radius: 23px; }
  #planner .planner-content { padding-bottom: 16px; }
  .panel-collapsed #planner,
  #planner.collapsed { top: auto; left: auto; right: 12px; width: min(380px, 55vw); }
  body.driving-ui .app-shell .map-context { left: 72px; max-width: calc(45vw - 96px); bottom: 32px; }
  body.driving-ui .app-shell .map-tools { left: 12px; bottom: 62px; }
  body.driving-ui .app-shell .report-button { left: 72px; right: auto; bottom: 62px; }
  body.driving-ui .app-shell .toast { left: 12px; right: auto; bottom: 130px; transform: none; max-width: calc(45vw - 24px); }
  #nav-panel { left: auto; right: 12px; top: var(--darb-top); width: min(420px, 58vw); max-height: calc(100dvh - 172px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 9px 14px 12px; }
  #nav-panel .maneuver { gap: 10px; padding-top: 3px; }
  #nav-panel .maneuver-icon { width: 52px; height: 58px; }
  #nav-panel .maneuver-icon svg { width: 49px; height: 49px; }
  #nav-panel .maneuver-copy strong { font-size: 28px; }
  #nav-panel .maneuver-copy p { font-size: 13px; line-height: 1.6; }
  #nav-panel .maneuver-copy small { font-size: 10px; }
  .trip-summary { left: auto; right: 12px; width: min(420px, 58vw); }
  body.driving-ui.navigating .app-header { top: var(--darb-top); bottom: auto; left: 12px; right: auto; }
  body.driving-ui.navigating .app-shell .map-tools { left: 12px; bottom: 62px; }
  body.driving-ui.navigating .app-shell .toast { bottom: 130px; }
  body.driving-ui .app-shell .maplibregl-ctrl-bottom-left,
  body.driving-ui .app-shell .maplibregl-ctrl-bottom-right,
  body.driving-ui .app-shell .leaflet-bottom { bottom: 2px !important; max-width: calc(42vw - 20px); }
  body.driving-ui .map-pick-banner { top: var(--darb-top); left: auto; right: 12px; width: min(420px, 58vw); }
  body.driving-ui .search-results { max-height: 38dvh; }
}

@media (max-height: 560px) and (max-width: 549px) {
  body.driving-ui:not(.panel-collapsed):not(.navigating):not(.picking) { --darb-bottom-space: calc(100dvh - 72px - env(safe-area-inset-top)); }
  body.driving-ui:not(.panel-collapsed):not(.navigating):not(.picking) .region-switcher { display: none; }
  #planner .planner-heading { margin-bottom: 8px; }
  #planner .planner-heading h1 { font-size: 20px; }
  #planner .waypoint-row { min-height: 56px; }
  #planner .search-results { max-height: 35dvh; }
  #nav-panel { max-height: 36dvh; }
  #nav-panel .maneuver-copy strong { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .vehicle-heading, #planner, .map-tool, .destination-shortcut { transition: none !important; }
}
