.replay-mode-switch {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 2px;
    padding: 0;
    border: 1px solid rgba(var(--theme-paper-rgb), .24);
    border-radius: 16px;
    background: rgba(var(--theme-ink-rgb), .9);
    box-shadow: 0 8px 20px rgba(var(--theme-ink-rgb), .2);
}
.replay-mode-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 3.8rem;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: rgba(var(--theme-paper-rgb), .75);
    font: 800 .84rem/1.2 "Segoe UI", "Noto Sans TC", sans-serif;
    white-space: nowrap;
    cursor: pointer;
    touch-action: manipulation;
}
.replay-mode-option:hover { color: var(--theme-paper); background: rgba(var(--theme-paper-rgb), .1); }
.replay-mode-option[aria-pressed="true"] {
    background: var(--theme-brand);
    color: var(--theme-paper);
    border-color: var(--theme-brand-line);
}
.replay-mode-option:focus-visible { outline: 2px solid var(--theme-paper); outline-offset: -3px; }
:root[data-theme="classic"] .replay-mode-switch {
    border-color: #8a6d3b;
    border-radius: 7px;
    background: linear-gradient(180deg, #fbf4e4, #e5d4ae);
    box-shadow: inset 0 1px 0 #ffffffb0, 0 3px 0 #8a6d3b, 0 5px 7px #140c0550;
}
:root[data-theme="classic"] .replay-mode-option {
    border-radius: 4px;
    color: var(--theme-ink);
    font-family: Georgia, "Noto Serif TC", "Songti TC", "PMingLiU", serif;
}
:root[data-theme="classic"] .replay-mode-option[aria-pressed="true"] {
    background: linear-gradient(180deg, var(--theme-brand-strong), var(--theme-brand-deep));
    color: var(--theme-paper);
    border-color: var(--theme-brand-deeper);
    box-shadow: inset 0 2px 4px #3c120850;
}
:root[data-theme="tech"] .replay-mode-switch {
    border-color: rgba(34, 211, 238, .4);
    border-radius: 0;
    box-shadow: 0 0 18px rgba(34, 211, 238, .16);
}
:root[data-theme="tech"] .replay-mode-option { border-radius: 0; }
:root[data-theme="tech"] .replay-mode-option[aria-pressed="true"] {
    background: linear-gradient(180deg, var(--theme-brand-soft), var(--theme-brand));
    color: var(--theme-ink);
}
/* Navigation belongs to the lower controls in both modes. Move the same switch
   between these hosts so its state, focus and listeners stay in sync. */
.playback-navigation { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; order: 1; }
.playback-header-actions { order: 2; }
.route-map-navigation { flex: 0 0 100%; min-width: 0; padding-bottom: 4px; }
.route-map-navigation .replay-mode-switch { display: flex; box-shadow: none; }
.route-map-navigation .replay-mode-option { flex: 1 1 0; }
@media (max-width: 720px), (any-pointer: coarse) and (max-width: 1180px), (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
    /* Only the destination is shown on touch layouts: one tap switches modes. */
    .replay-mode-option[aria-pressed="true"] { display: none; }
    .replay-mode-switch { border-radius: 12px; box-shadow: none; }
    .replay-mode-option { min-width: 3.2rem; padding-inline: 8px; }
    .playback-navigation .cinematic-launch { min-width: 0; padding-inline: 8px; flex-shrink: 1; }
    .playback-navigation .cinematic-launch .peek-label { overflow: hidden; text-overflow: ellipsis; }
    .bottom-overlay:not(.is-track-compact) .playback-navigation {
        grid-column: 1; grid-row: 1; gap: 6px; min-width: 0;
    }
    .bottom-overlay:not(.is-track-compact) .playback-header-meta {
        display: flex; flex-direction: row; align-items: center; gap: 3px 10px;
        grid-column: 1 / -1; grid-row: 2;
    }
    .bottom-overlay:not(.is-track-compact) .playback-header-meta :is(.playback-track-meta, .playback-time-meta) { display: flex; width: auto; }
    .bottom-overlay:not(.is-track-compact) .playback-header-meta .playback-time-meta { flex: 1 1 auto; margin-left: 0; }
    .bottom-overlay:not(.is-track-compact) .playback-header-actions { grid-row: 1; }
    .bottom-overlay.is-track-compact .playback-navigation { display: none; }
    .route-map-dock .route-map-tools { flex-wrap: nowrap; }
    .route-map-navigation { display: flex; flex: 1.5 1 54px; padding: 0; }
    .route-map-navigation .replay-mode-switch { flex: 1 1 auto; min-width: 0; }
    .route-map-navigation .replay-mode-option { min-width: 0; min-height: 52px; padding: 0 3px; font-size: .75rem; }
}
@media (max-width: 360px) {
    .bottom-overlay:not(.is-track-compact) .playback-panel .playback-header { column-gap: 4px; }
    .bottom-overlay:not(.is-track-compact) .playback-navigation,
    .playback-header-actions { gap: 4px; }
    .playback-navigation .replay-mode-option { min-width: 44px; padding-inline: 6px; }
    .playback-navigation .cinematic-launch { padding-inline: 6px; }
    /* Keep readable captions and usable hit areas on the narrowest phones. */
    .route-map-dock .route-map-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .route-map-dock .route-map-settings { width: auto; }
}
@media (min-width: 600px) and (max-width: 720px), (any-pointer: coarse) and (min-width: 600px) and (max-width: 1180px) {
    .bottom-overlay:not(.is-track-compact) .playback-panel .playback-header { display: flex; }
    .bottom-overlay:not(.is-track-compact) .playback-header-meta { display: flex; flex-direction: column; align-items: stretch; }
    .bottom-overlay:not(.is-track-compact) .playback-header-meta :is(.playback-track-meta, .playback-time-meta) { display: flex; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) and (min-width: 600px) {
    .bottom-overlay:not(.is-track-compact) .playback-header-meta { display: flex; flex-direction: row; align-items: center; }
    .bottom-overlay:not(.is-track-compact) .playback-header-meta :is(.playback-track-meta, .playback-time-meta) { display: flex; }
}

.route-map-tools .route-map-tool-button svg {
    width: 18px;
    height: 18px;
}
.route-map-tools > button:focus-visible,
.route-point-card button:focus-visible { outline: 3px solid var(--theme-brand-soft); outline-offset: 2px; }
.route-map-dock {
    position: absolute;
    z-index: 34;
    right: 18px;
    bottom: 18px;
    width: 290px;
    display: grid;
    gap: 8px;
}
.route-map-tools {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px;
    padding: 5px;
    border: 1px solid rgba(var(--theme-paper-rgb), .22);
    border-radius: 16px;
    background: rgba(var(--theme-ink-rgb), .78);
    box-shadow: 0 12px 28px rgba(var(--theme-ink-rgb), .25);
    backdrop-filter: blur(16px);
}
.route-map-dock[hidden], .route-map-tools[hidden], .route-point-preview[hidden], .route-point-card[hidden] { display: none !important; }
.route-map-tools .route-map-tool-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 12px;
    font-size: 0.75rem;
}
.route-map-tools .route-map-tool-button:is([aria-pressed="true"], [aria-expanded="true"]) {
    background: linear-gradient(180deg, var(--theme-brand), var(--theme-brand-deep));
    border-color: var(--theme-brand-line);
    color: var(--theme-paper);
}
.route-tool-caption { display: none; }
.route-map-summary {
    position: absolute;
    z-index: 33;
    left: calc(32px + var(--tracks-panel-width));
    bottom: 27px;
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    border-radius: 8px;
    background: rgba(var(--theme-ink-rgb), .6);
    color: var(--theme-paper);
    font-size: 0.6875rem;
    font-weight: 700;
    white-space: nowrap;
}
.route-map-summary:empty,
.viewer-frame:not(.is-route-map) .route-map-summary { display: none; }
.route-point-card {
    position: absolute;
    z-index: 36;
    right: 18px;
    top: 74px;
    width: min(350px, calc(100% - 36px));
    max-height: calc(100% - 74px - var(--route-map-footer, 86px));
    overflow-y: auto;
    overscroll-behavior: contain;
    display: grid;
    gap: 10px;
    box-sizing: border-box;
    padding: 18px;
    border: 1px solid var(--theme-surface-line);
    border-radius: 16px;
    background: var(--theme-paper);
    color: var(--theme-ink);
    box-shadow: 0 12px 30px rgba(var(--theme-ink-rgb), .18);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}
.route-point-card strong { padding-right: 26px; font-size: 1.0625rem; overflow-wrap: anywhere; }
.route-point-card { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
.route-point-card > * { min-width: 0; }
.route-point-card time { color: var(--theme-muted); font-weight: 600; }
.route-point-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin: 3px 0; }
.route-point-details div { min-width: 0; }
.route-point-details dt { color: var(--theme-muted); font-size: 0.6875rem; margin-bottom: 3px; }
.route-point-details dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.route-point-weather { border-top: 1px solid var(--theme-surface-line-3); padding-top: 12px; }
.route-point-weather:empty { display: none; }
.route-weather-condition { display:flex;align-items:center;gap:6px; }
.route-weather-condition svg { flex:0 0 23px;width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;color:#2878a8; }
.route-point-navigation { display: flex; align-items: center; gap: 10px; color: var(--theme-muted); }
.route-point-navigation button { width: 38px; height: 32px; border: 1px solid var(--theme-surface-line); border-radius: 8px; background: transparent; color: var(--theme-ink); font-size: 22px; cursor: pointer; }
.route-point-card button:disabled { opacity: .4; cursor: default; }
.route-point-card button:focus-visible, .route-point-card summary:focus-visible, .route-point-card select:focus-visible { outline: 2px solid var(--theme-brand); outline-offset: 2px; }
.route-data-note { font-size: 0.6875rem; line-height: 1.5; color: var(--theme-muted); margin: 0; }
.route-data-note:empty { display: none; }
.route-analysis-section { border-top: 1px solid var(--theme-surface-line); padding-top: 12px; }
.route-analysis-section summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.route-chart-controls { display: flex; gap: 8px; margin-top: 10px; }
.route-chart-controls select { min-width: 0; width: 50%; padding: 7px; font: inherit; border: 1px solid var(--theme-surface-line); border-radius: 7px; background: var(--theme-paper); color: var(--theme-ink); }
.route-chart-scale { margin-top: 10px; color: var(--theme-muted); font-size: 0.625rem; }
.route-analysis-chart { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.route-chart-axis { display: flex; justify-content: space-between; font-size: 0.625rem; color: var(--theme-muted); margin: 0 0 8px; }
.route-range-control { margin-top: 10px; }
.route-range-control label { display: flex; justify-content: space-between; }
.route-range-control input { width: 100%; margin: 0; min-height: 32px; accent-color: var(--theme-brand); }
#routeRangeStats { grid-template-columns: repeat(3, 1fr); margin: 10px 0; }
#btnRouteRangePlay { width: 100%; margin-top: 10px; }
.route-more-stats { margin-top: 10px; }
.route-more-stats .route-point-details { margin: 10px 0; }
.route-more-stats .route-data-note + .route-data-note { margin-top:8px; }
.route-stats-scope { display:flex;align-items:center;justify-content:space-between;gap:8px;margin:10px 0; }
.route-stats-scope select { min-width:0;max-width:65%;min-height:36px;padding:6px 9px;border:1px solid var(--theme-surface-line);border-radius:8px;background:var(--theme-surface-4);color:var(--theme-ink);font:inherit; }
#routeSummaryStats { margin:14px 0;gap:16px 12px; }
#routeSummaryStats dd { font-size: 1rem;line-height:1.35; }
#routeStatsWarning:not(:empty) { margin-bottom:10px; }
.route-point-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: var(--theme-muted);
    font-size: 23px;
    cursor: pointer;
}
.route-chart-reading {
    display: grid;
    gap: 5px;
    margin: 9px 0;
    color: var(--theme-ink);
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
}
.route-chart-reading-point, .route-chart-reading-value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 3px 8px;
    min-width: 0;
}
.route-chart-reading-point, #routeChartMetricLabel { color: var(--theme-muted); }
.route-chart-reading time { overflow-wrap: anywhere; }
#routeChartPointValue { white-space: nowrap; }
.route-point-play {
    min-height: 38px;
    border: 0;
    border-radius: 9px;
    background: var(--theme-brand);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.viewer-frame.is-route-map #bottomOverlay,
.viewer-frame.is-route-map #telemetryOverlay,
.viewer-frame.is-route-map #pigeonLabelLayer,
.viewer-frame.is-route-map #weather3dStatus,
.viewer-frame.is-route-map #altitudeChartPanel { display: none !important; }
.viewer-frame.is-cinematic #routeMapDock,
.viewer-frame.is-cinematic #routePointPreview,
.viewer-frame.is-cinematic #routeMapTools,
.viewer-frame.is-cinematic #routeMapSummary,
.viewer-frame.is-cinematic #routePointCard { display: none !important; }
.settings-legacy-link {
    display: block;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(var(--theme-paper-rgb), .15);
    color: var(--theme-paper);
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

@media (max-width: 720px), (any-pointer: coarse) and (max-width: 1180px) {
    .route-map-dock { left: 12px; right: 12px; bottom: 12px; width: auto; }
    .route-map-tools .route-map-tool-button { flex-direction: column; gap: 4px; min-height: 52px; width: 100%; }
    .route-tool-caption { display: block; font-size: 0.625rem; line-height: 1.2; text-align: center; }
    .route-map-summary { left: 20px; bottom: calc(var(--route-map-footer, 86px) + 2px); max-width: calc(100% - 40px); box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; }
    .has-route-details .route-map-summary, .has-route-preview .route-map-summary { display: none; }
    .route-point-card { left: 12px; right: 12px; top: auto; bottom: var(--route-map-footer, 86px); width: auto; max-height: min(58vh, calc(100% - var(--route-map-footer, 86px) - 64px)); padding: 16px; }
    .route-point-navigation button { height: 38px; }
}

.route-point-section summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.route-point-section[open] .route-point-navigation { margin: 8px 0 12px; }
.route-point-section .route-point-play { width: 100%; margin-top: 12px; }
.route-point-section .route-point-weather { margin-top: 14px; }
.route-point-section .route-data-note { margin-top: 10px; }
.viewer-frame.is-route-map .cesium-viewer-fullscreenContainer { display: none !important; }

/* Keep both logos together above the Map controls, including the Live row. */
.route-map-attribution {
    position: absolute; left: 8px; right: 8px; bottom: var(--route-map-attribution-bottom, 90px); z-index: 35;
    display: flex; justify-content: flex-end; align-items: flex-end;
    min-height: 24px; padding-left: 96px; box-sizing: border-box; pointer-events: none;
}
.route-map-attribution[hidden] { display: none; }
.route-map-attribution .cesium-credits-panel { min-width: 0; max-width: 100%; padding: 3px 5px; }
.viewer-frame.is-route-map .brand-watermark-viewer {
    left: 8px; bottom: var(--route-map-attribution-bottom, 90px); z-index: 35;
    gap: 4px; min-height: 24px; padding: 4px 6px;
}
.viewer-frame.is-route-map .brand-watermark-logo { width: 12px; height: 12px; }
.viewer-frame.is-route-map .brand-watermark-text { font-size: 8px; letter-spacing: .06em; }
.viewer-frame.is-route-map .tracks-panel:not(.is-collapsed) { bottom: var(--route-map-footer, 128px); }
.viewer-frame.is-route-map .route-map-summary { bottom: calc(var(--route-map-footer, 128px) + 2px); }
@media (max-width: 720px), (any-pointer: coarse) and (max-width: 1180px), (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
    .viewer-frame.is-route-map:not(.tracks-collapsed) .route-map-summary { display: none; }
}

/* Point picking opens a compact summary; detailed data remains an explicit action. */
.route-point-preview {
    position: absolute; z-index: 36; left: 0; top: 0;
    width: 300px; max-width: calc(100% - 24px); box-sizing: border-box;
    display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 9px; padding: 14px;
    border: 1px solid var(--theme-surface-line); border-radius: 13px; background: var(--theme-paper);
    color: var(--theme-ink); box-shadow: 0 10px 26px rgba(var(--theme-ink-rgb), .18); font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}
.route-point-preview::before { content:"";position:absolute;width:12px;height:12px;background:var(--theme-paper);pointer-events:none; }
.route-point-preview[data-side="right"]::before { left:-7px;top:var(--tip-y);transform:translateY(-50%) rotate(45deg);border-left:1px solid var(--theme-surface-line);border-bottom:1px solid var(--theme-surface-line); }
.route-point-preview[data-side="left"]::before { right:-7px;top:var(--tip-y);transform:translateY(-50%) rotate(45deg);border-right:1px solid var(--theme-surface-line);border-top:1px solid var(--theme-surface-line); }
.route-point-preview[data-side="above"]::before { bottom:-7px;left:var(--tip-x);transform:translateX(-50%) rotate(45deg);border-right:1px solid var(--theme-surface-line);border-bottom:1px solid var(--theme-surface-line); }
.route-point-preview[data-side="below"]::before { top:-7px;left:var(--tip-x);transform:translateX(-50%) rotate(45deg);border-left:1px solid var(--theme-surface-line);border-top:1px solid var(--theme-surface-line); }
.route-preview-heading { display:flex;align-items:baseline;gap:10px;padding-right:26px;min-width:0; }
.route-preview-heading strong { min-width:0; }
#routePreviewNumber { color:var(--theme-muted);font-size: 0.6875rem;white-space:nowrap; }
.route-preview-body { min-height:0;overflow:auto;overscroll-behavior:contain; }
.route-preview-content { padding:2px 0; }
#routePreviewWeather { margin-top:12px; }
#routePreviewStatus:not(:empty) { margin-top:10px; }
.route-point-preview strong { font-size: 0.9375rem; padding-right: 24px; overflow-wrap: anywhere; }
.route-point-preview time { color: var(--theme-muted); font-size: 0.6875rem; }
.route-point-preview .route-point-details dd { font-size: 0.875rem; }
.route-point-expand { min-height: 38px; padding: 6px 12px; border: 1px solid var(--theme-surface-line); border-radius: 8px;
    background: var(--theme-surface-4); color: var(--theme-ink); font: inherit; font-weight: 700; cursor: pointer; }
.route-point-preview button:focus-visible { outline: 2px solid var(--theme-brand); outline-offset: 2px; }
.route-live-status:empty { display: none; }
.route-live-status { min-width: 0; border: 1px solid rgba(var(--theme-paper-rgb), .2); border-radius: 13px;
    background: rgba(var(--theme-ink-rgb), .9); box-shadow: 0 8px 20px rgba(var(--theme-ink-rgb), .18); }
.route-live-status .live-status-row { border-top: 0; padding: 7px 9px; }
.route-live-status .live-status-info { overflow: hidden; }
.viewer-frame.is-route-map #liveMapTools { display: none !important; }
@media (max-width: 720px), (any-pointer: coarse) and (max-width: 1180px) {
    .route-point-preview .route-point-close { width: 44px; height: 44px; top: 0; right: 0; }
    .route-preview-heading { padding-right: 32px; }
    .route-point-expand { min-height: 44px; }
}
/* Let the compact dock shrink within the viewer rather than clipping its last button. */
.route-map-tools { min-width: 0; }
.route-map-tools .route-map-tool-button { box-sizing: border-box; }
@media (max-width: 720px), (any-pointer: coarse) and (max-width: 1180px) {
    .route-map-tools > button { flex: 1 1 40px; min-width: 0; }
}
@media (max-height: 500px) {
    .route-point-preview { padding:10px;gap:6px; }
    .route-point-card { top: 12px; max-height: calc(100% - var(--route-map-footer, 86px) - 24px); }
}

/* Inner foldable screens use touch targets without stretching the inspector. */
@media (any-pointer: coarse) and (min-width: 721px) and (max-width: 1180px) and (min-height: 561px) {
    .route-map-dock { left: auto; width: 400px; }
    .route-point-card { left: auto; width: 430px; box-sizing: border-box; }
}

/* Quantitative map layers share one popover; the toolbar keeps its five actions. */
.route-map-options[hidden], .route-weather-legend[hidden], .route-measure-bar[hidden] { display: none !important; }
.route-map-options {
    position: absolute; z-index: 38; top: 74px; right: 18px;
    width: 310px; max-width: calc(100% - 36px); box-sizing: border-box;
    max-height: calc(100% - 74px - var(--route-map-footer, 86px)); overflow-y: auto;
    display: grid; gap: 9px; padding: 18px; border: 1px solid var(--theme-surface-line); border-radius: 14px;
    background: var(--theme-paper); color: var(--theme-ink); box-shadow: 0 10px 26px rgba(var(--theme-ink-rgb), .18); font-size: 0.75rem;
}
.route-map-options > strong { padding-right: 24px; font-size: 0.9375rem; }
.route-map-options > label { margin-top: 6px; font-weight: 700; }
.route-map-options .route-events-toggle { display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:40px;margin:0;border-top:1px solid var(--theme-surface-line);padding-top:8px;cursor:pointer; }
.route-events-toggle input { width:20px;height:20px;accent-color:var(--theme-brand);cursor:pointer; }
.route-map-options select, .route-map-options button:not(.route-point-close), .route-point-jump input, .route-point-jump button,
.route-table-pagination button { min-width: 0; min-height: 38px; padding: 6px 9px; border: 1px solid var(--theme-surface-line); border-radius: 8px; background: var(--theme-surface-4); color: var(--theme-ink); font: inherit; }
.route-map-options select { width: 100%; }
.route-map-options button, .route-point-jump button, .route-table-pagination button { cursor: pointer; }
.route-map-options button:disabled, .route-map-options select:disabled, .route-table-pagination button:disabled { opacity: .45; cursor: default; }
.route-map-options :focus-visible, .route-point-jump :focus-visible, .route-point-table-scroll button:focus-visible { outline: 2px solid var(--theme-brand); outline-offset: 2px; }
.route-weather-hours { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 5px; }
.route-weather-legend, .route-measure-bar { border: 1px solid rgba(var(--theme-paper-rgb), .2); border-radius: 12px; background: rgba(var(--theme-ink-rgb),.9); color: var(--theme-paper); padding: 10px 12px; font-size: 0.6875rem; }
.route-weather-legend strong, .route-weather-legend time { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-weather-legend time { margin-top: 3px; color: rgba(var(--theme-paper-rgb), .7); }
.route-weather-scale { height: 7px; margin-top: 8px; border-radius: 5px; }
.route-weather-ticks { position: relative; display: flex; justify-content: space-between; gap: 6px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.route-weather-tick { position: absolute; transform: translateX(-50%); }
.route-weather-legend small { display: block; margin-top: 4px; color: rgba(var(--theme-paper-rgb), .7); }
.route-weather-legend small[hidden] { display: none; }
.route-weather-legend small:empty { display: none; }
.has-route-details .route-weather-legend, .has-route-preview .route-weather-legend, .has-route-map-options .route-weather-legend { display: none; }
.has-route-event .route-weather-legend, .has-route-event .route-map-summary { display:none; }
.route-measure-bar output { display: block; font-size: 1rem; font-weight: 700; }
.route-measure-bar > span { display: block; margin: 5px 0; }
.route-measure-actions { display: flex; gap: 6px; }
.route-measure-drag { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 26px; }
.route-measure-move-hint { display: none; align-items: center; gap: 3px; opacity: .7; white-space: nowrap; }
.route-measure-move-hint svg { width: 12px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.route-measure-bar.is-floating .route-measure-drag { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.route-measure-bar.is-floating .route-measure-move-hint { display: flex; }
.route-measure-drag:focus-visible { outline: 2px solid #f2b847; outline-offset: 2px; border-radius: 3px; }
.route-measure-bar.is-dragging .route-measure-drag { cursor: grabbing; }
.route-measure-bar button { flex: 1; min-height: 34px; padding: 4px 8px; border: 1px solid rgba(var(--theme-paper-rgb), .2); border-radius: 7px; background: rgba(var(--theme-paper-rgb), .06); color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
.route-measure-bar button:disabled { opacity: .4; }
.route-measure-bar.is-floating { position: absolute; z-index: 37; box-sizing: border-box; margin: 0; overflow: auto; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.route-measure-bar.is-floating output { padding-left: 10px; border-left: 3px solid #f2b847; font-variant-numeric: tabular-nums; }
.route-measure-bar.is-floating > span:empty { display: none; }
.route-measure-bar.is-floating .route-measure-actions { margin-top: 4px; }
.route-point-jump { display: flex; align-items: center; gap: 6px; margin: 10px 0; }
.route-point-jump input { width: 70px; }
.route-point-table-scroll { min-width: 0; max-width: 100%; max-height: 290px; overflow: auto; border: 1px solid var(--theme-surface-line); border-radius: 8px; overscroll-behavior: contain; }
#routePointTable { width: 100%; border-collapse: collapse; font-size: 0.6875rem; font-variant-numeric: tabular-nums; }
#routePointTable th { position: sticky; top: 0; z-index: 1; background: var(--theme-surface); font-weight: 700; }
#routePointTable th, #routePointTable td { padding: 7px 8px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--theme-surface-line-3); }
#routePointTable td:first-child { position: sticky; left: 0; background: var(--theme-paper); }
#routePointTable th:first-child { left: 0; z-index: 2; }
#routePointTable button { min-height: 32px; min-width: 34px; border: 0; border-radius: 6px; background: var(--theme-surface-2); color: var(--theme-ink); cursor: pointer; font: inherit; }
#routePointTable .is-selected { background: var(--theme-surface-2); }
#routePointTable .is-selected td:first-child { background: var(--theme-surface-2); }
.route-table-pagination { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 10px; font-size: 0.6875rem; }
@media (max-width: 720px), (any-pointer: coarse) and (max-width: 1180px) {
    .route-measure-bar.is-floating .route-measure-drag { min-height: 44px; }
    .route-point-card:has(#routeTableSection[open]),
    .route-point-card:has(#routeStatsSection[open]) { max-height: min(78vh, calc(100% - var(--route-map-footer, 86px) - 64px)); }
    .route-map-options { top: 12px; right: 12px; width: 360px; max-width: calc(100% - 24px); max-height: calc(100% - var(--route-map-footer, 86px) - 24px); }
    .route-map-options select, .route-map-options button:not(.route-point-close), .route-point-jump input,
    .route-point-jump button, .route-table-pagination button, #routePointTable button, .route-measure-bar button, .route-stats-scope select { min-height: 44px; }
    .route-point-card .route-point-close, .route-map-options .route-point-close { width: 44px; height: 44px; top: 0; right: 0; }
    .route-point-card > strong, .route-map-options > strong { padding-right: 32px; }
}
@media (max-height: 500px) {
    .route-map-options { top: 12px; max-height: calc(100% - var(--route-map-footer, 86px) - 24px); }
}

/* Recorded event badges share the map's existing tools and compact inspection cards. */
.route-event-markers[hidden], .route-event-card[hidden], #routeEventChoice[hidden] { display:none !important; }
.viewer-frame.is-route-measuring .route-event-markers { display:none; }
.route-event-markers { position:absolute;inset:0;z-index:32;pointer-events:none;overflow:hidden; }
.route-event-marker { position:absolute;transform:translate(-50%,-50%);display:grid;place-items:center;width:44px;height:44px;border:0;background:transparent;padding:0;cursor:pointer;pointer-events:auto; }
.route-event-marker-symbol { display:grid;place-items:center;width:30px;height:30px;box-sizing:border-box;border:2px solid #fff;border-radius:50%;color:#fff;box-shadow:0 2px 7px #11253990;pointer-events:none; }
.route-event-marker svg { width:18px;height:18px; }
.route-event-marker.is-cluster { width:52px;height:52px; }
.route-event-marker.has-event-stack .route-event-marker-symbol { position:absolute;width:28px;height:28px; }
.route-event-marker.has-event-stack .route-event-marker-symbol:first-child { left:0;bottom:0;z-index:2; }
.route-event-marker.has-event-stack .route-event-marker-symbol:nth-child(2) { right:6px;top:10px;z-index:1; }
.route-event-marker.has-event-stack svg { width:17px;height:17px; }
.route-event-marker-count { position:absolute;right:0;top:0;z-index:3;display:grid;place-items:center;min-width:19px;height:19px;padding:0 3px;box-sizing:border-box;border:1.5px solid #fff;border-radius:10px;background:#203b53;color:#fff;font:700 11px/1 system-ui;box-shadow:0 1px 4px #11253970;pointer-events:none; }
.route-event-marker.is-selected .route-event-marker-symbol { box-shadow:0 0 0 3px #f8bd54,0 2px 7px #11253990; }
.route-event-marker:focus-visible { outline:3px solid #61bbff;border-radius:50%; }
.route-event-marker.has-event-stack:focus-visible { border-radius:12px; }
.route-event-card { position:absolute;z-index:37;right:18px;top:74px;display:grid;grid-template-columns:minmax(0,1fr);gap:10px;width:310px;max-width:calc(100% - 36px);max-height:calc(100% - 74px - var(--route-map-footer,86px));box-sizing:border-box;overflow:auto;padding:18px;border:1px solid var(--theme-surface-line);border-radius:14px;background:var(--theme-paper);color:var(--theme-ink);box-shadow:0 10px 26px rgba(var(--theme-ink-rgb), .18);font-size: 0.75rem; }
.route-event-card > strong { padding-right:28px;font-size: 0.9375rem;overflow-wrap:anywhere; }
.route-event-card > time, .route-event-card > small { color:var(--theme-muted);font-size: 0.6875rem;line-height:1.5; }
.route-event-card p { margin:0;line-height:1.6; }
#routeEventValue { font-weight:700; }
#routeEventValue:empty { display:none; }
.route-event-heading { display:flex;align-items:center;gap:8px; }
.route-event-heading h3 { margin:0;font-size: 1rem; }
.route-event-heading svg { display:block;width:22px;height:22px; }
#routeEventChoice { width:100%;min-width:0;min-height:40px;border:1px solid var(--theme-surface-line);border-radius:8px;background:var(--theme-surface-4);color:inherit;padding:6px;font:inherit; }
.route-event-card button:focus-visible, #routeEventChoice:focus-visible { outline:2px solid var(--theme-brand);outline-offset:2px; }
@media (max-width:720px), (any-pointer:coarse) and (max-width:1180px) {
    .route-event-card { left:12px;right:12px;top:auto;bottom:var(--route-map-footer,86px);width:auto;max-width:none;max-height:calc(100% - var(--route-map-footer,86px) - 24px);padding:16px; }
    .route-event-card .route-point-close { width:44px;height:44px;top:0;right:0; }
    .route-event-card > strong { padding-right:32px; }
    #routeEventChoice, #btnRouteEventPlay, .route-map-options .route-events-toggle { min-height:44px; }
}
@media (any-pointer:coarse) and (min-width:721px) and (max-width:1180px) and (min-height:561px) {
    .route-event-card { left:auto;width:380px; }
}

/* Mode navigation matches the Replay telemetry corner; settings stay in the dock. */
.viewer-frame.is-route-map [data-flight-only] { display:none !important; }
.viewer-frame:not(.is-route-map) #settingsMapLabel { display:none; }
.viewer-frame.is-cinematic #replayModeSwitch { display:none !important; }
.route-map-dock.has-open-settings { z-index:39; }
.route-map-settings { position:relative; inset:auto; flex:0 0 42px; width:42px; min-height:42px; }
.route-map-settings .settings-menu-button:focus-visible { outline:3px solid var(--theme-brand-soft); outline-offset:2px; }
.route-map-settings .settings-popover { top:auto; bottom:calc(100% + 10px); box-sizing:border-box; width:min(350px,calc(100vw - 24px)); }
@media (max-width:720px), (any-pointer:coarse) and (max-width:1180px) {
    .route-map-settings { flex:1 1 40px; min-width:0; }
}
.settings-popover-header { display:flex; justify-content:space-between; align-items:center; gap:12px;
    position:sticky; top:-12px; z-index:2; background:var(--settings-panel-background); }
.settings-popover .settings-popover-close { flex:0 0 44px; width:44px; min-height:44px; border:0; border-radius:10px;
    padding:0; background:transparent; color:var(--theme-paper); font:24px/1 system-ui,sans-serif; cursor:pointer; }
.settings-popover-close:hover { background:rgba(var(--theme-paper-rgb),.12); }

/* Match Replay's archive / HUD chrome without changing route or weather colors.
   The dock must not use clip-path: its settings popover extends above the frame. */
:root[data-theme="classic"] .route-map-tools,
:root[data-theme="classic"] :is(.route-live-status, .route-weather-legend, .route-measure-bar) {
    border-color: rgba(168, 130, 63, .5);
    border-radius: 7px;
    background: rgba(43, 32, 22, .92);
    box-shadow: 3px 3px 0 rgba(58, 45, 32, .18);
}
:root[data-theme="classic"] .route-map-tools .route-map-tool-button:is([aria-pressed="true"], [aria-expanded="true"]) {
    transform: translateY(2px);
    border-color: var(--theme-brand-deeper);
    box-shadow: inset 0 2px 4px rgba(60, 18, 8, .5), 0 1px 0 var(--theme-brand-deeper);
}
:root[data-theme="tech"] :is(.route-map-tools, .route-map-card, .route-live-status, .route-weather-legend, .route-measure-bar) {
    border-color: rgba(34, 211, 238, .35);
    border-radius: 0;
    box-shadow: 0 0 18px rgba(34, 211, 238, .14), inset 0 0 24px rgba(34, 211, 238, .04);
}
:root[data-theme="tech"] .route-map-tools .route-map-tool-button:is([aria-pressed="true"], [aria-expanded="true"]) {
    color: var(--theme-ink);
    border-color: var(--theme-brand-soft);
    box-shadow: 0 0 12px rgba(34, 211, 238, .35);
}
.route-live-status :is(.live-edge-button, .live-refresh-button, .live-button) {
    color: var(--theme-paper);
    border-color: rgba(var(--theme-paper-rgb), .18);
    background: rgba(var(--theme-paper-rgb), .08);
}
.route-live-status .live-playback-state { color: rgba(var(--theme-paper-rgb), .8); }
.route-live-status .live-last-report { color: rgba(var(--theme-paper-rgb), .6); }
