/* Poppins (TTF — identical to native app) */
@font-face {
    font-family: 'Poppins'; font-style: normal; font-weight: 300; font-display: swap;
    src: url(../fonts/Poppins-Light.ttf) format('truetype');
}
@font-face {
    font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap;
    src: url(../fonts/Poppins-Regular.ttf) format('truetype');
}
@font-face {
    font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap;
    src: url(../fonts/Poppins-Medium.ttf) format('truetype');
}
@font-face {
    font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap;
    src: url(../fonts/Poppins-SemiBold.ttf) format('truetype');
}

/* ================================================================
   DESIGN TOKENS — gleiche Palette wie radarweather.live Homepage
   ================================================================ */
:root {
    --bg:           #0f1117;
    --bg2:          #1a1d27;
    --border:       rgba(42, 45, 58, 0.9);
    --text:         #e8eaf0;
    --muted:        #8b90a8;
    --accent:       #2a6b8a;
    --accent-bright:#5bb8db;
    --accent2:      rgba(42, 107, 138, 0.25);
    --glass:        rgba(26, 29, 39, 0.80);
    --glass2:       rgba(15, 17, 23, 0.88);
    --shadow:       rgba(0, 0, 0, 0.45);
    --green:        #30d158;
    --btn-bg:       rgba(42, 45, 58, 0.8);
    --glass-light:  rgba(255, 255, 255, 0.08);
    --divider:      rgba(180, 180, 180, 0.3);
    --accent-glow:  rgba(42, 107, 138, 0.4);
    --backdrop:     rgba(0, 0, 0, 0.5);
    /* Close-Button */
    --close-bg:         rgba(42, 45, 58, 0.8);
    --close-border:     rgba(52, 55, 68, 0.9);
    --close-icon:       #8b90a8;
    --close-hover-bg:   rgba(42, 107, 138, 0.15);
    --close-hover-icon: #e8eaf0;
    /* Kacheln (Section-Cards) */
    --tile-bg:          rgba(0, 0, 0, 0.15);
    --tile-border:      rgba(52, 55, 68, 0.9);
    --tile-shadow:      0 0 transparent;
    /* Slider-Bar */
    --slider-bg:         rgba(26, 29, 39, 0.80);
    --slider-border:     rgba(52, 55, 68, 0.9);
    --slider-shadow:     rgba(0, 0, 0, 0.45);
    --slider-thumb:      #2a6b8a;
    --slider-track:      rgba(52, 55, 68, 0.9);
    --slider-now-bar:    rgba(255, 255, 255, 0.55);
    --slider-now-text:   rgba(255, 255, 255, 0.55);
    --slider-text:       #e8eaf0;
    --slider-text-muted: #8b90a8;
    /* Searchbar + Ergebnisliste */
    --search-bg:             rgba(26, 29, 39, 0.80);
    --search-border:         rgba(52, 55, 68, 0.9);
    --search-shadow:         rgba(0, 0, 0, 0.45);
    --search-text:           #e8eaf0;
    --search-placeholder:    #8b90a8;
    --search-icon:           #8b90a8;
    --search-results-bg:     rgba(15, 17, 23, 0.88);
    --search-results-border: rgba(52, 55, 68, 0.9);
    --search-results-shadow: rgba(0, 0, 0, 0.45);
    --search-item-text:      #e8eaf0;
    --search-item-sub:       #8b90a8;
    --search-item-hover:     rgba(42, 107, 138, 0.15);
    --search-item-border:    rgba(52, 55, 68, 0.9);
    /* Layer-Buttons */
    --layer-btn-border:    rgba(0, 0, 0, 0.12);
    --layer-btn-bg:        transparent;
    --layer-icon:          #8b90a8;
    --layer-label:         #e8eaf0;
    --layer-active-border: #2a6b8a;
    --layer-active-bg:     transparent;
    --layer-active-icon:   #5bb8db;
    --layer-active-label:  #5bb8db;
    --warn-icon:           #f5a623;
    --seg-active-text:     #fff;
    --info-dot-hover-bg:   rgba(255, 255, 255, 0.18);
    /* Normale Buttons */
    --button-bg:             transparent;
    --button-text:           #e8eaf0;
    --button-border:         rgba(52, 55, 68, 0.9);
    /* Bottom-Panels */
    --panel-bg:              rgba(15, 17, 23, 0.88);
    --panel-border:          rgba(52, 55, 68, 0.9);
    --panel-shadow:          rgba(0, 0, 0, 0.45);
    --panel-handle-color:    #8b90a8;
    --panel-handle-opacity:  0.6;
    --panel-group-border:    rgba(42, 45, 58, 0.9);
    /* Sprach-Buttons */
    --lang-btn-bg:             transparent;
    --lang-btn-border:         rgba(52, 55, 68, 0.9);
    --lang-btn-text:           #8b90a8;
    --lang-btn-active-bg:      rgba(42, 107, 138, 0.15);
    --lang-btn-active-border:  #2a6b8a;
    --lang-btn-active-text:    #2a6b8a;
    /* Warn-Button */
    --warn-btn-opacity:        0.7;
    --warn-btn-text:           #e8eaf0;
    /* Detail-Panel Inhalte */
    --tile-title:              #e8eaf0;
    --tile-chevron:            #8b90a8;
    --tile-value:              #e8eaf0;
    --tile-label:              #8b90a8;
    --tile-divider:            rgba(180, 180, 180, 0.3);
    --live-badge-bg:           rgba(34, 197, 94, 0.12);
    --live-badge-text:         rgba(34, 197, 94, 0.85);
    --chart-bar-opacity:       0.85;
    --chart-gust-opacity:      0.25;
    --chart-grid-opacity:      0.3;
    --chart-bg:                rgba(255, 255, 255, 0.06);
    --chart-empty-bg:          rgba(255, 255, 255, 0.08);
    --gauge-bg:                rgba(255, 255, 255, 0.06);
    --gauge-seg-active:        0.85;
    --gauge-seg-inactive:      0.18;
    --sun-arc-day:             rgba(255, 200, 50, 0.3);
    --sun-arc-active:          rgba(255, 200, 50, 0.6);
    --sun-glow:                rgba(255, 200, 50, 0.15);
    --sun-core:                #ffc832;
    --moon-fill:               rgba(160, 180, 220, 0.6);
    --moon-shadow:             rgba(15, 17, 23, 0.9);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; overflow: hidden; }
#map { width: 100vw; height: 100vh; }

/* ================================================================
   LEGEND (floating on map, top-left)
   ================================================================ */
#legend-container {
    position: fixed; top: 12px; left: 12px; z-index: 10;
    display: flex; flex-direction: column; gap: 8px;
}
#legend, #wind-legend {
    background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-radius: 14px; padding: 10px 14px;
    box-shadow: 0 2px 16px var(--shadow); border: 1px solid var(--border);
    display: flex; flex-direction: column; flex-shrink: 0;
}
#legend .legend-title, #wind-legend .legend-title { font-family: 'Poppins', sans-serif; font-size: 11px; font-weight: 400; color: var(--text); margin-bottom: 6px; }
#legend-bar, #wind-legend-bar { width: 20px; flex: 1; border-radius: 4px; }
.legend-inner { display: flex; gap: 8px; flex: 1; }
.legend-labels { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.legend-labels span { font-family: 'Poppins', sans-serif; font-size: 11px; font-weight: 400; color: var(--muted); white-space: nowrap; line-height: 1; }

/* Legend: compact on mobile, below search bar + country switcher */
@media (orientation: portrait) {
    #legend-container { top: 100px; }
    #legend, #wind-legend { padding: 6px 8px; border-radius: 10px; }
    #legend .legend-title, #wind-legend .legend-title { font-size: 9px; margin-bottom: 3px; }
    #legend-bar, #wind-legend-bar { width: 14px; height: 100px; }
    .legend-inner { gap: 5px; }
    .legend-labels span { font-size: 9px; }
}

/* Legend toggle — default: Mobile=aus, Desktop=an */
@media (orientation: portrait) {
    #legend-container { display: none; }
    body.legend-visible #legend-container { display: flex; }
}
@media (orientation: landscape) {
    body.legend-hidden #legend-container { display: none; }
}


/* ================================================================
   BOTTOM BAR (forecast controls, always visible)
   ================================================================ */
#bottom-bar {
    position: fixed; left: 0; right: 0; z-index: 12;
    display: flex; flex-direction: column; gap: 8px; align-items: center;
    padding: 0 12px 8px;
    transition: opacity 0.25s ease, visibility 0.25s ease,
                right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Mobile: positioned + toggled by JS */
@media (orientation: portrait) {
    #bottom-bar { bottom: 0; }
}
#bottom-bar.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

/* Country Switcher (below search bar) */
#country-switcher { display: none; }
/* Country label on slider bar */
#country-label {
    font-size: 13px; font-weight: 400; color: var(--slider-text);
    white-space: nowrap; user-select: none; flex-shrink: 0;
}

/* Controls Bar */
#controls {
    background: var(--slider-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-radius: 28px; padding: 8px 18px;
    box-shadow: 0 4px 24px var(--slider-shadow); border: 1px solid var(--slider-border);
    display: flex; align-items: center; gap: 12px;
    width: 100%; max-width: 420px;
}
#controls label { display: none; }
#play-btn {
    background: var(--accent2); border: 1px solid var(--border);
    cursor: pointer; width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; color: var(--muted); padding: 0; flex-shrink: 0;
}
#play-btn:hover { background: var(--accent2); color: var(--accent); }
#play-btn.active { background: var(--green); border-color: var(--green); color: #fff; }
#play-btn svg { width: 18px; height: 18px; }
#time-display { display: flex; flex-direction: column; align-items: center; min-width: 48px; }
#time-clock { font-size: 14px; font-weight: 400; color: var(--slider-text); line-height: 1.2; }
#time-label { font-size: 10px; font-weight: 400; color: var(--slider-text-muted); line-height: 1.2; }

input[type="range"] {
    -webkit-appearance: none; appearance: none; flex: 1; height: 4px;
    background: var(--slider-track); border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
    border-radius: 50%; background: var(--slider-thumb); cursor: pointer;
    box-shadow: 0 1px 8px var(--accent-glow); transition: transform 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%; background: var(--slider-thumb);
    cursor: pointer; border: none; box-shadow: 0 1px 8px var(--accent-glow);
}

/* Slider wrapper (created dynamically for now-marker) */
#slider-wrapper {
    position: relative; flex: 1; display: flex; align-items: center;
}
#slider-wrapper input[type="range"] { width: 100%; flex: none; }
#now-marker {
    position: absolute; top: 50%; width: 2px; height: 14px;
    transform: translate(-50%, -50%);
    background: var(--slider-now-bar); border-radius: 1px;
    pointer-events: none; z-index: 1;
}
#now-marker::after {
    content: 'Jetzt'; position: absolute;
    bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
    font-size: 8px; font-weight: 400; color: var(--slider-now-text);
    white-space: nowrap; letter-spacing: 0.02em;
}

/* ================================================================
   PANEL — Bottom Sheet (mobile) / Left Sidebar (desktop)
   ================================================================ */
#panel {
    position: fixed; left: 0; right: 0; z-index: 11;
    background: var(--panel-bg-solid);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -4px 32px var(--panel-shadow); border: 1px solid var(--panel-border);
    border-bottom: none;
    bottom: 0; /* JS overrides on mobile to sit above ad */
    height: 80vh;
    transform: translateY(0);
    will-change: transform;
    overflow: hidden;
    display: flex; flex-direction: column;
}
/* Desktop: glass effect (semi-transparent + blur) */
@media (orientation: landscape) {
    #panel { background: var(--panel-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
}

/* Drag Handle — large touch target (min 44px) */
#panel-handle {
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 0 6px;
    cursor: pointer;
    -webkit-user-select: none; user-select: none;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}
#panel-handle-bar {
    width: 40px; height: 5px;
    background: var(--accent); border-radius: 3px;
    opacity: 1;
}

/* Close button — top right in panel handle */
#panel-close-btn {
    position: absolute; top: 8px; right: 12px;
    background: var(--close-bg); border: 1px solid var(--close-border);
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--close-icon); cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
#panel-close-btn:hover,
#panel-close-btn:active {
    color: var(--close-hover-icon); background: var(--close-hover-bg);
}
/* Hide close button on desktop */
@media (orientation: landscape) {
    #panel-close-btn { display: none !important; }
}


/* Panel Content — scrollable, fills remaining space */
/* Panel Content — scrollable, fills remaining space */
#panel-content {
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1; min-height: 0;
    padding: 0 12px 12px;
}
#panel-content::-webkit-scrollbar { width: 4px; }
#panel-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#panel-content { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ================================================================
   RIGHT PANEL — Detail sidebar (desktop only, hidden by default)
   ================================================================ */
#right-panel {
    position: fixed;
    top: 0; bottom: 0; right: 0;
    width: 305px;
    z-index: 11;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 22px 0 0 22px;
    box-shadow: -4px 0 32px var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(0);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
#right-panel.right-panel-hidden {
    transform: translateX(100%);
}
#right-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px 10px;
    flex-shrink: 0;
}
#right-panel-title {
    font-size: 15px;
    font-weight: 400;
    color: var(--text);
}
#right-panel-close {
    background: var(--close-bg);
    border: 1px solid var(--close-border);
    border-radius: 50%;
    width: 28px; height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--close-icon);
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
#right-panel-close:hover {
    color: var(--close-hover-icon);
    background: var(--close-hover-bg);
}
#right-panel-content {
    flex: 1;
    overflow-x: hidden;
    overflow-y: scroll;             /* always reserve scrollbar space — no content jump */
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px 10px;
    zoom: 0.85;
}
#right-panel-content::-webkit-scrollbar { width: 6px; background: transparent; }
#right-panel-content::-webkit-scrollbar-track { background: transparent; }
#right-panel-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#right-panel-content { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Right panel reopen tab */
#right-panel-tab {
    position: fixed;
    right: 0; top: 50%;
    transform: translateY(-50%);
    z-index: 11;
    width: 28px; height: 48px;
    background: var(--glass2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 10px 0 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    padding: 0;
    transition: opacity 0.25s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
#right-panel-tab:hover { color: var(--text); }
#right-panel-tab.right-panel-tab-hidden {
    opacity: 0;
    pointer-events: none;
}

/* Section toggle headers — remove all click/hover feedback */
#precip-radar-toggle, #precip-toggle, #weather-temp-toggle {
    -webkit-tap-highlight-color: transparent;
}

/* Mobile: right panel + tab hidden (overlay used instead) */
@media (orientation: portrait) {
    #right-panel { display: none; }
    #right-panel-tab { display: none; }
}

/* ================================================================
   MOBILE WEATHER OVERLAY (fullscreen slide-up)
   ================================================================ */
#mobile-weather-overlay {
    position: fixed;
    top: 12px; left: 0; right: 0; bottom: 0;
    z-index: 15;
    background: var(--panel-bg-solid);
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(0);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}
#mobile-weather-overlay.mwo-hidden {
    transform: translateY(100%);
    pointer-events: none;
}
#mwo-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 4px;
    cursor: grab;
    flex-shrink: 0;
}
#mwo-handle:active { cursor: grabbing; }
.mwo-handle-bar {
    width: 40px;
    height: 5px;
    background: var(--panel-handle-color);
    opacity: var(--panel-handle-opacity);
    border-radius: 3px;
}
#mwo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px 12px;
    flex-shrink: 0;
}
#mwo-title {
    font-size: 17px;
    font-weight: 400;
    color: var(--text);
}
#mwo-close {
    background: var(--close-bg);
    border: 1px solid var(--close-border);
    border-radius: 50%;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--close-icon);
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
#mwo-close:hover { color: var(--close-hover-icon); background: var(--close-hover-bg); }
#mwo-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#mwo-content::-webkit-scrollbar { width: 4px; background: transparent; }
#mwo-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#mwo-content { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }


/* Desktop: overlay + button never shown */
@media (orientation: landscape) {
    #mobile-weather-overlay { display: none !important; }
}

/* ================================================================
   LAYER STRIP (horizontal on mobile, vertical on desktop)
   ================================================================ */
#layer-strip {
    display: flex; gap: 4px;
    flex-direction: column;
    padding: 0 0 8px;
}

.layer-btn {
    position: relative;
    display: flex; flex-direction: row; align-items: center;
    gap: 12px;
    border-radius: 10px;
    cursor: pointer; user-select: none;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    padding: 9px 12px;
    min-width: 0;
}
.layer-icon {
    width: 22px; height: 22px;
    color: var(--layer-icon);
    pointer-events: none;
    transition: color 0.2s ease;
}
/* keep old img/placeholder working as fallback */
.layer-btn img, .layer-btn .layer-icon-placeholder {
    width: 40px; height: 40px; object-fit: cover; border-radius: 10px;
    pointer-events: none;
}
.layer-label {
    font-size: 13px; font-weight: 400; color: var(--layer-label);
    line-height: 1.1; text-align: left;
    pointer-events: none; letter-spacing: 0;
    transition: color 0.2s ease;
}
.layer-btn:hover { background: var(--accent2); }
.layer-btn:hover .layer-icon { color: var(--text); }
.layer-btn.active {
    background: var(--layer-active-bg);
    border-color: var(--layer-active-border);
    box-shadow: none;
}
.layer-btn.active .layer-icon { color: var(--layer-active-icon); }
.layer-btn.active .layer-label { color: var(--layer-active-label); }
/* Warnungen icon: amber color */
.layer-icon--warn { color: var(--warn-icon); }
.layer-btn.active .layer-icon--warn { color: var(--warn-icon); }


/* ================================================================
   PANEL OPTIONS (overlay groups)
   ================================================================ */
#panel-options {
    display: flex;
    flex-direction: column; gap: 10px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-top: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                padding-top 0.25s ease;
}
#panel.expanded #panel-options {
    max-height: 600px;
    opacity: 1;
    padding-top: 4px;
}


.overlay-group {
    border: 1px solid var(--panel-group-border);
    border-radius: 10px; padding: 3px 10px;
    display: flex; flex-direction: column; gap: 2px;
    transition: opacity 0.25s ease;
}
.overlay-group.disabled { opacity: 0.4; pointer-events: none; }
.overlay-group-title {
    font-size: 12px; font-weight: 400; color: var(--text);
    letter-spacing: 0.3px; text-transform: uppercase;
    min-width: 54px;
}
.overlay-row {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.overlay-label {
    font-size: 11px; font-weight: 400; color: var(--text);
}
/* ================================================================
   SEGMENTED GROUP — unified Material-style toggle (matches native app)
   ================================================================ */
.seg-group {
    display: flex;
    position: relative;
    width: 100%;
    background: var(--btn-bg);
    border-radius: 90px;
    overflow: hidden;
    height: 32px;
    border: 0.4px solid var(--seg-group-border, var(--divider));
}
.seg-indicator {
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    border-radius: 90px;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}
.seg-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    font-weight: 400;
    line-height: 18px;
    color: var(--muted);
    transition: color 0.2s ease;
    padding: 0 6px;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.seg-active { color: var(--seg-active-text); }
.seg-img {
    width: 20px; height: 20px;
    object-fit: contain;
    pointer-events: none;
}
.seg-divider {
    width: 1px;
    background: var(--divider);
    height: 60%;
    align-self: center;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
    z-index: 1;
}

/* Compact variant for small inline switchers (overlay rows, settings) */
.seg-compact {
    flex: 1;
    min-width: 0;
}
.seg-compact .seg-group {
    height: 28px;
}
.seg-compact .seg-btn {
    font-size: 11px;
    padding: 0 8px;
}

/* Legacy compat — overlay-switcher is now seg-group */
.overlay-switcher {
    display: flex;
    background: var(--btn-bg);
    border-radius: 12px; padding: 2px;
    flex-shrink: 0;
}
.overlay-btn {
    padding: 2px 8px; border-radius: 10px; cursor: pointer;
    font-size: 10px; font-weight: 400; color: var(--muted);
    transition: all 0.25s ease; user-select: none; white-space: nowrap;
    text-align: center;
}
.overlay-btn:hover { color: var(--text); }
#group-snow .overlay-switcher {
    flex-wrap: wrap; border-radius: 14px; gap: 2px;
}
#group-snow .overlay-btn { flex: 1 1 auto; min-width: 0; }
.overlay-btn.active {
    background: var(--accent); color: #fff;
    box-shadow: 0 1px 8px var(--accent-glow);
}

/* Settings section — card style like right-panel sections */
.settings-section {
    margin-top: 10px;
    border: 1px solid var(--tile-border);
    border-radius: 12px;
    background: var(--tile-bg);
    box-shadow: 0 var(--tile-shadow);
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
}
#panel.expanded .settings-section {
    max-height: 200px; opacity: 1;
}
.settings-header {
    padding: 8px 10px 0;
    font-size: 12px; font-weight: 400; color: var(--text);
}
.settings-body {
    padding: 6px 10px 8px;
    display: flex; flex-direction: column; gap: 6px;
}

/* Panel collapsible sections */
.panel-collapse-section {
    margin-bottom: 2px;
}
.panel-collapse-header {
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-collapse-header span {
    font-size: 12px; font-weight: 400; color: var(--text);
}
.panel-collapse-chevron {
    color: var(--muted);
    transition: transform 0.2s ease;
    transform: rotate(0deg);
}
.panel-collapse-header.open .panel-collapse-chevron {
    transform: rotate(90deg);
}
.panel-collapse-body {
    display: none;
    padding: 0 10px 8px;
    flex-direction: column;
    gap: 12px;
}
.panel-collapse-body.open {
    display: flex;
}

/* Temperature switcher — same style as lang-switcher */
.temp-switcher {
    display: flex;
    background: var(--btn-bg);
    border-radius: 14px; padding: 2px;
    flex-shrink: 0;
}
.temp-btn {
    padding: 3px 10px; border-radius: 12px; cursor: pointer;
    font-size: 10px; font-weight: 400; color: var(--muted);
    transition: all 0.25s ease; user-select: none; white-space: nowrap;
    text-align: center;
}
.temp-btn:hover { color: var(--text); }
.temp-btn.active {
    background: var(--accent); color: #fff;
    box-shadow: 0 1px 8px var(--accent-glow);
}
.settings-row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.settings-row-label {
    font-size: 10px; font-weight: 400; color: var(--muted);
    min-width: 54px;
}
/* Panel footer — WDTEC collapsible section (shown on desktop via media query) */
#panel-footer {
    display: none;
}
#panel-footer-copy {
    font-size: 11px; color: var(--muted); opacity: 0.7;
    line-height: 1.4;
}
#panel-footer-links {
    margin-top: 4px;
    display: flex; flex-direction: column; gap: 6px;
    align-items: flex-end;
}
.panel-footer-btn {
    width: auto; padding: 7px 16px; border-radius: 12px;
    cursor: pointer; border: none;
    font-size: 11px; font-weight: 400; color: var(--muted);
    background: var(--btn-bg);
    font-family: inherit;
    transition: all 0.25s ease; user-select: none;
    text-align: center;
}
.panel-footer-btn:hover { color: var(--text); background: var(--btn-bg); }

/* Language switcher */
.lang-switcher {
    display: flex;
    background: var(--btn-bg);
    border-radius: 14px; padding: 2px;
    flex-shrink: 0;
}
.lang-btn {
    padding: 3px 10px; border-radius: 12px; cursor: pointer;
    font-size: 10px; font-weight: 400; color: var(--muted);
    transition: all 0.25s ease; user-select: none; white-space: nowrap;
    text-align: center; text-transform: uppercase;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active {
    background: var(--accent); color: #fff;
    box-shadow: 0 1px 8px var(--accent-glow);
}

/* ================================================================
   FULLSCREEN BUTTON (top-right corner)
   ================================================================ */
#fullscreen-btn {
    position: fixed; top: 12px; right: 12px; z-index: 11;
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 24px var(--shadow);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}
#fullscreen-btn:hover { color: var(--text); background: var(--btn-bg); }

/* ================================================================
   GLOBE TOGGLE BUTTON (top-right, next to fullscreen)
   ================================================================ */
#globe-btn {
    position: fixed; top: 12px; right: 62px; z-index: 11;
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 24px var(--shadow);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
#globe-btn:hover { color: var(--text); background: var(--btn-bg); }
#globe-btn.active { color: var(--accent); border-color: var(--accent); }

/* Fullscreen: shift UI below notch / Dynamic Island */
:fullscreen #map-search,
:fullscreen #fullscreen-btn,
:fullscreen #globe-btn,
:fullscreen #legend-container {
    top: calc(12px + env(safe-area-inset-top, 0px));
}
:fullscreen #globe-btn {
    top: calc(12px + env(safe-area-inset-top, 0px));
}
:fullscreen #bottom-bar {
    bottom: 12px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ================================================================
   MAP SEARCH (geocoder, floating top-center)
   ================================================================ */
#map-search {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    width: calc(100% - 24px);
    max-width: 340px;
    pointer-events: none; /* let clicks pass through the wrapper… */
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
#map-search-box {
    pointer-events: all;
    background: var(--search-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-radius: 28px; padding: 8px 14px 8px 18px;
    box-shadow: 0 4px 24px var(--search-shadow); border: 1px solid var(--search-border);
    display: flex; align-items: center; gap: 10px;
}
#map-search-icon {
    width: 15px; height: 15px; color: var(--search-icon); flex-shrink: 0;
}
#map-search-input {
    flex: 1; min-width: 0;
    background: none; border: none; outline: none;
    font-size: 13px; font-weight: 400; color: var(--search-text); font-family: inherit;
}
#map-search-input::placeholder { color: var(--search-placeholder); }
#map-search-clear {
    pointer-events: all;
    display: none;
    background: none; border: none; cursor: pointer; padding: 2px;
    color: var(--search-icon); flex-shrink: 0; line-height: 0;
    transition: color 0.15s;
}
#map-search-clear:hover { color: var(--search-text); }
#map-search-clear svg { width: 14px; height: 14px; }

#map-search-results {
    pointer-events: all;
    display: none;
    margin-top: 6px;
    background: var(--search-results-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-radius: 16px; border: 1px solid var(--search-results-border);
    box-shadow: 0 4px 24px var(--search-results-shadow);
    overflow: hidden;
}
.map-search-item {
    padding: 12px 18px; cursor: pointer;
    display: flex; flex-direction: column; gap: 3px;
    border-bottom: 1px solid var(--search-item-border);
    transition: background 0.15s;
}
.map-search-item:last-child { border-bottom: none; }
.map-search-item:hover { background: var(--search-item-hover); }
.map-search-item-name { font-size: 16px; font-weight: 400; color: var(--search-item-text); font-family: inherit; }
.map-search-item-sub  { font-size: 14px; font-weight: 400; color: var(--search-item-sub); font-family: inherit; }

@media (orientation: landscape) {
    #map-search {
        /* centre within the visible map area (sidebar = 200px) */
        left: calc(100px + 50vw);
        max-width: 400px; width: 400px;
    }
    #country-switcher {
        left: calc(100px + 50vw);
    }
    /* Fullscreen button: right of searchbar */
    #fullscreen-btn {
        right: auto;
        left: calc(100px + 50vw + 212px); /* half searchbar (200px) + 12px gap */
    }
    #globe-btn {
        right: auto;
        left: calc(100px + 50vw + 262px); /* fullscreen + 38px button + 12px gap */
    }
}
@media (min-width: 1200px) {
    #map-search {
        left: calc(120px + 50vw); /* sidebar = 240px */
    }
    #country-switcher {
        left: calc(120px + 50vw);
    }
    #fullscreen-btn {
        left: calc(120px + 50vw + 212px);
    }
    #globe-btn {
        left: calc(120px + 50vw + 262px);
    }
}

/* When right panel is open: both sidebars cancel out, centre at 50% */
@media (orientation: landscape) {
    body.right-panel-open #map-search,
    body.right-panel-open #country-switcher {
        left: 50%;
    }
    body.right-panel-open #fullscreen-btn {
        left: calc(50% + 212px);
    }
    body.right-panel-open #globe-btn {
        left: calc(50% + 262px);
    }
    body.right-panel-open #bottom-bar {
        right: 240px;
    }
}


/* ================================================================
   LOADING OVERLAY
   ================================================================ */
#loading {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 100;
    background: var(--glass2); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-radius: 18px; padding: 20px 32px;
    box-shadow: 0 4px 32px var(--shadow); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 12px; transition: opacity 0.3s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.spinner {
    width: 28px; height: 28px; border: 3px solid var(--accent2);
    border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes radarPulse { 0%,100% { opacity:1; } 50% { opacity:0.45; } }
#loading-text { font-size: 13px; font-weight: 400; color: var(--muted); white-space: nowrap; }
#progress-bar-container {
    width: 180px; height: 4px; background: var(--border);
    border-radius: 2px; overflow: hidden; display: none;
}
#progress-bar {
    width: 0%; height: 100%; background: var(--accent);
    border-radius: 2px; transition: width 0.15s ease;
}

/* ================================================================
   ALERTS POPUP OVERLAY (centered modal)
   ================================================================ */
#alerts-popup-overlay {
    position: fixed; inset: 0; z-index: 30;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.25s ease;
}
#alerts-popup-overlay.hidden { opacity: 0; pointer-events: none; }
#alerts-popup-backdrop {
    position: absolute; inset: 0;
    background: var(--shadow);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
#alerts-popup {
    position: relative; z-index: 1;
    width: calc(100% - 24px); max-width: 420px; max-height: 80vh;
    background: var(--panel-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-radius: 18px; border: 1px solid var(--panel-border);
    box-shadow: 0 8px 48px var(--panel-shadow);
    display: flex; flex-direction: column;
    overflow: hidden;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#alerts-popup-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px 0;
}
#alerts-popup-title {
    font-size: 18px; font-weight: 400; color: var(--text);
}
#alerts-popup-close {
    background: var(--close-bg); border: 1px solid var(--close-border);
    border-radius: 50%; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--close-icon); padding: 0;
    transition: all 0.2s ease;
}
#alerts-popup-close:hover { color: var(--close-hover-icon); background: var(--close-hover-bg); }
#alerts-popup-content {
    padding: 12px 18px 18px;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}
#alerts-popup-content::-webkit-scrollbar { width: 4px; background: transparent; }
#alerts-popup-content::-webkit-scrollbar-track { background: transparent; }
#alerts-popup-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#alerts-popup-content { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.alerts-disclaimer {
    font-size: 11px; color: var(--muted); text-align: center;
    margin-bottom: 14px; line-height: 1.4;
}
.alert-card {
    border-radius: 14px; margin-bottom: 10px;
    overflow: hidden; display: flex;
    background: var(--bg2); border: 1px solid var(--border);
}
.alert-card:last-of-type { margin-bottom: 0; }
.alert-severity-bar {
    width: 28px; min-width: 28px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    writing-mode: vertical-rl; text-orientation: mixed;
    transform: rotate(180deg);
    font-size: 12px; font-weight: 400; color: var(--text);
}
.alert-card-inner {
    flex: 1; min-width: 0;
}
.alert-card-header {
    padding: 12px 14px;
    cursor: pointer; user-select: none;
    display: flex; align-items: flex-start; gap: 10px;
    transition: background 0.15s ease;
}
.alert-card-header:hover { background: var(--glass-light); }
.alert-card-header-text { flex: 1; min-width: 0; }
.alert-card-time {
    font-size: 11px; font-weight: 300; color: var(--muted); line-height: 1.4;
}
.alert-card-headline {
    font-size: 14px; font-weight: 400; color: var(--text);
    margin-top: 4px; line-height: 1.3;
}
.alert-card-chevron {
    width: 20px; height: 20px; flex-shrink: 0;
    color: var(--muted); transition: transform 0.25s ease;
    margin-top: 2px;
}
.alert-card.expanded .alert-card-chevron { transform: rotate(90deg); }
.alert-card-body {
    max-height: 0; overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
}
.alert-card.expanded .alert-card-body { max-height: 600px; }
.alert-card-body-inner {
    padding: 0 14px 14px;
    border-top: 1px solid var(--border);
}
.alert-card-desc {
    font-size: 13px; font-weight: 400; color: var(--text);
    line-height: 1.55; margin-top: 12px;
    white-space: pre-line;
}
.alert-card-instruction {
    font-size: 13px; font-weight: 400; color: var(--text);
    line-height: 1.55; margin-top: 8px;
    white-space: pre-line;
}
.alert-source {
    font-size: 11px; color: var(--muted); text-align: center;
    margin-top: 14px;
}
#alerts-popup-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}
#alerts-popup-footer:empty { display: none; }
.alert-lang-switcher {
    display: flex; justify-content: center; gap: 6px;
    padding: 12px 18px;
}
.alert-lang-btn {
    padding: 5px 16px; border-radius: 18px; cursor: pointer;
    font-size: 12px; font-weight: 400; color: var(--lang-btn-text);
    background: var(--lang-btn-bg); border: 1px solid var(--lang-btn-border);
    transition: all 0.2s ease; user-select: none;
    font-family: inherit;
}
.alert-lang-btn:hover { color: var(--lang-btn-active-text); border-color: var(--lang-btn-active-border); }
.alert-lang-btn.active {
    color: var(--lang-btn-active-text); border-color: var(--lang-btn-active-border);
    background: var(--lang-btn-active-bg);
}
.alerts-empty {
    text-align: center; padding: 24px 0;
    color: var(--muted); font-size: 14px;
}
.alerts-loading {
    display: flex; flex-direction: column; align-items: center;
    gap: 10px; padding: 32px 0;
}

/* Handle hidden on desktop */
#alerts-popup-handle { display: none; }

/* ── Mobile: alerts popup as bottom sheet ── */
@media (orientation: portrait) {
    #alerts-popup-overlay {
        align-items: flex-end; justify-content: stretch;
        transition: opacity 0.2s ease;
    }
    #alerts-popup-backdrop {
        background: var(--backdrop);
        backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    }
    #alerts-popup {
        width: 100%; max-width: none; max-height: 85vh;
        border-radius: 20px 20px 0 0; border-bottom: none;
        background: var(--bg);
        backdrop-filter: none; -webkit-backdrop-filter: none;
        transform: translateY(0);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        padding-bottom: env(safe-area-inset-bottom);
    }
    #alerts-popup-overlay.hidden #alerts-popup {
        transform: translateY(100%);
    }
    #alerts-popup-handle {
        display: flex; justify-content: center;
        padding: 10px 0 4px; cursor: grab; flex-shrink: 0;
    }
    #alerts-popup-handle:active { cursor: grabbing; }
    .alerts-handle-bar {
        width: 40px; height: 5px;
        background: var(--panel-handle-color); opacity: var(--panel-handle-opacity); border-radius: 3px;
    }
    #alerts-popup-header { padding: 4px 16px 0; }
    #alerts-popup-content { padding: 8px 16px 16px; }
}

/* ================================================================
   LAYER HELP BOTTOM SHEET  (matches native app HelpView)
   ================================================================ */
#layer-help-overlay {
    position: fixed; inset: 0; z-index: 30;
    display: flex; align-items: flex-end; justify-content: center;
    transition: opacity 0.25s ease;
}
#layer-help-overlay.hidden { opacity: 0; pointer-events: none; }
#layer-help-backdrop {
    position: absolute; inset: 0;
    background: var(--backdrop);
}
#layer-help {
    position: relative; z-index: 1;
    width: 100%; max-width: 560px;
    max-height: 90vh;
    background: var(--bg2);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 40px var(--shadow);
    display: flex; flex-direction: column;
    overflow: hidden;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transform: translateY(0);
    transition: transform 0.3s ease;
}
#layer-help-overlay.hidden #layer-help { transform: translateY(100%); }
/* Handle bar */
#layer-help-handle {
    display: flex; justify-content: center; padding: 10px 0 4px;
}
.layer-help-handle-bar {
    width: 40px; height: 5px;
    background: var(--panel-handle-color); opacity: var(--panel-handle-opacity); border-radius: 3px;
}
/* Close button */
#layer-help-close {
    position: absolute; top: 12px; right: 14px; z-index: 2;
    background: var(--glass-light); border: none;
    border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--muted); padding: 0;
    transition: background 0.2s ease;
}
#layer-help-close:hover { background: var(--glass-light); }
/* Title — starts below close button */
#layer-help-header { padding: 48px 24px 0; }
#layer-help-title {
    font-size: 20px; font-weight: 600; color: var(--text);
    line-height: 1.3;
}
/* Scrollable content */
#layer-help-content {
    padding: 8px 24px 32px;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    color: var(--text); font-size: 14px; line-height: 1.6;
}
#layer-help-content::-webkit-scrollbar { width: 4px; background: transparent; }
#layer-help-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#layer-help-content { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
#layer-help-content h2 {
    font-size: 18px; font-weight: 600; color: var(--text); margin: 18px 0 8px;
}
#layer-help-content h3 {
    font-size: 16px; font-weight: 600; color: var(--text); margin: 14px 0 6px;
}
#layer-help-content p { margin: 0 0 10px; line-height: 1.6; }
#layer-help-content ul { margin: 0 0 10px; padding-left: 22px; list-style-type: disc; }
#layer-help-content li { margin-bottom: 6px; line-height: 1.55; }
#layer-help-content li::marker { color: var(--accent-bright); }
#layer-help-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
#layer-help-content strong { font-weight: 600; color: var(--text); }
#layer-help-content em { font-style: italic; }
#layer-help-content a { color: var(--accent-bright); text-decoration: underline; text-underline-offset: 2px; }
#layer-help-content a:hover { opacity: 0.85; }
/* Dark theme overrides removed — all colors now use CSS variables */
/* Desktop: centered modal */
@media (orientation: landscape) {
    #layer-help-overlay { align-items: center; }
    #layer-help {
        max-width: 500px; max-height: 75vh;
        border-radius: 20px; width: calc(100% - 48px);
    }
    #layer-help-overlay.hidden #layer-help { transform: translateY(20px); }
    #layer-help-handle { display: none; }
}

/* Info pill — base (desktop: right-aligned in row) */
.layer-btn.active:has(.layer-info-dot) {
    padding-right: 32px;
}
.layer-info-dot {
    position: absolute;
    right: 8px; top: 50%; transform: translateY(-50%);
    height: 18px;
    padding: 0 8px;
    border-radius: 8px;
    background: var(--glass-light);
    border: 1px solid var(--divider);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.2s ease;
    z-index: 2;
    flex-shrink: 0;
    font-family: 'Poppins', sans-serif; font-size: 9px; font-weight: 600; line-height: 1;
}
/* Enlarged touch target (44px minimum) via pseudo-element */
.layer-info-dot::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 44px; height: 44px;
    transform: translate(-50%, -50%);
    border-radius: 24px;
}
.layer-info-dot:hover {
    color: var(--text);
    border-color: var(--muted);
    background: var(--info-dot-hover-bg);
}

/* ================================================================
   POPUP (MapLibre)
   ================================================================ */
.maplibregl-marker { z-index: 10 !important; }
.maplibregl-popup { z-index: 20 !important; }
.maplibregl-popup-content {
    border-radius: 14px !important;
    padding: 0 !important;
    background: var(--bg2) !important;
    box-shadow: 0 8px 32px var(--shadow) !important;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    overflow: visible;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
}
.maplibregl-popup-close-button { font-size: 18px; color: var(--muted); top: 8px; right: 10px; z-index: 1; }
.maplibregl-popup-close-button:hover { color: var(--text); background: transparent; }
.maplibregl-popup-tip { border-top-color: var(--bg2) !important; border-bottom-color: var(--bg2) !important; }

/* ================================================================
   DESKTOP LAYOUT (>= 768px)
   ================================================================ */
@media (orientation: landscape) {
    /* Panel becomes left sidebar */
    #panel {
        top: 0; bottom: 0; left: 0; right: auto;
        width: 240px; height: auto; max-height: none; padding-bottom: 0;
        border-radius: 0 22px 22px 0;
        background: var(--glass2); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
        box-shadow: 4px 0 32px var(--shadow);
        border: 1px solid var(--border);
        border-left: none;
        transform: none !important;
        overflow: hidden;
    }
    #panel-handle { display: none; }


    #panel-content {
        max-height: none; height: calc(100% - 8px);
        padding: 16px 12px 140px; /* 140px bottom for fixed ad bar */
        overflow-y: auto;
    }

    /* Options always visible on desktop */
    #panel-options { max-height: none !important; opacity: 1 !important; padding-top: 4px !important; overflow: visible !important; }
    .settings-section { max-height: none !important; opacity: 1 !important; overflow: visible !important; }
    #panel-footer { display: block; }
    .settings-row-label { font-size: 11px; }
    .temp-btn { font-size: 10px; }

    /* Layer strip: desktop additions (border-bottom separator) */
    #layer-strip {
        border-bottom: 1px solid var(--border);
        margin-bottom: 8px;
    }
    .layer-btn.active::before {
        content: '';
        position: absolute; left: 0; top: 6px; bottom: 6px;
        width: 3px; border-radius: 0 3px 3px 0;
        background: var(--accent);
    }
    .overlay-label { font-size: 11px; }
    .overlay-group-title { font-size: 10px; }
    .overlay-btn { font-size: 10px; }
    .map-search-item-sub { font-size: 14px; }

    /* Legend shifts right to make room for sidebar, scaled down 30% */
    #legend-container { left: 256px; transform: scale(0.7); transform-origin: top left; }


    /* Panel: reset expanded z-index on desktop */
    #panel.expanded { z-index: 11; }

    /* Bottom bar centered, stacked */
    #bottom-bar {
        left: 240px; right: 0; bottom: 0;
        padding: 0 16px 16px;
        flex-direction: column; align-items: center; gap: 8px;
    }
    #controls { max-width: 480px; padding: 10px 24px; }
    #controls label { display: block; font-size: 13px; }
    #time-clock { font-size: 15px; }
    #time-label { font-size: 11px; }
    #time-display { min-width: 54px; }
}

/* ================================================================
   LARGE DESKTOP (>= 1200px)
   ================================================================ */
@media (min-width: 1200px) {
    .layer-icon { width: 24px; height: 24px; }
    .layer-btn img, .layer-btn .layer-icon-placeholder { width: 48px; height: 48px; }
}

/* ================================================================
   AD CONTAINERS
   ================================================================ */

/* Hidden state (ads disabled / blocked / Pro user) */
.ad-container.ad-hidden { display: none !important; }

/* Ad panel — fixed bar at bottom on mobile, inside sidebar on desktop */
#ad-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 13;
    background: var(--glass2);
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    display: flex; justify-content: center;
}
@media (orientation: landscape) {
    #ad-panel {
        position: fixed; bottom: 0; left: 0; width: 240px;
        z-index: 12;
        padding: 10px 12px 8px; display: block;
        background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}
#ad-right-panel {
    flex-shrink: 0; margin: 0;
    padding: 8px 12px; overflow: hidden;
    border-top: 1px solid var(--border);
    display: flex; justify-content: center;
}
@media (orientation: landscape) {
    #ad-right-panel { padding: 10px 14px 8px; display: block; }
}

/* Mobile banner (fixed bottom, above panel) */
#ad-banner-mobile {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    z-index: 10;
    display: flex;
    justify-content: center;
    padding: 4px 0;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    border-top: 1px solid var(--border);
}

/* Desktop: hide mobile banner */
@media (orientation: landscape) {
    #ad-banner-mobile { display: none !important; }
}

/* ================================================================
   TEST AD PLACEHOLDERS (realistic demo ads)
   ================================================================ */
.test-ad {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.test-ad-label {
    font-size: 9px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    background: var(--accent2);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Panel native ad (card style) */
.test-ad-native {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.2s ease;
}
.test-ad-native:hover { background: var(--btn-bg); }

.test-ad-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.test-ad-sponsor {
    font-size: 9px;
    color: var(--muted);
    font-weight: 400;
}
.test-ad-body {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.test-ad-icon { flex-shrink: 0; }
.test-ad-icon svg { width: 34px; height: 34px; }
.test-ad-info { flex: 1; min-width: 0; }
.test-ad-title {
    font-size: 12px;
    font-weight: 400;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 2px;
}
.test-ad-desc {
    font-size: 10px;
    color: var(--muted);
    line-height: 1.35;
}

/* Mobile banner ad (320x50 style) */
.test-ad-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 320px;
    height: 50px;
    padding: 0 12px;
    background: var(--glass2);
    border-radius: 0;
    cursor: pointer;
}
.test-ad-banner-icon { flex-shrink: 0; }
.test-ad-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.test-ad-banner-title {
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
}
.test-ad-banner-cta {
    font-size: 11px;
    color: var(--accent);
    font-weight: 400;
}

/* ================================================================
   ADBLOCKER POPUP OVERLAY
   ================================================================ */
#adblocker-popup-overlay {
    position: fixed; inset: 0; z-index: 35;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
#adblocker-popup-overlay.visible {
    opacity: 1; pointer-events: auto;
}

#adblocker-popup-backdrop {
    position: absolute; inset: 0;
    background: var(--backdrop);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}

#adblocker-popup {
    position: relative; z-index: 1;
    width: calc(100% - 32px); max-width: 380px;
    background: var(--glass2);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-radius: 18px; border: 1px solid var(--border);
    box-shadow: 0 8px 48px var(--shadow);
    display: flex; flex-direction: column;
    overflow: hidden;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#adblocker-popup-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 0;
}
#adblocker-popup-title {
    font-size: 17px; font-weight: 400; color: var(--text);
}
#adblocker-popup-close {
    background: var(--btn-bg); border: 1px solid var(--border);
    border-radius: 50%; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--muted); padding: 0;
    transition: all 0.2s ease;
}
#adblocker-popup-close:hover {
    color: var(--text); background: var(--accent2);
}

#adblocker-popup-content {
    padding: 18px 20px 8px;
    text-align: center;
}
.adblocker-icon {
    margin-bottom: 12px;
}
.adblocker-text {
    font-size: 14px; line-height: 1.5;
    color: var(--text);
    margin: 0 0 10px;
}
.adblocker-text-muted {
    font-size: 12px;
    color: var(--muted);
}

#adblocker-popup-footer {
    padding: 8px 20px 18px;
    display: flex; justify-content: center;
}
.adblocker-btn {
    background: var(--accent);
    color: #fff;
    border: none; border-radius: 10px;
    padding: 10px 32px;
    font-size: 14px; font-weight: 400;
    cursor: pointer;
    transition: opacity 0.2s ease;
    font-family: inherit;
}
.adblocker-btn:hover { opacity: 0.85; }
