:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f26;
    --bg-panel: rgba(20, 25, 32, 0.15);
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --accent-blue: #0a64ca;
    --accent-light-blue: #4a90e2;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* Light mode - Grey glass UI */
body.light-mode {
    --bg-primary: #e8eaed;
    --bg-secondary: #f1f3f4;
    --bg-panel: rgba(60, 64, 67, 0.15);
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: rgba(60, 64, 67, 0.12);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Time Display (Centered under slider in controls) */
#timestampDisplay {
    position: static;
    color: var(--text-primary);
    font-size: 20px;
    text-align: center;
    background: transparent;
    padding: 4px 8px;
    border-radius: 8px;
    z-index: 1000;
    opacity: 0.95;
    border: none;
    font-weight: 600;
    transition: color 0.3s ease;
    width: auto;
    min-width: 0;
    box-sizing: border-box;
    font-family: var(--font-heading);
    margin-top: 6px;
}

#timestampDisplay:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-blue);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

/* Map */
#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 307px;
    bottom: 0;
    z-index: 1;
    background: #0f1419;
    /* Dark background to match theme */
    transition: right 0.3s ease;
}

#map.panel-collapsed {
    right: 0;
}

body.light-mode #map {
    background: #e8eaed;
    /* Light background for light mode */
}


/* Bottom Controls Bar */
.controls {
    position: absolute;
    bottom: 10px;
    left: calc(50% - 153px);
    /* Offset by half the webcam panel width to center on map area */
    transform: translateX(-50%);
    width: 54%;
    min-width: 495px;
    max-width: 810px;
    border-radius: 14px;
    height: 80px;
    padding: 12px 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    z-index: 1000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    flex-wrap: nowrap;
    align-items: center;
    box-shadow: var(--shadow),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

body.webcam-panel-collapsed .controls {
    left: 50%;
    /* Center normally when panel is collapsed */
}

.controls:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.slider-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-primary);
    font-size: 13px;
    width: 100%;
    flex: 1;
    min-width: 0;
}

.slider-wrapper {
    position: relative;
    width: 100%;
    margin: 0px;
}

.slider {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 13px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 9px;
    outline: none;
    margin: 0;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: height 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.25);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider-progress-track {
    position: absolute;
    height: 13px;
    background: rgba(0, 160, 255, 0.6);
    left: 0;
    right: 0;
    top: 0;
    z-index: 1;
    border-radius: 9px;
    pointer-events: none;
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.3s ease-out, background-color 0.3s ease;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 25px;
    height: 25px;
    background: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 3;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.2);
    border: none;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: pulse 1.5s infinite ease-in-out;
}

.slider::-moz-range-thumb {
    width: 25px;
    height: 25px;
    background: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.2);
    border: none;
    transition: all 0.2s ease;
}

/* Light mode: grey glass controls */
body.light-mode .slider {
    background: rgba(60, 64, 67, 0.1);
    border: 1px solid rgba(60, 64, 67, 0.15);
}

body.light-mode .slider::-webkit-slider-thumb,
body.light-mode .slider::-moz-range-thumb {
    background: #5f6368;
    box-shadow: 0 2px 8px rgba(60, 64, 67, 0.3);
}

body.light-mode .play-btn,
body.light-mode .theme-btn,
body.light-mode .control-select {
    background-color: rgba(60, 64, 67, 0.08);
    color: #202124;
    border-color: rgba(60, 64, 67, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.light-mode .controls {
    border-color: rgba(60, 64, 67, 0.12);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}


.slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    animation: pulse 1.5s infinite ease-in-out;
}

.time-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 5px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
    letter-spacing: 0.5px;
}

.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex-shrink: 0;
    white-space: nowrap;
    margin-top: 0;
    height: 34px;
}

.play-btn {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 11px;
    font-size: 13px;
    transition: all 0.2s ease;
    min-width: 66px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 34px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.play-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0.6;
    z-index: -1;
    border-radius: 12px;
}

.play-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.play-icon {
    font-size: 27px;
    line-height: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.control-select {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 5px 10px;
    padding-right: 22px;
    cursor: pointer;
    border-radius: 9px;
    font-size: 11px;
    transition: all 0.2s ease;
    min-width: 70px;
    height: 28px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 0.8em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.control-select:hover {
    background-color: rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.control-select option {
    background-color: #333;
    color: white;
}

body.light-mode .control-select option {
    background-color: #1f2630;
    color: #e8ecf1;
}

.theme-btn {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 9px;
    font-size: 11px;
    transition: all 0.2s ease;
    min-width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 28px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.theme-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0.6;
    z-index: -1;
    border-radius: 12px;
}

.theme-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.theme-icon,
.temp-icon {
    font-size: 14px;
    line-height: 1;
}

.mobile-fab .temp-icon {
    font-size: 16px;
}

.theme-btn.active,
.mobile-fab.active {
    background-color: rgba(255, 136, 0, 0.35);
    border-color: rgba(255, 136, 0, 0.55);
    box-shadow: 0 0 12px rgba(255, 136, 0, 0.4);
}

.legend-stack {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.legend-panel {
    background: rgba(24, 28, 35, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 12px 6px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    color: #e8eaed;
    font-family: var(--font-body, inherit);
    width: 300px;
    max-width: calc(100vw - 24px);
    display: none;
    user-select: none;
}

.legend-panel.active {
    display: block;
}

.legend-panel__title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 5px;
    text-align: center;
    opacity: 0.92;
}

.legend-panel__segments {
    display: flex;
    height: 10px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.legend-panel__segment {
    flex: 1 1 0;
}

.legend-panel__labels {
    display: flex;
    margin-top: 3px;
    font-size: 10px;
    line-height: 1;
    opacity: 0.85;
}

.legend-panel__labels span {
    flex: 1 1 0;
    text-align: center;
}

body.light-mode .legend-panel {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 0, 0, 0.08);
    color: #1a1f26;
}

@media (max-width: 768px) {
    .legend-stack {
        top: 8px;
        left: 8px;
        right: 8px;
        gap: 6px;
    }
    .legend-panel {
        width: 100%;
        padding: 6px 10px 5px;
    }
    .legend-panel__title {
        font-size: 10px;
        margin-bottom: 4px;
    }
    .legend-panel__segments {
        height: 8px;
    }
    .legend-panel__labels {
        font-size: 9px;
    }
}

.separator {
    width: 1px;
    height: 22px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 9px;
}

.desktop-only-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
    width: 100%;
    margin-top: -60px;
}

.button-group-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

/* Legend */
.legend {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    min-width: 180px;
    box-shadow: var(--shadow);
    z-index: 1000;
    opacity: 0.75;
}

.legend-title {
    font-size: 11px;
    margin-bottom: 4px;
    text-align: center;
    color: var(--text-primary);
}

.legend-gradient {
    height: 12px;
    margin: 4px 0;
    border-radius: 2px;
    background: linear-gradient(to right,
            #e6e6ff 0%,
            /* Less than 2 */
            #c8c8ff 6.25%,
            /* 2 to 3 */
            #9696ff 12.5%,
            /* 3 to 5 */
            #6464ff 18.75%,
            /* 5 to 7 */
            #00ffff 25%,
            /* 7 to 10 */
            #00c8c8 31.25%,
            /* 10 to 15 */
            #009696 37.5%,
            /* 15 to 25 */
            #ffff00 43.75%,
            /* 25 to 35 */
            #ffc800 50%,
            /* 35 to 55 */
            #ff9600 56.25%,
            /* 55 to 80 */
            #ff6400 62.5%,
            /* 80 to 120 */
            #ff0000 68.75%,
            /* 120 to 180 */
            #c80000 75%,
            /* 180 to 270 */
            #960000 81.25%,
            /* 270 to 400 */
            #640000 87.5%,
            /* 400+ */
            #640000 100%
            /* End color */
        );
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    margin-top: 2px;
    color: var(--text-secondary);
}

.legend-labels span {
    position: relative;
    text-align: center;
    transform: translateX(50%);
}

/* Pulse animation for slider thumb */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

/* ========================================
   MOBILE RESPONSIVE - COMPLETE REDESIGN
   ======================================== */
@media (max-width: 768px) {

    /* Hide webcam panel on mobile */
    .webcam-panel {
        display: none !important;
    }

    .webcam-panel-toggle {
        display: none !important;
    }

    /* Make map fullscreen on mobile */
    #map {
        right: 0 !important;
        left: 0 !important;
    }

    /* Disable hover effects on mobile */
    .controls:hover {
        transform: translateX(-50%) !important;
        box-shadow: var(--shadow) !important;
        border-color: var(--border-color) !important;
    }

    .slider:hover,
    .play-btn:hover,
    .theme-btn:hover,
    .control-select:hover {
        transform: none !important;
        box-shadow: none !important;
        border-color: inherit !important;
    }

    /* Reduce backdrop blur on mobile for better performance */
    .controls,
    .legend {
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }

    /* Simplify shadows on mobile */
    .controls,
    .legend {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    }

    .legend {
        display: none;
    }

    /* === CONTROLS BAR - Slim & Clean === */
    .controls {
        left: 50% !important;
        transform: translateX(-50%) !important;
        -webkit-transform: translateX(-50%) !important;
        width: 88%;
        min-width: unset;
        max-width: 420px;
        padding: 10px 16px 8px;
        bottom: 20px;
        border-radius: 16px;
        height: auto;
        touch-action: manipulation;
        will-change: auto;
        position: absolute !important;
        gap: 0;
    }

    /* Hide desktop button group on mobile - replaced by FABs */
    .button-group {
        display: none !important;
    }

    .slider-container {
        font-size: 12px;
        width: 100%;
        min-width: 0;
    }

    #timestampDisplay {
        position: static;
        font-size: 15px;
        padding: 2px 0;
        width: auto;
        min-width: 0;
        border-radius: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border: none;
        text-align: center;
        opacity: 0.9;
        margin-top: 2px;
        font-weight: 600;
        letter-spacing: 0.3px;
    }

    .slider {
        height: 14px;
        border-radius: 8px;
        margin: 0;
    }

    .slider:hover,
    .slider:focus {
        height: 14px;
    }

    .slider-progress-track {
        height: 14px;
        border-radius: 8px;
    }

    .slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
        border: 2px solid rgba(255, 255, 255, 0.9);
        animation: none !important;
    }

    .slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
        border: 2px solid rgba(255, 255, 255, 0.9);
        animation: none !important;
    }
}

/* Mobile FAB styles - hidden on desktop */
.mobile-fab-group {
    display: none;
}

@media (max-width: 768px) {
    .mobile-fab-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        position: fixed;
        bottom: 80px;
        left: 14px;
        z-index: 1100;
    }

    .mobile-fab {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--bg-panel);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        cursor: pointer;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.15s ease, background 0.15s ease;
        -webkit-appearance: none;
        appearance: none;
        padding: 0;
    }

    .mobile-fab:active {
        transform: scale(0.9);
    }

    .mobile-fab-play {
        width: 48px;
        height: 48px;
    }

    .mobile-fab-play.playing svg {
        display: none;
    }

    .mobile-fab-play.playing::after {
        content: '';
        width: 16px;
        height: 16px;
        border-left: 5px solid var(--text-primary);
        border-right: 5px solid var(--text-primary);
        box-sizing: border-box;
    }

    .mobile-fab-theme {
        font-size: 16px;
    }

    .mobile-fab-range {
        width: 44px;
        height: 44px;
        font-size: 10px;
        font-weight: 700;
        text-align: center;
        text-align-last: center;
        color: var(--text-primary);
        background-image: none;
        padding: 0;
        font-family: var(--font-heading);
    }

    .mobile-fab-range option {
        background: #1a1f26;
        color: #e8eaed;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .controls {
        width: 92%;
        padding: 8px 14px 6px;
        bottom: 16px;
    }

    #timestampDisplay {
        font-size: 14px;
    }

    .slider::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
        animation: none !important;
    }

    .slider::-moz-range-thumb {
        width: 26px;
        height: 26px;
        animation: none !important;
    }

    .mobile-fab-group {
        bottom: 70px;
        left: 10px;
        gap: 8px;
    }

    .mobile-fab {
        width: 40px;
        height: 40px;
    }

    .mobile-fab-play {
        width: 44px;
        height: 44px;
    }

    .mobile-fab-range {
        width: 40px;
        height: 40px;
        font-size: 9px;
    }
}

/* Leaflet overrides for theme */
.leaflet-control-attribution {
    background: var(--bg-panel) !important;
    color: var(--text-secondary) !important;
    border-top: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-panel) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}


/* Dark mode filter for radar overlays */
body:not(.light-mode) .radar-overlay {
    filter: invert(1) hue-rotate(180deg) brightness(1.1) contrast(1.1);
}

/* Light mode keep original */
body.light-mode .radar-overlay {
    filter: none;
}

/* Lightning marker styles - handled by Leaflet circleMarker */

/* Remove any filtering on light basemap for normal colors */
body.light-mode .base-tiles {
    filter: none;
}

/* City labels */
.city-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-primary);
    text-shadow:
        -1px -1px 2px rgba(0, 0, 0, 0.8),
        1px -1px 2px rgba(0, 0, 0, 0.8),
        -1px 1px 2px rgba(0, 0, 0, 0.8),
        1px 1px 2px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
}

body.light-mode .city-label {
    text-shadow:
        -1px -1px 2px rgba(255, 255, 255, 0.9),
        1px -1px 2px rgba(255, 255, 255, 0.9),
        -1px 1px 2px rgba(255, 255, 255, 0.9),
        1px 1px 2px rgba(255, 255, 255, 0.9);
}

/* Main Container Layout */
.main-container {
    position: relative;
    height: 100vh;
    width: 100vw;
    display: flex;
    transition: all 0.3s ease;
}

/* Distance label styles */
.distance-label {
    background: none;
    color: rgba(255, 255, 255, 0.5);
    border: none;
    padding: 0;
    font-size: 14px;
    font-weight: 900;
    text-align: center;
    line-height: 1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    pointer-events: none;
    user-select: none;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.dark-mode .distance-label {
    background: none;
    color: rgba(204, 204, 204, 0.5);
    border: none;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Webcam Panel */
.webcam-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 307px;
    height: 100vh;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    z-index: 1200;
    transform: translateX(0);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.webcam-panel.collapsed {
    transform: translateX(100%);
}

.webcam-panel-toggle {
    position: fixed;
    right: 307px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 64px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1300;
    transition: right 0.3s ease;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.15);
    color: var(--text-primary);
    opacity: 1;
    visibility: visible;
}

body.webcam-panel-collapsed .webcam-panel-toggle {
    right: 0;
    border-radius: 8px 0 0 8px;
    border-right: 1px solid var(--border-color);
    border-left: none;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
}

.webcam-panel-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-blue);
    box-shadow: -2px 0 15px rgba(0, 0, 0, 0.25);
}

.toggle-icon {
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1;
    display: block;
    font-weight: bold;
}

.toggle-icon::before {
    content: '▶';
}

body.webcam-panel-collapsed .toggle-icon::before {
    content: '◀';
}


.webcam-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 16px 16px;
    /* Hide scrollbar but keep scrolling */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.webcam-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.webcam-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.webcam-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
}

.webcam-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-blue);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.webcam-item.video {
    min-height: 162px;
}

.webcam-item.static {
    min-height: 144px;
}

.media-container {
    position: relative;
    width: 100%;
    background: #000;
}

.webcam-media {
    width: 100%;
    height: auto;
    display: block;
    background: #000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.webcam-item video {
    width: 100%;
    height: 144px;
    object-fit: contain;
    background: #000;
}

.webcam-item img {
    width: 100%;
    height: 144px;
    object-fit: contain;
    background: #000;
}



.webcam-name {
    padding: 4px 12px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

/* Webcam Area Grouping */
.webcam-area-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    transition: background 0.2s ease;
    user-select: none;
}

.webcam-area-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.area-chevron {
    font-size: 10px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    display: inline-block;
    transform: rotate(90deg);
}

.webcam-area-header.collapsed .area-chevron {
    transform: rotate(0deg);
}

.area-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-heading);
    flex: 1;
}

.area-count {
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 500;
}

.webcam-area-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}



/* Loading state for webcam media */
.media-container .loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-secondary);
    font-size: 12px;
    z-index: 2;
}

.webcam-item.static .media-container .loading {
    height: 144px;
}

.webcam-item.video .media-container .loading {
    height: 144px;
}

/* Error state for webcam media */
.webcam-name .error {
    color: #ff6b6b;
    font-size: 11px;
    text-align: center;
    padding: 4px 8px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(255, 107, 107, 0.2);
    margin: 0;
}

/* Webcam Popup */
.webcam-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 307px;
    /* Only cover the map area, not the webcam panel */
    height: 100%;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease, right 0.3s ease;
}

.webcam-popup.panel-collapsed {
    right: 0;
}

.popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: transparent;
    cursor: pointer;
}


.webcam-popup.show {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    /* Now centered within the map area only */
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    width: 750px;
    max-width: calc(100vw - 327px);
    /* Account for webcam panel */
    max-height: 80vh;
    overflow: hidden;
    transition: transform 0.15s ease-out, max-width 0.3s ease;
}

.webcam-popup.panel-collapsed .popup-content {
    max-width: calc(100vw - 40px);
}

.webcam-popup.show .popup-content {
    transform: translate(-50%, -50%) scale(1);
}

.popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 16px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.popup-close:hover {
    background: rgba(255, 0, 0, 0.8);
    transform: scale(1.1);
}

.popup-header {
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.05);
}

.popup-header h3 {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    font-family: var(--font-heading);
}

.popup-body {
    padding: 0;
}

.popup-media-container {
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 450px;
    max-height: 60vh;
}

.popup-media-container video,
.popup-media-container img {
    max-width: 100%;
    max-height: 60vh;
    width: auto;
    height: auto;
    object-fit: contain;
    background: #000;
}

.popup-media-container .loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 12px;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 20px;
    border-radius: 6px;
}

.popup-media-container .error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff6b6b;
    font-size: 12px;
    background: rgba(255, 107, 107, 0.1);
    padding: 12px 20px;
    border-radius: 6px;
    border: 1px solid rgba(255, 107, 107, 0.2);
}

/* Large popup (from gallery) */
.webcam-popup.popup-large {
    z-index: 3000;
    right: 0;
}

.webcam-popup.popup-large .popup-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.webcam-popup.popup-large .popup-content {
    width: 92vw;
    max-width: 1400px;
    max-height: 92vh;
}

.webcam-popup.popup-large .popup-media-container {
    max-height: 80vh;
}

.webcam-popup.popup-large .popup-media-container video,
.webcam-popup.popup-large .popup-media-container img {
    max-height: 80vh;
}

/* Popup Nav Arrows */
.popup-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 64px;
    background: rgba(0, 0, 0, 0.45);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 32px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    line-height: 1;
}

.popup-nav-arrow:hover {
    background: rgba(0, 0, 0, 0.7);
}

.popup-nav-prev {
    left: 8px;
}

.popup-nav-next {
    right: 8px;
}

/* Popup dots & counter - hidden on desktop */
.popup-dots,
.popup-counter {
    display: none;
}

/* Webcam Panel Header */
.webcam-panel-header {
    padding: 10px 16px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.webcam-panel-title {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-heading);
    margin: 0;
}

.gallery-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gallery-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

/* Webcam Gallery Overlay */
.webcam-gallery {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.webcam-gallery.show {
    opacity: 1;
    visibility: visible;
}

.gallery-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    cursor: pointer;
}

.gallery-container {
    position: absolute;
    top: 2vh;
    left: 2vw;
    right: 2vw;
    bottom: 2vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.gallery-title {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-heading);
    margin: 0;
}

.gallery-close {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.gallery-close:hover {
    background: rgba(255, 0, 0, 0.6);
}

.gallery-grid {
    flex: 1;
    overflow: hidden;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
}

.gallery-grid .webcam-item {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gallery-grid .webcam-item .media-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.gallery-grid .webcam-item img,
.gallery-grid .webcam-item video {
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.gallery-grid .webcam-item .webcam-name {
    flex-shrink: 0;
    font-size: 11px;
    padding: 3px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-grid .webcam-item .loading {
    height: 100%;
}

/* Mobile Gallery FAB - hidden on desktop */
.mobile-gallery-fab {
    display: none;
}

/* ========================================
   MOBILE: POPUP, GALLERY, DRAWER REDESIGN
   ======================================== */
@media (max-width: 768px) {

    /* === CAMERA POPUP - Full-screen immersive viewer === */
    .webcam-popup {
        right: 0 !important;
    }

    .webcam-popup .popup-backdrop {
        background: rgba(0, 0, 0, 0.95);
    }

    .webcam-popup.show .popup-backdrop {
        background: rgba(0, 0, 0, 0.95);
    }

    .popup-content {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        background: #000 !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        box-shadow: none !important;
        transform: none !important;
        display: flex;
        flex-direction: column;
    }

    .webcam-popup.show .popup-content {
        transform: none !important;
    }

    /* Large popup also full-screen on mobile */
    .webcam-popup.popup-large .popup-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }

    .popup-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 15;
        background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
        padding: 14px 60px 24px 16px;
        border-bottom: none;
    }

    .popup-header h3 {
        color: #fff;
        font-size: 15px;
        font-weight: 600;
        text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    }

    .popup-close {
        width: 44px !important;
        height: 44px !important;
        font-size: 24px !important;
        top: 10px !important;
        right: 10px !important;
        background: rgba(255, 255, 255, 0.15) !important;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 20;
    }

    .popup-body {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .popup-media-container {
        width: 100%;
        height: 100%;
        min-height: 0 !important;
        max-height: none !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .popup-media-container video,
    .popup-media-container img {
        max-width: 100%;
        max-height: 100vh !important;
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    /* Nav arrows - larger touch targets, semi-transparent */
    .popup-nav-arrow {
        width: 48px;
        height: 72px;
        font-size: 28px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

    .popup-nav-prev {
        left: 6px;
    }

    .popup-nav-next {
        right: 6px;
    }

    /* Popup counter - "3 / 17" indicator */
    .popup-counter {
        display: block;
        position: absolute;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 15;
        color: rgba(255, 255, 255, 0.7);
        font-size: 13px;
        font-weight: 500;
        font-family: var(--font-heading);
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        padding: 6px 16px;
        border-radius: 20px;
        letter-spacing: 1px;
    }

    /* Popup dots hidden - use counter instead for 17 cameras */
    .popup-dots {
        display: none;
    }


    /* === GALLERY - 2 columns, scrollable === */
    .gallery-container {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        border: none;
    }

    .gallery-header {
        padding: 12px 16px;
        background: rgba(0, 0, 0, 0.2);
    }

    .gallery-title {
        font-size: 15px;
    }

    .gallery-close {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        gap: 8px;
        padding: 8px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .gallery-grid .webcam-item {
        min-height: 120px;
    }

    .gallery-grid .webcam-item .media-container {
        min-height: 100px;
    }

    .gallery-grid .webcam-item img,
    .gallery-grid .webcam-item video {
        height: 120px;
        object-fit: cover;
    }

    .gallery-grid .webcam-item .webcam-name {
        font-size: 11px;
        padding: 4px 8px;
    }


    /* === MOBILE GALLERY FAB - top right === */
    .mobile-gallery-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 14px;
        right: 14px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--bg-panel);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        cursor: pointer;
        z-index: 1100;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
        transition: transform 0.15s ease, background 0.15s ease;
    }

    .mobile-gallery-fab:active {
        transform: scale(0.9);
    }
}

@media (max-width: 480px) {
    .mobile-gallery-fab {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
    }

    .gallery-grid .webcam-item img,
    .gallery-grid .webcam-item video {
        height: 100px;
    }
}

/* ---------------------------------------------------------------------------
   Cursor readout chip — rain intensity + temperature under the pointer.
   Positioned in JS (absolute within the map container); follows the cursor on
   desktop, pinned above the bottom controls on mobile (tap to read).
--------------------------------------------------------------------------- */
.cursor-readout {
    position: absolute;
    z-index: 1200;
    left: 0;
    top: 0;
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px 11px;
    border-radius: 11px;
    background: rgba(16, 20, 26, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.25;
    color: #fff;
    white-space: nowrap;
    pointer-events: none;
    will-change: left, top;
}

.cursor-readout.visible {
    display: flex;
}

.cursor-readout .cr-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cursor-readout .cr-ic {
    font-size: 13px;
    line-height: 1;
}

.cursor-readout .cr-val {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
}

.cursor-readout .cr-sub {
    opacity: 0.66;
    font-size: 11px;
}

.cursor-readout .cr-wind .cr-arrow {
    display: inline-block;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    color: var(--accent-light-blue, #4a90e2);
    transform-origin: 50% 50%;
}

/* Animated wind-particle canvas — sits above the map panes, ignores pointer
   events so the map stays draggable. Shown with the wind overlay toggle. */
.wind-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 450;
    pointer-events: none;
}

body.light-mode .cursor-readout {
    background: rgba(255, 255, 255, 0.92);
    color: #202124;
    border-color: rgba(60, 64, 67, 0.18);
}

/* Mobile: fixed badge above the controls bar instead of following a cursor. */
.cursor-readout.mobile {
    left: 50% !important;
    top: auto !important;
    bottom: 92px;
    transform: translateX(-50%);
    z-index: 1500;
    font-size: 13px;
    padding: 9px 13px;
}