body, #globeViz, canvas {
    margin: 0;
    background: #000;
    overflow: hidden;
}
#controls {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    max-width: calc(100vw - 16px);
    pointer-events: none;
}
#arc-key, #busiest-key, #longest-key, #bottom-row {
    pointer-events: auto;
}
.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 180, 220, 0.65);
    font-family: monospace;
    font-size: 0.78em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    user-select: none;
    cursor: pointer;
    padding: 4px 10px;
    border: 1px solid rgba(0, 180, 220, 0.4);
    border-radius: 2px;
    background: transparent;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chip:has(input:checked) {
    background: rgba(0, 180, 220, 0.18);
    border-color: #00d4ff;
    color: #00d4ff;
}
.chip:hover {
    background: rgba(0, 180, 220, 0.1);
    border-color: rgba(0, 180, 220, 0.65);
    color: #00d4ff;
}
.chip:has(input:checked):hover {
    background: rgba(0, 180, 220, 0.26);
}
.chip input[type="checkbox"] {
    display: none;
}
.seg-ctrl {
    display: inline-flex;
    border: 1px solid rgba(0, 180, 220, 0.5);
    overflow: hidden;
}
.seg-btn {
    padding: 4px 10px;
    background: transparent;
    border: none;
    border-right: 1px solid rgba(0, 180, 220, 0.35);
    color: rgba(0, 180, 220, 0.5);
    font-family: monospace;
    font-size: 0.78em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    outline: none;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.seg-btn:last-child {
    border-right: none;
}
.seg-btn.active {
    background: rgba(0, 180, 220, 0.18);
    color: #00d4ff;
}
.seg-btn:hover:not(.active) {
    background: rgba(0, 180, 220, 0.1);
    color: rgba(0, 180, 220, 0.85);
}
#heatmap-mode-seg {
    display: inline-flex;
}
.seg-short {
    display: none;
}
#bottom-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(0, 180, 220, 0.4);
    border-top: 2px solid rgba(0, 200, 255, 0.6);
    padding: 8px 10px;
}
#heatmap-extra {
    display: none;
    align-items: center;
    gap: 8px;
}
#heatmap-extra.visible {
    display: flex;
}
.ctrl-sep {
    color: rgba(0, 180, 220, 0.45);
    font-family: monospace;
    user-select: none;
}
#top-right {
    position: fixed;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10;
}
#recenter-btn {
    display: none;
    background: rgba(0, 180, 220, 0.08);
    border: 1px solid rgba(0, 180, 220, 0.7);
    color: #00d4ff;
    font-family: monospace;
    font-size: 0.78em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 10px;
    user-select: none;
    outline: none;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
#recenter-btn.visible {
    display: inline-block;
}
#recenter-btn:hover {
    background: rgba(0, 180, 220, 0.22);
    border-color: #00d4ff;
    color: #fff;
}
#recenter-btn:active {
    background: rgba(0, 180, 220, 0.35);
}
#fullscreen-btn {
    background: rgba(0, 180, 220, 0.08);
    border: 1px solid rgba(0, 180, 220, 0.7);
    color: #00d4ff;
    font-family: monospace;
    font-size: 0.78em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 10px;
    user-select: none;
    outline: none;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
#fullscreen-btn:hover {
    background: rgba(0, 180, 220, 0.22);
    border-color: #00d4ff;
    color: #fff;
}
#fullscreen-btn:active {
    background: rgba(0, 180, 220, 0.35);
}
#fullscreen-btn.active {
    background: rgba(0, 180, 220, 0.18);
    border-color: rgba(0, 180, 220, 0.5);
    color: #00d4ff;
}
body.ui-hidden #controls {
    display: none !important;
}
#last24h-btn, #video-play-btn {
    background: rgba(0, 180, 220, 0.08);
    border: 1px solid rgba(0, 180, 220, 0.7);
    color: #00d4ff;
    font-family: monospace;
    font-size: 0.78em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 10px;
    user-select: none;
    outline: none;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
#last24h-btn:hover, #video-play-btn:hover {
    background: rgba(0, 180, 220, 0.22);
    border-color: #00d4ff;
    color: #fff;
}
#last24h-btn:active, #video-play-btn:active {
    background: rgba(0, 180, 220, 0.35);
}
#last24h-btn.active, #video-play-btn.active {
    background: rgba(0, 180, 220, 0.25);
    border-color: #00d4ff;
    color: #fff;
}
#video-play-btn {
    display: none;
}
#heatmap-slider-wrap {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 260px;
    gap: 2px;
}
#heatmap-slider-wrap.visible {
    display: flex;
}
#slider-day-ticks {
    position: relative;
    height: 14px;
    width: 100%;
    pointer-events: none;
}
.slider-day-tick {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.slider-day-tick-line {
    width: 1px;
    height: 4px;
    background: rgba(0, 180, 220, 0.55);
}
.slider-day-tick-label {
    color: rgba(0, 180, 220, 0.65);
    font-family: monospace;
    font-size: 0.58em;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
#heatmap-time {
    width: 100%;
    cursor: pointer;
    appearance: none;
    height: 4px;
    background: rgba(0, 180, 220, 0.08);
    border: 1px solid rgba(0, 180, 220, 0.7);
    outline: none;
}
#heatmap-time::-webkit-slider-thumb {
    appearance: none;
    width: 10px;
    height: 18px;
    background: #00d4ff;
    cursor: pointer;
    border: none;
}
#heatmap-time::-moz-range-thumb {
    width: 10px;
    height: 18px;
    background: #00d4ff;
    cursor: pointer;
    border: none;
    border-radius: 0;
}
#heatmap-time:disabled {
    cursor: default;
    border-color: rgba(0, 180, 220, 0.5);
}
#heatmap-time:disabled::-webkit-slider-thumb {
    cursor: default;
    background: #4a6a72;
}
#heatmap-time:disabled::-moz-range-thumb {
    cursor: default;
    background: #4a6a72;
}
#heatmap-progress {
    display: none;
    align-items: center;
    gap: 6px;
    width: 260px;
}
#heatmap-progress-bar {
    flex: 1;
    height: 4px;
    background: #1a3a44;
    border: 1px solid rgba(0, 180, 220, 0.5);
    position: relative;
    overflow: hidden;
}
#heatmap-progress-fill {
    height: 100%;
    background: #00d4ff;
    width: 0%;
}
#heatmap-progress-count {
    color: #00d4ff;
    font-family: monospace;
    font-size: 0.7em;
    letter-spacing: 0.08em;
    white-space: nowrap;
}
#video-download-btn {
    background: rgba(0, 180, 220, 0.08);
    border: 1px solid rgba(0, 180, 220, 0.7);
    color: #00d4ff;
    font-family: monospace;
    font-size: 0.78em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 10px;
    user-select: none;
    outline: none;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
#video-download-btn:hover {
    background: rgba(0, 180, 220, 0.22);
    border-color: #00d4ff;
    color: #fff;
}
#video-download-btn:active {
    background: rgba(0, 180, 220, 0.35);
}

button, label, input[type="checkbox"], input[type="range"] {
    touch-action: manipulation;
}

#arc-key, #busiest-key, #longest-key {
    align-self: flex-start;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(0, 180, 220, 0.4);
    border-top: 2px solid rgba(0, 200, 255, 0.6);
}
#arc-key-toggle, #busiest-key-toggle, #longest-key-toggle {
    color: rgba(0, 180, 220, 0.6);
    font-family: monospace;
    font-size: 0.68em;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: 5px 10px 3px;
    user-select: none;
    cursor: pointer;
}
#busiest-key-toggle, #longest-key-toggle {
    color: #00d4ff;
}
#arc-key-body {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 2px 10px 8px;
}
#arc-key-body.visible { display: flex; }
#busiest-key-body {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 6px;
}
#busiest-key-body.visible { display: flex; }
.key-item {
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(0, 180, 220, 0.8);
    font-family: monospace;
    font-size: 0.7em;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
}
.key-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.busiest-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(0, 180, 220, 0.85);
    font-family: monospace;
    font-size: 0.68em;
    letter-spacing: 0.08em;
    white-space: nowrap;
    cursor: pointer;
    padding: 3px 8px 3px 10px;
    background: rgba(0, 180, 220, 0.05);
    border: 1px solid rgba(0, 180, 220, 0.25);
    transition: background 0.12s, border-color 0.12s;
}
.busiest-row:hover {
    background: rgba(0, 180, 220, 0.18);
    border-color: rgba(0, 180, 220, 0.7);
}
.busiest-row:active {
    background: rgba(0, 180, 220, 0.28);
}
.busiest-rank {
    color: rgba(0, 180, 220, 0.7);
    width: 10px;
    text-align: right;
    flex-shrink: 0;
}
.busiest-code {
    font-weight: bold;
    color: #00d4ff;
    width: 30px;
    flex-shrink: 0;
}
.busiest-out {
    color: #00e676;
    min-width: 36px;
    text-align: right;
}
.busiest-in {
    color: #ff6d00;
    min-width: 36px;
    text-align: right;
}
.busiest-select-btn {
    background: none;
    border: none;
    color: rgba(0, 180, 220, 0.6);
    font-family: monospace;
    font-size: 0.75em;
    cursor: pointer;
    padding: 0;
    margin: 0;
    margin-left: auto;
    user-select: none;
    outline: none;
    flex-shrink: 0;
    line-height: 1;
}
#longest-key-body {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 6px;
}
#longest-key-body.visible { display: flex; }
.flight-route {
    color: #00d4ff;
    font-weight: bold;
    min-width: 50px;
}
.longest-dist {
    color: #00e676;
    min-width: 58px;
    flex-shrink: 0;
}


@media (max-width: 600px) {
#recenter-btn, #fullscreen-btn {
        padding: 8px 10px;
        font-size: 1em;
    }
    .recenter-text, .fullscreen-text {
        display: none;
    }

    #controls {
        left: 0;
        right: 0;
        bottom: 0;
        max-width: none;
    }
    #bottom-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 12px;
        padding: 10px 12px;
        border-left: none;
        border-right: none;
        border-bottom: none;
        width: 100%;
        box-sizing: border-box;
    }

    .chip {
        font-size: 0.85em;
        padding: 8px 10px;
        width: 100%;
        box-sizing: border-box;
    }

    #airports-label {
        order: 1;
    }
    #bordermap-label {
        order: 2;
    }
    #autopilot-label {
        order: 3;
    }
    #heatmap-label {
        order: 4;
    }
    #heatmap-mode-seg {
        order: 5;
        grid-column: 1 / -1;
        width: 100%;
    }
    #heatmap-extra {
        order: 6;
    }
    #heatmap-mode-seg .seg-btn {
        flex: 1;
        padding: 8px 10px;
        font-size: 0.85em;
    }
    .seg-short { display: inline; }
    .seg-long { display: none; }

    #heatmap-extra {
        grid-column: 1 / -1;
        flex-wrap: wrap;
        gap: 8px;
    }
    #heatmap-extra .ctrl-sep {
        display: none;
    }

    #last24h-btn, #video-play-btn, #video-download-btn {
        font-size: 0.85em;
        padding: 6px 12px;
    }

    #heatmap-slider-wrap {
        flex: 1;
        min-width: 0;
        max-width: none;
    }
    #heatmap-progress {
        flex: 1;
        min-width: 0;
        max-width: none;
    }

    .busiest-row {
        min-height: 44px;
        gap: 10px;
        font-size: 0.82em;
        padding: 0 10px 0 12px;
    }
    #busiest-key-body, #longest-key-body {
        gap: 3px;
        max-height: 58vh;
        max-height: 58svh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #busiest-key-toggle, #longest-key-toggle {
        padding: 10px 12px;
        font-size: 0.8em;
    }
}
