:root {
    --bg-glass: rgba(18, 18, 22, 0.7);
    --border-glass: rgba(255, 255, 255, 0.09);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #2563eb;
    --primary-hover: #3b82f6;
    --primary-glow: rgba(37, 99, 235, 0.4);
    --shadow-color: rgba(0, 0, 0, 0.6);
    --radius-panel: 16px;
    --radius-button: 8px;
    --font-header: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    font-family: var(--font-body);
    background-color: #0c0a09;
    overflow: hidden;
}

/* Fullscreen Map */
#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Glassmorphic Panel Base */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    box-shadow: 0 12px 40px 0 var(--shadow-color);
    border-radius: var(--radius-panel);
    color: var(--text-primary);
    z-index: 1000;
}

.glass-panel.hidden {
    display: none !important;
}

/* Hover Value Panel (Top Center) */
#hover-panel {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 20px;
    min-width: 160px;
    text-align: center;
    pointer-events: none; /* Let clicks pass through to map */
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.hover-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.hover-value {
    font-family: var(--font-header);
    font-size: 1.5rem;
    font-weight: 800;
    color: #38bdf8; /* sky blue */
    margin: 4px 0;
}

.hover-coords {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

/* Main Dashboard Control Panel (Bottom Center) */
#control-panel {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 680px;
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
}

header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

header .rain-icon {
    font-size: 1.15rem;
    color: #3b82f6;
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

header h1 {
    margin: 0;
    font-family: var(--font-header);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

header h1 .badge {
    font-size: 0.65rem;
    font-family: var(--font-body);
    font-weight: 600;
    background: var(--primary-color);
    padding: 1px 6px;
    border-radius: 999px;
    margin-left: 4px;
    vertical-align: middle;
}

header .ref-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

header .ref-time .value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Timeline Display */
.timeline-display {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.timeline-display .time-step {
    font-family: var(--font-header);
    font-size: 1.0rem;
    font-weight: 600;
}

.timeline-display .time-relative {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Timeline Slider */
.slider-container {
    position: relative;
    width: 100%;
}

#time-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

#time-slider:hover {
    background: rgba(255, 255, 255, 0.25);
}

#time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-primary);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.5), 0 0 0 3px var(--primary-glow);
    transition: transform 0.1s ease, background-color 0.1s ease;
}

#time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: var(--primary-hover);
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0 4px;
    margin-top: 4px;
}

.slider-ticks span {
    width: 1px;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.slider-ticks span.hour-tick {
    height: 6px;
    background: rgba(255, 255, 255, 0.4);
    position: relative;
}

/* Playback Control Row */
.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-controls button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
}

.player-controls button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.player-controls button:active {
    transform: translateY(1px);
}

.player-controls button.btn-primary {
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-glow);
    font-size: 1.0rem;
    width: 38px;
    height: 38px;
}

.player-controls button.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 14px var(--primary-glow);
}

/* Setting Groups */
.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.setting-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.setting-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 65px;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    cursor: pointer;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-primary);
}

.setting-group input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
}

.setting-val {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 34px;
    text-align: right;
}

/* Bottom Row (Ensemble Selection and Legend) */
.bottom-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .bottom-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.section-label {
    display: block;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Ensemble Member Selector Dropdown */
.ensemble-select-container {
    width: 100%;
}

.glass-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: rgba(30, 41, 59, 0.65);
    background-image: url("data:image/svg+xml;utf8,<svg fill='%23f8fafc' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 6px 32px 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-button);
    cursor: pointer;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.glass-select:hover, .glass-select:focus {
    background-color: rgba(30, 41, 59, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.05);
}

.glass-select optgroup {
    background: #0f172a;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
}

.glass-select option {
    background: #1e293b;
    color: var(--text-primary);
    font-size: 0.8rem;
    padding: 6px;
}

/* Legend Panel */
.legend-container {
    width: 100%;
}

.legend-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 6px;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

.legend-bar span {
    flex: 1;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Customized MapLibre GL Navigation Control Styles */
.maplibregl-ctrl-group {
    background: var(--bg-glass) !important;
    border: 1px solid var(--border-glass) !important;
    box-shadow: 0 4px 12px var(--shadow-color) !important;
    border-radius: 8px !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
}

.maplibregl-ctrl-group button {
    background: transparent !important;
    border-bottom: 1px solid var(--border-glass) !important;
    color: var(--text-primary) !important;
    transition: background-color 0.2s ease;
}

.maplibregl-ctrl-group button:last-child {
    border-bottom: none !important;
}

.maplibregl-ctrl-group button:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}


/* Chart Panel (Location Time-Series) */
#chart-panel {
    position: absolute;
    top: 120px;
    right: 24px;
    width: 340px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}

/* Hide scrollbar but keep functionality */
#chart-panel::-webkit-scrollbar {
    display: none;
}
#chart-panel {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Close Button styling */
.chart-close-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, transform 0.1s ease;
}

.chart-close-btn:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

/* Chart Header */
.chart-header h3 {
    margin: 0;
    font-family: var(--font-header);
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 20px; /* Don't overlap with close button */
}

.chart-header-icon {
    color: #a855f7; /* purple accent */
}

.chart-coords {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-family: monospace;
}

/* Chart Container */
.chart-container {
    width: 100%;
    position: relative;
    height: 180px;
}

/* Statistics Grid */
.chart-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
}

.stat-box .stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-box .stat-val {
    font-family: var(--font-header);
    font-size: 1.05rem;
    font-weight: 700;
    color: #38bdf8; /* sky blue */
}

