:root {
    color-scheme: light;
    --ink: #182027;
    --muted: #69727a;
    --line: rgba(24, 32, 39, 0.12);
    --panel: rgba(251, 252, 250, 0.88);
    --track: #1a2744;
    --accent: #c85f41;
    --paper: #f6f7f4;
    --landmark: #8d6e56;
}

body.dark-theme {
    color-scheme: dark;
    --ink: #f4f7fb;
    --muted: rgba(244, 247, 251, 0.64);
    --line: rgba(244, 247, 251, 0.12);
    --panel: rgba(7, 11, 18, 0.42);
    --track: #f4f8ff;
    --paper: #05070d;
    --landmark: #d7b89d;
}

* {
    box-sizing: border-box;
}

html,
body {
    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;
}

.app-shell,
#map {
    width: 100%;
    height: 100%;
}

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

#map::after {
    position: absolute;
    inset: 0;
    z-index: 420;
    pointer-events: none;
    background:
        radial-gradient(circle at 73% 42%, rgba(246, 247, 244, 0) 0 25%, rgba(246, 247, 244, 0.12) 48%, rgba(246, 247, 244, 0.42) 100%),
        linear-gradient(90deg, rgba(246, 247, 244, 0.38), rgba(246, 247, 244, 0.08) 28%, rgba(246, 247, 244, 0) 74%, rgba(246, 247, 244, 0.2));
    content: "";
}

.dark-theme #map::after {
    background:
        radial-gradient(circle at 77% 45%, rgba(5, 7, 13, 0) 0 36%, rgba(5, 7, 13, 0.04) 64%, rgba(5, 7, 13, 0.15) 100%),
        linear-gradient(90deg, rgba(5, 7, 13, 0.28), rgba(5, 7, 13, 0.07) 32%, rgba(5, 7, 13, 0) 76%, rgba(5, 7, 13, 0.06));
}

.share-mode .leaflet-tile-pane {
    filter: saturate(0.32) contrast(0.82) brightness(1.02);
    opacity: 0.82;
}

.share-mode.dark-theme .leaflet-tile-pane {
    filter: saturate(0.18) contrast(0.86) brightness(1.28);
    opacity: 0.72;
}

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

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

.flight-panel,
.control-panel,
.query-panel {
    position: fixed;
    z-index: 500;
    width: min(360px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 50px rgba(31, 41, 45, 0.12);
    backdrop-filter: blur(18px);
}

.flight-panel {
    top: 24px;
    left: 24px;
    padding: 20px;
}

.query-panel {
    top: 24px;
    right: 24px;
    padding: 14px;
}

.query-panel form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.query-panel label:first-child,
.query-panel button,
.job-status {
    grid-column: span 2;
}

.query-panel label {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.query-panel span,
.job-status {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

input {
    width: 100%;
    min-width: 0;
    height: 36px;
    padding: 0 11px;
    border: 1px solid rgba(24, 32, 39, 0.16);
    border-radius: 6px;
    outline: none;
    background: rgba(255, 255, 255, 0.78);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

input:focus {
    border-color: rgba(21, 59, 86, 0.42);
    box-shadow: 0 0 0 3px rgba(21, 59, 86, 0.1);
}

button {
    height: 38px;
    border: 0;
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
}

button:disabled {
    cursor: wait;
    opacity: 0.55;
}

.share-actions {
    display: none;
    position: fixed;
    right: 28px;
    top: 28px;
    z-index: 520;
    align-items: flex-end;
    flex-direction: column;
    gap: 7px;
}

.theme-toggle,
.range-toggle,
.export-toggle {
    width: auto;
    height: 24px;
    padding: 0 8px;
    border: 0;
    border-radius: 999px;
    background: rgba(251, 252, 250, 0.24);
    color: rgba(24, 32, 39, 0.46);
    box-shadow: none;
    backdrop-filter: blur(10px);
    font-size: 9px;
    font-weight: 720;
    letter-spacing: 0.1em;
    opacity: 0.72;
    text-transform: uppercase;
}

.range-menu,
.export-menu {
    position: relative;
}

.range-options,
.export-options {
    position: absolute;
    top: 31px;
    right: 0;
    display: none;
    min-width: 104px;
    padding: 5px;
    border: 1px solid rgba(244, 247, 251, 0.08);
    border-radius: 10px;
    background: rgba(9, 12, 17, 0.72);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(14px);
}

.range-options {
    min-width: 190px;
    padding: 10px;
}

.range-menu.is-open .range-options,
.export-menu.is-open .export-options {
    display: grid;
    gap: 2px;
}

.range-menu.is-open .range-options {
    gap: 9px;
}

.export-option {
    width: 100%;
    height: 28px;
    padding: 0 9px;
    border-radius: 7px;
    background: transparent;
    color: rgba(244, 247, 251, 0.72);
    font-size: 10px;
    font-weight: 720;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
}

.range-field {
    display: grid;
    gap: 5px;
}

.range-field span {
    color: rgba(244, 247, 251, 0.46);
    font-size: 9px;
    font-weight: 760;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
}

.range-field input {
    width: 170px;
    height: 30px;
    padding: 0 8px;
    border-color: rgba(244, 247, 251, 0.1);
    border-radius: 7px;
    background: rgba(244, 247, 251, 0.06);
    color: rgba(244, 247, 251, 0.82);
    font-size: 11px;
    font-weight: 650;
}

.range-field input:focus {
    border-color: rgba(244, 247, 251, 0.24);
    box-shadow: 0 0 0 3px rgba(244, 247, 251, 0.07);
}

.range-hint {
    margin-top: -1px;
    color: rgba(244, 247, 251, 0.4);
    font-size: 9px;
    font-weight: 650;
    letter-spacing: 0.04em;
    line-height: 1.2;
    text-transform: uppercase;
}

.range-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.range-action {
    height: 28px;
    border-radius: 7px;
    background: rgba(244, 247, 251, 0.12);
    color: rgba(244, 247, 251, 0.78);
    font-size: 10px;
    font-weight: 760;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.range-action-secondary {
    background: transparent;
    color: rgba(244, 247, 251, 0.58);
}

.range-action:hover,
.range-action:focus-visible,
.export-option:hover,
.export-option:focus-visible {
    background: rgba(244, 247, 251, 0.1);
    color: rgba(244, 247, 251, 0.92);
}

.theme-toggle:hover,
.theme-toggle:focus-visible,
.range-toggle:hover,
.range-toggle:focus-visible,
.export-toggle:hover,
.export-toggle:focus-visible {
    opacity: 1;
}

.share-mode .share-actions {
    display: flex;
}

.dark-theme .theme-toggle,
.dark-theme .range-toggle,
.dark-theme .export-toggle {
    background: rgba(244, 247, 251, 0.08);
    color: rgba(244, 247, 251, 0.52);
}

.job-status {
    margin-top: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-kicker {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 34px;
    font-weight: 650;
    letter-spacing: 0;
    line-height: 1;
}

.flight-code-line {
    display: none;
    margin-top: 10px;
    color: rgba(24, 32, 39, 0.52);
    font-size: 11px;
    font-weight: 760;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.share-mode .query-panel,
.share-mode .control-panel {
    display: none;
}

.share-mode .leaflet-control-zoom {
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: none;
}

.share-mode .leaflet-control-zoom a {
    width: 27px;
    height: 27px;
    border: 0;
    background: rgba(244, 247, 251, 0.08);
    color: rgba(244, 247, 251, 0.54);
    line-height: 27px;
    backdrop-filter: blur(10px);
}

.share-mode .leaflet-control-zoom a:hover,
.share-mode .leaflet-control-zoom a:focus {
    background: rgba(244, 247, 251, 0.14);
    color: rgba(244, 247, 251, 0.82);
}

.share-mode .flight-panel {
    top: 46px;
    left: 56px;
    width: 420px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.share-mode .panel-kicker {
    display: none;
}

.share-mode h1 {
    max-width: 420px;
    font-size: 38px;
    font-weight: 760;
    line-height: 1;
}

.share-mode .title-route,
.share-mode .title-callsign {
    display: inline;
}

.share-mode .title-route {
    font-weight: 780;
}

.share-mode .title-callsign {
    margin-left: 14px;
    font-weight: 680;
}

.share-mode .flight-code-line {
    display: block;
    margin-top: 20px;
    color: rgba(24, 32, 39, 0.56);
    font-size: 14px;
    font-weight: 560;
    letter-spacing: 0;
    text-transform: none;
}

.share-mode.dark-theme .flight-code-line {
    color: rgba(244, 247, 251, 0.62);
}

.share-mode .route-label {
    display: block;
    margin-top: 6px;
    max-width: 420px;
    color: rgba(24, 32, 39, 0.56);
    font-size: 14px;
    font-weight: 560;
    line-height: 1.25;
}

.share-mode.dark-theme .route-label {
    color: rgba(244, 247, 251, 0.62);
}

.share-mode .metric-grid {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 50px;
    gap: 14px;
}

.share-mode .metric-grid dd {
    font-size: 15px;
}

.share-mode .metric-grid dt,
.share-mode .airport-metric,
.share-mode .selected-metric,
.share-mode .distance-metric {
    display: none;
}

.share-mode .flight-count-metric {
    grid-column: 1;
    display: block;
}

.share-mode .flight-count-metric dd {
    margin-top: 0;
    color: var(--ink);
    font-size: 62px;
    font-weight: 760;
    line-height: 0.84;
    letter-spacing: 0;
}

.share-mode .flight-count-metric dd::after {
    content: " real flights";
    display: block;
    margin-top: 9px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.1em;
    line-height: 1;
    text-transform: uppercase;
}

.share-mode .selected-metric {
    display: none;
}

.share-mode .airport-code {
    font-size: 22px;
}

.share-mode .airport-metric {
    padding: 0;
    border: 0;
    background: transparent;
}

.share-mode .metric-grid .metric-wide {
    grid-column: 1;
}

.share-mode .metric-grid .metric-wide:not(.airport-metric) dd {
    margin-top: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 520;
    letter-spacing: 0.01em;
}

.share-mode .period-metric {
    margin-top: 4px;
}

.route-label {
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px 14px;
    margin: 20px 0 0;
}

.metric-grid div,
.metric-grid dt,
.metric-grid dd {
    min-width: 0;
    margin: 0;
}

.metric-grid dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.metric-grid dd {
    margin-top: 5px;
    overflow: hidden;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-grid .metric-wide {
    grid-column: span 2;
}

.metric-grid .metric-wide dd {
    text-overflow: clip;
}

.airport-metric {
    padding: 10px 12px 11px;
    border: 1px solid rgba(24, 32, 39, 0.1);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.5);
}

.airport-metric dd {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding-right: 0;
    white-space: normal;
}

.airport-code {
    flex: 0 0 auto;
    color: var(--ink);
    font-size: 22px;
    font-weight: 720;
    line-height: 1;
    letter-spacing: 0;
}

.airport-name {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
}

.control-panel {
    right: 24px;
    bottom: 24px;
    display: grid;
    grid-template-columns: auto minmax(150px, 1fr);
    align-items: center;
    gap: 12px;
    padding: 14px;
}

.select-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

select {
    min-width: 0;
    height: 36px;
    padding: 0 34px 0 11px;
    border: 1px solid rgba(24, 32, 39, 0.16);
    border-radius: 6px;
    outline: none;
    background: rgba(255, 255, 255, 0.78);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

select:focus {
    border-color: rgba(21, 59, 86, 0.42);
    box-shadow: 0 0 0 3px rgba(21, 59, 86, 0.1);
}

.switch-control {
    grid-column: span 2;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-height: 30px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
}

.switch-control input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--track);
}

.airport-point-label {
    position: relative;
    pointer-events: none;
}

.airport-point {
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 5px;
    border: 1px solid rgba(250, 251, 248, 0.9);
    border-radius: 50%;
    background: rgba(24, 32, 39, 0.72);
    box-shadow: none;
    transform: translate(-50%, -50%);
}

.airport-map-code {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 26px;
    padding: 0;
    background: transparent;
    color: rgba(24, 32, 39, 0.82);
    font-size: 9px;
    font-weight: 820;
    letter-spacing: 0.02em;
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.86);
    transition: opacity 140ms ease;
    transform: translate(var(--label-x, -30px), var(--label-y, -14px));
}

.share-mode .airport-map-code {
    color: rgba(24, 32, 39, 0.76);
}

.dark-theme .airport-point {
    border-color: rgba(244, 247, 251, 0.88);
    background: rgba(244, 248, 255, 0.68);
}

.dark-theme .airport-map-code {
    color: rgba(244, 247, 251, 0.84);
    text-shadow: 0 1px 8px rgba(5, 7, 13, 0.88);
}

.landmark-marker {
    position: relative;
    color: rgba(141, 110, 86, 0.46);
    font-size: 10px;
    font-weight: 680;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.85),
        0 0 10px rgba(255, 255, 255, 0.9);
    white-space: nowrap;
}

.dark-theme .landmark-marker {
    color: rgba(190, 160, 135, 0.42);
    text-shadow: 0 1px 8px rgba(5, 7, 13, 0.72);
}

.landmark-dot {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(141, 110, 86, 0.46);
    box-shadow: 0 0 0 2px rgba(250, 251, 248, 0.28);
    transform: translate(-50%, -50%);
}

.dark-theme .landmark-dot {
    background: rgba(190, 160, 135, 0.42);
    box-shadow: 0 0 0 2px rgba(5, 7, 13, 0.22);
}

.landmark-text {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(var(--label-x), var(--label-y));
}

.landmark-marker--point-only .landmark-dot {
    opacity: 0.62;
}

.leaflet-tooltip.flight-tooltip {
    border: 1px solid rgba(24, 32, 39, 0.1);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    box-shadow: 0 8px 24px rgba(24, 32, 39, 0.12);
    font-size: 12px;
    font-weight: 650;
}

.leaflet-tooltip.route-hover-tooltip {
    border: 0;
    border-radius: 999px;
    background: rgba(244, 247, 251, 0.14);
    color: rgba(244, 247, 251, 0.82);
    box-shadow: none;
    backdrop-filter: blur(8px);
    font-size: 10px;
    font-weight: 720;
    letter-spacing: 0.06em;
}

.leaflet-tooltip.route-hover-tooltip::before {
    display: none;
}

@media (max-width: 720px) {
    .flight-panel {
        top: 14px;
        left: 14px;
        padding: 16px;
    }

    .control-panel {
        right: 14px;
        bottom: 14px;
        left: 14px;
        width: auto;
    }

    .query-panel {
        right: 14px;
        left: 14px;
        width: auto;
    }

    .flight-panel {
        top: 216px;
    }

    h1 {
        font-size: 28px;
    }

    .share-mode .flight-panel {
        top: 16px;
        left: 16px;
        width: min(360px, calc(100vw - 32px));
        padding: 18px;
    }

    .share-mode h1 {
        font-size: 32px;
        line-height: 1;
    }

    .share-mode .flight-code-line {
        margin-top: 14px;
        font-size: 13px;
    }

    .share-mode .route-label {
        font-size: 13px;
    }

    .share-mode .metric-grid {
        margin-top: 36px;
    }

    .share-mode .flight-count-metric dd {
        font-size: 54px;
    }

}
