/* ===== Root Theme Configuration ===== */
:root {
    /* Base colors - Clean, minimal dark theme */
    --bg-primary: #0a0f1e;
    --bg-secondary: rgba(10, 15, 30, 0.95);
    --bg-panel: rgba(10, 15, 30, 0.95);
    --border-color: rgba(100, 150, 255, 0.25);
    --border-subtle: rgba(100, 150, 255, 0.15);

    /* Text colors - Clear hierarchy */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-tertiary: rgba(255, 255, 255, 0.6);
    --text-highlight: #6b9fff;

    /* Category colors - Saturated but not overwhelming */
    --cat-conflict: #ff6b6b;
    --cat-disaster: #ffb84d;
    --cat-political: #5b9fff;
    --cat-humanitarian: #2dd4a3;
    --cat-economic: #a78bfa;

    /* Spacing scale - Consistent 8px base unit */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Font sizes - Consistent scale */
    --font-xs: 0.75rem;
    --font-sm: 0.875rem;
    --font-md: 1rem;
    --font-lg: 1.125rem;
    --font-xl: 1.25rem;
    --font-2xl: 1.5rem;

    /* Shadows - Minimal, subtle depth only */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.3);

    /* Border radius - Consistent rounding */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Transitions - Fast, snappy for better UX */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;

    /* Z-index scale */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal: 400;
    --z-popover: 500;
    --z-tooltip: 600;
}

/* ===== Base Layout ===== */
.hidden {
    display: none !important;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

#cesiumContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ===== Header ===== */
#header {
    position: absolute;
    top: var(--space-lg);
    left: var(--space-lg);
    z-index: var(--z-fixed);
    background: var(--bg-panel);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    padding: var(--space-sm) var(--space-md);
}

.header-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header-icon {
    font-size: 1.5rem;
    color: var(--text-highlight);
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#pageTitle {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

#eventCount {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-buttons {
    display: flex;
    gap: var(--space-xs);
}

.mobile-toggle-btn {
    display: none;
    padding: var(--space-sm);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.mobile-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--text-highlight);
    color: var(--text-primary);
}

.mobile-toggle-btn i {
    font-size: 1.25rem;
}

/* ===== High Contrast Mode ===== */
[data-high-contrast="true"] {
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.95);
    --text-tertiary: rgba(255, 255, 255, 0.85);
    --border-color: rgba(255, 255, 255, 0.5);
    --border-subtle: rgba(255, 255, 255, 0.35);
    --bg-panel: rgba(0, 0, 0, 0.98);
    --bg-secondary: rgba(0, 0, 0, 0.98);
    --bg-primary: #000000;
    --text-highlight: #ffff00;
    --cat-conflict: #ff6b6b;
    --cat-disaster: #ffd93d;
    --cat-political: #6bcbff;
    --cat-humanitarian: #6bff9e;
    --cat-economic: #c46bff;
}

[data-high-contrast="true"] .filter-btn,
[data-high-contrast="true"] .layer-item,
[data-high-contrast="true"] .theme-btn {
    border-width: 2px;
    background: rgba(255, 255, 255, 0.1);
}

[data-high-contrast="true"] .category-badge {
    border-width: 2px;
}

[data-high-contrast="true"] #header,
[data-high-contrast="true"] #filterPanel,
[data-high-contrast="true"] #infoPanel,
[data-high-contrast="true"] #themeControls {
    border-width: 2px;
    background: rgba(0, 0, 0, 0.95);
}

[data-high-contrast="true"] .close-btn {
    background: rgba(255, 255, 255, 0.2);
    border-width: 2px;
}

[data-high-contrast="true"] .loading-spinner {
    border-color: rgba(255, 255, 0, 0.3);
    border-top-color: #ffff00;
}

[data-high-contrast="true"] #loadingProgress {
    background: linear-gradient(90deg, #ffff00, #6bff9e);
}

[data-high-contrast="true"] .skeleton {
    background: rgba(255, 255, 255, 0.15);
}

[data-high-contrast="true"] *:focus-visible {
    outline: 3px solid #ffff00;
    outline-offset: 3px;
}

[data-high-contrast="true"] .skip-link {
    background: #ffff00;
    color: #000;
}

/* ===== High Performance Mode ===== */
[data-high-performance="true"] #header,
[data-high-performance="true"] #filterPanel,
[data-high-performance="true"] #infoPanel,
[data-high-performance="true"] #timePlayback {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(10, 15, 30, 0.98) !important;
    box-shadow: var(--shadow-sm) !important;
}

[data-high-performance="true"] .filter-btn,
[data-high-performance="true"] .layer-item,
[data-high-performance="true"] .time-btn {
    transition: background 0.1s, border-color 0.1s !important;
}

[data-high-performance="true"] #header:hover,
[data-high-performance="true"] #filterPanel:hover {
    transform: none !important;
    box-shadow: var(--shadow-sm) !important;
}

[data-high-performance="true"] .loading-spinner {
    animation: spin 1s linear infinite !important;
}

[data-high-performance="true"] #loadingProgress::after,
[data-high-performance="true"] .skeleton::before {
    animation: none !important;
}

/* ===== Base Layout ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

/* Enhanced text readability */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: -0.02em;
}

p {
    line-height: 1.6;
}

/* ===== Focus Styles ===== */
:focus-visible {
    outline: 2px solid var(--text-highlight);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ===== Cesium Container ===== */
#cesiumContainer {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

.cesium-viewer-bottom {
    display: none;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

@keyframes markerPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes markerPopIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes markerPopOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes infoPanelIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth fade-in animations */
#header, #filterPanel, #infoPanel, #timePlayback {
    animation: fadeIn 0.3s ease forwards;
}

#header { animation-delay: 0.05s; }
#filterPanel { animation-delay: 0.1s; }
#timePlayback { animation-delay: 0.15s; }
#infoPanel { animation-delay: 0.2s; }

/* ===== Info Panel Positioning ===== */
/* Default position - left side, draggable */
#infoPanel {
    right: auto;
    left: 20px;
}

/* Info panel class styles */
.info-panel {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: var(--z-popover);
    width: 320px;
    max-width: 450px;
    min-height: 80px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    overflow: hidden;
    transition: transform var(--transition-base), width var(--transition-base), height var(--transition-base);
}

.info-panel.minimized {
    width: 200px;
    min-height: auto;
}

.info-panel.minimized .info-content,
.info-panel.minimized .panel-footer {
    display: none !important;
}

.info-panel.minimized .panel-header {
    border-bottom: none;
}

.panel-header {
    background: rgba(255, 255, 255, 0.05);
    padding: var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.panel-header:active {
    cursor: grabbing;
}

.panel-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.panel-actions {
    display: flex;
    gap: 4px;
}

.info-content {
    padding: var(--space-md);
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: var(--space-md);
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin: 0;
}

.event-content {
    display: none;
}

.event-content.active {
    display: block;
}

.event-content h2 {
    margin-bottom: var(--space-sm);
    font-size: 1.25rem;
    word-wrap: break-word;
}

.event-metadata {
    margin-top: var(--space-md);
    padding: var(--space-sm);
    border-left: 3px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.info-description-wrapper {
    margin-top: var(--space-md);
}

.info-description-wrapper p {
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.panel-footer {
    padding: var(--space-xs);
    border-top: 1px solid var(--border-subtle);
    text-align: right;
}

.toggle-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Info panel collapsed state */
#infoPanel.collapsed {
    min-height: 50px;
    max-height: 50px;
}

#infoPanel.collapsed #infoContent {
    display: none;
}

#infoPanel.collapsed #emptyState {
    display: none !important;
}

#infoPanel:not(.collapsed) #emptyState[style*="display: block"] {
    display: none !important;
}

#infoPanel.collapsed .panel-header span#panelTitle {
    display: inline;
}

#infoPanel:not(.collapsed) .panel-header span#panelTitle {
    display: none;
}

#infoPanel:not(.collapsed) #minimizeInfo {
    display: inline;
}

#infoPanel.collapsed #expandInfo {
    display: inline;
}

#infoPanel:not(.collapsed) #expandInfo {
    display: none;
}

#infoPanel:hover {
    box-shadow: var(--shadow-lg);
}

#infoPanel.hidden {
    opacity: 0;
    pointer-events: none;
}

#infoPanel:not(.hidden) {
    animation: infoPanelIn 0.3s ease forwards;
}

#infoPanel.dragging {
    cursor: grabbing;
    opacity: 0.9;
}

/* ===== Loading Indicator ===== */
#loadingIndicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: var(--z-modal);
    text-align: center;
}

.loading-content {
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: var(--space-lg) var(--space-xl);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-md);
    border: 3px solid rgba(100, 150, 255, 0.2);
    border-top-color: var(--text-highlight);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#loadingStatus {
    font-size: var(--font-md);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.loading-progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: var(--space-sm);
}

#loadingProgress {
    height: 100%;
    background: linear-gradient(90deg, var(--text-highlight), var(--cat-humanitarian));
    transition: width var(--transition-base);
}

/* Skeleton Loading */
.loading-skeleton-container {
    margin-top: var(--space-md);
    text-align: left;
}

.loading-skeleton-header {
    margin-bottom: var(--space-md);
}

.loading-skeleton-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.loading-skeleton-button-group {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.loading-skeleton-stats {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
}

.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.08));
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-title {
    height: 24px;
    width: 80%;
    margin-bottom: var(--space-sm);
}

.skeleton-text {
    height: 16px;
    width: 60%;
}

.skeleton-button {
    height: 36px;
    width: 100px;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ===== Skip Link (Accessibility) ===== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--text-highlight);
    color: #000;
    padding: var(--space-sm) var(--space-md);
    z-index: var(--z-tooltip);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
}

/* ===== Category Badge ===== */
.category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-badge.conflict {
    background: rgba(255, 107, 107, 0.2);
    color: var(--cat-conflict);
    border: 1px solid var(--cat-conflict);
}

.category-badge.disaster {
    background: rgba(255, 184, 77, 0.2);
    color: var(--cat-disaster);
    border: 1px solid var(--cat-disaster);
}

.category-badge.political {
    background: rgba(91, 159, 255, 0.2);
    color: var(--cat-political);
    border: 1px solid var(--cat-political);
}

.category-badge.humanitarian {
    background: rgba(45, 212, 163, 0.2);
    color: var(--cat-humanitarian);
    border: 1px solid var(--cat-humanitarian);
}

.category-badge.economic {
    background: rgba(167, 139, 250, 0.2);
    color: var(--cat-economic);
    border: 1px solid var(--cat-economic);
}

/* ===== Draggable Panel ===== */
.panel-header {
    background: rgba(255, 255, 255, 0.05);
    user-select: none;
}

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

.draggable-panel {
    cursor: grab;
}

.draggable-panel:active {
    cursor: grabbing;
}

#infoPanel.dragging {
    cursor: grabbing;
    opacity: 0.9;
}

/* ===== Panel Buttons ===== */
.minimize-btn,
.expand-btn,
.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.minimize-btn:hover,
.expand-btn:hover,
.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.close-btn:active {
    transform: scale(0.9);
}

/* ===== Mobile Sheet ===== */
.mobile-sheet {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: var(--bg-panel);
}

.mobile-sheet.hidden {
    display: none;
}

.mobile-sheet:not(.hidden) {
    animation: slideInUp 0.3s ease forwards;
}

.mobile-sheet.active {
    transform: translateY(0);
}

.mobile-sheet.hidden .mobile-sheet-content {
    transform: translateY(100%);
}

.mobile-sheet-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-sheet-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.mobile-sheet-content {
    background: var(--bg-panel);
    padding: var(--space-md);
    overflow-y: auto;
    max-height: 70vh;
}

.close-sheet-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.close-sheet-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Mobile Event Sheet Styles */
.mobile-event-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.mobile-event-icon {
    font-size: 2rem;
}

.mobile-event-info {
    flex: 1;
}

.mobile-event-info h2 {
    margin: 0 0 var(--space-xs);
    font-size: 1.125rem;
    font-weight: 600;
}

.mobile-event-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.mobile-event-metadata {
    background: rgba(255, 255, 255, 0.05);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.mobile-event-description {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.expand-mobile-btn {
    width: 100%;
    padding: var(--space-md);
    background: var(--text-highlight);
    border: none;
    border-radius: var(--radius-md);
    color: #000;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.expand-mobile-btn:hover {
    opacity: 0.9;
}

.expand-mobile-btn:active {
    transform: scale(0.98);
}

/* Mobile toggle buttons */
.mobile-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--font-sm);
    font-weight: 600;
    transition: all var(--transition-base);
}

.mobile-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.mobile-toggle-btn:active {
    transform: scale(0.92);
}

.mobile-toggle-btn i {
    font-size: 1.25rem;
}

/* Clear mobile filters button */
.clear-mobile-filters-btn {
    width: 100%;
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.clear-mobile-filters-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--text-highlight);
    color: var(--text-primary);
}

/* Expand mobile button */
.expand-mobile-btn {
    width: 100%;
    padding: var(--space-md);
    background: var(--text-highlight);
    border: none;
    border-radius: var(--radius-md);
    color: #000;
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.expand-mobile-btn:hover {
    background: var(--text-highlight);
    opacity: 0.9;
}

.expand-mobile-btn:active {
    transform: scale(0.98);
}

/* ===== Filter Panel ===== */
#filterPanel {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: var(--z-dropdown);
    width: 260px;
    max-height: calc(100vh - 160px);
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    transition: transform var(--transition-base), opacity var(--transition-base);
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateX(0);
}

#filterPanel.filter-panel-visible {
    display: flex;
    opacity: 1;
    transform: translateX(0);
}

/* Hide filter panel when closed */
#filterPanel:not(.filter-panel-visible) {
    display: none;
}

/* Filter toggle button */
.filter-toggle-btn {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: var(--z-dropdown);
    display: none;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
}

.filter-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--text-highlight);
}

.filter-toggle-btn i {
    font-size: var(--font-lg);
}

/* Show filter toggle button on large screens when panel is hidden */
@media (min-width: 768px) {
    .filter-toggle-btn {
        display: flex;
    }
}

/* Hide filter toggle button on mobile */
@media (max-width: 767px) {
    .filter-toggle-btn {
        display: none !important;
    }
}

.filter-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.filter-panel-header h3 {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.close-filter-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    line-height: 1;
}

.close-filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ===== Filter Panel Content ===== */
.filter-panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-md);
}

.filter-panel-content::-webkit-scrollbar {
    width: 4px;
}

.filter-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.filter-panel-content::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: var(--radius-full);
}

.filter-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-highlight);
}

/* ===== Layer Controls ===== */
#layerList {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.layer-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.layer-item.active {
    background: rgba(107, 159, 255, 0.12);
    border-color: var(--text-highlight);
}

.layer-item .layer-color {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.layer-item .layer-name {
    flex: 1;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.layer-item .layer-count {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===== Weather Layers Section ===== */
.weather-layers-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.weather-layers-section h4 {
    margin: 0 0 var(--space-md) 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.weather-layer-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.weather-layer-group .layer-item {
    margin-bottom: 0;
}

.layer-alpha-control,
.satellite-type-selector {
    margin-top: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
}

.layer-alpha-control label,
.satellite-type-selector label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
}

.layer-alpha-slider,
.satellite-select {
    width: 100%;
    padding: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-sm);
    cursor: pointer;
}

.layer-alpha-slider {
    height: 24px;
    padding: 0;
}

.layer-alpha-value {
    display: block;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

.satellite-description {
    margin: var(--space-xs) 0 0 0;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.layer-status {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
}

.layer-item.active .layer-status {
    color: var(--text-highlight);
}

/* ===== Clustering Toggle ===== */
.clustering-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    margin-top: var(--space-sm);
}

.clustering-toggle label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.clustering-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--text-highlight);
}

.clustering-status {
    font-size: var(--font-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

/* ===== Time Playback Controls ===== */
#timePlayback {
    position: absolute;
    left: 50% !important;
    bottom: 16px;
    z-index: 1000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%) !important;
    max-width: 400px;
    width: auto;
    min-width: 320px;
}

.time-controls-left,
.time-controls-right {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.time-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.time-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.time-btn:active {
    transform: scale(0.9);
}

.time-btn i {
    font-size: 1rem;
}

.timeline-container {
    flex: 1;
    margin: 0 var(--space-sm);
}

.timeline-slider {
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, var(--border-subtle), var(--text-highlight));
    border-radius: var(--radius-full);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.timeline-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--text-highlight);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.timeline-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.timeline-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--text-highlight);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: transform var(--transition-fast);
}

.timeline-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.time-display {
    min-width: 120px;
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#currentTime {
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: var(--font-sm);
    color: #ffffff;
    font-weight: 600;
    line-height: 1.3;
}

.time-display-time {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff !important;
    line-height: 1.2;
    display: block;
}

.time-display-date {
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8) !important;
    line-height: 1.2;
    display: block;
}

.time-info {
    font-weight: 600;
}

/* ===== Text Utilities ===== */
.word-wrap-break {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.truncated-text {
    display: block;
}

.full-text-container {
    display: none;
}

.full-text-container.hidden {
    display: none;
}

.full-text-container.expanded {
    display: block;
}

.toggle-description-btn {
    margin-top: var(--space-sm);
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-highlight);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition-base);
}

.toggle-description-btn:hover {
    background: rgba(107, 159, 255, 0.1);
    border-color: var(--text-highlight);
}

/* ===== Responsive Design ===== */
@media (max-width: 799px) {
    /* Full-width time playback bar at bottom */
    #timePlayback {
        left: 0 !important;
        right: 0;
        width: 100%;
        max-width: none;
        transform: none !important;
        border-radius: 0;
        border-width: 1px 0 0 0;
        padding: var(--space-sm) var(--space-md);
        min-width: 0;
        flex-wrap: nowrap;
        gap: var(--space-sm);
    }

    /* Simplified time controls for mobile - hide rewind/fast forward */
    .time-controls-right {
        display: none;
    }

    .time-controls-left .time-btn:not(#playPauseBtn) {
        display: none !important;
    }

    /* Show only play/pause button */
    #playPauseBtn {
        display: flex !important;
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    .timeline-container {
        flex: 1;
        margin: 0 var(--space-sm);
        min-width: 0;
        flex-shrink: 1;
    }

    .timeline-slider {
        width: 100%;
    }

    .time-display {
        min-width: 0;
        max-width: 120px;
        flex-shrink: 0;
    }

    #currentTime {
        font-size: 0.75rem;
    }

    .time-display-time {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .time-display-date {
        font-size: 0.6rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hide desktop filter panel */
    #filterPanel {
        display: none !important;
    }

    /* Hide desktop info panel */
    #infoPanel {
        display: none !important;
    }

    /* Header adjustments */
    #header {
        left: var(--space-md);
        right: var(--space-md);
        width: auto;
        min-height: 56px;
    }

    #header h1 {
        font-size: 1rem;
    }

    #header p {
        font-size: 0.7rem;
    }

    /* Show mobile toggle buttons */
    .mobile-toggle-btn {
        display: inline-flex !important;
    }

    /* Mobile layers sheet - 60% height when active */
    #mobileLayersSheet {
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        height: 60%;
        max-height: 60%;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    #mobileLayersSheet.hidden {
        display: none;
    }

    #mobileLayersSheet:not(.hidden) {
        display: block;
        animation: none;
    }

    #mobileLayersSheet.active {
        transform: translateY(0);
    }

    /* Mobile event sheet - 60% height, overlays playback */
    #mobileEventSheet {
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        height: 60%;
        max-height: 60%;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    #mobileEventSheet.hidden {
        display: none;
    }

    #mobileEventSheet:not(.hidden) {
        display: block;
        animation: none;
    }

    #mobileEventSheet.active {
        transform: translateY(0);
    }

    /* Mobile event sheet content - full height with scroll */
    #mobileEventSheet .mobile-sheet-content {
        max-height: none;
        height: calc(100% - 60px);
        overflow-y: auto;
        padding-bottom: var(--space-md);
    }

    /* Mobile layers sheet - 60% height when active */
    #mobileLayersSheet {
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        height: 60%;
        max-height: 60%;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    #mobileLayersSheet.hidden {
        display: none;
    }

    #mobileLayersSheet:not(.hidden) {
        display: block;
        animation: none;
    }

    #mobileLayersSheet.active {
        transform: translateY(0);
    }

    /* Mobile sheet content for 60% height */
    #mobileLayersSheet .mobile-sheet-content {
        max-height: calc(60% - 60px);
        overflow-y: auto;
    }

    /* Ensure mobile event details are visible when not hidden */
    #mobileEventDetails {
        display: none;
    }

    #mobileEventDetails:not(.hidden),
    #mobileEventDetails[style*="display: block"] {
        display: block !important;
    }

    /* Mobile event header styling */
    .mobile-event-header {
        display: flex;
        align-items: flex-start;
        gap: var(--space-md);
        margin-bottom: var(--space-md);
    }

    .mobile-event-icon {
        font-size: 2rem;
        flex-shrink: 0;
    }

    .mobile-event-info {
        flex: 1;
    }

    .mobile-event-info h2 {
        margin: 0 0 var(--space-xs);
        font-size: 1.125rem;
        font-weight: 600;
        word-wrap: break-word;
    }

    .mobile-event-date {
        font-size: 0.875rem;
        color: var(--text-secondary);
        margin-bottom: var(--space-md);
    }

    .mobile-event-metadata {
        background: rgba(255, 255, 255, 0.05);
        padding: var(--space-sm);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-md);
        font-size: 0.875rem;
        color: var(--text-tertiary);
        word-wrap: break-word;
    }

    .mobile-event-description {
        font-size: 0.95rem;
        line-height: 1.6;
        color: var(--text-secondary);
        word-wrap: break-word;
    }

    /* Layer items for mobile */
    .mobile-sheet-content .layer-item {
        min-height: 48px;
        padding: var(--space-md);
    }

    .mobile-sheet-content .weather-layers-section {
        margin-top: var(--space-lg);
        padding-top: var(--space-lg);
    }

    .mobile-sheet-content .weather-layers-section h4 {
        margin-bottom: var(--space-md);
    }

    .mobile-sheet-content .weather-layer-group {
        margin-bottom: var(--space-md);
    }
}

@media (max-width: 767px) {
    #header {
        padding: var(--space-sm) var(--space-md);
        min-height: 56px;
        background: var(--bg-panel);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-radius: var(--radius-md);
        border: 1px solid var(--border-subtle);
    }

    #header h1 {
        font-size: 1rem;
    }

    #header p {
        font-size: 0.7rem;
    }

    /* Show mobile toggle buttons */
    .mobile-toggle-btn {
        display: inline-flex !important;
    }

    .filter-btn {
        padding: var(--space-sm) var(--space-md);
        min-width: 44px;
    }

    .filter-btn .icon {
        font-size: var(--font-lg);
    }

    .filter-btn .label {
        font-size: 0.75rem;
    }

    .filter-btn .count {
        font-size: 0.7rem;
        min-width: 20px;
        height: 18px;
        line-height: 18px;
    }

    #mobileFilterSheet {
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
    }

    .mobile-sheet-header {
        padding: var(--space-md);
    }

    .mobile-sheet-header h3 {
        font-size: 1.1rem;
    }

    .mobile-sheet-content {
        padding: var(--space-md);
    }

    .layer-item {
        min-height: 48px;
        padding: var(--space-md);
    }

    .category-badge {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
}

/* Hide mobile sheets on large displays */
@media (min-width: 768px) {
    #mobileEventSheet,
    #mobileFilterSheet {
        display: none !important;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    #header {
        padding: 10px 16px;
    }

    #header h1 {
        font-size: 1.1rem;
    }

    .filter-btn {
        padding: 10px 14px;
    }

    #filterPanel {
        width: 320px;
    }

    .layer-item {
        padding: 10px;
    }
}

@media (min-width: 1024px) {
    #infoPanel {
        width: 340px;
    }

    #filterPanel {
        width: 320px;
    }
}
