:root {
    color-scheme: dark;
    --ink: #f4f6f7;
    --muted: rgba(244, 246, 247, 0.62);
    --subtle: rgba(244, 246, 247, 0.38);
    --panel: rgba(10, 15, 19, 0.72);
    --panel-strong: rgba(10, 15, 19, 0.88);
    --line: rgba(244, 246, 247, 0.13);
    --map-tint: rgba(8, 12, 16, 0.05);
    --arrival: #55b7d8;
    --departure: #e17754;
    --selected: #f1c75b;
    --runway: #dfe6df;
    --runway-glow: rgba(241, 199, 91, 0.34);
    --taxiway: rgba(180, 196, 192, 0.62);
    --apron: rgba(180, 196, 192, 0.18);
    --paper: #081017;
}

body.light-theme {
    color-scheme: light;
    --ink: #152025;
    --muted: rgba(21, 32, 37, 0.62);
    --subtle: rgba(21, 32, 37, 0.44);
    --panel: rgba(249, 251, 248, 0.76);
    --panel-strong: rgba(249, 251, 248, 0.92);
    --line: rgba(21, 32, 37, 0.13);
    --map-tint: rgba(250, 251, 247, 0.2);
    --arrival: #19799c;
    --departure: #c65c3f;
    --selected: #9a7a1b;
    --runway: #243237;
    --runway-glow: rgba(154, 122, 27, 0.26);
    --taxiway: rgba(36, 50, 55, 0.48);
    --apron: rgba(36, 50, 55, 0.12);
    --paper: #eef2ee;
}

* {
    box-sizing: border-box;
}

html,
body,
.airspace-shell,
#airspace-map {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#airspace-map {
    position: relative;
    z-index: 0;
    background: var(--paper);
}

#airspace-map::after {
    position: absolute;
    inset: 0;
    z-index: 420;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(6, 10, 14, 0.26), transparent 35%, transparent 72%, rgba(6, 10, 14, 0.14)),
        linear-gradient(180deg, rgba(6, 10, 14, 0.06), transparent 38%, rgba(6, 10, 14, 0.16));
    content: "";
}

.light-theme #airspace-map::after {
    background:
        linear-gradient(90deg, rgba(250, 251, 247, 0.28), transparent 35%, transparent 72%, rgba(250, 251, 247, 0.2)),
        linear-gradient(180deg, rgba(250, 251, 247, 0.16), transparent 48%, rgba(250, 251, 247, 0.22));
}

.leaflet-control-attribution {
    color: rgba(24, 32, 39, 0.48);
    font-size: 10px;
}

.leaflet-control-attribution a {
    color: inherit;
}

.summary-panel,
.mode-panel,
.timeline-panel,
.tool-strip {
    position: fixed;
    z-index: 500;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(18px);
}

.summary-panel {
    top: 22px;
    left: 22px;
    width: min(366px, calc(100vw - 44px));
    padding: 20px;
}

.eyebrow {
    color: var(--selected);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1 {
    margin: 8px 0 5px;
    font-size: 27px;
    font-weight: 760;
    letter-spacing: 0;
    line-height: 1.04;
}

p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0 0;
}

.metric-grid div {
    min-width: 0;
    padding: 11px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.04);
}

.light-theme .metric-grid div {
    background: rgba(21, 32, 37, 0.035);
}

dt {
    margin: 0 0 5px;
    color: var(--subtle);
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

dd {
    margin: 0;
    color: var(--ink);
    font-size: 18px;
    font-weight: 780;
    line-height: 1;
}

.mode-panel {
    top: 22px;
    right: 22px;
    width: min(330px, calc(100vw - 44px));
    padding: 10px;
}

.segmented-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.04);
}

button {
    display: inline-grid;
    place-items: center;
    min-width: 0;
    height: 36px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 780;
}

button:hover {
    color: var(--ink);
}

button.is-active {
    background: var(--panel-strong);
    color: var(--ink);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.flow-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin-top: 10px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.04);
}

.flow-control button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 8px;
    white-space: nowrap;
}

.radius-control {
    display: block;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.04);
}

.radius-control > span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
    color: var(--subtle);
    font-size: 10px;
    font-weight: 780;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.radius-control strong {
    color: var(--ink);
    font-size: 12px;
    letter-spacing: 0;
}

.radius-control input {
    display: block;
}

.arrival-swatch,
.departure-swatch {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.arrival-swatch {
    background: var(--arrival);
}

.departure-swatch {
    background: var(--departure);
}

.tool-strip {
    top: 228px;
    right: 22px;
    display: grid;
    grid-template-columns: repeat(3, 38px);
    gap: 6px;
    padding: 7px;
}

.tool-strip button {
    height: 38px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.tool-strip svg {
    width: 17px;
    height: 17px;
    stroke-width: 2.2;
}

.track-hover-card {
    position: fixed;
    bottom: 154px;
    left: 22px;
    z-index: 510;
    width: min(315px, calc(100vw - 44px));
    padding: 15px 16px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-strong);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(18px);
    pointer-events: none;
}

.track-hover-card[hidden] {
    display: none;
}

.track-hover-kicker {
    color: var(--selected);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.track-hover-card strong {
    display: block;
    margin-top: 14px;
    color: var(--ink);
    font-size: 25px;
    font-weight: 820;
    line-height: 1;
}

.track-hover-airline {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 760;
}

.track-hover-route {
    margin-top: 15px;
    overflow: hidden;
    color: var(--ink);
    font-size: 13px;
    font-weight: 780;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-hover-detail {
    margin-top: 14px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    font-weight: 760;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-panel {
    bottom: 18px;
    left: 50%;
    width: min(1020px, calc(100vw - 44px));
    padding: 12px 14px;
    transform: translateX(-50%);
}

.timeline-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.timeline-head span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.timeline-head strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
    line-height: 1;
}

#window-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 760;
    white-space: nowrap;
}

.timeline-track {
    position: relative;
}

.hour-bars {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
    align-items: end;
    gap: 3px;
    height: 46px;
    margin-top: 5px;
    margin-bottom: 8px;
}

.hour-bar {
    position: relative;
    min-width: 0;
    height: 100%;
    border: 0;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.light-theme .hour-bar {
    background: rgba(21, 32, 37, 0.06);
}

.hour-bar span {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--arrival), var(--departure));
    opacity: 0.72;
}

.hour-bar.is-active {
    outline: 2px solid var(--selected);
    outline-offset: 1px;
}

.hour-bar.is-past {
    background: rgba(255, 255, 255, 0.05);
}

.hour-bar.is-current {
    background: rgba(255, 255, 255, 0.05);
}

.light-theme .hour-bar.is-past,
.light-theme .hour-bar.is-current {
    background: rgba(21, 32, 37, 0.06);
}

.timeline-playhead {
    position: absolute;
    top: -8px;
    bottom: 4px;
    left: 0;
    width: 1px;
    border-radius: 999px;
    background: var(--selected);
    box-shadow: 0 0 18px rgba(241, 199, 91, 0.5);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%);
    transition: left 110ms linear, opacity 180ms ease;
}

.timeline-playhead.is-visible {
    opacity: 1;
}

.timeline-playhead span {
    position: absolute;
    top: -22px;
    left: 50%;
    padding: 2px 5px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-strong);
    color: var(--ink);
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
    transform: translateX(-50%);
}

.timeline-insight {
    min-height: 16px;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--selected);
}

.leaflet-interactive:focus {
    outline: none;
}

@media (max-width: 760px) {
    body {
        overflow: hidden;
    }

    .summary-panel {
        top: 12px;
        left: 12px;
        width: calc(100vw - 24px);
        padding: 15px;
    }

    h1 {
        font-size: 23px;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .mode-panel {
        top: auto;
        right: 12px;
        bottom: 136px;
        left: 12px;
        width: auto;
    }

    .tool-strip {
        top: auto;
        right: 12px;
        bottom: 316px;
    }

    .track-hover-card {
        display: none;
    }

    .timeline-panel {
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
        padding: 12px;
        transform: none;
    }

    .timeline-head strong {
        font-size: 18px;
    }

    .flow-control button {
        padding: 0 4px;
        font-size: 11px;
    }

    .timeline-insight {
        font-size: 10px;
    }
}
