/* style.css */


/* ============================================================
   TW1ANALYST — SEVERE WEATHER COMMAND CENTER
   Storm-ops broadcast aesthetic · amber accent · stencil headlines
   ============================================================ */

:root {
    /* Space reserved for the iOS home-indicator / notch gesture area.
       Resolves to 0px on devices without one (Android, desktop, older iPhones). */
    --sab: env(safe-area-inset-bottom, 0px);

    /* Base surface palette — deep slate with warm undertone */
    --bg-0:        #0a0d12;
    --bg-1:        #11151c;
    --bg-2:        #161b24;
    --surface:     #1a2230;
    --surface-2:   #232c3d;
    --border:      #2a3548;
    --border-soft: #1f2735;

    /* Typography colors */
    --text:        #f3f4f6;
    --text-muted:  #94a3b8;
    --text-dim:    #64748b;

    /* Brand accent — storm amber */
    --accent:      #ffb020;
    --accent-soft: rgba(255, 176, 32, 0.18);
    --accent-line: rgba(255, 176, 32, 0.45);

    /* Live / hot */
    --hot:         #ff3b30;
    --hot-soft:    rgba(255, 59, 48, 0.2);

    /* Severity tokens */
    --sev-tornado: #ef4444;
    --sev-severe:  #f97316;
    --sev-sws:     #eab308;
    --sev-marine:  #fb923c;

    --radius-sm: 4px;
    --radius:    6px;
    --radius-lg: 10px;
}

* {
    box-sizing: border-box;
}

/* GLOBAL ---------------------------------------------------- */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--bg-0);
    color: var(--text);
    font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    /* Faint horizontal scanlines — CRT broadcast vibe */
    background-image: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.012) 0px,
        rgba(255, 255, 255, 0.012) 1px,
        transparent 1px,
        transparent 3px
    );
}

h1, h2, h3, h4, h5, h6 {
    font-family: "Oswald", "IBM Plex Sans", sans-serif;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin: 0;
}

code, kbd, samp, pre, .mono {
    font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

#map,
.maplibregl-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* MapLibre attribution */
.maplibregl-ctrl-attrib {
    background: rgba(10, 13, 18, 0.75) !important;
    color: var(--text-muted) !important;
}
.maplibregl-ctrl-attrib a {
    color: var(--accent) !important;
}

/* POPUPS ---------------------------------------------------- */
.maplibregl-popup {
    z-index: 5000;
}

.maplibregl-popup-content {
    background: rgba(17, 21, 28, 0.96);
    color: var(--text);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 12px 14px;
}

.maplibregl-popup-tip {
    border-top-color: rgba(17, 21, 28, 0.96) !important;
    border-bottom-color: rgba(17, 21, 28, 0.96) !important;
}

.maplibregl-popup-close-button {
    color: var(--text-muted);
    font-size: 18px;
    padding: 2px 8px;
}

/* TOP BAR --------------------------------------------------- */
#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background:
        linear-gradient(to bottom, rgba(10,13,18,0.98), rgba(10,13,18,0.86));
    border-bottom: 1px solid var(--border);
    box-shadow:
        inset 0 -1px 0 var(--accent-line),
        0 4px 16px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-bug {
    display: inline-flex;
    flex-direction: column;
    padding: 7px 14px 7px 16px;
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, rgba(255,176,32,0.10), rgba(0,0,0,0)) ,
        var(--bg-1);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    box-shadow: 0 0 18px rgba(255, 176, 32, 0.12);
    position: relative;
}

.brand-title {
    font-family: "Oswald", sans-serif;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text);
    line-height: 1;
}

.brand-subtitle {
    font-family: "IBM Plex Mono", monospace;
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 4px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Thin separator between logical button groups (info tools vs. radar tools) */
.ui-control-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* BUTTONS --------------------------------------------------- */
/* Button icon/label visibility — icon always shown for quicker recognition,
   label alongside it on desktop, tucked underneath on mobile (see media query). */
.btn-icon  { display: flex; line-height: 0; align-items: center; justify-content: center; flex-shrink: 0; }
.btn-icon svg { width: 16px; height: 16px; }
.btn-label { display: inline; }

.ui-control-button {
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-1);
    font-family: "Oswald", sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    color: var(--text);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.ui-control-button:active { transform: scale(0.95); }

.ui-control-button:hover {
    border-color: var(--accent-line);
    background: var(--surface);
    color: var(--accent);
    box-shadow:
        inset 0 0 0 1px var(--accent-line),
        0 4px 12px rgba(0, 0, 0, 0.6);
}

.ui-control-button.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow:
        inset 0 0 0 1px var(--accent),
        0 0 16px rgba(255, 176, 32, 0.35);
}

/* BOTTOM STRIP --------------------------------------------- */
#bottom-strip {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 36px;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px;
    background:
        linear-gradient(to top, rgba(10,13,18,0.98), rgba(10,13,18,0.86));
    border-top: 1px solid var(--border);
    box-shadow: inset 0 1px 0 var(--accent-line);
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    color: var(--text-muted);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

#bottom-strip-left,
#bottom-strip-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-label {
    font-family: "Oswald", sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 10px;
    color: var(--accent);
    padding: 2px 7px;
    border: 1px solid var(--accent-line);
    border-radius: 2px;
    background: var(--accent-soft);
}

#status-text,
#status-layers {
    color: var(--text);
}

/* SIDE PANELS ---------------------------------------------- */
.side-panel {
    position: absolute;
    top: 60px;
    bottom: 36px;
    width: 360px;
    z-index: 2500;
    padding: 12px;
    box-sizing: border-box;
    pointer-events: none;
}

.side-panel-left  { left: 0; }
.side-panel-right { right: 0; }

/* Smooth slide + fade — replaces instant display:none */
.side-panel {
    transition:
        opacity 0.28s ease,
        transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0s linear 0s;
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
}

.side-panel-left.hidden  { transform: translateX(-18px); }
.side-panel-right.hidden { transform: translateX(18px);  }

.side-panel.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.22s ease,
        transform 0.28s cubic-bezier(0.4, 0, 1, 1),
        visibility 0s linear 0.28s;
}

.side-panel-inner {
    height: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: rgba(17, 21, 28, 0.96);
    border: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 0 0 1px rgba(255, 176, 32, 0.05),
        0 14px 36px rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

/* PANEL HEADERS -------------------------------------------- */
.side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: relative;
    flex-shrink: 0; /* never let the header (and its close button) get squeezed
                        when the panel's content is taller than its max-height —
                        only .side-panel-body should shrink/scroll */
}

.side-panel-header::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
}

.side-panel-header-warning {
    background: linear-gradient(135deg, rgba(239,68,68,0.22), var(--surface));
}
.side-panel-header-warning::before {
    background: var(--sev-tornado);
}

.side-panel-header-forecast {
    background: linear-gradient(135deg, rgba(255,176,32,0.18), var(--surface));
}
.side-panel-header-forecast::before {
    background: var(--accent);
}

.side-panel-header-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.side-panel-title {
    font-family: "Oswald", sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text);
    line-height: 1.1;
}

.side-panel-subtitle {
    font-family: "IBM Plex Mono", monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.side-panel-close {
    border: 1px solid var(--border);
    background: var(--bg-1);
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: 0.12s ease;
    flex-shrink: 0;
}
.side-panel-close:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* PANEL BODY ------------------------------------------------ */
.side-panel-body {
    padding: 14px 16px;
    overflow-y: auto;
    color: var(--text);
    font-size: 13px;
    line-height: 1.55;
    flex: 1;
}

.side-panel-location {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 8px 10px;
    margin-bottom: 12px;
    background: rgba(10, 13, 18, 0.6);
    border: 1px solid var(--border-soft);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-sm);
}

.side-panel-section {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-soft);
}
.side-panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.side-panel-section-title {
    font-family: "Oswald", sans-serif;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 6px;
}

.side-panel-text {
    color: var(--text);
    font-size: 13px;
}

.side-panel-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    background: rgba(10, 13, 18, 0.6);
    font-family: "IBM Plex Mono", monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* WARNING SEVERITY HEADERS --------------------------------- */
#warning-panel-header.warning-tornado {
    background: linear-gradient(135deg, rgba(239,68,68,0.4), var(--surface));
}
#warning-panel-header.warning-tornado::before { background: var(--sev-tornado); }

#warning-panel-header.warning-severe {
    background: linear-gradient(135deg, rgba(249,115,22,0.4), var(--surface));
}
#warning-panel-header.warning-severe::before { background: var(--sev-severe); }

#warning-panel-header.warning-sws {
    background: linear-gradient(135deg, rgba(234,179,8,0.35), var(--surface));
}
#warning-panel-header.warning-sws::before { background: var(--sev-sws); }

#warning-panel-header.warning-marine {
    background: linear-gradient(135deg, rgba(251,146,60,0.4), var(--surface));
}
#warning-panel-header.warning-marine::before { background: var(--sev-marine); }

/* FORECAST -------------------------------------------------- */
.forecast-openmeteo {
    font-size: 13px;
    line-height: 1.55;
}

.forecast-openmeteo-section {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: rgba(10, 13, 18, 0.65);
    border: 1px solid var(--border-soft);
    border-left: 2px solid var(--accent);
}

.forecast-openmeteo-title {
    font-family: "Oswald", sans-serif;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
}

/* POPUP CONTENT -------------------------------------------- */
.popup-title {
    font-family: "Oswald", sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 4px;
    color: var(--text);
}

.popup-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.popup-mping,
.popup-nws {
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    max-width: min(320px, 90vw);
    color: var(--text);
}

.popup-mping {
    border-left: 3px solid var(--accent);
    padding-left: 10px;
}

.popup-nws {
    border-left: 3px solid var(--sev-tornado);
    padding-left: 10px;
}

.popup-nws-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.popup-nws-text {
    flex: 1;
    padding-right: 4px;
}

.popup-divider {
    border-top: 1px solid var(--border-soft);
    margin: 8px 0;
}

.nws-info-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font-family: "Oswald", sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.12s ease;
}
.nws-info-btn:hover {
    background: var(--accent);
    color: var(--bg-0);
    box-shadow: 0 0 14px rgba(255, 176, 32, 0.7);
}

/* FORECAST TARGET CIRCLE ----------------------------------- */
.forecast-target-circle {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    box-shadow:
        0 0 0 2px var(--bg-0),
        0 0 18px rgba(255, 176, 32, 0.8);
    pointer-events: none;
    z-index: 4000;
    animation: target-ping 0.8s ease-out;
}

@keyframes target-ping {
    0%   { transform: scale(0.4); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* LEGEND ---------------------------------------------------- */
.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 13px;
}

.legend-color {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* MAPLIBRE NAV CONTROLS ------------------------------------ */
.maplibregl-ctrl-group {
    background: var(--bg-1) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6) !important;
}
.maplibregl-ctrl-group button {
    background-color: transparent !important;
}
.maplibregl-ctrl-group button:hover {
    background-color: var(--surface) !important;
}
.maplibregl-ctrl-group button + button {
    border-top: 1px solid var(--border) !important;
}

/* MOBILE ---------------------------------------------------- */
/* ── Tablet (≤900px) ──────────────────────────────────────── */
@media (max-width: 900px) {
    #top-bar { height: 54px; padding: 6px 10px; }
    .brand-title    { font-size: 14px; }
    .brand-subtitle { font-size: 8px; }
    .ui-control-button { padding: 6px 10px; font-size: 12px; }
    #bottom-strip { height: 32px; font-size: 10px; padding: 2px 10px; }
    .side-panel {
        top: auto; bottom: 32px; left: 0; right: 0; width: 100%; padding: 6px;
    }
    .side-panel-inner {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        height: 60vh;
    }
    .side-panel-left.hidden,
    .side-panel-right.hidden { transform: translateY(24px); }
}

/* ── Mobile (≤640px or coarse pointer) ───────────────────── */
@media (max-width: 640px), (pointer: coarse) and (max-width: 900px) {

    /* --- Top bar: compact --- */
    #top-bar { height: 48px; padding: 4px 10px; }
    .brand-bug  { padding: 4px 10px 4px 11px; }
    .brand-title    { font-size: 13px; letter-spacing: 0.12em; }
    .brand-subtitle { display: none; }

    /* --- Bottom strip: status only --- */
    #bottom-strip {
        height: calc(28px + var(--sab));
        font-size: 9px;
        padding: 2px 10px calc(2px + var(--sab)) 10px;
        box-sizing: border-box;
    }
    #bottom-strip-right { display: none; }

    /* --- Top-right controls → floating bottom dock --- */
    .top-bar-right {
        position: fixed;
        bottom: calc(28px + var(--sab) + 10px);
        left: 50%;
        transform: translateX(-50%);
        z-index: 4500;
        justify-content: center;
        width: max-content;
        max-width: calc(100vw - 20px);
        background: rgba(10, 13, 18, 0.95);
        border: 1px solid var(--border);
        border-radius: 22px;
        padding: 8px 10px;
        gap: 4px;
        backdrop-filter: blur(22px);
        -webkit-backdrop-filter: blur(22px);
        box-shadow:
            0 8px 32px rgba(0, 0, 0, 0.75),
            inset 0 1px 0 rgba(255, 176, 32, 0.14),
            inset 0 0 0 1px rgba(255, 176, 32, 0.06);
    }

    /* --- Buttons: square-ish tap targets with icon on top, tiny label below.
       Keeping the label (instead of icon-only) makes each control identifiable
       at a glance without needing to memorize what the glyphs mean. --- */
    .ui-control-button {
        width: 56px;
        height: 52px;
        padding: 0;
        border-radius: 14px;
        flex-direction: column;
        gap: 3px;
        justify-content: center;
    }
    .btn-label {
        font-size: 8px;
        letter-spacing: 0.06em;
    }
    .btn-icon svg { width: 19px; height: 19px; }

    /* Active glow */
    .ui-control-button.active {
        box-shadow: 0 0 18px rgba(255, 176, 32, 0.45), inset 0 0 0 1.5px var(--accent);
    }

    /* Divider becomes a short horizontal rule between stacked rows-worth of
       groups in the dock (kept subtle, matches the pill's rounded shape) */
    .ui-control-divider {
        width: 1px;
        height: 32px;
        margin: 0 2px;
    }

    /* --- Drag handle (shown on mobile) --- */
    .panel-drag-handle {
        display: block;
        width: 38px;
        height: 4px;
        border-radius: 2px;
        background: rgba(255, 255, 255, 0.18);
        margin: 10px auto 4px;
        flex-shrink: 0;
    }

    /* --- Panels: full-width sheet from bottom --- */
    .side-panel {
        top: auto;
        bottom: calc(28px + var(--sab));
        left: 0;
        right: 0;
        width: 100%;
        padding: 0;
    }
    .side-panel-inner {
        border-radius: 20px 20px 0 0;
        max-height: 72vh;   /* fallback for browsers without dvh support */
        max-height: 72dvh;  /* tracks the real visible viewport as Safari's
                               address bar shows/hides, instead of the
                               often-taller "100vh" value */
        height: auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .side-panel-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .side-panel-left.hidden,
    .side-panel-right.hidden { transform: translateY(36px); }

    /* --- Close button: bigger touch target --- */
    .side-panel-close { width: 38px; height: 38px; font-size: 20px; }

    /* --- Radar control: left side, above dock --- */
    #radar-control-container {
        right: auto;
        left: 10px;
        bottom: calc(28px + var(--sab) + 68px);
    }

    /* --- MapLibre attribution / zoom controls --- */
    .maplibregl-ctrl-bottom-right {
        bottom: calc(28px + var(--sab) + 68px) !important;
        right: 8px !important;
    }
    .maplibregl-ctrl-bottom-left {
        bottom: calc(28px + var(--sab) + 68px) !important;
        left: 8px !important;
    }

    /* --- Volume canvas height on mobile --- */
    #vol-canvas { height: 200px !important; }
    #cs-canvas  { height: 180px !important; }
}

/* ── Mobile: Cross Section split view ────────────────────────
   Activated via body.cs-split-active (set in script.js while the
   Cross Section flow is live on a touch/narrow viewport). The map
   keeps the top half of the screen; the existing cross-section
   panel — same canvas, status text, smooth toggle and TF editor —
   is pinned to the bottom half instead of floating as a tall sheet.
   Desktop / non-split layouts are untouched.
   Base state (hidden) is unconditional so desktop never sees this
   button at all; the mobile media query below is the only place
   that ever reveals it. */
.cs-split-close {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-1);
    color: var(--text);
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
    z-index: 20;
    box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 176, 32, 0.06);
    transition: 0.12s ease;
}
.cs-split-close:hover,
.cs-split-close:active {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 16px rgba(255, 176, 32, 0.55);
}

@media (max-width: 640px), (pointer: coarse) and (max-width: 900px) {
    body.cs-split-active #cross-section-panel {
        top: 50%;
        bottom: 28px;
        height: auto;
    }
    body.cs-split-active #cross-section-panel .side-panel-inner {
        height: 100%;
        max-height: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: var(--bg-0);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    body.cs-split-active #cross-section-panel .side-panel-header,
    body.cs-split-active #cross-section-panel .side-panel-footer,
    body.cs-split-active #cross-section-panel .panel-drag-handle,
    body.cs-split-active #cross-section-panel #cs-status,
    body.cs-split-active #cross-section-panel #cs-content,
    body.cs-split-active #cross-section-panel .cs-smooth-row {
        display: none;
    }
    body.cs-split-active #cross-section-panel .side-panel-body {
        display: flex;
        flex-direction: column;
        height: 100%;
        padding: 8px;
        gap: 8px;
        overflow: hidden;
    }
    body.cs-split-active #cross-section-panel .cs-split-close {
        display: flex;
    }
    body.cs-split-active #cs-canvas {
        flex: 1 1 0%;
        min-height: 0;
        width: 100% !important;
        height: auto !important;
        margin-top: 0 !important;
    }
    body.cs-split-active #cs-tf-wrap {
        flex: 0 0 auto;
        margin-top: 0 !important;
    }
}

/* Drag handle hidden on desktop */
.panel-drag-handle { display: none; }

/* ── Volume screen box overlay ───────────────────────────────
   A fixed outlined square that stays centered on the visible map
   area, indicating which geographic region the volume renderer is
   sampling. Shown whenever vol-split-active or vol-live is set. */
#vol-screen-box {
    display: none;
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    box-sizing: border-box;
    border: 2px solid #ffb020;
    border-radius: 4px;
    background: rgba(255, 176, 32, 0.04);
    box-shadow:
        0 0 0 1px rgba(255, 176, 32, 0.18),
        inset 0 0 32px rgba(255, 176, 32, 0.04);
}
#vol-screen-box.active { display: block; }

/* Corner tick marks — pure CSS, no extra DOM */
#vol-screen-box::before,
#vol-screen-box::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border-color: #ffb020;
    border-style: solid;
    opacity: 0.9;
}
#vol-screen-box::before {
    top: -2px; left: -2px;
    border-width: 2px 0 0 2px;
    border-radius: 2px 0 0 0;
}
#vol-screen-box::after {
    bottom: -2px; right: -2px;
    border-width: 0 2px 2px 0;
    border-radius: 0 0 2px 0;
}

/* ── Vol split close button ──────────────────────────────────
   Same design as .cs-split-close; always hidden on desktop, only
   shown by body.vol-split-active on mobile. */
.vol-split-close {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-1);
    color: var(--text);
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
    z-index: 20;
    box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 176, 32, 0.06);
    transition: 0.12s ease;
}
.vol-split-close:hover,
.vol-split-close:active {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 16px rgba(255, 176, 32, 0.55);
}

@media (max-width: 640px), (pointer: coarse) and (max-width: 900px) {
    body.vol-split-active #volume-panel {
        top: 50%;
        bottom: 28px;
        height: auto;
    }
    body.vol-split-active #volume-panel .side-panel-inner {
        height: 100%;
        max-height: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: var(--bg-0);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    body.vol-split-active #volume-panel .side-panel-header,
    body.vol-split-active #volume-panel .side-panel-footer,
    body.vol-split-active #volume-panel .panel-drag-handle,
    body.vol-split-active #volume-panel #vol-status,
    body.vol-split-active #volume-panel #vol-content {
        display: none;
    }
    body.vol-split-active #volume-panel .side-panel-body {
        display: flex;
        flex-direction: column;
        height: 100%;
        padding: 8px;
        gap: 8px;
        overflow: hidden;
    }
    body.vol-split-active #volume-panel .vol-split-close {
        display: flex;
    }
    body.vol-split-active #vol-canvas {
        flex: 1 1 0%;
        min-height: 0;
        width: 100% !important;
        height: auto !important;
        margin-top: 0 !important;
    }
    body.vol-split-active #vol-tf-wrap {
        flex: 0 0 auto;
        margin-top: 0 !important;
    }
}

/* SOFT POPUP ENTRANCE -------------------------------------- */
.maplibregl-popup-content {
    animation: popup-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes popup-in {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Brand bug subtle hover lift */
.brand-bug {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.brand-bug:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 22px rgba(255, 176, 32, 0.22);
}

/* Smooth scrollbars in panels */
.side-panel-body::-webkit-scrollbar { width: 8px; }
.side-panel-body::-webkit-scrollbar-track { background: transparent; }
.side-panel-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 8px;
}
.side-panel-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-line);
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ============================================================
   RADAR STATION MARKERS
   ============================================================ */
/* (rendered via maplibre symbol layer; size set in JS) */

/* ============================================================
   FLOATING RADAR CONTROL BAR (bottom right)
   ============================================================ */
#radar-control {
    position: fixed;
    bottom: 56px;
    right: 16px;
    z-index: 30;
    background: rgba(10, 13, 18, 0.94);
    border: 1px solid rgba(255, 176, 32, 0.45);
    border-radius: 10px;
    color: #e9eef6;
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    letter-spacing: 0.06em;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.65), 0 0 22px rgba(255, 176, 32, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    transition: border-radius 220ms ease, box-shadow 220ms ease;
    min-width: 320px;
}
#radar-control.hidden {
    display: none;
}

#radar-control .rc-idle,
#radar-control .rc-playing,
#radar-control .rc-products {
    display: none;
}

/* state: idle */
#radar-control.state-idle .rc-idle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

/* state: playing */
#radar-control.state-playing .rc-playing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

/* state: products (idle bar + products panel above) */
#radar-control.state-products {
    border-radius: 14px;
}
#radar-control.state-products .rc-products {
    display: block;
    padding: 14px 16px 8px 16px;
    border-bottom: 1px solid rgba(255, 176, 32, 0.18);
    max-height: 360px;
    overflow-y: auto;
    animation: rc-products-slide 220ms ease-out;
}
#radar-control.state-products .rc-idle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

@keyframes rc-products-slide {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* buttons */
.rc-btn {
    background: rgba(255, 176, 32, 0.10);
    border: 1px solid rgba(255, 176, 32, 0.45);
    color: var(--accent);
    width: 28px;
    height: 28px;
    border-radius: 5px;
    cursor: pointer;
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 140ms ease, transform 90ms ease;
    flex-shrink: 0;
}
.rc-btn:hover {
    background: rgba(255, 176, 32, 0.22);
}
.rc-btn:active {
    transform: scale(0.94);
}
.rc-close {
    border-color: rgba(255, 88, 88, 0.55);
    color: #ff7a7a;
    background: rgba(255, 88, 88, 0.08);
}
.rc-close:hover {
    background: rgba(255, 88, 88, 0.20);
}

.rc-divider {
    color: rgba(233, 238, 246, 0.25);
    font-weight: 300;
}
.rc-station {
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.14em;
}
.rc-vcp {
    color: rgba(233, 238, 246, 0.78);
    font-size: 11px;
}

/* When products panel open, flip the expand arrow */
#radar-control.state-products #rc-btn-expand {
    transform: rotate(180deg);
}

/* Scrubber: 15 ticks, leftmost=oldest, rightmost=newest */
.rc-scrubber {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 4px;
}
.rc-tick {
    flex: 1;
    height: 14px;
    border-radius: 2px;
    background: rgba(233, 238, 246, 0.18);
    cursor: pointer;
    transition: background 120ms ease, height 120ms ease;
}
.rc-tick:hover {
    background: rgba(255, 176, 32, 0.45);
    height: 18px;
}
.rc-tick.current {
    background: var(--accent);
    height: 22px;
    box-shadow: 0 0 8px rgba(255, 176, 32, 0.65);
}
.rc-tick.played {
    background: rgba(255, 176, 32, 0.32);
}

/* Products panel */
.rc-products-title {
    font-family: "Oswald", sans-serif;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.22em;
    color: var(--accent);
    text-align: center;
    margin-bottom: 10px;
}
.rc-products-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rc-product-btn {
    background: transparent;
    border: 1px solid rgba(233, 238, 246, 0.10);
    color: #e9eef6;
    text-align: left;
    padding: 9px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.10em;
    transition: background 120ms ease, border-color 120ms ease;
}
.rc-product-btn:hover {
    background: rgba(255, 176, 32, 0.10);
    border-color: rgba(255, 176, 32, 0.35);
}
.rc-product-btn.active {
    background: rgba(255, 176, 32, 0.18);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 700;
}
/* Radar Control Container */
#radar-control-container {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 500;
  font-family: system-ui, sans-serif;
  color: #e5e7eb;
}

/* Main Control Bar */
#radar-control-bar {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  gap: 8px;
}

.rc-btn {
  background: rgba(30, 64, 175, 0.9);
  border: none;
  color: #e5e7eb;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
}

.rc-btn:hover {
  background: rgba(37, 99, 235, 1);
}

.rc-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

#radar-product-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
}

#radar-station-label {
  font-size: 13px;
  font-weight: 600;
}

/* Drawer Menu */
#radar-drawer {
  position: absolute;
  right: 0;
  bottom: 48px;
  width: 220px;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 12px;
  padding: 10px 10px 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.7);
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}

#radar-drawer.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.rc-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9ca3af;
  margin-bottom: 4px;
}

.rc-subtitle {
  font-size: 11px;
  margin-top: 8px;
  margin-bottom: 2px;
  color: #9ca3af;
}

.rc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rc-item {
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.rc-item:hover {
  background: rgba(55, 65, 81, 0.9);
}

.rc-item.active {
  background: rgba(37, 99, 235, 0.9);
}

.product-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #222;
    color: white;
    border: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: background 0.2s;
    z-index: 1000;
}

.product-btn:hover {
    background: #333;
}

.product-panel {
    position: absolute;
    bottom: 50px;
    right: 10px;
    width: 180px;
    background: rgba(20,20,20,0.95);
    border: 1px solid #444;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(120%);
    z-index: 1001;
}

.product-panel.visible {
    transform: translateX(0);
}

.product-item {
    padding: 6px 10px;
    border-radius: 6px;
    background: #2a2a2a;
    color: white;
    cursor: pointer;
    transition: background 0.15s;
    z-index: 1002;
}

.product-item:hover {
    background: #3a3a3a;
}

.product-item.selected {
    background: #0066ff;
}

/* ── Volume transfer-function editor ─────────────────────────────────────── */
.vol-tf-canvas {
    display: block;
    width: 100%;
    height: 80px;
    border-radius: 6px;
    cursor: crosshair;
    border: 1px solid rgba(255,255,255,0.1);
    background: #0d1117;
    box-sizing: border-box;
}

/* ── Products panel rows ─────────────────────────────────────────────────── */
.product-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 7px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    color: #e5e7eb;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
    gap: 10px;
}
.product-row:hover {
    background: rgba(255,176,32,0.10);
    border-color: rgba(255,176,32,0.25);
}
.product-row-active {
    background: rgba(255,176,32,0.16) !important;
    border-color: #ffb020 !important;
    color: #ffb020;
}
.product-row-left {
    flex: 1;
    min-width: 0;
}
.product-row-name {
    font-family: 'Oswald', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.product-row-desc {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-row-active .product-row-desc {
    color: rgba(255,176,32,0.65);
}
.product-row-unit {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}
.product-row-active .product-row-unit {
    color: #ffb020;
}

/* Force crosshair during point-selection modes */
body.radar-selecting,
body.radar-selecting * {
    cursor: crosshair !important;
}

/* ── Cross-section A/B endpoint markers ──────────────────────────────────── */
.cs-endpoint-marker {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.9);
    color: #0a0d12;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px rgba(0,255,255,0.4), 0 2px 8px rgba(0,0,0,0.7);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.cs-endpoint-marker:active {
    cursor: grabbing;
    transform: scale(1.15);
    box-shadow: 0 0 0 4px rgba(0,255,255,0.6), 0 4px 16px rgba(0,0,0,0.8);
}

/* ============================================================
   FLOATING RADAR PLAYBACK BAR (bottom right)
   ============================================================ */
#radar-product-bar {
    position: fixed;
    bottom: 56px;
    right: 16px;
    z-index: 30;
    background: rgba(10, 13, 18, 0.94);
    border: 1px solid rgba(255, 176, 32, 0.45);
    border-radius: 10px;
    color: #e9eef6;
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    box-shadow: 0 10px 32px rgba(0,0,0,0.65), 0 0 22px rgba(255,176,32,0.10);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    min-width: 180px;
}

/* Main row: ▶  KNKX */
#radar-product-bar > button,
#radar-product-bar > div.radar-bar-label {
    display: inline-flex;
    align-items: center;
}

/* Collapsed state: single row of controls */
.radar-product-bar-collapsed {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}

.radar-product-bar-expanded {
    display: block;
    padding: 8px 12px;
}

.radar-product-bar-expanded > .radar-bar-button,
.radar-product-bar-expanded > .radar-bar-label {
    display: inline-flex;
}

.radar-bar-button {
    background: rgba(255, 176, 32, 0.10);
    border: 1px solid rgba(255, 176, 32, 0.45);
    color: var(--accent);
    width: 28px;
    height: 28px;
    border-radius: 5px;
    cursor: pointer;
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 140ms ease, transform 90ms ease;
    flex-shrink: 0;
}
.radar-bar-button:hover  { background: rgba(255,176,32,0.22); }
.radar-bar-button:active { transform: scale(0.94); }
.radar-bar-button-close  {
    border-color: rgba(255,88,88,0.55);
    color: #ff7a7a;
    background: rgba(255,88,88,0.08);
}
.radar-bar-button-close:hover { background: rgba(255,88,88,0.20); }

.radar-bar-label {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.10em;
    padding: 0 4px;
}

/* Expanded scrubber strip */
.radar-playback-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 8px;
    border-top: 1px solid rgba(255,176,32,0.18);
}
.radar-playback-strip.hidden { display: none; }

.radar-frames-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 3px;
    overflow: hidden;
}

.radar-frame-dot {
    flex: 1;
    height: 14px;
    min-width: 6px;
    border-radius: 2px;
    background: rgba(233,238,246,0.18);
    border: none;
    cursor: pointer;
    font-size: 0;
    transition: background 120ms ease, height 120ms ease;
    padding: 0;
}
.radar-frame-dot:hover    { background: rgba(255,176,32,0.45); }
.radar-frame-dot.active   { background: var(--accent); height: 18px; }
.radar-frames-empty {
    font-size: 10px;
    color: rgba(233,238,246,0.35);
    letter-spacing: 0.08em;
}
@media (hover: none) and (pointer: coarse) and (min-width: 901px) {
    .btn-label { display: none !important; }
    .btn-icon  { display: flex !important; }
    .ui-control-button {
        width: 44px !important;
        height: 44px !important;
        min-width: 0 !important;
        padding: 0 !important;
        border-radius: 50% !important;
        gap: 0 !important;
        justify-content: center !important;
    }
    .ui-control-button::before { display: none !important; }
}
