/* Shared base */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
    height: 100%;
}

body.leaf-layout {
    background: #0f172a;
    color: #f8fafc;
    /* font-size: 1.5em; REMOVED to fix header size mismatch */
    min-height: 100%;
}

body.leaf-layout .content-container {
    font-size: 1.25rem; /* Apply scaled text only to content area */
}

body.map-layout {
    background: #f8fafc;
    --map-hero-height: 64px;
}

body.hub-layout {
    background: #f8fafc;
    color: #0f172a;
}

body.silo-layout {
    background: #f8fafc;
    color: #0f172a;
}

/* Theme variables for map layout */
body.map-theme-light {
    --panel-bg: rgba(255, 248, 240, 0.95);
    --panel-text: #334155;
    --panel-link: #2563eb;
    --panel-border: rgba(148, 163, 184, 0.35);
    --panel-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    --panel-backdrop: none;
    --panel-label: #334155;
}

body.map-theme-dark {
    --panel-bg: rgba(22, 18, 16, 0.65);
    --panel-text: #e2e8f0;
    --panel-link: #fbbf24;
    --panel-border: rgba(214, 132, 73, 0.2);
    --panel-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    --panel-backdrop: blur(10px);
    --panel-label: #e2e8f0;
}

/* Map core layout */
body.map-layout #map,
body.hub-layout #map,
body.leaf-layout #map {
    width: 100%;
}

body.map-layout #map {
    height: calc(100vh - var(--map-hero-height));
    /* Account for potential mobile browser bars or layout shifts */
    min-height: 400px;
}

body.map-layout #controls {
    position: absolute;
    /* Reset top since search is now in header */
    top: calc(12px + var(--map-hero-height));
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(80vw, 300px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: none;
}

/* New Header Search Styles */
.search-input-header {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    border-radius: 99px !important; /* Pill shape */
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    font-size: 0.95rem;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.search-input-header::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-input-header:focus {
    background: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05) !important;
}

.search-suggestions-header {
    position: absolute;
    top: 110%;
    left: 0;
    width: 100%;
    background: #0f172a;
    color: #f1f5f9; /* Fixed legibility */
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    overflow: hidden;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: none; /* JS toggles this */
}

/* Light Theme overrides for Header Search if needed */
body.map-theme-light .search-input-header {
    background: rgba(15, 23, 42, 0.1) !important;
    border-color: rgba(15, 23, 42, 0.1) !important;
    color: #0f172a !important;
}
body.map-theme-light .search-input-header::placeholder {
    color: rgba(15, 23, 42, 0.5);
}
body.map-theme-light .search-suggestions-header {
    background: #fff;
    color: #0f172a;
}

/* Mobile Header tweaks */
@media (max-width: 768px) {
    .navbar {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .header-search-wrapper {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    body.map-layout #controls {
        top: calc(12px + var(--map-hero-height)); /* Consistent with desktop now */
        width: 42px; /* Collapsed state by default? Or just small icons? */
        /* Let's keep it 200px but maybe collapsed logic later. For now 200px. */
        width: 200px; 
    }
}

/* REMOVED: body.map-layout #search-box { ... } block entirely */

.search-suggest {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    font-size: 0.9rem;
}
.search-suggest:hover {
    background: rgba(255,255,255,0.05);
}
body.map-theme-light .search-suggest:hover {
    background: rgba(0,0,0,0.05);
}

.search-suggest:last-child {
    border-bottom: none;
}

.control-panel {
    background: var(--panel-bg);
    border-radius: 6px;
    box-shadow: var(--panel-shadow);
    color: var(--panel-text);
    font-size: 12px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    backdrop-filter: var(--panel-backdrop);
}

.control-panel.search-panel {
    border: none;
    box-shadow: none;
}

body.hub-layout .control-panel.search-panel,
body.map-layout .control-panel.search-panel {
    border: none;
    box-shadow: none;
}

.control-panel summary {
    cursor: pointer;
    padding: 8px 10px;
    font-weight: 600;
    list-style: none;
}

.control-panel summary::-webkit-details-marker {
    display: none;
}

.control-panel summary::after {
    content: '▾';
    float: right;
    transition: transform 0.2s ease;
}

.control-panel[open] summary::after {
    transform: rotate(180deg);
}

.control-panel .panel-body {
    padding: 8px 10px 10px;
    border-top: 1px solid var(--panel-border);
    max-height: min(40vh, 260px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--panel-border) transparent;
}

.control-panel .panel-body::-webkit-scrollbar {
    width: 8px;
}

.control-panel .panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.control-panel .panel-body::-webkit-scrollbar-thumb {
    background-color: var(--panel-border);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

#layers-control .leaflet-control-layers {
    box-shadow: none;
    border: none;
    margin: 0;
}

#layers-control .leaflet-control-layers-expanded {
    background: transparent;
    padding: 0;
}

#layers-control .leaflet-control-layers label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--panel-text);
    padding: 4px 0;
}

#layers-control .leaflet-control-layers input[type="checkbox"],
#layers-control .leaflet-control-layers input[type="radio"] {
    accent-color: #2563eb;
    width: 14px;
    height: 14px;
}

body.map-layout #search-box {
    position: absolute;
    top: calc(12px + var(--map-hero-height));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: min(520px, 90vw);
}

.search-input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--panel-text);
    outline: none;
    font-size: 14px;
}

.search-suggestions {
    margin-top: 6px;
    display: none;
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.search-suggest {
    padding: 6px 8px;
    cursor: pointer;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.search-suggest:last-child {
    border-bottom: none;
}

.locate-control.leaflet-bar a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-decoration: none;
    background: #ffffff;
    color: #334155;
}

.locate-control.leaflet-bar a:hover {
    background: #f1f5f9;
}

.control-panel select,
.control-panel input[type="search"],
.control-panel input[type="text"] {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.6);
    color: var(--panel-text);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 13px;
    outline: none;
}

.control-panel select option {
    color: #0f172a;
}

.panel-padding {
    padding: 8px 10px;
}

.breadcrumbs-panel {
    background: var(--panel-bg);
    color: var(--panel-text);
    border: 1px solid var(--panel-border);
    box-shadow: var(--panel-shadow);
    backdrop-filter: var(--panel-backdrop);
}

body.hub-layout .breadcrumbs-panel {
    background: var(--panel-bg);
    color: var(--panel-text);
    border: 1px solid var(--panel-border);
    box-shadow: var(--panel-shadow);
    backdrop-filter: var(--panel-backdrop);
}

.breadcrumb-link {
    color: var(--panel-link);
    text-decoration: none;
}

.breadcrumb-link:hover,
.breadcrumb-link:focus {
    text-decoration: underline;
}

.panel-label {
    font-size: 12px;
    color: var(--panel-label);
    margin-right: 6px;
}

.panel-select {
    font-size: 13px;
    width: 100%;
}

.map-overlay-bottom-left {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 1000;
}

.panel-credit {
    font-size: 11px;
    color: #cbd5f5;
}

/* Leaf layout */
body.leaf-layout {
    min-height: 100%;
}

body.leaf-layout .hero,
body.map-layout .hero {
    position: relative;
    z-index: 2600;
    padding: 10px 10px 10px;
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.3), transparent 55%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.35), transparent 45%),
        #0f172a;
}

body.leaf-layout .brand-logo,
body.map-layout .brand-logo {
    height: 34px;
    width: auto;
    display: block;
}

body.leaf-layout .hero .navbar,
body.map-layout .hero .navbar {
    padding: 0;
    position: relative;
    z-index: 2600;
}

body.leaf-layout .hero .navbar-collapse,
body.map-layout .hero .navbar-collapse {
    position: relative;
    z-index: 2600;
}

body.leaf-layout .hero .dropdown-menu,
body.map-layout .hero .dropdown-menu {
    z-index: 3000;
}

body.leaf-layout .hero .navbar-toggler,
body.map-layout .hero .navbar-toggler {
    border-color: rgba(148, 163, 184, 0.5);
}

body.leaf-layout .hero .navbar-toggler-icon,
body.map-layout .hero .navbar-toggler-icon {
    filter: invert(1);
}

body.leaf-layout .hero .nav-link,
body.map-layout .hero .nav-link {
    color: #cbd5f5;
    font-size: 0.9em;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: rgba(15, 23, 42, 0.35);
    white-space: nowrap;
}

body.leaf-layout .hero .nav-link:hover,
body.leaf-layout .hero .nav-link:focus,
body.map-layout .hero .nav-link:hover,
body.map-layout .hero .nav-link:focus {
    border-color: rgba(148, 163, 184, 0.4);
    color: #e2e8f0;
}

body.leaf-layout .glass {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.25);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 18px 20px;
    box-sizing: border-box;
}

body.leaf-layout .hero h1 {
    margin: 0 0 8px;
    font-size: clamp(1.5em, 3.4vw, 2.1em);
}

body.leaf-layout .hero p {
    margin: 6px 0 0;
    color: #cbd5f5;
}

body.leaf-layout .content {
    padding: 18px 0 28px;
}

body.leaf-layout .content-container {
    max-width: 1200px;
    margin: 0 auto;
}

body.leaf-layout .card-title {
    font-weight: 600;
    margin-bottom: 8px;
}

body.leaf-layout .stat-list {
    color: #cbd5f5;
    display: grid;
    gap: 10px;
    font-size: 0.9em;
}

body.leaf-layout .stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

body.leaf-layout .stat-item i {
    width: 18px;
    text-align: center;
}

body.leaf-layout .related ul {
    margin: 0;
    padding-left: 18px;
    color: #cbd5f5;
    font-size: 0.9em;
}

body.leaf-layout .related a {
    color: #60a5fa;
    text-decoration: none;
}

body.leaf-layout #map {
    height: clamp(260px, 45vh, 520px);
}

body.leaf-layout .leaf-narrative {
    line-height: 1.7;
}

body.leaf-layout .stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

body.leaf-layout .stat {
    padding: 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

body.leaf-layout .stat .label {
    font-size: 0.8em;
    color: #94a3b8;
}

body.leaf-layout .stat .value {
    font-size: 1.1em;
    font-weight: 600;
    margin-top: 4px;
}

body.leaf-layout .custom-div-icon {
    border: 1px solid #cbd5e1;
}

.weather-icon {
    width: 26px;
    height: 26px;
}

.popup-icon-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.popup-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.popup-link-block {
    display: inline-block;
    margin-top: 6px;
}

.popup-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.popup-muted {
    color: #475569;
    font-size: 12px;
}

.popup-details {
    margin-top: 6px;
    font-size: 12px;
    color: #475569;
}

.popup-line-height {
    line-height: 1.7;
}

/* Tier 1 weather markers */
.tier1-marker-wrap {
    background: transparent;
    border: none;
}

.tier1-marker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    color: #0f172a;
    font-size: 12px;
    font-weight: 600;
}

.tier1-marker .tier1-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.tier1-marker .tier1-temp {
    color: #0f172a;
    font-weight: 700;
}

@media (max-width: 640px) {
    body.leaf-layout .hero {
        padding: 20px 18px 14px;
    }

    body.leaf-layout #map {
        height: clamp(220px, 40vh, 420px);
    }

    body.leaf-layout .content {
        padding: 16px 0 24px;
    }

    body.leaf-layout .hero h1 {
        font-size: 1.4em;
    }
}

@media (max-width: 420px) {
    body.leaf-layout .brand-logo {
        height: 28px;
    }
}

@media (max-width: 576px) {
    body.leaf-layout .content-container {
        padding-left: 16px;
        padding-right: 16px;
    }

    body.leaf-layout .glass {
        padding: 18px;
    }

    body.leaf-layout .hero h1 {
        font-size: 1.6em;
    }

    body.leaf-layout .card-title,
    body.leaf-layout .fw-semibold {
        font-size: 1em;
    }

    body.leaf-layout .stat-list,
    body.leaf-layout .related ul,
    body.leaf-layout .text-secondary,
    body.leaf-layout .text-light {
        font-size: 0.95em;
    }
}

.popup-title-sm {
    font-weight: 600;
    margin-bottom: 4px;
}

#hover-tooltip {
    position: absolute;
    z-index: 1001;
    background: rgba(15, 23, 42, 0.85);
    color: #f8fafc;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    transform: translate(10px, 10px);
    white-space: normal;
    max-width: 260px;
    display: none;
}

/* Hub-specific controls */
body.hub-layout #controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(26vw, 360px);
}

body.hub-layout .control-panel {
    background: rgba(15, 23, 42, 0.65);
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    color: #e2e8f0;
    font-size: 12px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.25);
    backdrop-filter: blur(10px);
}

body.hub-layout .panel-credit {
    color: #cbd5f5;
}

body.hub-layout .city-search-input {
    width: 100%;
    border: none;
    background: transparent;
    color: #e2e8f0;
    outline: none;
    font-size: 14px;
}

body.hub-layout .city-suggestions {
    margin-top: 6px;
    display: none;
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

body.hub-layout .city-suggest {
    padding: 6px 8px;
    cursor: pointer;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

body.hub-layout .city-suggest:last-child {
    border-bottom: none;
}

body.hub-layout #map {
    height: 100vh;
}

.hub-search-box {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: min(520px, 90vw);
}

.attribution {
    font-size: 12px;
    color: #cbd5f5;
}

.hub-list {
    display: grid;
    gap: 6px;
}

.hub-list a {
    color: #93c5fd;
    text-decoration: none;
    font-size: 12px;
}

.featured-cities-list {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.hub-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #cbd5f5;
    margin: 8px 0 6px;
}

@media (max-width: 900px) {
    body.hub-layout #controls {
        width: min(44vw, 360px);
    }

    .hub-search-box {
        position: static;
        transform: none;
        width: 100%;
        padding: 0 12px;
        margin-top: 12px;
    }
}

@media (max-width: 700px) {
    body.hub-layout #controls {
        position: static;
        width: 100%;
        padding: 12px 12px 0;
    }

    body.hub-layout #map {
        height: 70vh;
    }
}

@media (max-width: 480px) {
    body.hub-layout #map {
        height: 60vh;
    }

    body.hub-layout #controls {
        padding: 10px;
    }
}

/* Breadcrumbs panel */
.map-breadcrumbs {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
    background: var(--panel-bg);
    padding: 6px 8px;
    border-radius: 6px;
    box-shadow: var(--panel-shadow);
    border: 1px solid var(--panel-border);
    backdrop-filter: var(--panel-backdrop);
    font-size: 12px;
    color: var(--panel-text);
}

#legend-items {
    max-height: 55vh;
    overflow: auto;
}

/* Legend + popup styles */
.legend-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0;
    white-space: nowrap;
}

.custom-div-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 2px solid #ffffff;
}

.custom-div-icon i {
    font-size: 16px;
}

.popup {
    min-width: 200px;
}

.popup h3 {
    margin: 0 0 10px;
    font-size: 16px;
    color: #1e293b;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 5px;
}

.popup .meta {
    font-size: 12px;
    color: #475569;
    display: grid;
    gap: 4px;
}

.popup .label {
    font-weight: 600;
    color: #1e293b;
}

.weather-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 13px;
}

.weather-main {
    grid-column: span 2;
    font-size: 14px;
    font-weight: bold;
    color: #334155;
    margin-bottom: 5px;
}

.weather-val {
    font-weight: 600;
    color: #0f172a;
}

.label {
    color: #64748b;
}

/* Silo layout */
body.silo-layout .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

body.silo-layout #map {
    height: 500px;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    margin-bottom: 28px;
}

body.silo-layout .breadcrumbs {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 10px;
}

body.silo-layout .breadcrumbs a {
    color: #2563eb;
    text-decoration: none;
}

body.silo-layout h1 {
    margin: 0 0 12px;
    font-size: 32px;
}

body.silo-layout .subtitle {
    color: #475569;
    margin-bottom: 24px;
}

body.silo-layout .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

body.silo-layout .card {
    background: #fff;
    padding: 18px 18px 16px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

body.silo-layout .card h3 {
    margin: 0 0 10px;
    font-size: 16px;
}

body.silo-layout .card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

body.silo-layout .card li {
    margin-bottom: 8px;
    color: #334155;
    font-size: 14px;
}

body.silo-layout .card li a {
    color: #0f172a;
    text-decoration: none;
}

body.silo-layout .related-links {
    margin-top: 32px;
}

body.silo-layout .related-links a {
    display: inline-block;
    margin-right: 12px;
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #1e293b;
    font-size: 13px;
    text-decoration: none;
}

body.silo-layout .legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: #475569;
    margin-bottom: 10px;
}

body.silo-layout .legend span {
    display: flex;
    align-items: center;
    gap: 6px;
}

body.silo-layout .legend i {
    font-size: 14px;
}

.inline-note {
    font-size: 12px;
    color: #64748b;
}

.inline-title {
    font-weight: 600;
}

.inline-muted {
    margin: 6px 0;
    color: #475569;
}

.inline-small {
    font-size: 14px;
}

.inline-meta {
    margin-top: 12px;
    font-size: 13px;
    color: #64748b;
}

/* Color utility classes */
.color-ffce00 { color: #ffce00; }
.color-f5f5f5 { color: #f5f5f5; }
.color-fceabb { color: #fceabb; }
.color-bbd2c5 { color: #bbd2c5; }
.color-bfc1c2 { color: #bfc1c2; }
.color-3a9ad9 { color: #3a9ad9; }
.color-2b6cb0 { color: #2b6cb0; }
.color-e0f7fa { color: #e0f7fa; }
.color-ffffff { color: #ffffff; }
.color-d5d8dc { color: #d5d8dc; }
.color-708090 { color: #708090; }
.color-ff4500 { color: #ff4500; }
.color-8b4513 { color: #8b4513; }
.color-1e90ff { color: #1e90ff; }
.color-00ced1 { color: #00ced1; }
.color-d2691e { color: #d2691e; }
.color-ffd700 { color: #ffd700; }
.color-ff8c00 { color: #ff8c00; }
.color-add8e6 { color: #add8e6; }
.color-d2b48c { color: #d2b48c; }
.color-a52a2a { color: #a52a2a; }
.color-40e0d0 { color: #40e0d0; }
.color-2563eb { color: #2563eb; }
.color-0ea5e9 { color: #0ea5e9; }
.color-10b981 { color: #10b981; }
.color-14b8a6 { color: #14b8a6; }
.color-22c55e { color: #22c55e; }
.color-16a34a { color: #16a34a; }
.color-f59e0b { color: #f59e0b; }
.color-f97316 { color: #f97316; }
.color-ef4444 { color: #ef4444; }
.color-dc2626 { color: #dc2626; }
.color-b91c1c { color: #b91c1c; }
.color-991b1b { color: #991b1b; }
.color-7f1d1d { color: #7f1d1d; }
.color-581c87 { color: #581c87; }
.color-4c0519 { color: #4c0519; }
.color-450a0a { color: #450a0a; }
.color-334155 { color: #334155; }
.color-64748b { color: #64748b; }
.color-94a3b8 { color: #94a3b8; }
.color-38bdf8 { color: #38bdf8; }
.color-60a5fa { color: #60a5fa; }
.color-cbd5f5 { color: #cbd5f5; }
.color-93c5fd { color: #93c5fd; }
.color-7dd3fc { color: #7dd3fc; }
.color-cbd5e1 { color: #cbd5e1; }
.color-e2e8f0 { color: #e2e8f0; }
.color-0f172a { color: #0f172a; }
.color-1e293b { color: #1e293b; }
.color-475569 { color: #475569; }

/* Weather Mood Cards */
.weather-mood-card {
    position: relative;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat;
    overflow: hidden;
    background-color: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Dark Overlay per leggibilità testo */
.weather-mood-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to bottom right, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.4));
    z-index: 1;
}

/* Assicurati che il contenuto stia sopra l'overlay */
.weather-mood-card > * {
    position: relative;
    z-index: 2;
}

.weather-conditions-card {
    border-radius: 20px;
    padding: 16px;
}

.weather-conditions-hero {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #f8fafc;
    min-height: 220px;
    padding-left: 0 !important;
    padding-bottom: 0 !important;    
}

.weather-conditions-time {
    text-align: right;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 0.95rem;
}

.weather-conditions-main {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.weather-conditions-temp {
    font-size: 3.5rem;
    font-weight: 600;
    line-height: 1;
}

.weather-conditions-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 1rem;
}

.weather-conditions-label {
    font-weight: 600;
    font-size: 1.1rem;
}

.weather-conditions-sub {
    color: rgba(248, 250, 252, 0.85);
    font-size: 0.95rem;
}

.weather-conditions-metrics {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

@media (min-width: 992px) {
    .weather-conditions-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.weather-metric-tile {
    background: rgba(248, 250, 252, 0.9);
    border-radius: 14px;
    padding: 10px 12px;
    color: #1f2937;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.weather-metric-tile i {
    color: #64748b;
    font-size: 0.95rem;
}

.weather-metric-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.weather-metric-value {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}

/* Images Mapping */
.weather-mood-default { background-image: url('/images/weather-moods/weather-mood-default.webp') !important; }
.weather-mood-sunny { background-image: url('/images/weather-moods/weather-mood-sunny.webp') !important; }
.weather-mood-clear-night { background-image: url('/images/weather-moods/weather-mood-clear-night.webp') !important; }
.weather-mood-partly-cloudy { background-image: url('/images/weather-moods/weather-mood-partly-cloudy.webp') !important; }
.weather-mood-cloudy { background-image: url('/images/weather-moods/weather-mood-cloudy.webp') !important; }
.weather-mood-cloudy-night { background-image: url('/images/weather-moods/weather-mood-cloudy-night.webp') !important; }
.weather-mood-rain { background-image: url('/images/weather-moods/weather-mood-rain.webp') !important; }
.weather-mood-snow { background-image: url('/images/weather-moods/weather-mood-snow.webp') !important; }
.weather-mood-storm { background-image: url('/images/weather-moods/weather-mood-storm.webp') !important; }
.weather-mood-fog { background-image: url('/images/weather-moods/weather-mood-fog.webp') !important; }

/* Weather Hub / Editorial Mode Styles */

/* Desktop Layout Adjustments */
@media (min-width: 992px) {
    body.weather-hub-mode #map {
        width: calc(100% - 400px) !important;
    }
    
    body.weather-hub-mode #controls {
        right: 410px !important;
        top: 80px !important;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }

    .weather-sidebar {
        position: fixed;
        top: 56px; /* Navbar height */
        right: 0;
        bottom: 0;
        width: 400px;
        background: #0f172a; 
        z-index: 3000;
        overflow-y: auto;
        border-left: 1px solid rgba(148, 163, 184, 0.25);
        box-shadow: -4px 0 12px rgba(0,0,0,0.25);
        display: flex;
        flex-direction: column;
        color: #f8fafc;
    }
}

/* Mobile Layout Adjustments */
@media (max-width: 991.98px) {
    .weather-sidebar {
        position: relative;
        width: 100%;
        z-index: 3000;
        background: #0f172a;
        color: #f8fafc;
        order: 2;
        border-top: 1px solid rgba(148, 163, 184, 0.25);
    }
    
    body.weather-hub-mode #map {
        height: 50vh !important;
    }
}

/* Glass Panels */
.glass-panel {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.25);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
}

/* Champion Cards */
.champion-card { 
    padding: 12px; 
    margin-bottom: 8px; 
    border-radius: 10px; 
    font-size: 0.95rem; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.champion-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.champion-card.hot { 
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.05));
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}
.champion-card.hot strong { color: #fff; }
.champion-card.hot i { color: #ef4444; }

.champion-card.cold { 
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.05));
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}
.champion-card.cold strong { color: #fff; }
.champion-card.cold i { color: #3b82f6; }

/* City Items */
.city-item { 
    display:flex; 
    justify-content: space-between; 
    padding: 10px; 
    border-bottom: 1px solid rgba(148, 163, 184, 0.15); 
    color: #cbd5e1; 
    text-decoration: none; 
    align-items: center;
}
.city-item:hover { 
    background: rgba(255,255,255,0.05); 
    padding-left:14px; 
    transition: all 0.2s; 
    color: #fff; 
}
.city-item:last-child { border-bottom: none; }

/* Components */
.narrative-box { 
    background: rgba(30, 41, 59, 0.6); 
    border-radius: 10px; 
    padding: 15px; 
    font-style: italic; 
    color: #e2e8f0; 
    border-left: 4px solid #64748b;
    line-height: 1.5;
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    background: rgba(15, 23, 42, 0.8);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

/* Leaf Page Shared Styles */
.ad-slot {
    background: #f1f3f5;
    border: 1px dashed #cbd5e1;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.85rem;
}
.ad-leaderboard { height: 90px; }
.ad-sidebar { width: 100%; height: 250px; }

/* Narrative adjustments for Leaf pages */
.leaf-layout .narrative-box { font-size: 1.1rem; }

/* Map adjustments for Leaf pages */
#map.leaf-map {
    height: 350px;
    border-radius: 16px;
    overflow: hidden;
}

/* Weather Grid */
.weather-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
@media (min-width: 992px) {
    .weather-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Extracted Inline Styles */

.subtle-ad-container {
    background: rgba(255,255,255,0.05); 
    border: 1px dashed rgba(255,255,255,0.2); 
    border-radius: 6px; 
    padding: 20px; 
    color: #64748b;
}

.small-caps-label {
    letter-spacing: 1px; 
    font-size: 0.7rem;
}

.sidebar-scroll-container {
    max-height: 400px; 
    overflow-y: auto;
}

.icon-fixed-width {
    width: 24px; 
    text-align: center;
}

.icon-w-20 {
    width: 20px;
    display: inline-block;
    text-align: center;
}

.z-relative-2 {
    z-index: 2; 
    position: relative;
}

.breadcrumb-chevron {
    --bs-breadcrumb-divider: '>';
}


.leaf-title {
    font-size: 1.1rem !important; /* Matched to narrative box size per request */
    font-weight: normal !important;
    font-style: normal !important;
    line-height: 1.4;
    margin: 0;
}

/* ============================================
   UNIFIED POPUP & TOOLTIP STYLES
   Canonical: popup radius 12px, tooltip radius 6px
   ============================================ */

/* Popup Wrapper */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    padding: 0 !important;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
    line-height: normal;
}

.leaflet-popup-scrolled {
    border: none !important;
}

.leaflet-popup-tip {
    box-shadow: none !important;
}

/* Hide default close button (we use custom X) */
.leaflet-popup-close-button {
    display: none !important;
}

/* Popup buttons: full-width, flush at bottom */
.leaflet-popup-content .btn {
    border-radius: 0 !important;
}

/* Tooltips */
.leaflet-tooltip {
    border-radius: 6px !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    background: #fff !important;
    color: #0f172a !important;
    padding: 6px 10px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    text-align: center !important;
    white-space: normal !important;
    opacity: 0.95 !important;
}

/* Custom Popup Header Bar (X close button) */
.popup-header-bar {
    padding: 4px 8px 0 0;
    margin-bottom: 0;
}
.popup-header-bar i {
    cursor: pointer;
    transition: color 0.2s;
}
.popup-header-bar i:hover {
    color: #0f172a !important;
}

/* Popup header (h6) horizontal padding */
.popup-wrapper h6 {
    padding-right: .25rem !important;
    padding-left: .25rem !important;
}

/* ============================================
   RESPONSIVE MARKER & TOUCH TARGETS (Mobile)
   ============================================ */

/* CSS Custom Properties for Marker Scaling */
:root {
    --marker-scale: 1;
    --marker-tier1-size: 30px;
    --marker-tier1-svg-width: 60px;
    --marker-tier1-svg-height: 30px;
    --marker-locality-size: 20px;
    --marker-event-size: 30px;
    --marker-aircraft-size: 36px;
    --hit-radius: 20px;
}

/* Mobile marker scaling (screens < 768px) */
@media (max-width: 768px) {
    :root {
        --marker-scale: 1.4;
        --marker-tier1-size: 42px;
        --marker-tier1-svg-width: 84px;
        --marker-tier1-svg-height: 42px;
        --marker-locality-size: 28px;
        --marker-event-size: 42px;
        --marker-aircraft-size: 50px;
        --hit-radius: 28px;
    }

    /* Increase Leaflet control touch targets */
    .leaflet-bar a {
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
        font-size: 18px !important;
    }

    .leaflet-touch .leaflet-bar a {
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
    }

    /* Zoom controls */
    .leaflet-touch .leaflet-control-zoom a {
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
    }

    /* Attribution control */
    .leaflet-control-attribution {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }

    /* Layer control checkbox - increase touch area */
    #layers-control .leaflet-control-layers label {
        padding: 8px 0;
        font-size: 14px;
    }

    #layers-control input[type="checkbox"],
    #layers-control input[type="radio"] {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px;
    }

    /* Larger custom div icons on mobile */
    .custom-div-icon i {
        font-size: 20px !important;
    }

    /* Tier1 weather markers - larger on mobile */
    .tier1-marker {
        transform: translateY(-3px) scale(var(--marker-scale, 1));
        transform-origin: center bottom;
    }

    .tier1-marker .tier1-icon img,
    .tier1-marker .tier1-icon i {
        width: 32px !important;
        height: 32px !important;
    }

    .tier1-marker .tier1-temp {
        font-size: 14px !important;
        padding: 3px 8px !important;
    }

    /* Larger tooltip text on mobile */
    .geoscope-tooltip {
        font-size: 13px !important;
        padding: 8px 12px !important;
    }

    /* Popup sizing on mobile */
    .leaflet-popup-content-wrapper {
        border-radius: 12px !important;
    }

    .leaflet-popup-content {
        margin: 14px 16px !important;
    }

    /* Aircraft canvas layer - handled via JS but CSS fallback */
    .geoscope-aircraft-canvas {
        /* DPR scaling handled in JS */
    }
}

/* Small mobile (screens < 480px) - even larger scaling */
@media (max-width: 480px) {
    :root {
        --marker-scale: 1.6;
        --marker-tier1-size: 48px;
        --marker-tier1-svg-width: 96px;
        --marker-tier1-svg-height: 48px;
        --marker-locality-size: 32px;
        --marker-event-size: 48px;
        --marker-aircraft-size: 56px;
        --hit-radius: 32px;
    }

    /* Tier1 marker sizing for SVG mode */
    .tier1-marker .tier1-icon img {
        width: 40px !important;
        height: 40px !important;
    }

    /* Even larger custom div icons on small mobile */
    .custom-div-icon i {
        font-size: 24px !important;
    }
}

/* High DPI (Retina) displays - ensure crisp rendering */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .custom-div-icon i {
        image-rendering: -webkit-optimize-contrast;
    }
}

