/* Custom dark palette variables */
:root {
    --dark-bg: #1A1A1D;
    --dark-surface: #2C3A47;
    --text-color: #E8EAE6;
    --accent-color: #3E82F7;
    --border-color: #4C596D;
}

/* Ensure full coverage on mobile */
html {
    background: #05060a;
    height: 100%;
}

/* Base Styles */
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(circle at top, #141824 0, #05060a 55%, #000000 100%);
    color: #f5f5f7;
    padding: 24px 32px 32px;
    padding: max(24px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left));
    box-sizing: border-box;
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Slightly bolder, more defined typography for Arabic UI */
html[lang="ar"] body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Cairo', 'Tajawal', sans-serif;
    font-weight: 600;
}

/* Ensure popup text in Arabic also uses the stronger weight */
html[lang="ar"] .leaflet-popup-content {
    font-weight: 600;
}

.geo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    position: relative;
    z-index: 2500;
}

.geo-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 20px;
}

.geo-title-block {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Remove title block entirely */
.geo-title-block {
    display: none;
}

.geo-logo-dot {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, #4fd1ff, #005eff);
    box-shadow: 0 0 12px rgba(0, 140, 255, 0.8);
}

.geo-title {
    margin: 0;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 18px;
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.geo-title-main {
    font-weight: 700;
}

.geo-title-sub {
    font-weight: 400;
    opacity: 0.8;
    text-transform: none;
    font-size: 16px;
    color: #4fd1ff;
}

.geo-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #a0a4b8;
}

.geo-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.4);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.lang-btn {
    background: transparent;
    border: none;
    color: #a0a4b8;
    cursor: pointer;
    padding: 0 4px;
    font-size: 10px;
    text-transform: inherit;
    letter-spacing: inherit;
}

.lang-btn.lang-active {
    color: #4fd1ff;
    font-weight: 600;
}

.lang-separator {
    color: rgba(148, 163, 184, 0.7);
    font-size: 10px;
}

/* --- PREFERENCES MENU --- */
.geo-view-toggle {
    position: relative;
}

/* Remove 2D/3D toggle button */
.geo-view-toggle {
    display: none;
}

.view-toggle-btn {
    background: rgba(20, 24, 36, 0.8);
    border: 1px solid #3a4552;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #d1d5db;
    transition: all 0.2s ease;
    padding: 0;
}

.view-toggle-btn:hover {
    background: rgba(30, 34, 46, 0.9);
    border-color: #4a5562;
    color: #ffffff;
    transform: scale(1.05);
}

.view-toggle-btn:active {
    transform: scale(0.95);
}

.view-toggle-btn svg {
    width: 20px;
    height: 20px;
}

/* Use map icon when globe is active (button switches to 2D) */
body[data-view-mode="3d"] .view-toggle-btn {
    background-image: url("/MAP-ICON.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px 20px;
}

body[data-view-mode="3d"] .view-toggle-btn svg {
    opacity: 0;
}

/* Hide MapLibre globe control button */
.maplibregl-ctrl-globe-enabled {
    display: none !important;
}

/* MapLibre attribution: smaller and collapsed by default */
.maplibregl-ctrl-attrib {
    font-size: 7px;
    line-height: 1.2;
    transform: scale(0.75);
    transform-origin: bottom right;
    opacity: 0.7;
}

.geo-prefs {
    position: relative;
}

.prefs-trigger {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.85);
    color: #a0a4b8;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.prefs-trigger-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 999px;
    border: 2px solid rgba(79, 209, 255, 0.7);
    pointer-events: none;
    animation: prefs-pulse 3s ease-out 2;
    box-shadow: 0 0 12px rgba(79, 209, 255, 0.5);
}

.prefs-trigger-pulse.hidden {
    display: none;
}

@keyframes prefs-pulse {
    0% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(1.25);
    }
    100% {
        opacity: 0;
        transform: scale(1.4);
    }
}

.prefs-hint {
    position: absolute;
    right: 50%;
    transform: translateX(50%);
    top: 32px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(79, 209, 255, 0.4);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11px;
    color: #4fd1ff;
    white-space: nowrap;
    z-index: 2001;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.prefs-hint.hidden {
    display: none;
}

.prefs-trigger:hover {
    border-color: rgba(79, 209, 255, 0.6);
    color: #4fd1ff;
}

.prefs-menu {
    position: absolute;
    left: 0;
    right: auto;
    top: 28px;
    width: 230px;
    background: rgba(10, 14, 20, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 12px;
    padding: 8px;
    font-size: 11px;
    z-index: 5000;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    scrollbar-width: none;
}

.prefs-menu::-webkit-scrollbar {
    display: none;
}

.prefs-menu.hidden {
    display: none;
}

.prefs-section {
    margin-bottom: 7px;
}

.prefs-section:last-child {
    margin-bottom: 0;
}

.prefs-section.prefs-mobile-actions {
    display: none;
}

.prefs-section + .prefs-section {
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    padding-top: 7px;
}

.prefs-label {
    color: #94a3b8;
    margin-bottom: 4px;
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.prefs-row,
.prefs-col {
    display: flex;
    gap: 6px;
}

.prefs-col {
    flex-direction: column;
}

.prefs-menu button {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #e5e7eb;
    border-radius: 6px;
    padding: 3px 5px;
    cursor: pointer;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s ease;
    flex: 1;
}

.prefs-menu button:hover {
    border-color: rgba(79, 209, 255, 0.6);
    background: rgba(30, 41, 59, 0.95);
}

.prefs-menu button.active {
    border-color: #4fd1ff;
    color: #4fd1ff;
    background: rgba(79, 209, 255, 0.1);
}

.prefs-segment {
    display: flex;
    gap: 4px;
    padding: 3px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.prefs-seg-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    padding: 4px 6px;
    border-radius: 8px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.prefs-seg-btn.active {
    background: rgba(79, 209, 255, 0.22);
    color: #e2e8f0;
    border: 1px solid rgba(79, 209, 255, 0.4);
}

.prefs-time-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.prefs-time-grid .time-chip {
    flex: 0 0 auto;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.prefs-time-grid .time-chip.active {
    background: rgba(79, 209, 255, 0.22);
    border-color: rgba(79, 209, 255, 0.45);
    color: #e2e8f0;
}

.prefs-chip-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
}

.prefs-menu .prefs-chip-grid .chip {
    width: 100%;
    justify-content: center;
    border-radius: 6px;
    padding: 4px 5px;
    font-size: 10px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.prefs-menu .prefs-chip-grid .chip.chip-active {
    border-color: rgba(79, 209, 255, 0.6);
    color: #e2e8f0;
    background: rgba(79, 209, 255, 0.18);
}

.prefs-toggle {
    display: flex;
    gap: 4px;
}

.prefs-toggle-btn {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #cbd5e1;
}

.prefs-toggle-btn.active {
    background: rgba(79, 209, 255, 0.22);
    border-color: rgba(79, 209, 255, 0.45);
    color: #e2e8f0;
}

.geo-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #20e38f;
    box-shadow: 0 0 10px rgba(32, 227, 143, 0.9);
}

.geo-tagline {
    margin: 6px 0 10px;
    font-size: 13px;
    color: #b3b8d0;
}

.geo-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.desktop-filters {
    position: relative;
    z-index: 100;
}

.chip {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 4px 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    background: rgba(15, 23, 42, 0.7);
    color: #e5e7eb;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chip:hover {
    border-color: rgba(79, 209, 255, 0.6);
}

.chip-active {
    border-color: #4fd1ff;
    background: radial-gradient(circle at top, rgba(79, 209, 255, 0.16), rgba(15, 23, 42, 0.9));
    box-shadow: 0 0 10px rgba(79, 209, 255, 0.5);
}

.filter-separator {
    color: rgba(148, 163, 184, 0.4);
    margin: 0 4px;
    font-size: 14px;
}

/* --- CATEGORY DOT STYLES --- */
.category-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    animation: category-pulse 2s infinite ease-in-out;
}

@keyframes category-pulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.5; 
        transform: scale(0.85);
    }
}

/* --- TIME FILTER DROPDOWN STYLES --- */
.time-filter-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.time-dropdown {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 4px 28px 4px 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    background: rgba(15, 23, 42, 0.7);
    color: #e5e7eb;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    font-family: inherit;
}

.time-dropdown:hover {
    border-color: rgba(79, 209, 255, 0.6);
}

.time-dropdown:focus {
    outline: none;
    border-color: #FFCC33;
    box-shadow: 0 0 10px rgba(255, 204, 51, 0.4);
}

.time-dropdown option {
    background: #1A1A1D;
    color: #e5e7eb;
    padding: 8px;
}

.dropdown-arrow {
    position: absolute;
    right: 10px;
    pointer-events: none;
    color: #a0a4b8;
    font-size: 10px;
    transition: color 0.2s ease;
}

.time-filter-wrapper:hover .dropdown-arrow {
    color: #4fd1ff;
}

.time-dropdown.time-active {
    border-color: #FFCC33;
    background: radial-gradient(circle at top, rgba(255, 204, 51, 0.16), rgba(15, 23, 42, 0.9));
    box-shadow: 0 0 10px rgba(255, 204, 51, 0.4);
}

/* --- LIVE NEWS FEED BUTTON --- */
.live-feed-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.live-feed-btn:hover {
    border-color: rgba(32, 227, 143, 0.6);
}

.live-feed-btn.active {
    border-color: #20e38f;
    background: radial-gradient(circle at top, rgba(32, 227, 143, 0.2), rgba(15, 23, 42, 0.9));
    box-shadow: 0 0 12px rgba(32, 227, 143, 0.5);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #20e38f;
    box-shadow: 0 0 6px #20e38f;
    animation: live-pulse 1.5s infinite ease-in-out;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Slow pulse animation for first-time users */
@keyframes first-time-pulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(32, 227, 143, 0.4);
        border-color: rgba(32, 227, 143, 0.6);
    }
    50% { 
        box-shadow: 0 0 0 4px rgba(32, 227, 143, 0);
        border-color: rgba(32, 227, 143, 1);
    }
}

.live-feed-btn.first-time-pulse {
    animation: first-time-pulse 2s infinite ease-in-out;
}

/* Main content container for map and sidebar */
#main-content {
    display: flex;
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0;
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    min-height: 0; /* Allow flex children to shrink below content size */
    background: transparent;
}

/* Map Container Styling */
#map {
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0;
    width: 100%;
    height: 100%;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: transparent !important;
    transition: margin-right 0.3s ease-out;
    position: relative; /* For fullscreen button positioning */
    z-index: 1;
}

/* Background layer behind the map */
#map-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    background: radial-gradient(circle at 30% 20%, #0f1b2e 0%, #070b14 55%, #03050a 100%);
    opacity: 1;
}

#map-bg::before {
    content: "GEOINTEL.LIVE";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    font-family: "Segoe UI", "Inter", system-ui, sans-serif;
    font-size: clamp(72px, 10.8vw, 168px);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-kerning: normal;
    font-variant-ligatures: none;
    text-rendering: geometricPrecision;
    text-transform: uppercase;
    color: rgba(59, 130, 246, 0.2);
    text-shadow:
        0 0 40px rgba(59, 130, 246, 0.5),
        0 0 80px rgba(59, 130, 246, 0.4),
        0 0 120px rgba(59, 130, 246, 0.3),
        0 0 160px rgba(59, 130, 246, 0.2),
        0 0 200px rgba(59, 130, 246, 0.15);
    -webkit-text-stroke: 2px rgba(59, 130, 246, 0.2);
    opacity: 0.85;
    padding-top: 8%;
}

/* Mobile-specific adjustments for background text */
@media (max-width: 768px) {
    #map-bg::before {
        font-size: clamp(48px, 12vw, 96px);
        letter-spacing: -0.01em;
        padding-top: 10%;
        text-shadow:
            0 0 30px rgba(59, 130, 246, 0.5),
            0 0 60px rgba(59, 130, 246, 0.4),
            0 0 90px rgba(59, 130, 246, 0.3),
            0 0 120px rgba(59, 130, 246, 0.2),
            0 0 150px rgba(59, 130, 246, 0.15);
        -webkit-text-stroke: 1.5px rgba(59, 130, 246, 0.25);
    }
}

#map-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(0, 0, 0, 0) 40%,
        rgba(0, 0, 0, 0.6) 100%
    );
}

/* 3D globe background should be transparent to show #map-bg */
#globe-container {
    background: transparent;
}

/* Globe icon: add equator line */
#view-toggle-btn svg line.globe-equator {
    stroke-width: 2;
}

/* Let the globe canvas show the container background */
#globe-container .maplibregl-canvas,
#globe-container .maplibregl-canvas-container {
    background: transparent !important;
}

/* When sidebar is open, shrink map to not be hidden behind it */
body.sidebar-open #map {
    margin-right: 320px;
}

/* In 3D mode, sidebar is fixed so no map margin needed */
body.sidebar-open #map {
    margin-right: 0;
}

/* 3D globe should be fullscreen with UI overlaid */
body {
    overflow: hidden;
}

body #main-content {
    position: fixed;
    inset: 0;
    border-radius: 0;
    z-index: 0;
}

body #map {
    border-radius: 0;
    border: none;
}

body #map-bg {
    border-radius: 0;
}

body #fullscreen-toggle {
    display: none;
}

body .geo-header {
    position: fixed;
    top: 16px;
    left: 24px;
    right: 24px;
    z-index: 2000;
    margin: 0;
    pointer-events: none;
}

body .geo-header .geo-header-right,
body .geo-header .geo-header-right *,
body .geo-header .geo-title-block,
body .geo-header .geo-title-block * {
    pointer-events: auto;
}

body .desktop-filters {
    position: fixed;
    top: 64px;
    left: 24px;
    right: 24px;
    z-index: 100;
}

body .geo-tagline {
    position: fixed;
    top: auto;
    bottom: 12px;
    left: 24px;
    right: auto;
    transform: none;
    z-index: 5;
    margin: 0;
    text-align: left;
}

body .geo-meta {
    position: fixed;
    top: 22px;
    left: 64px;
    right: auto;
    bottom: auto;
    z-index: 5;
}

body .geo-title-block {
    position: fixed;
    top: auto;
    bottom: 6px;
    left: 24px;
    right: auto;
    z-index: 5;
    text-align: left;
    font-size: 10px;
    letter-spacing: 0.08em;
}

body .map-watermark {
    left: auto;
    right: 24px;
    bottom: 24px;
    font-size: 14px;
    opacity: 0.55;
}

/* Hide browser scrollbar when sidebar is open on desktop to prevent map shift/jitter */
body.sidebar-open {
    overflow: hidden !important;
}

/* Hide gray areas outside map bounds */
.leaflet-container {
    background: #0a0a0a;
    height: 100% !important;
    width: 100% !important;
}

/* Compact, low-contrast Leaflet attribution */
.leaflet-control-attribution {
    font-size: 7px;
    line-height: 1.2;
    opacity: 0.45;
    background: rgba(2, 6, 23, 0.55);
    color: #9ca3af;
    padding: 1px 4px;
    border-radius: 5px;
    margin: 3px;
}

html[data-theme="light"] .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.75);
    color: #475569;
    opacity: 0.65;
}

/* --- SIDEBAR STYLES --- */
#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: rgba(20, 24, 36, 0.95);
    border-left: 1px solid rgba(79, 209, 255, 0.3);
    padding: 16px;
    box-sizing: border-box;
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

#sidebar::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

#sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

#sidebar h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #4fd1ff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#close-sidebar {
    background: transparent;
    border: none;
    color: #a0a4b8;
    font-size: 18px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#close-sidebar:hover {
    background: rgba(255, 82, 82, 0.2);
    color: #FF5252;
}

#cluster-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cluster-item {
    padding: 12px;
    background: rgba(44, 58, 71, 0.6);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.cluster-item:hover {
    background: rgba(44, 58, 71, 0.9);
}

.cluster-item.active {
    border-left-color: #FF5252;
    background: rgba(44, 58, 71, 0.9);
}

.cluster-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.cluster-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.cluster-item-category {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a0a4b8;
}

.cluster-item-text {
    font-size: 12px;
    color: #E8EAE6;
    line-height: 1.4;
}

/* --- AI SUMMARY STYLES --- */
.ai-summary-container {
    margin-bottom: 16px;
    border: 1px solid rgba(79, 209, 255, 0.3);
    background: rgba(79, 209, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
}

/* Loading state */
.ai-summary-loading {
    margin-bottom: 16px;
    border: 1px solid rgba(79, 209, 255, 0.3);
    background: rgba(79, 209, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
}

.ai-summary-loading-spinner {
    width: 20px;
    height: 20px;
    margin: 12px auto;
    border: 2px solid rgba(79, 209, 255, 0.3);
    border-top-color: #4fd1ff;
    border-radius: 50%;
    animation: ai-summary-spin 0.8s linear infinite;
}

@keyframes ai-summary-spin {
    to { transform: rotate(360deg); }
}

.ai-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ai-summary-title {
    font-size: 11px;
    font-weight: 600;
    color: #4fd1ff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ai-summary-auto {
    font-size: 10px;
    color: #4fd1ff;
    opacity: 0.7;
}

.ai-summary-content {
    font-size: 11px;
    color: #e5e7eb;
    line-height: 1.6;
}

.ai-summary-paragraph {
    margin: 0 0 8px 0;
}

.ai-summary-paragraph:last-of-type {
    margin-bottom: 8px;
}

.ai-summary-bullets {
    margin: 8px 0;
    padding-left: 18px;
    font-size: 11px;
    color: #e5e7eb;
    line-height: 1.5;
}

.ai-summary-bullets li {
    margin-bottom: 4px;
}

.ai-summary-footer {
    margin-top: 8px;
    font-size: 10px;
    color: #94a3b8;
    line-height: 1.4;
}

/* Light mode AI summary */
html[data-theme="light"] .ai-summary-container {
    border-color: rgba(79, 209, 255, 0.3);
    background: rgba(79, 209, 255, 0.06);
}

html[data-theme="light"] .ai-summary-content {
    color: #1a1a1d;
}

html[data-theme="light"] .ai-summary-bullets {
    color: #1a1a1d;
}

html[data-theme="light"] .ai-summary-footer {
    color: #64748b;
}

html[data-theme="light"] .ai-summary-loading {
    border-color: rgba(79, 209, 255, 0.3);
    background: rgba(79, 209, 255, 0.06);
}

/* Animation for new items in live feed */
@keyframes slideInFromTop {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.new-feed-item {
    animation: slideInFromTop 0.5s ease-out;
    border-left: 3px solid #20e38f;
    background: rgba(32, 227, 143, 0.1) !important;
}

/* Customizing Leaflet Dark Theme Look */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: var(--dark-surface);
    color: var(--text-color);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border: 1px solid rgba(79, 209, 255, 0.2);
}

.leaflet-popup-content-wrapper {
    max-width: 320px;
    border-radius: 12px !important;
    padding: 0 !important;
}

/* Wider popup for long posts (50% wider) */
.leaflet-popup.popup-wide .leaflet-popup-content-wrapper {
    max-width: 480px;
}

.leaflet-popup.popup-wide .leaflet-popup-content {
    max-width: 480px;
}

/* Mobile responsive for wide popups */
@media (max-width: 768px) {
    .leaflet-popup.popup-wide .leaflet-popup-content-wrapper {
        max-width: min(420px, calc(100vw - 40px));
    }
    
    .leaflet-popup.popup-wide .leaflet-popup-content {
        max-width: min(420px, calc(100vw - 40px));
    }
}

/* Screenshot mode: Scale down popup to 0.75x and ensure full opacity */
body.screenshot-ready .leaflet-popup,
html[data-screenshot-mode="1"] .leaflet-popup {
    transform: scale(0.75);
    transform-origin: center center;
    opacity: 1 !important;
    visibility: visible !important;
}

body.screenshot-ready .leaflet-popup-content-wrapper,
html[data-screenshot-mode="1"] .leaflet-popup-content-wrapper {
    opacity: 1 !important;
    visibility: visible !important;
}

.leaflet-popup-content {
    max-width: 320px;
    max-height: 80vh; /* Prevent popup from exceeding viewport */
    overflow-y: auto; /* Allow scrolling within popup if content is too tall */
    overflow-x: hidden;
    padding: 14px 16px !important;
    margin: 0 !important;
    
    /* Styled scrollbar for dark theme */
    scrollbar-width: thin; /* Firefox - thin scrollbar */
    scrollbar-color: rgba(79, 209, 255, 0.5) rgba(20, 24, 36, 0.8); /* Firefox - thumb and track colors */
}

/* Webkit scrollbar styling (Chrome, Safari, Opera) */
.leaflet-popup-content::-webkit-scrollbar {
    width: 8px; /* Width of the scrollbar */
}

.leaflet-popup-content::-webkit-scrollbar-track {
    background: rgba(20, 24, 36, 0.8); /* Dark track background */
    border-radius: 4px;
}

.leaflet-popup-content::-webkit-scrollbar-thumb {
    background: rgba(79, 209, 255, 0.5); /* Light blue thumb */
    border-radius: 4px;
    border: 1px solid rgba(20, 24, 36, 0.3);
}

.leaflet-popup-content::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 209, 255, 0.7); /* Brighter on hover */
}

/* MapLibre globe popup styling to match Leaflet */
.maplibregl-popup.globe-popup .maplibregl-popup-content {
    background: var(--dark-surface);
    color: var(--text-color);
    border-radius: 10px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
    padding: 14px;
    max-width: 240px; /* ~75% of 320px */
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 0.8rem;
}

.maplibregl-popup.globe-popup .share-button,
.maplibregl-popup.globe-popup .share-telegram-button {
    font-size: 11px;
    white-space: nowrap;
}

.maplibregl-popup.globe-popup .share-telegram-button {
    background: #0088cc !important;
    border-color: #0088cc !important;
    color: #ffffff !important;
}

.maplibregl-popup.globe-popup .maplibregl-popup-tip {
    border-top-color: var(--dark-surface) !important;
    border-bottom-color: var(--dark-surface) !important;
}

.maplibregl-popup.globe-popup .maplibregl-popup-close-button {
    color: #d1d5db;
    font-size: 16px;
}

/* Legacy media styles - now handled by .media-container */
.leaflet-popup-content video:not(.media-container video),
.leaflet-popup-content img:not(.media-container img) {
    width: auto;
    height: auto;
    max-width: 110px !important;
    max-height: 140px !important;
    object-fit: contain;
    border-radius: 4px;
}

/* Share button in popups */
.share-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    background: #303a46;
    color: white;
    border: 1px solid #3a4552;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.share-button:hover {
    background: #3b4654;
}

.share-button:active {
    background: #2a3440;
}

.share-button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.share-button.copied {
    background: #20e38f;
    border-color: #20e38f;
}

.share-telegram-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    background: #0088cc;
    color: white;
    border: 1px solid #0088cc;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
}

.share-telegram-button:hover {
    background: #0099dd;
    border-color: #0099dd;
}

.share-telegram-button:active {
    background: #0077aa;
}

.share-telegram-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}


/* Media container styling */
.leaflet-popup-content .media-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #3a4552;
    background: black;
    margin-top: 6px;
    box-sizing: border-box;
}

.leaflet-popup-content .media-container video,
.leaflet-popup-content .media-container img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    box-sizing: border-box;
}

.leaflet-popup-content .media-container.horizontal video,
.leaflet-popup-content .media-container.horizontal img {
    aspect-ratio: 16 / 9;
    object-fit: contain;
}

.leaflet-popup-content .media-container.vertical {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: black;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.leaflet-popup-content .media-container.vertical video,
.leaflet-popup-content .media-container.vertical img {
    max-width: 130px;
    max-height: 20vh; /* Use viewport height instead of fixed pixels - prevents screen shift */
    width: auto;
    height: auto;
    border: 1px solid #444;
    border-radius: 6px;
    box-sizing: border-box;
}

/* 3D globe popup media sizing (about 50% smaller) */
.maplibregl-popup.globe-popup .media-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #3a4552;
    background: black;
    margin-top: 6px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.maplibregl-popup.globe-popup .media-container video,
.maplibregl-popup.globe-popup .media-container img {
    width: 75%;
    height: auto;
    max-height: 30vh;
    display: block;
    border-radius: 6px;
    box-sizing: border-box;
}

.maplibregl-popup.globe-popup .media-container.horizontal video,
.maplibregl-popup.globe-popup .media-container.horizontal img {
    aspect-ratio: 16 / 9;
    object-fit: contain;
}

.maplibregl-popup.globe-popup .video-fullscreen-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(10, 14, 20, 0.7);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #e5e7eb;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 12px;
    cursor: pointer;
    z-index: 2;
}

/* On mobile, make media even smaller to prevent screen shift */
@media (max-width: 768px) {
    .leaflet-popup-content .media-container.vertical video,
    .leaflet-popup-content .media-container.vertical img {
        max-height: 17.5vh; /* Smaller on mobile to ensure popup fits */
    }
    
    .leaflet-popup-content .media-container.horizontal video,
    .leaflet-popup-content .media-container.horizontal img {
        max-height: 12.5vh; /* Constrain horizontal media too */
    }
}

/* --- ACCESS CODE MODAL --- */
.access-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 6, 10, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(10px);
}

.access-modal.hidden {
    display: none;
}

.access-modal-content {
    background: rgba(20, 24, 36, 0.95);
    border: 1px solid rgba(79, 209, 255, 0.3);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.access-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #4fd1ff, #005eff);
    box-shadow: 0 0 20px rgba(0, 140, 255, 0.6);
    margin: 0 auto 20px;
}

.access-modal-content h2 {
    margin: 0 0 8px;
    font-size: 20px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #f5f5f7;
}

.access-modal-content p {
    margin: 0 0 24px;
    color: #a0a4b8;
    font-size: 14px;
}

#access-code-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 18px;
    text-align: center;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 8px;
    color: #f5f5f7;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

#access-code-input:focus {
    border-color: #4fd1ff;
    box-shadow: 0 0 10px rgba(79, 209, 255, 0.3);
}

#access-submit-btn {
    width: 100%;
    padding: 14px;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: linear-gradient(135deg, #4fd1ff, #005eff);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

#access-submit-btn:hover {
    box-shadow: 0 0 20px rgba(79, 209, 255, 0.5);
    transform: translateY(-1px);
}

#access-submit-btn:active {
    transform: translateY(0);
}

.access-error {
    color: #ff4444 !important;
    margin-top: 16px !important;
    margin-bottom: 0 !important;
    min-height: 20px;
}

/* Telegram Share Modal - Popup Overlay */
.telegram-share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 6, 10, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(1px);
}

.telegram-share-modal.hidden {
    display: none;
}

/* Base Info Modal */
.base-info-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 6, 10, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    overflow-y: auto;
    padding: 20px;
}

.base-info-modal.hidden {
    display: none;
}

.base-info-modal-content {
    background: rgba(20, 24, 36, 0.98);
    border: 1px solid rgba(79, 209, 255, 0.3);
    border-radius: 18px;
    padding: 0;
    max-width: 1200px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
    position: relative;
    margin: auto;
}

.base-info-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(20, 24, 36, 0.9);
    border: 1px solid rgba(79, 209, 255, 0.3);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    color: #f5f5f7;
    z-index: 10;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.base-info-close:hover {
    background: rgba(239, 68, 68, 0.9);
    border-color: #ef4444;
    color: white;
}

#base-info-content {
    width: 100%;
}

/* Base popup within modal */
.base-info-modal-content .base-popup {
    max-height: 85vh;
}

.telegram-share-modal-content {
    background: rgba(20, 24, 36, 0.98);
    border: 1px solid rgba(79, 209, 255, 0.3);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    position: relative;
}

.telegram-share-modal-content h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #f5f5f7;
}

#telegram-share-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

#telegram-share-close:hover {
    opacity: 1;
}

#telegram-screenshot-img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #3a4552;
    display: block;
    margin: 0 auto;
}

#telegram-screenshot-loading {
    padding: 40px 20px;
    color: #a0a4b8;
}

.video-placeholder {
    width: 100%;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 20%, rgba(79, 209, 255, 0.3), rgba(15, 23, 42, 0.95));
    border-radius: 12px;
    border: 1px solid #3a4552;
}

.video-placeholder-icon {
    font-size: 32px;
    color: #4fd1ff;
    margin-bottom: 8px;
}

.video-placeholder-text {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #e5e7eb;
}

#telegram-share-post-btn,
#telegram-copy-link-btn,
#telegram-copy-img-btn,
#telegram-download-img-btn {
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    border: none;
}

#telegram-share-post-btn {
    background: #0088cc;
    color: white;
}

#telegram-share-post-btn:hover {
    background: #0099dd;
}

#telegram-copy-link-btn,
#telegram-copy-img-btn,
#telegram-download-img-btn {
    background: var(--dark-surface);
    color: var(--text-color);
    border: 1px solid #3a4552;
}

#telegram-copy-link-btn:hover,
#telegram-copy-img-btn:hover,
#telegram-download-img-btn:hover {
    background: #2a3440;
    border-color: #4a5568;
}

@media (max-width: 768px) {
    .base-info-modal {
        padding: 10px;
    }
    
    .base-info-modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 95vh;
    }
    
    .base-info-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .telegram-share-modal-content {
        max-width: 95%;
        padding: 20px;
        max-height: 85vh;
    }
    
    .telegram-share-modal-content h2 {
        font-size: 16px;
        margin-bottom: 16px;
    }
    
    #telegram-share-post-btn,
    #telegram-copy-link-btn,
    #telegram-copy-img-btn,
    #telegram-download-img-btn {
        padding: 8px 16px;
        font-size: 12px;
        flex: 1;
        min-width: 100px;
    }
}

/* Fullscreen button - shown on all devices */
.fullscreen-btn {
    display: flex; /* Show on all devices */
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(20, 24, 36, 0.9);
    border: 1px solid rgba(79, 209, 255, 0.4);
    color: #4fd1ff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.fullscreen-btn:hover {
    background: rgba(20, 24, 36, 0.95);
    border-color: rgba(79, 209, 255, 0.6);
    box-shadow: 0 4px 12px rgba(79, 209, 255, 0.3);
}

.fullscreen-btn:active {
    transform: scale(0.95);
}

.fullscreen-btn svg {
    width: 20px;
    height: 20px;
}

/* Floating action buttons for mobile quick actions */
.fab-container {
    display: none;
    position: fixed;
    bottom: 54px;
    left: 50%;
    transform: translateX(-50%);
    gap: 8px;
    z-index: 1520;
    width: calc(100% - 30px); /* 15px inset on both sides */
    justify-content: center;
}

.fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    border: 1px solid rgba(79, 209, 255, 0.35);
    background: rgba(15, 23, 42, 0.92);
    color: #e5e7eb;
    border-radius: 999px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.015em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(8px);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s ease;
}

.fab.glow {
    box-shadow: 0 0 14px rgba(79, 209, 255, 0.35), 0 6px 20px rgba(0, 0, 0, 0.4);
}

.fab:hover {
    border-color: rgba(79, 209, 255, 0.6);
    transform: translateY(-1px);
}

.fab:active {
    transform: translateY(0);
}

.fab-container.hidden {
    display: none !important;
}

/* Bottom sheet container (filters) */
.sheet {
    position: static;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    transform: none;
    height: auto;
    max-height: none;
    padding: 0;
    overflow: visible;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.sheet-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #94a3b8;
}

.sheet-close {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: #cbd5e1;
    border-radius: 8px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.sheet-close:hover {
    border-color: rgba(79, 209, 255, 0.6);
    color: #4fd1ff;
}

.sheet-content {
    padding: 0;
}

.sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
}

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 6, 10, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1300;
}

.sheet-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.filter-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.time-sheet-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.time-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.time-chip {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.9);
    color: #e5e7eb;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.time-chip.active {
    border-color: #4fd1ff;
    box-shadow: 0 0 12px rgba(79, 209, 255, 0.35), 0 4px 14px rgba(0, 0, 0, 0.35);
    background: radial-gradient(circle at 20% 20%, rgba(79, 209, 255, 0.22), rgba(15, 23, 42, 0.9));
}

.time-chip:hover {
    border-color: rgba(79, 209, 255, 0.65);
}

html[data-theme="light"] .time-chip {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .time-chip.active {
    border-color: #4fd1ff;
    background: radial-gradient(circle at 20% 20%, rgba(79, 209, 255, 0.2), rgba(255, 255, 255, 0.95));
    box-shadow: 0 0 10px rgba(79, 209, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .time-chip:hover {
    border-color: rgba(79, 209, 255, 0.6);
}

/* Light theme overrides for chips, fabs, sheets */
html[data-theme="light"] .chip {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(148, 163, 184, 0.45);
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .chip:hover {
    border-color: rgba(79, 209, 255, 0.6);
}

html[data-theme="light"] .chip-active {
    border-color: #4fd1ff;
    background: radial-gradient(circle at 20% 20%, rgba(79, 209, 255, 0.18), rgba(255, 255, 255, 0.98));
    box-shadow: 0 0 10px rgba(79, 209, 255, 0.35), 0 2px 8px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .fab {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(148, 163, 184, 0.45);
    color: #0f172a;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 0 10px rgba(79, 209, 255, 0.2);
}

html[data-theme="light"] .fab.glow {
    box-shadow: 0 0 12px rgba(79, 209, 255, 0.22), 0 4px 14px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] #filters-sheet,
html[data-theme="light"] #time-sheet {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .sheet-close {
    background: rgba(248, 250, 252, 0.95);
    border-color: rgba(148, 163, 184, 0.35);
    color: #0f172a;
}

html[data-theme="light"] .sheet-title {
    color: #334155;
}

html[data-theme="light"] .sheet-handle {
    background: rgba(148, 163, 184, 0.55);
}

html[data-theme="light"] .time-dropdown-desktop {
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(255, 255, 255, 0.95);
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .desktop-dropdown-arrow {
    color: #64748b;
}

/* Light theme overrides for chips, fabs, sheets */
html[data-theme="light"] .chip {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(148, 163, 184, 0.45);
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .chip:hover {
    border-color: rgba(79, 209, 255, 0.6);
}

html[data-theme="light"] .chip-active {
    border-color: #4fd1ff;
    background: radial-gradient(circle at 20% 20%, rgba(79, 209, 255, 0.18), rgba(255, 255, 255, 0.98));
    box-shadow: 0 0 10px rgba(79, 209, 255, 0.35), 0 2px 8px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .fab {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(148, 163, 184, 0.45);
    color: #0f172a;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 0 10px rgba(79, 209, 255, 0.2);
}

html[data-theme="light"] .fab.glow {
    box-shadow: 0 0 12px rgba(79, 209, 255, 0.22), 0 4px 14px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] #filters-sheet,
html[data-theme="light"] #time-sheet {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] .sheet-close {
    background: rgba(248, 250, 252, 0.95);
    border-color: rgba(148, 163, 184, 0.35);
    color: #0f172a;
}

html[data-theme="light"] .sheet-title {
    color: #334155;
}

/* Fullscreen mode styles */
body.fullscreen-mode {
    padding: 0 !important;
    overflow: hidden;
}

body.fullscreen-mode .geo-header,
body.fullscreen-mode .geo-tagline,
body.fullscreen-mode .geo-filters {
    display: none;
}

body.fullscreen-mode #main-content {
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    width: 100vw;
    max-width: 100vw;
}

body.fullscreen-mode #map {
    border-radius: 0;
    border: none;
    height: 100%;
    width: 100vw;
    margin-right: 0;
}

body.fullscreen-mode.sidebar-open #map {
    margin-right: 0;
}

body.fullscreen-mode .fullscreen-btn {
    background: rgba(20, 24, 36, 0.95);
}

/* Map watermark */
.map-watermark {
    position: absolute;
    bottom: 30px;
    left: 20px;
    color: #4a4a4a;
    font-family: 'Arial', sans-serif;
    font-size: 28px;
    font-weight: 500;
    letter-spacing: 0.05em;
    z-index: 1000;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    opacity: 0.7;
}

@media (max-width: 768px) {
    .map-watermark {
        font-size: 21px; /* 1.5x instead of 2x on mobile (14px * 1.5 = 21px) */
    }
}

@media (max-width: 768px) {
    body[data-view-mode="3d"] .map-watermark {
        top: auto;
        left: auto;
        bottom: 12px;
        right: 12px;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    /* Hide zoom controls on mobile */
    .leaflet-control-zoom {
        display: none !important;
    }
    
    .desktop-filters {
        display: none;
    }
    
    /* Move watermark to top-left on mobile to avoid FAB overlap */
    .map-watermark {
        top: 12px;
        left: 12px;
        bottom: auto;
    }
    
    .fab-container {
        display: none;
    }
    
    .fab {
        padding: 12px 18px;
        font-size: 12px;
        min-width: 110px;
    }
    
    /* Turn filters into a summonable bottom sheet on mobile */
    #filters-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        max-height: 80%;
        min-height: 0;
        background: rgba(12, 16, 28, 0.95);
        border-radius: 18px 18px 0 0;
        padding: 18px 18px 16px;
        box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.5);
        transform: translateY(100%);
        transition: transform 0.25s ease-out;
        z-index: 1510;
        overflow-y: auto;
        pointer-events: none;
    }
    
    #time-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        max-height: 70%;
        min-height: 0;
        background: rgba(12, 16, 28, 0.95);
        border-radius: 18px 18px 0 0;
        padding: 18px 18px 16px;
        box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.5);
        transform: translateY(100%);
        transition: transform 0.25s ease-out;
        z-index: 1510;
        overflow-y: auto;
        pointer-events: none;
    }
    
    #time-sheet.open {
        transform: translateY(0);
        pointer-events: auto;
    }
    
    #filters-sheet.open {
        transform: translateY(0);
        pointer-events: auto;
    }
    
    #filters-sheet .sheet-content {
        overflow-y: auto;
    }
    
    .sheet-header {
        display: flex;
    }
    
    /* Hide filters by default on mobile, show only when sheet is open */
    .geo-filters {
        display: none;
        gap: 10px;
        flex-direction: column;
        align-items: stretch;
        margin-top: 6px;
        margin-bottom: 6px;
    }
    
    #filters-sheet.open .geo-filters {
        display: flex;
        flex-wrap: nowrap;
        margin-bottom: 0;
    }
    
    #filters-sheet .chip {
        width: 100%;
        justify-content: flex-start;
    }
    
    .geo-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .geo-header-right {
        width: 100%;
        justify-content: space-between;
    }
    .geo-title {
        font-size: 16px;
    }

    .geo-view-toggle {
        display: none;
    }

    .prefs-language {
        display: block;
    }

    .prefs-theme-system {
        display: none;
    }

    .prefs-trigger {
        width: 34px;
        height: 34px;
        font-size: 0;
    }

    .prefs-trigger::before {
        content: "⚙";
        font-size: 16px;
        color: inherit;
    }

    .prefs-menu {
        left: 0;
        right: auto;
    }
    .geo-filters {
        gap: 6px;
    }
    .chip {
        padding: 3px 8px;
        font-size: 10px;
    }
    
    /* Sidebar below map on mobile */
    #main-content {
        flex-direction: column;
        overflow: visible;
    }
    
    body.sidebar-open #map {
        margin-right: 0;
    }
    
    /* On mobile, keep overflow visible for the body because sidebar is fixed to bottom */
    body.sidebar-open {
        overflow: visible !important; /* Keep mobile scrolling functional */
    }
    
    #sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 70vh;
        max-height: 70vh;
        transform: translateY(100%);
        border-left: none;
        border-top: 1px solid rgba(79, 209, 255, 0.3);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.45);
    }
    
    #sidebar.open {
        transform: translateY(0);
    }
    
    #map {
        border-radius: 12px;
        position: relative; /* For fullscreen button positioning */
    }
}

@media (max-width: 768px) {
    body[data-view-mode="3d"] {
        padding: 0;
        background: #05060a;
    }

    body[data-view-mode="3d"] #main-content {
        border-radius: 0;
    }
}

@media (min-width: 769px) {
    .desktop-filters {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        align-items: center;
        margin: 10px 0 6px;
    }
    
    .desktop-filters .geo-filters {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        align-items: center;
        margin: 0;
    }
    
    .desktop-filters .geo-filters .chip {
        height: 28px;
    }
    
    .desktop-separator {
        color: #cbd5e1;
        opacity: 0.7;
        margin: 0 4px;
        font-weight: 600;
    }
    
    .desktop-time-select {
        position: relative;
        display: flex;
        align-items: center;
    }
    
    .time-dropdown-desktop {
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        border-radius: 999px;
        border: 1px solid rgba(148, 163, 184, 0.35);
        background: rgba(15, 23, 42, 0.92);
        color: #e5e7eb;
        padding: 7px 28px 7px 12px;
        font-size: 12px;
        font-weight: 600;
        letter-spacing: 0.01em;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
        min-width: 140px;
        height: 28px;
        line-height: 14px;
    }
    
    .desktop-dropdown-arrow {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
        color: #94a3b8;
        font-size: 11px;
    }
    
    .desktop-filters .live-feed-btn {
        height: 28px;
    }
    
    .fab-container {
        display: none;
    }
    
    .sheet-header {
        display: none;
    }
    
    #filters-sheet {
        transform: none;
        padding: 0;
        display: none !important;
    }
    
    #time-sheet {
        transform: none;
        padding: 0;
        position: static;
        max-height: none;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        display: none !important;
    }
}

/* --- PULSING MARKER STYLES --- */

/* Pulse animation using opacity only - NO transforms to prevent position shifts */
@keyframes pulse {
    0% {
        opacity: 0.9;
    }
    50% {
        opacity: 0.3;
    }
    100% {
        opacity: 0.9;
    }
}

.pulsing-marker-container {
    width: 4px;
    height: 4px;
    position: relative;
}

.pulse-marker-ring {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    animation: pulse 1.5s infinite ease-in-out;
    /* background-color is set inline via style attribute */
}

.pulse-marker-dot {
    width: 2px;
    height: 2px;
    border-radius: 50%;
    position: absolute;
    top: 1px;
    left: 1px;
    z-index: 10;
    /* background-color is set inline via style attribute */
}

/* Pulsing animation for newly added events - opacity only */
@keyframes newPing {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
    100% {
        opacity: 1;
    }
}

.new-ping-pulse {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    animation: newPing 0.33s ease-out 3;
}

/* --- MAP MARKERS (exact replica of category-dot) --- */
.map-marker-wrapper {
    background: transparent !important;
    border: none !important;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-marker-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--marker-color, #4fd1ff);
    box-shadow:
        0 0 6px var(--marker-color, #4fd1ff),
        0 0 14px var(--marker-color, #4fd1ff),
        0 0 28px var(--marker-color, #4fd1ff);
    position: relative;
    animation: category-pulse 2s infinite ease-in-out;
    filter: saturate(1.2) brightness(1.15);
}

.map-marker-dot::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px solid var(--marker-color, #4fd1ff);
    opacity: 0.8;
    animation: neon-pulse 2.6s ease-out infinite;
}

@keyframes neon-pulse {
    0% {
        transform: scale(0.6);
        opacity: 0.9;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* --- LIGHT MODE OVERRIDES --- */
html[data-theme="light"] {
    background: #f6f7f9;
}

html[data-theme="light"] body {
    background: radial-gradient(circle at top, #eef1f4 0, #f6f7f9 55%, #ffffff 100%);
    color: #1a1a1d;
}

html[data-theme="light"] .geo-tagline {
    color: #4a5568;
}

html[data-theme="light"] .geo-meta {
    color: #64748b;
}

html[data-theme="light"] .prefs-trigger {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(148, 163, 184, 0.4);
    color: #64748b;
}

html[data-theme="light"] .prefs-trigger:hover {
    border-color: rgba(79, 209, 255, 0.6);
    color: #4fd1ff;
}

html[data-theme="light"] .prefs-menu {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .prefs-label {
    color: #64748b;
}

html[data-theme="light"] .prefs-menu button {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(148, 163, 184, 0.35);
    color: #1e293b;
}

html[data-theme="light"] .prefs-menu button:hover {
    border-color: rgba(79, 209, 255, 0.6);
    background: rgba(241, 245, 249, 1);
}

html[data-theme="light"] .prefs-menu button.active {
    border-color: #4fd1ff;
    color: #4fd1ff;
    background: rgba(79, 209, 255, 0.1);
}

html[data-theme="light"] .prefs-trigger-pulse {
    border-color: rgba(79, 209, 255, 0.6);
}

html[data-theme="light"] .prefs-hint {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(79, 209, 255, 0.4);
    color: #4fd1ff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* RTL support for preferences */
html[dir="rtl"] .prefs-hint {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

html[dir="rtl"] .prefs-menu {
    right: auto;
    left: 0;
}

html[data-theme="light"] .chip {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(148, 163, 184, 0.4);
    color: #1e293b;
}

html[data-theme="light"] .chip:hover {
    border-color: rgba(79, 209, 255, 0.6);
}

html[data-theme="light"] .chip-active {
    border-color: #4fd1ff;
    background: radial-gradient(circle at top, rgba(79, 209, 255, 0.16), rgba(255, 255, 255, 0.95));
    box-shadow: 0 0 10px rgba(79, 209, 255, 0.5);
}

html[data-theme="light"] .time-dropdown {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(148, 163, 184, 0.4);
    color: #1e293b;
}

html[data-theme="light"] .time-dropdown:hover {
    border-color: rgba(79, 209, 255, 0.6);
}

html[data-theme="light"] .time-dropdown:focus {
    border-color: #FFCC33;
    box-shadow: 0 0 10px rgba(255, 204, 51, 0.4);
}

html[data-theme="light"] .time-dropdown.time-active {
    border-color: #FFCC33;
    background: radial-gradient(circle at top, rgba(255, 204, 51, 0.16), rgba(255, 255, 255, 0.95));
    box-shadow: 0 0 10px rgba(255, 204, 51, 0.4);
}

html[data-theme="light"] .time-dropdown option {
    background: #ffffff;
    color: #1e293b;
}

html[data-theme="light"] .dropdown-arrow {
    color: #64748b;
}

html[data-theme="light"] .time-filter-wrapper:hover .dropdown-arrow {
    color: #4fd1ff;
}

html[data-theme="light"] .live-feed-btn.active {
    border-color: #20e38f;
    background: radial-gradient(circle at top, rgba(32, 227, 143, 0.2), rgba(255, 255, 255, 0.95));
    box-shadow: 0 0 12px rgba(32, 227, 143, 0.5);
}

html[data-theme="light"] #map {
    background: #f6f7f9;
    border-color: rgba(148, 163, 184, 0.25);
}

html[data-theme="light"] .leaflet-container {
    background: #f6f7f9;
}

html[data-theme="light"] .leaflet-popup-content-wrapper,
html[data-theme="light"] .leaflet-popup-tip {
    background: #ffffff;
    color: #1a1a1d;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
}

html[data-theme="light"] .leaflet-popup-content {
    color: #1a1a1d;
}

html[data-theme="light"] .leaflet-popup-content * {
    color: #1a1a1d;
}

html[data-theme="light"] .leaflet-popup-content p,
html[data-theme="light"] .leaflet-popup-content div,
html[data-theme="light"] .leaflet-popup-content span {
    color: #1a1a1d !important;
    opacity: 1 !important;
}

html[data-theme="light"] .share-button {
    background: #f1f5f9;
    color: #1e293b;
    border-color: rgba(148, 163, 184, 0.4);
}

html[data-theme="light"] .share-button:hover {
    background: #e2e8f0;
}

html[data-theme="light"] .share-button:active {
    background: #cbd5e1;
}

html[data-theme="light"] .share-button.copied {
    background: #20e38f;
    border-color: #20e38f;
    color: #ffffff;
}

html[data-theme="light"] #sidebar {
    background: rgba(255, 255, 255, 0.98);
    border-left-color: rgba(79, 209, 255, 0.3);
}

html[data-theme="light"] .sidebar-header {
    border-bottom-color: rgba(148, 163, 184, 0.2);
}

html[data-theme="light"] #sidebar h2 {
    color: #4fd1ff;
}

html[data-theme="light"] #close-sidebar {
    color: #64748b;
}

html[data-theme="light"] #close-sidebar:hover {
    background: rgba(255, 82, 82, 0.2);
    color: #FF5252;
}

html[data-theme="light"] .cluster-item {
    background: rgba(241, 245, 249, 0.9);
}

html[data-theme="light"] .cluster-item:hover {
    background: rgba(241, 245, 249, 1);
}

html[data-theme="light"] .cluster-item.active {
    background: rgba(241, 245, 249, 1);
}

html[data-theme="light"] .cluster-item-category {
    color: #64748b;
}

html[data-theme="light"] .cluster-item-text {
    color: #1a1a1d;
}

html[data-theme="light"] .fullscreen-btn {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(79, 209, 255, 0.4);
    color: #4fd1ff;
}

html[data-theme="light"] .fullscreen-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(79, 209, 255, 0.6);
    box-shadow: 0 4px 12px rgba(79, 209, 255, 0.2);
}

html[data-theme="light"] .map-watermark {
    color: #cbd5e1;
}

html[data-theme="light"] .access-modal {
    background: rgba(246, 247, 249, 0.98);
}

html[data-theme="light"] .access-modal-content {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(79, 209, 255, 0.3);
}

html[data-theme="light"] .access-modal-content p {
    color: #64748b;
}

html[data-theme="light"] #access-code-input {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(148, 163, 184, 0.4);
    color: #1a1a1d;
}

html[data-theme="light"] #access-code-input:focus {
    border-color: #4fd1ff;
    box-shadow: 0 0 10px rgba(79, 209, 255, 0.3);
}

html[data-theme="light"] .telegram-share-modal {
    background: rgba(246, 247, 249, 0.7);
}

html[data-theme="light"] .telegram-share-modal-content {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(79, 209, 255, 0.3);
}

html[data-theme="light"] .telegram-share-modal-content h2 {
    color: #1a1a1d;
}

html[data-theme="light"] #telegram-share-close {
    color: #64748b;
}

html[data-theme="light"] #telegram-screenshot-loading {
    color: #64748b;
}

html[data-theme="light"] #telegram-copy-link-btn,
html[data-theme="light"] #telegram-copy-img-btn,
html[data-theme="light"] #telegram-download-img-btn {
    background: #f1f5f9;
    color: #1e293b;
    border-color: rgba(148, 163, 184, 0.4);
}

html[data-theme="light"] #telegram-copy-link-btn:hover,
html[data-theme="light"] #telegram-copy-img-btn:hover,
html[data-theme="light"] #telegram-download-img-btn:hover {
    background: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.6);
}

html[data-theme="light"] .video-placeholder {
    background: radial-gradient(circle at 30% 20%, rgba(79, 209, 255, 0.15), rgba(241, 245, 249, 0.95));
    border-color: rgba(148, 163, 184, 0.4);
}

html[data-theme="light"] .video-placeholder-text {
    color: #1e293b;
}

html[data-theme="light"] .media-container {
    border-color: rgba(148, 163, 184, 0.4);
    background: #000000;
}

/* 3D Globe Popup Styles */
.globe-popup {
    color: #d1d5db;
    font-size: 14px;
    line-height: 1.6;
}

.globe-popup button {
    background: transparent;
    border: none;
    color: #d1d5db;
    font-size: 20px;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s ease;
}

.globe-popup button:hover {
    color: #ffffff;
}

/* --- MILITARY BASE MARKER STYLES --- */
.base-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

.base-marker-symbol {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #FF6B35;
    text-shadow:
        0 0 8px #FF6B35,
        0 0 16px #FF6B35,
        0 0 24px rgba(255, 107, 53, 0.8);
    position: relative;
    animation: category-pulse 2s infinite ease-in-out;
    filter: saturate(1.2) brightness(1.15);
    line-height: 1;
    font-family: 'Arial', 'Helvetica', sans-serif;
    border-radius: 0; /* Square shape */
}

.base-marker-symbol::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 0; /* Square border */
    border: 1px solid #FF6B35;
    opacity: 0.4;
    animation: neon-pulse 2.6s ease-out infinite;
}

/* --- BASE POPUP STYLES --- */
/* Override Leaflet popup constraints - CRITICAL FIX */
.leaflet-popup-content-wrapper {
    max-width: none !important;
}

.leaflet-popup-content {
    width: auto !important;
    max-width: 820px;
    margin: 0;
    padding: 0;
}

.base-popup-wrapper .leaflet-popup-content-wrapper {
    padding: 0;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
    width: 90%;
    max-width: 1200px;
    min-width: 600px;
}

.base-popup-wrapper .leaflet-popup-content {
    margin: 0;
    padding: 0;
    max-width: 100%;
    width: 100%;
    overflow: visible !important;
    max-height: none !important;
}

.base-popup {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: visible;
}

.base-image {
    position: relative;
    width: 100%;
    aspect-ratio: 21 / 9;
    max-height: 400px;
    background-color: #0a0f1a;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.base-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.base-image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 0%, transparent 40%, rgba(0, 0, 0, 0.3) 70%, rgba(0, 0, 0, 0.85) 100%);
    pointer-events: none;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px 24px 24px;
}

.base-popup .badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: #2563eb;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: white;
    z-index: 2;
    pointer-events: auto;
    backdrop-filter: blur(6px);
}

.base-header {
    margin-top: auto;
    z-index: 2;
    pointer-events: auto;
    width: 100%;
    max-width: 100%;
}

.base-header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.base-header .subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 6px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.base-content {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: #0f172a;
    overflow: visible;
    max-height: none;
}

.base-content .grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 18px;
}

.base-content .label {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 6px;
}

.base-content .pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.base-content .pill {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    background: rgba(37, 99, 235, 0.25);
    color: #93c5fd;
    border: 1px solid rgba(37, 99, 235, 0.35);
}

.base-content .coord {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px;
    color: #cbd5f5;
}

.base-content .actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.base-content .btn {
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #1e293b;
    background: #020617;
    color: #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
}

.base-content .btn.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.base-content .btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.base-content .btn:active {
    transform: translateY(0);
}

@media (max-width: 1000px) {
    .base-popup-wrapper .leaflet-popup-content-wrapper {
        width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
    }
    
    .base-popup-wrapper .leaflet-popup-content {
        width: 100%;
        max-width: 100%;
    }
    
    .base-popup {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 700px) {
    .base-popup-wrapper .leaflet-popup-content-wrapper {
        width: 95%;
        max-width: 95%;
        min-width: 320px;
    }
    
    .base-image {
        aspect-ratio: 21 / 9;
        max-height: 300px;
    }
    
    .base-image-overlay {
        padding: 16px 18px 20px;
    }
    
    .base-header h1 {
        font-size: 22px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    .base-header .subtitle {
        font-size: 13px;
    }
    
    .base-content {
        padding: 18px 20px 20px;
    }
    
    .base-content .grid {
        grid-template-columns: 1fr;
    }
    
    .base-content .actions {
        flex-direction: column;
    }
    
    .base-content .btn {
        width: 100%;
    }
}

/* Light theme for base popups */
html[data-theme="light"] .base-popup-wrapper .leaflet-popup-content-wrapper {
    background: #ffffff;
    border-color: rgba(148, 163, 184, 0.3);
}

html[data-theme="light"] .base-content {
    background: #ffffff;
}

html[data-theme="light"] .base-content h1 {
    color: #1a1a1d;
}

html[data-theme="light"] .base-content .subtitle {
    color: #64748b;
}

html[data-theme="light"] .base-content .label {
    color: #64748b;
}

html[data-theme="light"] .base-content .coord {
    color: #1e293b;
}

html[data-theme="light"] .base-content .btn {
    background: #f1f5f9;
    border-color: rgba(148, 163, 184, 0.4);
    color: #1e293b;
}

html[data-theme="light"] .base-content .btn.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

/* Globe container positioning */
#globe-container {
    z-index: 10;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Leaflet map container */
#leaflet-map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Ensure Leaflet map is below globe when globe is visible */
#leaflet-map .leaflet-container {
    z-index: 1;
    position: relative;
}

/* When globe is visible, hide Leaflet container */
body[data-view-mode="3d"] #leaflet-map {
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: 0;
}

/* When globe is visible, hide Leaflet panes/controls as backup */
body[data-view-mode="3d"] #leaflet-map .leaflet-pane,
body[data-view-mode="3d"] #leaflet-map .leaflet-control-container {
    z-index: 0;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Ensure Leaflet map is interactive in 2D mode */
body:not([data-view-mode="3d"]) #leaflet-map {
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 1;
}

body:not([data-view-mode="3d"]) #globe-container {
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: 0;
    display: none;
}


/* =============================================================================
   VESSEL TRACKING LAYER
   ============================================================================= */

/* Vessel status dot in the toggle button */
.vessel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 5px #f59e0b;
    opacity: 0.5;
    transition: opacity 0.2s, box-shadow 0.2s;
}

.vessel-dot.vessel-dot-active {
    opacity: 1;
    box-shadow: 0 0 8px #f59e0b, 0 0 16px rgba(245, 158, 11, 0.5);
    animation: vessel-pulse 2s infinite ease-in-out;
}

@keyframes vessel-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px #f59e0b; }
    50%       { opacity: 0.6; box-shadow: 0 0 4px #f59e0b; }
}

/* Vessel map marker icon wrapper — no Leaflet default styles */
.vessel-marker-icon {
    background: transparent !important;
    border: none !important;
}

/* Vessel popup subtle data grid */
.vessel-popup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    font-size: 12px;
    margin-bottom: 8px;
}
/* Shared viewport layout keeps controls in place when switching renderers. */
body .geo-header { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); }
.geo-header-right { width: auto; margin: 0; }
body .geo-header .geo-header-right { justify-content: flex-start; }
body .geo-meta { left: 68px; }
html[dir] .prefs-menu { position: fixed; top: max(64px, env(safe-area-inset-top)); left: 12px; right: auto; width: min(280px, calc(100vw - 24px)); box-sizing: border-box; max-height: calc(100dvh - 80px - env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.prefs-trigger { min-width: 44px; min-height: 44px; }
body .geo-tagline { bottom: calc(42px + env(safe-area-inset-bottom)); max-width: calc(100vw - 48px); font-size: 11px; pointer-events: none; }
body.sidebar-open #map { margin-right: 0; }
.leaflet-container a.leaflet-popup-close-button,
.maplibregl-popup.globe-popup .maplibregl-popup-close-button,
.sheet-close, #close-sidebar, #telegram-share-close, .base-info-close {
    width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 24px; line-height: 44px; z-index: 2;
}
.gi-popup-header { padding-inline-end: 44px; }
.base-marker-symbol { width: 16px; height: 16px; font-size: 13px; text-shadow: none; animation: none; filter: none; }
.base-marker-symbol::after { display: none; }
body:not([data-connection="live"]) .geo-status-dot,
body:not([data-connection="live"]) .live-dot { background: #d99838; box-shadow: none; animation: none; }
.map-notice { position: fixed; left: 50%; transform: translateX(-50%); bottom: 110px; z-index: 1200; padding: 12px 16px; border-radius: 12px; background: var(--dark-surface); color: var(--text-color); max-width: calc(100vw - 56px); width: max-content; box-shadow: 0 2px 12px #0006; }
.map-notice button { min-height: 44px; margin-inline-start: 8px; cursor: pointer; }
#globe-loading { bottom: 180px; }
[hidden] { display: none !important; }
@media (max-width: 768px) {
    body .geo-tagline { display: none; }
    .prefs-menu button { min-height: 44px; }
}
html[data-screenshot-mode="1"] .map-notice { display: none !important; }

/* Anchor the preferences trigger to its panel in either reading direction. */
#geo-prefs { position: fixed; left: max(12px, env(safe-area-inset-left)); right: auto; top: max(16px, env(safe-area-inset-top)); }

/* Automated capture: fixed composition, no UI animation or scroll clipping. */
html[data-screenshot-mode="1"] *, html[data-screenshot-mode="1"] *::before,
html[data-screenshot-mode="1"] *::after { animation: none !important; transition: none !important; }
html[data-screenshot-mode="1"] .geo-header,
html[data-screenshot-mode="1"] .desktop-filters,
html[data-screenshot-mode="1"] .geo-tagline,
html[data-screenshot-mode="1"] .sheet,
html[data-screenshot-mode="1"] .fab-container,
html[data-screenshot-mode="1"] #sidebar,
html[data-screenshot-mode="1"] .map-watermark,
html[data-screenshot-mode="1"] .leaflet-popup,
html[data-screenshot-mode="1"] .maplibregl-popup,
html[data-screenshot-mode="1"] .access-modal { display: none !important; }
#screenshot-card { position: fixed; z-index: 5000; top: 64px; left: 64px; width: 560px; padding: 28px; box-sizing: border-box; background: #101722; color: #e5e7eb; border: 1px solid #526176; border-radius: 16px; box-shadow: 0 8px 40px #0009; transform-origin: top left; }
#screenshot-card > div { font-size: 20px !important; line-height: 1.55 !important; }
#screenshot-card .media-container { max-height: 330px; overflow: hidden; }
#screenshot-card img { display: block; width: 100%; max-height: 330px; object-fit: contain; }
#screenshot-brand { position: fixed; bottom: 50px; left: 64px; z-index: 5000; font-size: 30px; letter-spacing: 3px; color: #91d7ed; font-weight: 700; }
#screenshot-map-note { position: fixed; bottom: 28px; left: 64px; z-index: 5000; color: #b7c5d5; font-size: 14px; }
.screenshot-country-label { color: #9facbf; text-align: center; font-size: 14px; text-shadow: 0 1px 3px #000; }
.screenshot-media-unavailable { padding: 28px; text-align: center; color: #b7c5d5; background: #202d40; }

html[data-screenshot-mode="1"] .leaflet-control-zoom { display: none !important; }

/* Mobile polish: compact time grid in the preferences menu (was 6 full-width rows) */
.prefs-time-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.prefs-time-grid .time-chip { width: 100%; font-size: 12px; }
/* Popup close buttons: the default grey (#757575) was nearly invisible on the dark card */
.leaflet-container a.leaflet-popup-close-button,
.maplibregl-popup.globe-popup .maplibregl-popup-close-button { color: #e5e7eb; }
.leaflet-container a.leaflet-popup-close-button:hover,
.maplibregl-popup.globe-popup .maplibregl-popup-close-button:hover { color: #ffffff; }

/* "N new events" pill (top centre, above the map, below menus and sheets) */
#new-events-pill {
    position: fixed;
    top: calc(max(16px, env(safe-area-inset-top)) + 56px); /* below the header row */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid rgba(79, 209, 255, 0.55);
    background: rgba(10, 14, 20, 0.92);
    color: #e5e7eb;
    font: 600 13px/1 inherit;
    letter-spacing: 0.02em;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 14px rgba(79, 209, 255, 0.25);
    backdrop-filter: blur(8px);
    cursor: pointer;
    white-space: nowrap;
    animation: new-events-in 0.35s ease-out;
}
#new-events-pill[hidden] { display: none !important; }
#new-events-pill .new-events-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ff4b4b;
    box-shadow: 0 0 0 0 rgba(255, 75, 75, 0.7);
    animation: new-events-pulse 1.6s infinite;
}
@keyframes new-events-in { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes new-events-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 75, 75, 0.7); } 70% { box-shadow: 0 0 0 9px rgba(255, 75, 75, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 75, 75, 0); } }
@media (prefers-reduced-motion: reduce) {
    #new-events-pill, #new-events-pill .new-events-dot { animation: none; }
}
html[data-screenshot-mode="1"] #new-events-pill { display: none !important; }
/* Desktop: the category filter bar occupies the top row, so sit below it */
@media (min-width: 769px) {
    #new-events-pill { top: 118px; }
}

/* --- Neon night theme: surfaces behind the map --- */
html { background: #050818; }
body { background: radial-gradient(circle at 50% 0%, #16225e 0%, #070b26 45%, #03040f 100%); }
#map-bg { background: radial-gradient(circle at 50% 38%, #14246a 0%, #080e30 42%, #03040f 100%); }
.leaflet-container { background: #060b24; }

/* Flat-map event dots: keep the dot solid and pulse only its glow (the old pulse faded the
   whole dot to 50%, so markers looked dim half the time) */
.map-marker-dot {
    width: 12px;
    height: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.95);
    box-sizing: border-box;
    animation: neon-marker-glow 2s infinite ease-in-out;
    filter: none;
}
@keyframes neon-marker-glow {
    0%, 100% { box-shadow: 0 0 4px var(--marker-color, #4fd1ff), 0 0 12px var(--marker-color, #4fd1ff), 0 0 22px var(--marker-color, #4fd1ff); }
    50% { box-shadow: 0 0 6px var(--marker-color, #4fd1ff), 0 0 18px var(--marker-color, #4fd1ff), 0 0 36px var(--marker-color, #4fd1ff); }
}
@media (prefers-reduced-motion: reduce) {
    .map-marker-dot { animation: none; }
}
