[hidden] { display: none !important; }

:root {
    color-scheme: dark;
    --bg: #070a0f;
    --surface: rgba(255,255,255,0.055);
    --border: rgba(255,255,255,0.12);
    --text: #f5f7fb;
    --muted: #9ba7b7;
    --accent: #77f2ca;
    --danger: #ff7272;
    --shadow: 0 24px 70px rgba(0,0,0,0.38);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 80% 10%, rgba(42,104,144,0.2), transparent 26rem),
        radial-gradient(circle at 8% 90%, rgba(50,130,110,0.12), transparent 24rem),
        linear-gradient(145deg, #05070b, #0b111a 55%, #080b11);
}

body.modal-open { overflow: hidden; }

button, input, select { font: inherit; }

.app-shell {
    width: min(1480px, calc(100% - 36px));
    margin: 0 auto;
    padding: 18px 0 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    align-items: flex-end;
    min-height: 76px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.brand,
.eyebrow,
.label,
.event-topline,
.timeline-range,
.metric-topline,
.speed-control,
.modal-summary span {
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.brand { color: var(--accent); font-size: 0.72rem; font-weight: 800; }
.eyebrow { margin-top: 9px; color: var(--muted); font-size: 0.62rem; }

.top-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pill-button,
.speed-control {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
}

.pill-button {
    padding: 0 15px;
    cursor: pointer;
    color: var(--text);
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 10px 0 13px;
    color: var(--muted);
    font-size: 0.58rem;
}

.speed-control select {
    color: var(--text);
    border: 0;
    background: transparent;
}

.speed-control option { color: #111; }

.hero-grid {
    display: grid;
    grid-template-columns: minmax(230px, 0.68fr) minmax(460px, 1.32fr);
    gap: 14px;
    padding-top: 14px;
}

.year-card,
.event-card,
.timeline-controls,
.metrics-section,
.metric-card {
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.year-card {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 22px;
}

.label { color: var(--muted); font-size: 0.6rem; }

#currentYear {
    font-size: clamp(3rem, 6vw, 6rem);
    line-height: 0.9;
    letter-spacing: -0.06em;
}

.era-label { color: var(--accent); font-size: 0.8rem; }

.event-card {
    min-height: 200px;
    padding: 22px 26px;
}

.event-topline {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.58rem;
}

.event-card h1 {
    margin: 24px 0 8px;
    font-size: clamp(2rem, 4vw, 4.4rem);
    line-height: 0.92;
    letter-spacing: -0.05em;
}

.event-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.impact-row {
    display: grid;
    grid-template-columns: auto minmax(100px, 240px) auto;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.impact-track,
.progress-track {
    overflow: hidden;
    background: rgba(255,255,255,0.09);
}

.impact-track { height: 4px; border-radius: 999px; }

#impactFill,
#progressFill {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 180ms ease;
}

.timeline-controls {
    margin-top: 14px;
    padding: 14px 20px;
}

.timeline-range {
    display: grid;
    grid-template-columns: 36px 1fr 1fr 36px;
    gap: 12px;
    align-items: center;
    color: var(--muted);
    font-size: 0.58rem;
}

.timeline-range span:nth-of-type(2) { text-align: right; }

.timeline-range button {
    width: 36px;
    height: 36px;
    cursor: pointer;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
}

#timelineSlider {
    width: 100%;
    margin: 16px 0 9px;
    accent-color: var(--accent);
}

.progress-track { height: 2px; }

.metrics-section {
    margin-top: 14px;
    padding: 14px;
}

.section-heading {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: end;
    margin-bottom: 10px;
}

.section-heading h2 {
    margin: 6px 0 0;
    font-size: clamp(1.5rem, 2.5vw, 2.8rem);
    line-height: 0.95;
    letter-spacing: -0.04em;
}

.section-heading p {
    max-width: 390px;
    margin: 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 11px;
}

.metric-card {
    min-height: 184px;
    padding: 14px;
    cursor: pointer;
    box-shadow: none;
    transition: transform 160ms ease, border-color 160ms ease;
}

.metric-card:hover,
.metric-card:focus-visible {
    transform: translateY(-3px);
    outline: none;
    border-color: rgba(119,242,202,0.42);
}

.metric-card.is-unavailable { opacity: 0.42; }

.metric-topline {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.49rem;
}

.metric-body {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.metric-card h3 {
    margin: 18px 0 5px;
    color: var(--muted);
    font-size: 0.75rem;
}

.metric-card strong {
    display: block;
    font-size: clamp(1.7rem, 2.7vw, 3rem);
    line-height: 0.95;
    letter-spacing: -0.05em;
}

.metric-card p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.61rem;
}

.expand-button {
    width: 30px;
    height: 30px;
    margin-top: 16px;
    cursor: pointer;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50%;
    background: rgba(255,255,255,0.035);
}

.sparkline {
    width: 100%;
    height: 62px;
    margin-top: 8px;
    overflow: visible;
    color: var(--accent);
}

.spark-line {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    vector-effect: non-scaling-stroke;
}

.spark-cursor {
    stroke: rgba(255,255,255,0.32);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    vector-effect: non-scaling-stroke;
}

.spark-dot {
    fill: var(--accent);
    stroke: #07100d;
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(1,4,8,0.76);
    backdrop-filter: blur(12px);
}

.modal-dialog {
    position: absolute;
    inset: min(5vh, 48px) max(3vw, 20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 26px;
    background: #0b1017;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 26px 12px;
}

.modal-header h2 {
    margin: 7px 0 4px;
    font-size: clamp(2rem, 4vw, 4.4rem);
    line-height: 0.92;
}

.modal-header p { margin: 0; color: var(--muted); }

.close-button {
    width: 44px;
    height: 44px;
    cursor: pointer;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    font-size: 1.7rem;
}

.modal-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 0 26px 12px;
}

.modal-summary > div {
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 14px;
    background: rgba(255,255,255,0.035);
}

.modal-summary span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.52rem;
}

.expanded-chart {
    flex: 1;
    min-height: 350px;
    margin: 0 12px 12px;
}

.screen-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-content: center;
    text-align: center;
    background: #070a0f;
    transition: opacity 400ms ease;
}

.screen-overlay.is-hidden { opacity: 0; }

.loader {
    width: 42px;
    height: 42px;
    margin: 0 auto 16px;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

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

@media (max-width: 1100px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
    .topbar,
    .section-heading,
    .hero-grid {
        grid-template-columns: 1fr;
        display: grid;
    }

    .top-actions { justify-content: flex-start; }

    .metrics-grid { grid-template-columns: 1fr; }

    .modal-dialog { inset: 12px; }

    .modal-summary { grid-template-columns: 1fr; }
}
