:root {
  --safe-top: max(env(safe-area-inset-top, 0px), var(--native-safe-area-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--native-safe-area-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--native-safe-area-left, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--native-safe-area-right, 0px));
}
html, body { height: 100dvh; overflow: hidden; }
#app { height: var(--viewport-height, 100dvh); width: var(--viewport-width, 100%); top: var(--viewport-top, 0px); left: var(--viewport-left, 0px); transform: scale(var(--viewport-unscale, 1)); transform-origin: top left; }
.sheet { touch-action: pan-y; left: calc(10px + var(--safe-left)); right: calc(10px + var(--safe-right)); bottom: calc(10px + var(--safe-bottom)); }
.br-navigating .staging-ribbon, .br-navigating .scale-legend { display: none; }
.nav-top { top: calc(8px + var(--safe-top))!important; left: calc(8px + var(--safe-left))!important; right: calc(8px + var(--safe-right))!important; touch-action: pan-y; }
.nav-top>div:not(.nav-maneuver) { padding-right: 54px!important; }
.nav-instruction { overflow-wrap: anywhere; line-height: 1.15; }
.nav-exit { width: 44px!important; height: 44px!important; top: 5px; right: 5px; }
.nav-step-hint { min-height: 32px; line-height: 1.3; }
.nav-bottom { left: calc(8px + var(--safe-left))!important; right: calc(8px + var(--safe-right))!important; bottom: calc(8px + var(--safe-bottom))!important; max-width: none; gap: 8px!important; }
.nav-bottom strong { font-size: 16px!important; white-space: normal; }
.nav-bottom button { flex-basis: 44px; min-width: 44px; height: 44px; }
#navVoice { font-size: 11px; background: #edf3ff; color: #0b5cff; font-weight: 700; }
.br-navigating .map-zoom { top: calc(var(--safe-top) + var(--nav-top-height, 210px) + 20px)!important; right: calc(12px + var(--safe-right)); }
.community-fab { right: calc(12px + var(--safe-right)); bottom: calc(var(--nav-dock-height, 64px) + 20px + var(--safe-bottom)); }
.modal, .pin-sheet, .community-modal { padding: calc(8px + var(--safe-top)) var(--safe-right) var(--safe-bottom) var(--safe-left); }
.modal-card, .pin-card, .community-card { max-height: 100%; padding-bottom: 20px; }
.community-label select, .community-label textarea { font-size: 16px; }
.community-disclaimer { color: #64748b; font-size: 12px; line-height: 1.4; }
.community-reports { display: grid; gap: 8px; margin-top: 12px; }
.community-report { padding: 12px; border-radius: 12px; background: #f1f5f9; overflow-wrap: anywhere; }
.community-report strong { text-transform: capitalize; }
.community-report small { display: block; color: #64748b; margin-top: 5px; }
.community-report p { margin: 8px 0 0; }
.route-choices { display: grid; gap: 6px; }
.route-choice { min-height: 44px; border: 1px solid #dbe3ec; border-radius: 12px; background: #f8fafc; padding: 10px; text-align: left; color: #334155; }
.route-choice[aria-pressed="true"] { border-color: #0b5cff; background: #eaf1ff; }
.route-directions { margin: 10px 0; }
.route-directions summary { padding: 10px 0; color: #0b5cff; }
.route-directions li { margin: 10px 0; }
#navLanes small { display: block; font-size: 10px; color: #64748b; margin-top: 5px; }
.lane-strip { display: flex; gap: 8px; font-size: 21px; color: #cbd5e1; }
.lane-strip .active { color: #0b5cff; font-weight: 900; }
#navGpsStatus { font-size: 12px; color: #9a3412; }
#navGpsStatus[data-safety="hazard"],#routeMeta[data-safety="hazard"] { background:#171717; color:#ffe05a; border-left:5px solid #ffe05a; padding:5px 8px; }
#navGpsStatus[data-safety="uncertain"],#navGpsStatus[data-safety="unknown"],#routeMeta[data-safety="unknown"] { color:var(--text,#f3f4f6); background:var(--panel,#252b34); padding:5px 8px; }
#routeMeta[data-safety]:not([data-safety=""]) { cursor:pointer; font-size:12px; max-height:42px; overflow:auto; }
.toggle { flex-wrap: wrap; }
.toggle-note { flex-basis: 100%; }
@media (min-width:760px) and (min-height:501px) { .sheet { right: auto; } }
@media (orientation:landscape) and (max-height:500px) {
  .sheet { top: calc(8px + var(--safe-top)); bottom: calc(8px + var(--safe-bottom)); width: min(46vw,390px); max-height: none; right: auto; }
  .nav-top { width: min(46vw,440px); right: auto!important; max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 16px); overflow-y: auto; }
  .nav-maneuver { width: 56px; min-width: 56px; font-size: 32px; }
  .nav-instruction { font-size: 18px!important; }
  .nav-bottom { left: auto!important; width: min(45vw,380px); }
  .br-navigating .map-zoom { top: calc(8px + var(--safe-top))!important; }
  .community-card, .modal-card { border-radius: 22px; }
}
@media (max-width:350px) { .nav-maneuver { min-width: 52px; width:52px; } .nav-instruction { font-size:18px!important; } .nav-bottom { gap:5px!important; padding:8px!important; } .nav-bottom strong { font-size:13px!important; } }

.toast { pointer-events:none; bottom:calc(var(--nav-dock-height,64px) + 76px + var(--safe-bottom)); max-width:calc(100% - 32px - var(--safe-left) - var(--safe-right)); }

/* Chrome scrolls without accidental pinch/double-tap page magnification. Map
   gestures remain MapLibre's; visualViewport fitting also handles browser zoom. */
button, summary { touch-action: manipulation; }
input, select, textarea { font-size: max(16px, 1em); }
.nav-bottom #navRecenter { flex: 0 0 68px; width:68px; border-radius:16px; font-size:11px; font-weight:700; }
#navRecenter[aria-pressed="false"] { background:#edf3ff; color:#0b5cff; }
#navRecenter[aria-pressed="true"] { background:#0b5cff; color:white; }
#resetMapView { font-size:24px; }
#directionsDetail { color:#0b5cff; background:#edf3ff; border:0; border-radius:12px; padding:12px; min-height:44px; }
.route-directions ol { padding-left:26px; font-size:15px; line-height:1.4; }
@media (orientation:landscape) and (max-height:500px) {
  .map-zoom { display:grid; grid-template-columns:44px 44px; }
}

@media (max-width:759px) and (orientation:portrait) { .recenter { top:302px; } }
.map-zoom .layers-button { height:50px; display:flex; flex-direction:column; align-items:center; justify-content:center; color:#0b5cff; gap:0; }
.layers-button small { font-size:10px; font-weight:700; }
.layers-button span { font-size:25px; line-height:24px; }
.layer-off { display:none!important; }
#layersPanel { z-index:95; }
.layers-card { max-width:460px; }
.layers-help { font-size:12px; color:#64748b; line-height:1.45; }
.layer-row { display:flex; align-items:center; gap:12px; padding:13px 0; border-bottom:1px solid #e2e8f0; }
.layer-row i { width:12px; height:12px; border-radius:50%; flex-shrink:0; }
.layer-row span { flex:1; min-width:0; }
.layer-row strong { display:block; font-size:15px; }
.layer-row small { display:block; color:#64748b; font-size:11px; line-height:1.4; overflow-wrap:anywhere; }
.layer-row input { width:24px; height:24px; accent-color:#0b5cff; margin:10px; flex-shrink:0; }
@media (orientation:landscape) and (max-height:500px) { .map-zoom { grid-template-columns:46px 46px; } .layers-card { max-height:100%; } }

/* A dedicated navigation action remains visible without squeezing ETA/speed. */
#navRecenter.nav-follow { position:absolute; pointer-events:auto; left:calc(12px + var(--safe-left)); bottom:calc(var(--nav-dock-height,64px) + 20px + var(--safe-bottom)); min-height:46px; min-width:112px; padding:0 14px; border:1px solid var(--line,#dbe3ec); border-radius:24px; font:700 13px -apple-system,sans-serif; box-shadow:0 3px 14px #0003; }
@media (orientation:landscape) and (max-height:500px) { #navRecenter.nav-follow { left:auto; right:calc(132px + var(--safe-right)); } }

.route-why { margin:10px 0; font-size:14px; line-height:1.4; }
.route-why summary, #routeReportTechnical summary { min-height:44px; padding:12px 0; cursor:pointer; color:var(--accent,#0b5cff); }
#routeReference { display:block; overflow-wrap:anywhere; color:var(--muted,#64748b); }
.route-report-button { min-height:44px; font-size:14px; }
#routeReportPanel { z-index:125; }
#routeReportComment { width:100%; min-height:90px; border:1px solid var(--line,#ddd); border-radius:12px; padding:12px; background:var(--raised,#f1f5f9); color:var(--ink,#132238); font:16px -apple-system,sans-serif; }
#routeReportData { white-space:pre-wrap; overflow-wrap:anywhere; max-height:240px; overflow:auto; font-size:11px; }

.nav-bottom { flex-wrap:wrap; }
.nav-bottom > .nav-current-road { flex:0 0 100%; min-width:0; display:flex; flex-direction:row; align-items:baseline; gap:8px; padding-bottom:6px; border-bottom:1px solid var(--line,#dbe3ec); }
.nav-current-road > span { flex-shrink:0; font-size:10px; color:var(--muted,#64748b); }
.nav-bottom .nav-current-road > strong { font-size:14px!important; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
@media (orientation:landscape) and (max-height:500px) {
  .nav-top, .nav-bottom { width:min(380px, calc(50% - 16px - max(var(--safe-left), var(--safe-right)))); }
}

/* Map-anchored labels never intercept map gestures. */
.nav-road-bubble { pointer-events:none; max-width:220px; padding:7px 12px; border:1px solid var(--line,#435063); border-radius:14px; background:var(--surface,#1c222b); color:var(--ink,#fff); box-shadow:0 3px 12px #0005; font:700 13px -apple-system,sans-serif; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.nav-preview-marker { pointer-events:none; width:32px; height:32px; border-radius:50%; border:3px solid white; background:#be252c; color:white; box-shadow:0 2px 10px #0006; text-align:center; font:800 15px/26px -apple-system,sans-serif; }
/* Leave more map visible while retaining the full maneuver instruction. */
.br-navigating .nav-route-chip { display:none; }
.br-navigating .nav-maneuver { width:52px; min-width:52px; font-size:32px; }
.br-navigating .nav-top>div:not(.nav-maneuver) { padding-top:10px; padding-bottom:10px; padding-left:12px; }
.br-navigating .nav-instruction { font-size:20px!important; line-height:1.15; }
.br-navigating .nav-step-hint { min-height:24px; font-size:10px; margin-top:6px; }
@media (orientation:landscape) and (max-height:500px) {
  .br-navigating .nav-instruction { font-size:18px!important; }
}

.account-heading { display:flex; align-items:center; gap:16px; }
.account-heading button { min-height:44px; font-size:13px; }
.account-card { max-width:460px; }
#accountIdentity { overflow-wrap:anywhere; }
#accountStatus { color:var(--muted); min-height:1.5em; }
.apple-sign-in { display:block; width:100%; min-height:48px; border:1px solid #fff; border-radius:12px; background:#000; color:#fff; font:600 17px -apple-system,sans-serif; }
.apple-sign-in:disabled { opacity:.55; }
.account-card .secondary { width:100%; margin-top:12px; }

.nav-distance { font-size:26px; font-weight:850; line-height:1.1; margin-bottom:4px; color:var(--ink); }
.nav-distance:empty { display:none; }
.nav-driver-marker { width:22px; height:22px; background:#0866ff; border:4px solid white; border-radius:50%; box-shadow:0 1px 5px #0005; pointer-events:none; }
@media (orientation:landscape) and (max-height:500px) { .nav-distance { font-size:22px; } }

/* Keep the settings entry explicit while retaining the current truck summary. */
#truckSummary { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; flex-shrink: 0; gap: 3px; padding: 9px 12px; border-radius: 16px; text-align: left; }
#truckSummary .truck-settings-label { font-size: 13px; font-weight: 800; }
#truckSummaryText { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 500; opacity: .8; }

.rig-picker { border: 1px solid var(--line, #dbe3ec); border-radius: 16px; padding: 12px; margin: 12px 0; }
.rig-picker summary { cursor: pointer; font-weight: 750; min-height: 28px; }
.rig-picker label { display: block; margin-top: 12px; font-size: 13px; font-weight: 650; }
.rig-picker input, .rig-picker select { width: 100%; min-height: 46px; margin-top: 5px; padding: 10px; font: inherit; font-size: 16px; border: 1px solid var(--line, #dbe3ec); border-radius: 10px; background: var(--raised, #f1f5f9); color: var(--ink, #172033); }
.rig-picker .muted { font-size: 13px; line-height: 1.45; }
.rig-results { display: grid; gap: 4px; }
.rig-result { padding: 12px; min-height: 44px; border: 1px solid var(--line, #dbe3ec); border-radius: 8px; background: var(--raised, #f1f5f9); color: var(--ink, #172033); text-align: left; font-size: 15px; }
.rig-confirm { align-items: flex-start; font-size: 13px; line-height: 1.45; }
.rig-confirm input { flex-shrink: 0; }

.nav-add-stop { position:absolute; pointer-events:auto; left:50%; transform:translateX(-50%); bottom:calc(var(--nav-dock-height,64px) + 20px + var(--safe-bottom)); min-height:46px; padding:0 10px; border:1px solid var(--line,#dbe3ec); border-radius:24px; background:var(--raised,#f1f5f9); color:var(--ink,#172033); font:700 13px -apple-system,sans-serif; }
.navigation-stop-modal { z-index:130; }
.stop-help { font-size:12px; line-height:1.4; }
.stop-field { display:block; margin:10px 0; font-size:13px; }
.stop-field input,.stop-field select { display:block; width:100%; padding:10px; min-height:46px; margin-top:5px; font-size:16px; border:1px solid var(--line,#dbe3ec); border-radius:12px; background:var(--raised,#f1f5f9); color:var(--ink,#172033); }
.stop-result { display:block; width:100%; padding:12px; margin:6px 0; text-align:left; border:1px solid var(--line,#dbe3ec); border-radius:12px; color:var(--ink,#172033); background:var(--raised,#f1f5f9); }
.stop-result[aria-pressed=true] { border-color:var(--accent,#0b5cff); }
.stop-result span,.stop-result small { display:block; margin-top:5px; }
@media (orientation:landscape) and (max-height:500px) { .nav-add-stop { left:auto; right:calc(254px + var(--safe-right)); transform:none; } }
@media (max-width:360px) { #navRecenter.nav-follow { min-width:90px; padding:0 8px; } .nav-add-stop { font-size:12px; padding:0 6px; } .community-fab { padding:0 8px; } }
/* Stop exploration leaves the actual map available above/beside the result sheet. */
.stop-map-marker { width:44px; height:44px; border-radius:50%; border:3px solid white; background:#172033; color:white; font:bold 18px -apple-system,sans-serif; box-shadow:0 2px 8px #0008; cursor:pointer; }
.stop-map-marker[aria-pressed=true] { background:#087e8b; transform:scale(1.12); }
.stop-map-browsing .navigation-stop-modal { background:transparent; pointer-events:none; align-items:flex-end; }
.stop-map-browsing .navigation-stop-modal .modal-card { pointer-events:auto; max-height:43dvh; width:100%; }
.stop-map-browsing #nav,.stop-map-browsing .community-fab,.stop-map-browsing .driver-road-bubble { visibility:hidden; }
.stop-map-browsing #stopSearchForm,.stop-map-browsing .navigation-stop-modal > .modal-card > .stop-help { display:none; }
.stop-map-browsing .navigation-stop-modal .modal-head { position:sticky; top:-16px; background:var(--panel,#1c2029); z-index:2; }
#stopMapActions .secondary { min-height:44px; padding:8px 12px; font-size:14px; }
.stop-evidence { font-weight:700; }
@media (orientation:landscape) and (max-height:600px) {
 .stop-map-browsing .navigation-stop-modal { justify-content:flex-start; align-items:stretch; padding-top:var(--safe-top); }
 .stop-map-browsing .navigation-stop-modal .modal-card { width:min(340px,44vw); max-height:100%; border-radius:0 20px 20px 0; }
}
#stopSelectedSummary strong,#stopSelectedSummary small { display:block; margin:4px 0; }
#stopSelectedSummary small { font-size:13px; }
.stop-map-browsing #stopMic { width:auto; min-height:34px; margin-top:4px; padding:4px 10px; font-size:12px; }
.stop-map-browsing #stopHeard { display:none; }
.stop-map-browsing #stopStatus { font-size:12px; line-height:1.3; margin:6px 0; }
.stop-map-browsing #stopMapActions .stop-help { display:none; }
.stop-map-browsing .modal-head h2 { font-size:20px; }
/* The result is the map plus one selection card; no scrolling business list. */
.stop-map-browsing .navigation-stop-modal .modal-head h2 { margin:0; }
.stop-map-browsing #stopSelectedSummary { margin:4px 0; }
.stop-map-browsing #stopSelectedSummary strong { font-size:16px; }
.stop-map-browsing #stopSelectedSummary small { font-size:11px; line-height:1.3; }
.stop-map-browsing #stopSelectedSummary .stop-selected-address { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.stop-map-browsing #stopMapActions { display:flex; gap:5px; }
.stop-map-browsing #stopMapActions .secondary { flex:1; padding:6px; min-width:0; font-size:12px; margin-top:4px; }
.stop-map-browsing #confirmNavStop { position:sticky; bottom:0; z-index:3; min-height:46px; margin-top:6px; flex-shrink:0; }
.stop-map-browsing .navigation-stop-modal .modal-card { padding-top:10px; padding-bottom:max(10px,var(--safe-bottom)); }

.stop-audio-controls { display:flex; gap:6px; align-items:center; }
.stop-audio-controls .secondary { flex:1; width:auto; min-width:0; }
.stop-map-browsing #stopMute { min-height:34px; margin-top:4px; padding:4px 10px; font-size:12px; }


/* Suggestions must never grow the planner beyond the keyboard-visible app. */
#planView .suggestions { max-height: min(180px, calc(var(--viewport-height, 100dvh) * .3)); overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
#planView .suggestion { min-height: 44px; overflow-wrap: anywhere; }
.planner-editing .sheet { z-index: 45; max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 16px); scroll-padding: 8px; overflow-anchor: none; }
.planner-editing .map-zoom, .planner-editing .recenter { visibility: hidden; }

/* Confirmed stops survive closing place search and route recalculation. */
.trip-stop-marker { display:flex; align-items:center; gap:6px; max-width:190px; padding:6px 9px 6px 6px; border:2px solid #fff; border-radius:18px; background:#075985; color:#fff; box-shadow:0 2px 8px #0006; pointer-events:none; font:600 12px/1.3 -apple-system,BlinkMacSystemFont,sans-serif; }
.trip-stop-marker strong { display:grid; place-items:center; flex-shrink:0; width:24px; height:24px; border-radius:50%; background:#fff; color:#075985; }
.trip-stop-marker span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }


/* Road choices stay reachable above active navigation in both orientations. */
#pinSheet{z-index:95}
#pinSheet button[hidden]{display:none!important}

/* Live alternatives leave guidance visible and keep the map interactive. */
#navRoutes { font-size:12px; font-weight:750; flex:0 0 56px; color:var(--ink); background:var(--raised); }
#navDestinationReference { margin-top:8px; padding-top:7px; border-top:1px solid var(--line,#dbe3ec); }
#navDestinationReference small { display:block; font-size:11px; opacity:.8; }
#navDestinationAddress { display:block; font-size:16px; line-height:1.25; overflow-wrap:anywhere; }
.navigation-options { position:absolute; z-index:45; left:calc(8px + var(--safe-left)); right:calc(8px + var(--safe-right)); bottom:calc(8px + var(--safe-bottom)); padding:12px; border-radius:18px; background:var(--surface,#fff); color:var(--ink,#172033); box-shadow:0 4px 24px #0005; max-height:40%; overflow:auto; }
.navigation-options header { display:flex; align-items:center; justify-content:space-between; }
.navigation-options button { min-height:44px; border-radius:12px; padding:8px 12px; border:1px solid var(--line,#dbe3ec); background:var(--raised,#f1f5f9); color:var(--ink,#172033); font-weight:700; }
.navigation-options p { margin:4px 0 8px; font-size:13px; line-height:1.3; }
#navigationOptionChoices { display:flex; gap:6px; margin-bottom:8px; }
#navigationOptionChoices button { flex:1; font-size:12px; }
#navigationOptionChoices button[aria-pressed="true"] { border:2px solid #0796ad; }
#switchNavigationRoute { width:100%; background:#0b5cff; color:white; }
#switchNavigationRoute:disabled { opacity:.45; }
.navigation-option-marker { max-width:160px; min-height:44px; padding:7px 10px; border:2px solid #fff; border-radius:14px; background:#344861; color:#fff; box-shadow:0 2px 8px #0006; font:700 12px -apple-system,sans-serif; }
.navigation-option-marker[aria-pressed="true"] { background:#087f91; }
.navigation-options-open .nav-bottom,.navigation-options-open .nav-add-stop,.navigation-options-open #navRecenter,.navigation-options-open .community-fab,.navigation-options-open .map-zoom { visibility:hidden; }
@media (orientation:landscape) and (max-height:500px) {
  .navigation-options { right:auto; width:calc(46% - 16px); max-height:62%; }
  .navigation-options-open .nav-top { max-height:30%; }
  #navDestinationAddress { font-size:14px; }
}

#navGoThrough {min-width:100px;min-height:44px;margin-top:8px;padding:8px 14px;border:1px solid var(--line);font-size:14px;font-weight:750;color:var(--ink);background:var(--raised);border-radius:12px;}
.navigation-options-open #navGoThrough {display:none;}
.road-picker {position:absolute;z-index:45;top:calc(12px + var(--safe-top));left:calc(12px + var(--safe-left));right:calc(12px + var(--safe-right));max-width:440px;margin:auto;padding:12px;background:var(--surface,#fff);color:var(--ink);border-radius:16px;box-shadow:0 3px 18px #0003;display:grid;grid-template-columns:1fr auto;gap:4px 12px;}
.road-picker strong {font-size:16px;}.road-picker span {font-size:13px;}.road-picker button {grid-column:2;grid-row:1 / 3;min-height:44px;}
.choosing-road #sheet,.choosing-road .nav-top,.choosing-road .nav-bottom,.choosing-road .nav-add-stop,.choosing-road #navRecenter,.choosing-road .community-fab {visibility:hidden;}

#routeView > .route-actions {display:flex;gap:8px;flex-shrink:0;margin-top:auto;}
#routeView .route-actions button {flex:1;min-width:0;min-height:44px;height:44px;margin:0;border-radius:14px;padding:8px;font-size:14px;}
#routeView .route-actions #startNavigation {flex:1.5;}

/* Confirmation must leave the map interactive and the chosen point visible. */
.choosing-road #pinSheet {background:transparent;pointer-events:none;align-items:flex-end;}
.choosing-road .scale-legend,.choosing-road .trip-cost-map-badge {visibility:hidden;}
.choosing-road #pinSheet .pin-card {pointer-events:auto;max-height:38%;padding:10px 14px;}
.choosing-road #pinSheet .pin-card h3 {font-size:16px;}
.choosing-road #pinCoord {font-size:12px;margin:4px 0;}
.choosing-road #pinSheet button {min-height:44px;margin-top:6px;}
.selected-road-pin {filter:drop-shadow(0 2px 4px #0009);}
@media (orientation:landscape) and (max-height:500px) {
  .choosing-road #pinSheet .pin-card {max-width:440px;max-height:42%;}
  .choosing-road #pinSheet .pin-card h3 {display:none;}
  .choosing-road #pinSheet button {width:auto;padding:8px 12px;}
}
