:root {
    color-scheme: light;
    --primary: #075985;
    --primary-dark: #0c4a6e;
    --surface: #ffffff;
    --muted: #64748b;
    --border: #dbe4ee;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #0f172a;
    background: #e2e8f0;
}

#map { position: fixed; inset: 0; }
.map-sidebar { display: contents; }
.landscape-map-controls { display: none; }
#map .maplibregl-canvas { transition: filter .5s ease; }

.map-panel {
    position: fixed;
    z-index: 5;
    top: 18px;
    left: 18px;
    width: min(390px, calc(100vw - 36px));
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    transition: width .2s ease, padding .2s ease, border-radius .2s ease;
}

.map-panel-content { transition: opacity .15s ease; }

.panel-toggle {
    position: absolute;
    z-index: 1;
    top: 12px;
    right: 12px;
    display: grid;
    width: 34px;
    min-height: 34px;
    padding: 0;
    place-items: center;
    border-radius: 10px;
    font-size: 21px;
    line-height: 1;
}

.gps-accuracy-status {
    position: absolute;
    z-index: 1;
    top: 12px;
    right: 124px;
    display: inline-flex;
    min-width: 44px;
    height: 34px;
    padding: 0 8px;
    gap: 4px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #991b1b;
    background: #fff1f2;
    border-color: #fecdd3;
    box-shadow: 0 3px 10px rgba(15, 23, 42, .06);
    white-space: nowrap;
}
.gps-accuracy-status.is-accurate {
    color: #166534;
    background: #f0fdf4;
    border-color: #bbf7d0;
}
.gps-accuracy-status.is-imprecise {
    color: #9a3412;
    background: #fff7ed;
    border-color: #fed7aa;
}
.gps-accuracy-status.is-floating {
    position: fixed;
    z-index: 7;
    top: 18px;
    right: 18px;
    box-shadow: var(--shadow);
}
.gps-accuracy-icon { font-size: 14px; line-height: 1; }
.gps-accuracy-status strong { min-width: 10px; font-size: 10px; line-height: 1; text-align: center; }

.live-toggle {
    position: absolute;
    z-index: 1;
    top: 12px;
    right: 54px;
    display: inline-flex;
    width: 62px;
    min-height: 34px;
    padding: 0 9px;
    gap: 6px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #475569;
    background: #fff;
    border-color: var(--border);
    font-size: 10px;
    letter-spacing: .04em;
}

.live-toggle:hover { color: #0f172a; background: #f8fafc; }

.live-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #94a3b8;
}

.live-toggle.active {
    color: #991b1b;
    background: #fff1f2;
    border-color: #fecdd3;
}

.live-toggle.active .live-dot {
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .14);
    animation: pulse 1s infinite;
}

.map-panel:not(.collapsed) .brand { padding-right: 164px; }

.map-panel.collapsed {
    width: 164px;
    height: 50px;
    padding: 0;
    border-radius: 14px;
}

.map-panel.collapsed .map-panel-content { display: none; }

.map-panel.collapsed .panel-toggle {
    top: 7px;
    right: 7px;
    width: 34px;
}

.map-panel.collapsed .live-toggle {
    top: 7px;
    right: 48px;
}

.collapsed-listing-count { display: none; }

.map-panel.collapsed .collapsed-listing-count {
    position: absolute;
    top: 7px;
    left: 7px;
    display: inline-flex;
    min-width: 40px;
    height: 34px;
    padding: 0 7px;
    gap: 3px;
    align-items: center;
    justify-content: center;
    border: 1px solid #dbe4ee;
    border-radius: 10px;
    color: #075985;
    background: #eff6ff;
    white-space: nowrap;
}

.simulation-panel {
    position: fixed;
    z-index: 6;
    top: 18px;
    right: 18px;
    width: min(280px, calc(100vw - 36px));
    padding: 14px;
    border: 1px solid rgba(191, 219, 254, .9);
    border-radius: 16px;
    background: rgba(255, 255, 255, .96);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}
.simulation-panel[hidden] { display: none; }
.simulation-panel > div:first-child { display: flex; gap: 3px; flex-direction: column; }
.simulation-panel strong { color: #1d4ed8; font-size: 10px; letter-spacing: .08em; }
.simulation-panel span { color: #475569; font-size: 11px; font-weight: 700; }
.simulation-progress { height: 6px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #dbeafe; }
.simulation-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: #2563eb; transition: width .35s ease; }
.simulation-actions { display: flex; margin-top: 10px; gap: 8px; }
.simulation-actions button { min-height: 34px; flex: 1; padding: 0 10px; font-size: 11px; font-weight: 850; }
.simulation-actions button:first-child { color: #fff; background: #2563eb; border-color: #2563eb; }
.simulation-actions button:first-child:hover { background: #1d4ed8; border-color: #1d4ed8; }
.simulation-actions button:nth-child(2) { color: #fff; background: #7c3aed; border-color: #7c3aed; }
.simulation-actions button:nth-child(2):hover { background: #6d28d9; border-color: #6d28d9; }
.simulation-actions button:last-child { color: #991b1b; background: #fff1f2; border-color: #fecdd3; }
.simulation-actions button:disabled { cursor: not-allowed; opacity: .45; }

.collapsed-listing-icon { font-size: 12px; line-height: 1; }
.collapsed-listing-count strong { font-size: 10px; line-height: 1; }

.floating-route-guidance {
    position: fixed;
    z-index: 6;
    top: 80px;
    left: 18px;
    display: flex;
    width: fit-content;
    max-width: min(330px, calc(100vw - 36px));
    min-height: 64px;
    padding: 10px 13px 10px 10px;
    gap: 10px;
    align-items: center;
    border: 1px solid rgba(191, 219, 254, .65);
    border-radius: 15px;
    color: #0f172a;
    background: rgba(255, 255, 255, .85);
    box-shadow: var(--shadow);
    backdrop-filter: none;
}
.floating-route-guidance[hidden] { display: none; }
.floating-route-guidance.is-visible { animation: floating-route-in .5s ease-out both; }
.floating-route-guidance.is-closing { animation: floating-route-out .5s ease-in both; pointer-events: none; }
.floating-route-maneuver {
    display: flex;
    flex: 0 0 auto;
    min-width: 88px;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}
.floating-route-distance {
    display: block;
    font-size: 24px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    white-space: nowrap;
}
.floating-route-distance[hidden] { display: none; }
.floating-route-icon {
    display: grid;
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    background: #2563eb;
    box-shadow: 0 7px 16px rgba(37, 99, 235, .25);
    font-size: 36px;
    font-weight: 900;
    line-height: 1;
}
.floating-route-content {
    min-width: 0;
    align-self: flex-start;
    padding-top: 2px;
}
.floating-route-content small {
    display: block;
    margin-bottom: 3px;
    color: #2563eb;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: .02em;
}
.floating-route-content strong {
    display: block;
    font-size: 18px;
    line-height: 1.3;
}
.floating-route-guidance.has-update .floating-route-icon { animation: floating-route-icon-pulse .32s ease; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.brand { display: flex; gap: 12px; align-items: center; }

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(135deg, #0284c7, #075985);
    font-size: 21px;
}

.place-search-launcher {
    display: grid;
    width: 46px;
    min-height: 46px;
    padding: 0;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, #0ea5e9, #075985);
    box-shadow: 0 7px 18px rgba(7, 89, 133, .22);
}
.place-search-launcher:hover { background: linear-gradient(135deg, #0284c7, #0c4a6e); transform: translateY(-1px); }
.place-search-launcher svg,
.place-search-input-wrap svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.place-search-view[hidden] { display: none; }
.place-search-header { display: flex; min-height: 38px; padding-right: 156px; gap: 10px; align-items: center; }
.place-search-header strong { font-size: 16px; }
.place-search-close { display: grid; width: 34px; min-height: 34px; padding: 0; place-items: center; color: #075985; background: #eff6ff; border-color: #bfdbfe; font-size: 18px; }
.place-search-close:hover { color: #fff; background: #075985; }
.place-search-form { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; margin-top: 14px; gap: 8px; }
.place-search-input-wrap { position: relative; display: block; min-width: 0; }
.place-search-input-wrap svg { position: absolute; top: 50%; left: 11px; width: 17px; height: 17px; color: #64748b; transform: translateY(-50%); pointer-events: none; }
.place-search-input-wrap input { width: 100%; height: 42px; padding: 0 11px 0 36px; border: 1px solid #cbd5e1; border-radius: 11px; color: #0f172a; background: #fff; font: inherit; font-size: 13px; outline: none; }
.place-search-input-wrap input:focus { border-color: #0284c7; box-shadow: 0 0 0 3px rgba(14, 165, 233, .15); }
.place-search-form > button { min-height: 42px; padding-inline: 16px; }
.place-search-status { min-height: 18px; margin: 10px 0 0; color: #64748b; font-size: 11px; line-height: 1.45; }
.place-search-results { display: grid; width: 100%; min-width: 0; max-height: min(48vh, 390px); margin-top: 8px; gap: 7px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.place-search-result { display: flex; width: 100%; min-width: 0; max-width: 100%; min-height: 0; padding: 11px 12px; gap: 10px; align-items: flex-start; overflow: hidden; border: 1px solid #dbe4ee; border-radius: 11px; color: #0f172a; background: #fff; text-align: left; }
.place-search-result:hover { color: #075985; background: #f0f9ff; border-color: #7dd3fc; }
.place-search-result-distance { display: flex; min-width: 52px; min-height: 38px; padding-left: 10px; flex: 0 0 auto; flex-direction: column; align-items: center; justify-content: center; border-left: 1px solid #dbe4ee; color: #0369a1; line-height: 1; white-space: nowrap; }
.place-search-result-distance strong { font-size: 13px; font-variant-numeric: tabular-nums; }
.place-search-result-distance small { margin-top: 4px; color: #64748b; font-size: 8px; font-weight: 850; letter-spacing: .08em; }
.place-search-result-copy { min-width: 0; flex: 1; }
.place-search-result-copy strong { display: block; overflow: hidden; font-size: 12px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.place-search-result-source { display: inline-flex; margin-top: 4px; padding: 2px 6px; border-radius: 999px; color: #075985; background: #e0f2fe; font-size: 8px; font-weight: 850; letter-spacing: .04em; }
.place-search-result-copy small { display: -webkit-box; max-width: 100%; margin-top: 3px; overflow: hidden; overflow-wrap: anywhere; color: #64748b; font-size: 10px; font-weight: 600; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.place-search-attribution { margin: 10px 0 0; color: #64748b; font-size: 9px; text-align: right; }
.place-search-attribution a { color: #0369a1; }

h1 { margin: 0; font-size: 18px; }
.subtitle { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

label { display: grid; gap: 5px; color: #475569; font-size: 12px; font-weight: 700; }

select, button {
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 11px;
    font: inherit;
}

select { width: 100%; padding: 0 11px; color: #0f172a; background: #fff; }

button {
    padding: 0 14px;
    cursor: pointer;
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 750;
}

button:hover { background: var(--primary-dark); }
button:disabled { cursor: wait; opacity: .65; }

.locate-button { grid-column: 1 / -1; }

.status {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin-top: 13px;
    padding: 10px 12px;
    border-radius: 11px;
    color: #334155;
    background: #f1f5f9;
    font-size: 12px;
    line-height: 1.45;
}

.status-dot {
    width: 9px;
    height: 9px;
    margin-top: 4px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #94a3b8;
}

.status.loading .status-dot { background: #f59e0b; animation: pulse 1s infinite; }
.status.success .status-dot { background: #16a34a; }
.status.error .status-dot { background: #dc2626; }

.category-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.category-legend[hidden] { display: none; }

.legend-item {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
}

.legend-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, .18);
}

.nearest-listings { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.nearest-listings[hidden] { display: none; }
.nearest-listings-list { display: grid; gap: 0; }
.nearest-listing-item { display: grid; width: 100%; min-width: 0; grid-template-columns: 16px minmax(0, 1fr) auto; min-height: 25px; padding: 2px 3px; gap: 5px; align-items: center; border: 0; border-radius: 7px; color: #334155; background: transparent; text-align: left; }
.nearest-listing-item:hover { color: #075985; background: #f0f9ff; }
.nearest-listing-icon { width: 10px; height: 10px; margin-left: 2px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(15, 23, 42, .18); }
.nearest-listing-item strong { min-width: 0; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.nearest-listing-distance { color: #64748b; font-size: 10px; font-weight: 800; white-space: nowrap; }

@keyframes pulse { 50% { opacity: .35; } }

.user-marker {
    width: 22px;
    height: 22px;
    border: 4px solid #fff;
    border-radius: 50%;
    background: #2563eb;
    box-shadow: 0 0 0 7px rgba(37, 99, 235, .2), 0 3px 10px rgba(0, 0, 0, .25);
}

.listing-popup { width: 245px; }
.popup-image { width: 100%; height: 115px; border-radius: 10px; object-fit: cover; background: #e2e8f0; }
.popup-category { margin: 10px 0 4px; color: #0284c7; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.listing-popup h3 { margin: 0; font-size: 16px; line-height: 1.25; }
.popup-address { margin: 7px 0; color: #64748b; font-size: 12px; line-height: 1.45; }
.popup-distance-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.popup-distance { margin: 0; flex: 0 0 auto; font-size: 12px; font-weight: 750; }
.popup-route-button {
    display: inline-flex;
    min-height: 30px;
    padding: 0 9px;
    gap: 5px;
    align-items: center;
    border-radius: 8px;
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
    font-size: 10px;
    font-weight: 800;
}
.popup-route-button:hover { color: #fff; background: #1d4ed8; border-color: #1d4ed8; }
.popup-route-icon { font-size: 13px; transform: rotate(-45deg); }
.popup-link { display: block; padding: 9px 12px; border-radius: 9px; color: #fff !important; background: var(--primary); text-align: center; text-decoration: none; font-weight: 750; }

.navigation-panel {
    position: fixed;
    z-index: 6;
    left: 50%;
    bottom: 22px;
    display: grid;
    width: min(560px, calc(100vw - 32px));
    min-height: 92px;
    padding: 15px 16px;
    grid-template-columns: 44px 1fr;
    gap: 13px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 18px;
    background: rgba(255, 255, 255, .97);
    box-shadow: var(--shadow);
    transform: translateX(-50%);
    backdrop-filter: blur(12px);
}
.navigation-panel[hidden] { display: none; }
.navigation-icon-group {
    display: flex;
    min-width: 44px;
    flex-direction: column;
    gap: 7px;
    align-items: center;
}
.navigation-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    background: #2563eb;
    font-size: 22px;
    transform: rotate(-45deg);
}
.navigation-direction-arrow {
    display: block;
    line-height: 1;
    transform-origin: center;
    transition: transform .25s ease-out;
}
.navigation-eyebrow { margin: 0 0 3px; color: #2563eb; font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.navigation-content { min-width: 0; }
.navigation-content h2 { margin: 0; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.navigation-summary { margin: 4px 0 0; color: #0f172a; font-size: 13px; font-weight: 800; }
.navigation-straight-distance { color: #dc2626; font-size: 11px; font-weight: 850; line-height: 1; white-space: nowrap; }
.navigation-straight-distance[hidden] { display: none; }
.navigation-instruction { margin: 3px 0 0; color: #64748b; font-size: 11px; line-height: 1.35; }
.navigation-actions {
    display: flex;
    width: 100%;
    margin-top: 8px;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}
.heading-toggle {
    display: inline-flex;
    min-height: 30px;
    padding: 0 10px;
    gap: 6px;
    align-items: center;
    border-radius: 9px;
    color: #334155;
    background: #f1f5f9;
    border-color: #dbe4ee;
    font-size: 10px;
    font-weight: 850;
}
.heading-toggle:hover { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.heading-toggle.active { color: #fff; background: #2563eb; border-color: #2563eb; }
.heading-toggle-icon { font-size: 15px; line-height: 1; }
.heading-toggle.active .heading-toggle-icon { animation: heading-pulse 1.5s ease-in-out infinite; }
.navigation-audio-actions {
    display: inline-flex;
    margin-left: auto;
    gap: 7px;
    align-items: center;
}
.voice-toggle {
    display: grid;
    width: 32px;
    min-height: 30px;
    padding: 0;
    place-items: center;
    border: 1px solid #bfdbfe;
    border-radius: 9px;
    color: #2563eb;
    background: #eff6ff;
}
.voice-toggle:hover { color: #1d4ed8; background: #dbeafe; border-color: #93c5fd; }
.voice-toggle svg {
    width: 18px;
    height: 18px;
    overflow: visible;
    fill: currentColor;
}
.voice-toggle .voice-waves,
.voice-toggle .voice-beep,
.voice-toggle .voice-slash {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
.voice-toggle .voice-beep { display: none; fill: currentColor; stroke: none; }
.voice-toggle .voice-slash { display: none; }
.voice-toggle.muted {
    color: #64748b;
    background: #f1f5f9;
    border-color: #dbe4ee;
}
.voice-toggle.muted .voice-waves { display: none; }
.voice-toggle.muted .voice-slash { display: block; }
.voice-toggle:not(.muted) .voice-waves { animation: voice-wave-pulse 1.25s ease-in-out infinite; }
.voice-toggle.beep-mode {
    color: #a16207;
    background: #fefce8;
    border-color: #fde68a;
}
.voice-toggle.beep-mode .voice-waves { display: none; }
.voice-toggle.beep-mode .voice-beep { display: block; }
.speedometer {
    display: inline-flex;
    min-height: 30px;
    margin-left: auto;
    padding: 0 10px;
    gap: 4px;
    align-items: center;
    justify-content: center;
    border: 1px solid #dbe4ee;
    border-radius: 9px;
    color: #334155;
    background: #f8fafc;
    white-space: nowrap;
}
.speedometer:hover { color: #334155; background: #f8fafc; border-color: #dbe4ee; }
.speedometer-icon { color: #2563eb; font-size: 16px; line-height: 1; }
.speedometer strong { min-width: 18px; color: #0f172a; font-size: 12px; text-align: right; }
.speedometer-unit { color: #64748b; font-size: 9px; font-weight: 800; }
.navigation-floating-message {
    position: absolute;
    z-index: 3;
    top: -48px;
    left: 50%;
    max-width: calc(100% - 32px);
    padding: 9px 14px;
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 999px;
    color: #fff;
    background: rgba(15, 23, 42, .92);
    box-shadow: 0 9px 24px rgba(15, 23, 42, .22);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    backdrop-filter: blur(8px);
    transform: translateX(-50%);
}
.navigation-floating-message[hidden] { display: none; }
.navigation-floating-message.is-visible {
    animation: navigation-floating-message 2.2s ease both;
}
.floating-speedometer {
    --speed-color: #2563eb;
    --speed-glow: rgba(37, 99, 235, .55);
    position: absolute;
    z-index: 1;
    top: -112px;
    left: 20px;
    display: flex;
    width: 94px;
    height: 94px;
    overflow: hidden;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 5px solid #fff;
    border-radius: 50%;
    color: #0f172a;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 0 0 3px var(--speed-color), 0 12px 28px rgba(15, 23, 42, .24);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(12px) scale(.82);
    pointer-events: none;
}
.floating-speedometer[hidden] { display: none; }
.floating-speedometer.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: speedometer-bounce-in .4s cubic-bezier(.2, .82, .25, 1) both;
    pointer-events: auto;
}
.floating-speedometer.is-closing {
    animation: speedometer-bounce-out .28s ease-in both;
    pointer-events: none;
}
.floating-speedometer-scale { position: absolute; inset: 0; }
.floating-speedometer-scale svg { display: block; width: 100%; height: 100%; }
.floating-speedometer-track,
.floating-speedometer-progress {
    fill: none;
    stroke-width: 7;
    stroke-linecap: round;
}
.floating-speedometer-track { stroke: #dbe4ee; }
.floating-speedometer-progress {
    stroke: var(--speed-color);
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
    filter: drop-shadow(0 0 3px var(--speed-glow));
    transition: stroke-dashoffset .5s ease, stroke .22s ease, filter .22s ease;
}
.floating-speedometer-reading {
    position: relative;
    z-index: 2;
    display: flex;
    margin-top: 14px;
    flex-direction: column;
    align-items: center;
}
.floating-speedometer-reading strong { font-size: 31px; line-height: 1; }
.floating-speedometer-reading span { margin-top: 3px; color: #64748b; font-size: 9px; font-weight: 850; }
.floating-speedometer.speed-range-blue {
    --speed-color: #2563eb;
    --speed-glow: rgba(37, 99, 235, .62);
}
.floating-speedometer.speed-range-green {
    --speed-color: #16a34a;
    --speed-glow: rgba(22, 163, 74, .62);
}
.floating-speedometer.speed-range-dark-blue {
    --speed-color: #1e3a8a;
    --speed-glow: rgba(30, 58, 138, .68);
}
.floating-speedometer.speed-range-orange {
    --speed-color: #f97316;
    --speed-glow: rgba(249, 115, 22, .72);
    color: #9a3412;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 0 0 4px var(--speed-color), 0 12px 30px rgba(249, 115, 22, .34);
}
.floating-speedometer.speed-range-red {
    --speed-color: #dc2626;
    --speed-glow: rgba(220, 38, 38, .8);
    color: #991b1b;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 0 0 4px var(--speed-color), 0 12px 30px rgba(220, 38, 38, .42);
}
.floating-speedometer.danger-speed::before {
    position: absolute;
    z-index: 1;
    bottom: -3px;
    left: 50%;
    width: 116%;
    content: '🔥🔥';
    opacity: .88;
    font-size: 36px;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    transform: translateX(-50%);
    filter: saturate(1.25) drop-shadow(0 -2px 5px rgba(239, 68, 68, .48));
    animation: speedometer-flame .48s ease-in-out infinite alternate;
}
.floating-speedometer.speed-range-orange strong,
.floating-speedometer.speed-range-red strong { text-shadow: 0 1px 5px #fff; }
.floating-speedometer.speed-range-orange span { color: #c2410c; text-shadow: 0 1px 4px #fff; }
.floating-speedometer.speed-range-red span { color: #991b1b; text-shadow: 0 1px 4px #fff; }
.navigation-stop {
    position: absolute;
    top: -18px;
    right: 14px;
    display: grid;
    width: 38px;
    min-height: 38px;
    padding: 0;
    place-items: center;
    border: 3px solid #fff;
    border-radius: 12px;
    color: #fff;
    background: #dc2626;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .22);
    font-size: 22px;
}
.navigation-stop:hover { color: #fff; background: #b91c1c; border-color: #fff; }
.navigation-panel.loading .navigation-icon { animation: pulse 1s infinite; }
.navigation-panel.error .navigation-icon { background: #dc2626; }
.navigation-panel.arrived .navigation-icon { background: #16a34a; }

.map-long-press-indicator {
    position: fixed;
    z-index: 9;
    width: 72px;
    height: 72px;
    pointer-events: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .26);
    transform: translate(-50%, -50%);
    backdrop-filter: blur(6px);
}
.map-long-press-indicator[hidden] { display: none; }
.map-long-press-indicator svg { position: absolute; inset: 4px; width: 64px; height: 64px; transform: rotate(-90deg); }
.map-long-press-indicator circle { fill: none; stroke-width: 5; }
.map-long-press-track { stroke: #dbeafe; }
.map-long-press-progress {
    stroke: #2563eb;
    stroke-linecap: round;
    stroke-dasharray: 176;
    stroke-dashoffset: 176;
    animation: map-long-press-progress .8s linear forwards;
}
.map-long-press-indicator span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #2563eb;
    font-size: 25px;
    transform: rotate(-45deg);
}

.navigation-confirm-modal {
    position: fixed;
    z-index: 11;
    inset: 0;
    display: grid;
    padding: 20px;
    place-items: center;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(4px);
}
.navigation-confirm-modal[hidden] { display: none; }
.navigation-confirm-card {
    width: min(340px, 100%);
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .3);
    text-align: center;
}
.navigation-confirm-icon {
    display: grid;
    width: 46px;
    height: 46px;
    margin: 0 auto 13px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: #dc2626;
    font-size: 23px;
    font-weight: 900;
}
.navigation-confirm-card h2 { margin: 0; font-size: 19px; }
.navigation-confirm-card p { margin: 8px 0 18px; color: #64748b; font-size: 12px; line-height: 1.5; }
.navigation-confirm-actions { display: flex; gap: 9px; }
.navigation-confirm-actions button { flex: 1; min-height: 40px; padding: 0 10px; }
.navigation-confirm-cancel { color: #334155; background: #f1f5f9; border-color: #dbe4ee; }
.navigation-confirm-cancel:hover { color: #0f172a; background: #e2e8f0; border-color: #cbd5e1; }
.navigation-confirm-accept { color: #fff; background: #dc2626; border-color: #dc2626; }
.navigation-confirm-accept:hover { background: #b91c1c; border-color: #b91c1c; }
.map-destination-confirm-icon { background: #2563eb; transform: rotate(-45deg); }
.map-destination-confirm-accept { color: #fff; background: #2563eb; border-color: #2563eb; }
.map-destination-confirm-accept:hover { background: #1d4ed8; border-color: #1d4ed8; }

.trip-summary-modal {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: grid;
    padding: 20px;
    place-items: center;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(4px);
}
.trip-summary-modal[hidden] { display: none; }
.trip-summary-card {
    width: min(390px, 100%);
    padding: 26px;
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .3);
    text-align: center;
}
.trip-summary-icon {
    display: grid;
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: #16a34a;
    box-shadow: 0 0 0 8px rgba(22, 163, 74, .12);
    font-size: 28px;
    font-weight: 900;
}
.trip-summary-icon.stopped { background: #f97316; box-shadow: 0 0 0 8px rgba(249, 115, 22, .13); font-size: 20px; }
.trip-summary-eyebrow { margin: 0 0 4px; color: #16a34a; font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.trip-summary-eyebrow.stopped { color: #c2410c; }
.trip-summary-card h2 { margin: 0; font-size: 22px; }
.trip-summary-destination { margin: 7px 0 18px; color: #475569; font-size: 13px; font-weight: 700; }
.trip-summary-details { display: grid; margin: 0; gap: 1px; overflow: hidden; border: 1px solid #e2e8f0; border-radius: 14px; background: #e2e8f0; text-align: left; }
.trip-summary-details div { display: flex; padding: 12px 14px; align-items: center; justify-content: space-between; background: #f8fafc; }
.trip-summary-details dt { color: #64748b; font-size: 12px; font-weight: 700; }
.trip-summary-details dd { margin: 0; color: #0f172a; font-size: 13px; font-weight: 850; }
.trip-summary-live-status { display: flex; margin: 14px 0; gap: 7px; align-items: center; justify-content: center; color: #64748b; font-size: 11px; font-weight: 700; }
.trip-summary-live-status span { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.trip-summary-close { width: 100%; }

.destination-marker {
    width: 34px;
    height: 42px;
}
.destination-pin {
    display: grid;
    width: 34px;
    height: 42px;
    padding-bottom: 7px;
    place-items: center;
    color: #fff;
    background: #ef4444;
    border: 3px solid #fff;
    border-radius: 50% 50% 50% 5px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, .3);
    font-size: 14px;
    transform: rotate(-45deg);
}
.destination-pin span { transform: rotate(45deg); }

@keyframes heading-pulse { 50% { transform: translateY(-2px); } }
@keyframes floating-route-in {
    from { opacity: 0; transform: translateY(-8px) scale(.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes floating-route-icon-pulse {
    50% { transform: scale(1.1); }
}
@keyframes floating-route-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-8px) scale(.97); }
}
@keyframes voice-wave-pulse {
    50% { opacity: .45; transform: translateX(-1px); }
}
@keyframes navigation-floating-message {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(.92); }
    14%, 78% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -7px) scale(.96); }
}
@keyframes speedometer-bounce-in {
    0% { opacity: 0; transform: translateY(12px) scale(.82); }
    62% { opacity: 1; transform: translateY(-3px) scale(1.055); }
    82% { transform: translateY(1px) scale(.985); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes speedometer-bounce-out {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    28% { opacity: 1; transform: translateY(-2px) scale(1.025); }
    100% { opacity: 0; transform: translateY(10px) scale(.82); }
}
@keyframes speedometer-flame {
    from { transform: translateX(-50%) translateY(2px) scale(.96); }
    to { transform: translateX(-50%) translateY(-3px) scale(1.06); }
}
@keyframes map-long-press-progress { to { stroke-dashoffset: 0; } }

.maplibregl-popup-content { padding: 13px; border-radius: 14px; box-shadow: var(--shadow); }
.maplibregl-popup-close-button { width: 28px; height: 28px; font-size: 20px; }

.theme-night {
    --surface: #0f172a;
    --muted: #94a3b8;
    --border: #334155;
    --shadow: 0 16px 42px rgba(0, 0, 0, .42);
}
.theme-night body { color: #e2e8f0; background: #020617; }
.theme-night #map { background: #020617; }
.theme-night #map .maplibregl-canvas {
    filter: brightness(.62) saturate(.78) contrast(1.08);
}
.theme-night .map-panel,
.theme-night .simulation-panel,
.theme-night .navigation-panel {
    color: #e2e8f0;
    background: rgba(15, 23, 42, .94);
    border-color: rgba(71, 85, 105, .82);
}
.theme-night .floating-route-guidance {
    color: #f8fafc;
    background: rgba(15, 23, 42, .85);
    border-color: rgba(96, 165, 250, .48);
}
.theme-night .floating-route-content small,
.theme-night .navigation-eyebrow { color: #60a5fa; }
.theme-night .subtitle,
.theme-night label,
.theme-night .legend-item,
.theme-night .simulation-panel span,
.theme-night .navigation-instruction,
.theme-night .speedometer-unit { color: #94a3b8; }
.theme-night select,
.theme-night .status,
.theme-night .heading-toggle,
.theme-night .speedometer,
.theme-night .voice-toggle.muted,
.theme-night .map-panel.collapsed .collapsed-listing-count {
    color: #e2e8f0;
    background: #1e293b;
    border-color: #475569;
}
.theme-night .live-toggle {
    color: #cbd5e1;
    background: #1e293b;
    border-color: #475569;
}
.theme-night .live-toggle:hover,
.theme-night .heading-toggle:hover,
.theme-night .speedometer:hover { color: #f8fafc; background: #334155; border-color: #64748b; }
.theme-night .live-toggle.active { color: #fecaca; background: #450a0a; border-color: #7f1d1d; }
.theme-night .gps-accuracy-status { color: #fecaca; background: #450a0a; border-color: #7f1d1d; }
.theme-night .gps-accuracy-status.is-accurate { color: #bbf7d0; background: #052e16; border-color: #166534; }
.theme-night .gps-accuracy-status.is-imprecise { color: #fed7aa; background: #431407; border-color: #9a3412; }
.theme-night .navigation-summary,
.theme-night .speedometer strong { color: #f8fafc; }
.theme-night .voice-toggle { color: #93c5fd; background: #172554; border-color: #1e40af; }
.theme-night .voice-toggle:hover { color: #dbeafe; background: #1e3a8a; border-color: #3b82f6; }
.theme-night .floating-speedometer,
.theme-night .floating-speedometer.speed-range-orange,
.theme-night .floating-speedometer.speed-range-red {
    color: #f8fafc;
    background: rgba(15, 23, 42, .95);
    border-color: #1e293b;
}
.theme-night .floating-speedometer-track { stroke: #475569; }
.theme-night .floating-speedometer-reading span { color: #cbd5e1; }
.theme-night .navigation-confirm-card,
.theme-night .trip-summary-card,
.theme-night .maplibregl-popup-content {
    color: #e2e8f0;
    background: #0f172a;
    border-color: #475569;
}
.theme-night .navigation-confirm-card p,
.theme-night .trip-summary-destination,
.theme-night .trip-summary-details dt,
.theme-night .trip-summary-live-status,
.theme-night .popup-address { color: #94a3b8; }
.theme-night .trip-summary-details { background: #334155; border-color: #334155; }
.theme-night .trip-summary-details div { background: #1e293b; }
.theme-night .trip-summary-details dd { color: #f8fafc; }
.theme-night .navigation-confirm-cancel { color: #e2e8f0; background: #1e293b; border-color: #475569; }
.theme-night .navigation-confirm-cancel:hover { color: #fff; background: #334155; border-color: #64748b; }
.theme-night .maplibregl-popup-anchor-top .maplibregl-popup-tip,
.theme-night .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.theme-night .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: #0f172a; }
.theme-night .maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.theme-night .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.theme-night .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: #0f172a; }
.theme-night .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: #0f172a; }
.theme-night .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: #0f172a; }
.theme-night .maplibregl-ctrl-group { background: #0f172a; }
.theme-night .maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(1) brightness(1.6); }
.theme-night .place-search-input-wrap input,
.theme-night .place-search-result { color: #f8fafc; background: #1e293b; border-color: #475569; }
.theme-night .place-search-result:hover { color: #7dd3fc; background: #334155; border-color: #0284c7; }
.theme-night .nearest-listing-item { color: #e2e8f0; }
.theme-night .nearest-listing-item:hover { color: #7dd3fc; background: #334155; }

.map-panel {
    transition: width .2s ease, padding .2s ease, border-radius .2s ease,
        color .4s ease, background-color .4s ease, border-color .4s ease;
}
.simulation-panel,
.navigation-panel,
.floating-route-guidance,
.navigation-confirm-card,
.trip-summary-card,
.maplibregl-popup-content {
    transition: color .4s ease, background-color .4s ease, border-color .4s ease;
}

/* Desktop navigation: keep the speed reading beside the bottom card. */
@media (min-width: 1025px) {
    .map-panel { top: 24px; left: 24px; }
    .gps-accuracy-status.is-floating { top: 24px; right: 24px; }
    .floating-route-guidance { top: 86px; left: 24px; max-width: 360px; }
    .simulation-panel { top: 76px; right: 24px; }

    .navigation-panel {
        bottom: 24px;
        width: 600px;
        padding: 18px 20px;
        gap: 16px;
    }
    .navigation-content h2 { font-size: 17px; }
    .navigation-summary { font-size: 14px; }
    .navigation-instruction { font-size: 12px; }
    .navigation-actions { margin-top: 12px; }

    .floating-speedometer {
        top: auto;
        bottom: 0;
        left: -132px;
        width: 108px;
        height: 108px;
    }
    .floating-speedometer-reading strong { font-size: 36px; }
    .floating-speedometer-reading span { font-size: 11px; }
    .maplibregl-ctrl-bottom-right { right: 14px; bottom: 24px; }
}

@media (max-width: 640px) {
    .map-panel { top: 10px; left: 10px; width: calc(100vw - 20px); padding: 14px; }
    .gps-accuracy-status.is-floating { top: 10px; right: 10px; }
    .floating-route-guidance { top: 70px; left: 10px; max-width: min(310px, calc(100vw - 20px)); }
    .controls { grid-template-columns: 1fr 1fr; }
    .maplibregl-ctrl-bottom-right { bottom: 8px; }
    .navigation-panel { bottom: 12px; width: calc(100vw - 20px); }
    .navigation-actions { gap: 6px; }
    .heading-toggle { padding: 0 8px; gap: 4px; font-size: 9px; }
    .navigation-audio-actions { gap: 5px; }
    .voice-toggle { width: 30px; }
    .speedometer { padding: 0 8px; }
    .simulation-panel { top: auto; right: 10px; bottom: 190px; width: 210px; }
    .floating-speedometer { top: -102px; left: 14px; width: 84px; height: 84px; }
    .floating-speedometer-reading strong { font-size: 28px; }
}

/* A scrollable control column leaves the landscape map unobstructed. */
@media (max-width: 1024px) and (orientation: landscape) {
    :root { --landscape-sidebar-width: clamp(280px, 36vw, 340px); }
    #map { left: var(--landscape-sidebar-width); }
    .map-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 8;
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: var(--landscape-sidebar-width);
        padding: 10px;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: #f1f5f9;
    }
    .theme-night .map-sidebar { background: #0f172a; }
    .map-sidebar > .map-panel,
    .map-sidebar > .floating-route-guidance,
    .map-sidebar > .navigation-panel,
    .map-sidebar > .simulation-panel {
        position: relative;
        inset: auto;
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
        transform: none;
        box-shadow: none;
    }
    .map-sidebar > .map-panel { padding: 12px; }
    .map-sidebar > .map-panel.collapsed { width: 164px; padding: 0; }
    .gps-accuracy-status.is-floating { position: absolute; top: 18px; left: 188px; right: auto; }
    .map-sidebar > .floating-route-guidance { order: 1; }
    .map-sidebar > .navigation-panel { order: 2; padding: 12px; gap: 10px; grid-template-columns: 34px minmax(0, 1fr); }
    .map-sidebar > .simulation-panel { order: 3; }
    .navigation-icon-group { min-width: 34px; }
    .navigation-icon { width: 34px; height: 34px; font-size: 19px; }
    .navigation-content h2 { padding-right: 24px; }
    .navigation-eyebrow { padding-right: 24px; font-size: 8px; }
    .navigation-summary { font-size: 12px; }
    .navigation-actions { flex-wrap: wrap; gap: 8px; }
    .navigation-stop { top: 6px; right: 6px; width: 28px; min-height: 28px; font-size: 18px; }
    .floating-speedometer {
        position: relative;
        inset: auto;
        grid-column: 2;
        width: 74px;
        height: 74px;
        margin: 4px 0;
        justify-self: start;
    }
    .floating-speedometer-reading strong { font-size: 26px; }
    .navigation-floating-message { top: 8px; white-space: normal; width: calc(100% - 24px); }
    .landscape-map-controls { display: block; order: 4; }
    .landscape-map-controls .maplibregl-ctrl-bottom-right { position: static; }
    .landscape-map-controls .maplibregl-ctrl-group { display: flex; float: none; width: fit-content; margin: 0; }
    .landscape-map-controls .maplibregl-ctrl-group button { border-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .floating-route-guidance.is-visible,
    .floating-route-guidance.is-closing,
    .floating-route-guidance.has-update .floating-route-icon,
    .voice-toggle:not(.muted) .voice-waves,
    .navigation-floating-message.is-visible,
    .floating-speedometer.is-open,
    .floating-speedometer.is-closing { animation: none; }
    .floating-speedometer-progress { transition: none; }
}
