:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #ebf5ff;
    background: #050912;
    --subtle: #9fadc4;
    --cyan: #73e3f2;
    --border: #6686ad3b;
}

* { box-sizing: border-box; }
body { margin: 0; }
main { position: relative; min-height: 540px; height: 100dvh; overflow: hidden; }
#scene, .labels { position: absolute; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.labels { pointer-events: none; overflow: hidden; }

header {
    position: absolute;
    inset: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 20px clamp(18px, 4vw, 56px);
    border-bottom: 1px solid var(--border);
    background: #090f1bea;
}

.mission-name { display: flex; align-items: center; gap: 14px; font-weight: 550; }
.course, #mission-id, .eyebrow, #elapsed, .endpoints {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}
.course { color: var(--cyan); border-right: 1px solid var(--border); padding-right: 14px; }
#mission-id, #elapsed { color: var(--subtle); font-size: .81rem; }

.telemetry {
    position: absolute;
    top: clamp(92px, 13vh, 140px);
    left: clamp(18px, 4vw, 56px);
    pointer-events: none;
    text-shadow: 0 2px 12px #050912;
}
.eyebrow { margin: 0 0 7px; color: var(--cyan); font-size: .78rem; letter-spacing: .11em; text-transform: uppercase; }
h1 { margin: 0 0 13px; font-size: clamp(2.15rem, 4vw, 4.4rem); font-weight: 590; line-height: 1; letter-spacing: -.055em; }
#epoch { margin: 0 0 4px; font-size: 1.06rem; }
#elapsed { margin: 0; }

.marker {
    position: absolute;
    top: 0;
    left: 0;
    padding: 3px 6px;
    border-radius: 4px;
    background: #070c17c9;
    color: #f4f7ff;
    font-size: .84rem;
    font-weight: 600;
    white-space: nowrap;
}
.marker.sun { color: #ffd18f; }
.marker.earth { color: #9bd7ff; }
.marker.mars { color: #ffb897; }
.marker.craft { color: var(--cyan); }
.marker[hidden] { display: none; }

footer {
    position: absolute;
    inset: auto clamp(18px, 4vw, 56px) 18px;
}
.playback {
    display: grid;
    gap: 12px;
    padding: 15px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #0b1323ef;
    box-shadow: 0 8px 40px #0008;
}
.preferences {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(80px, .32fr) minmax(0, 1fr);
    gap: clamp(8px, 2vw, 22px);
}
.control { display: grid; gap: 5px; min-width: 0; color: var(--subtle); font-size: .81rem; }
.control select { width: 100%; }
.transport { display: flex; align-items: center; gap: clamp(8px, 2vw, 22px); }
.mission-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#play-mission { border-color: #73e3f280; color: #b2f6ff; }
#show-settings { margin-left: auto; }
#settings-status { margin: 0; color: #ffcfaa; font-size: .81rem; }
#settings {
    width: min(92vw, 620px);
    max-height: 85dvh;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: clamp(12px, 3vw, 24px);
    background: #0b1323;
    color: inherit;
}
#settings::backdrop { background: #050912bf; }
#settings h2 { margin: 0; font-size: 1.25rem; }
#playback-duration { margin: 8px 0; color: var(--subtle); font-size: .9rem; }
.settings-table { max-height: 50dvh; overflow: auto; margin: 12px 0; }
.settings-table table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.settings-table th, .settings-table td { padding: 7px; text-align: left; border-bottom: 1px solid var(--border); }
.settings-table th { color: var(--subtle); }
.settings-table td:nth-child(2) { font-variant-numeric: tabular-nums; }
#settings .mission-actions { justify-content: space-between; }
button, select {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 12px;
    color: inherit;
    background: #142236;
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
button:hover, select:hover { background: #1d3149; }
#play { min-width: 78px; color: #061b24; background: var(--cyan); font-weight: 700; }
#play:hover { background: #b2f6ff; }
button:disabled, select:disabled { cursor: default; opacity: .55; }
.timeline { flex: 1; min-width: 0; }
input[type="range"] { width: 100%; accent-color: var(--cyan); margin: 0; cursor: pointer; }
.endpoints { display: flex; justify-content: space-between; gap: 4px; margin: 3px 0 0; color: var(--subtle); font-size: .72rem; }
.context { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 15px; margin: 10px 2px 0; color: var(--subtle); font-size: .75rem; }
.context a { color: inherit; }
#error { position: absolute; top: 42%; left: 50%; transform: translateX(-50%); width: min(90%, 420px); padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: #291524; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 640px) {
    header { flex-wrap: wrap; padding-block: 11px; }
    #mission-id { width: 100%; }
    .playback { padding: 10px; }
    .preferences { grid-template-columns: minmax(0, 1fr) minmax(80px, .38fr); }
    .control:last-child { grid-column: 1 / -1; }
    .transport { flex-wrap: wrap; }
    .timeline { order: -1; flex: 1 0 100%; }
    #show-settings { margin-left: 0; }
    footer { bottom: 12px; }
}

#maneuver, #mode {
    width: fit-content;
    max-width: min(360px, 84vw);
    margin: 9px 0 0;
    padding: 5px 9px;
    border-left: 2px solid var(--cyan);
    background: #091322d9;
    color: #c7f3fa;
    font-size: .85rem;
}
.marker.moon { color: #decabc; }
