/* My Little Satellite — Mission Control shell
   Visual language oriented on ESA OPS-SAT's MCS (sim-ops.opssat.esa.int):
   dark console, grouped sidebar, bracket-cornered telemetry cards, teal/red state chips.
   Deliberately single-theme (dark) — real ops consoles run dark to protect night vision. */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
    --bg: #131a25;
    --bg-2: #1b2432;
    --bg-3: #26333f;
    --bg-3-hover: #2e3f4f;
    --line: #2d3d4c;
    --card: rgba(210, 219, 226, 0.55);
    --line-soft: rgba(255, 255, 255, 0.035);
    --ink: #f2f6f8;
    --ink-dim: #93a7b8;
    --ink-faint: #5e7488;
    --teal: #3cd2a5;
    --teal-ink: #04241c;
    --red: #ff6060;
    --red-ink: #2a0a08;
    --amber: #ffb454;
    --amber-ink: #2a1900;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
}
body {
    margin: 0;
    background-color: var(--bg);
    background-image:
        radial-gradient(
            520px circle at 82% 12%,
            rgba(60, 210, 165, 0.07),
            transparent 62%
        ),
        radial-gradient(
            460px circle at 8% 78%,
            rgba(60, 210, 165, 0.05),
            transparent 60%
        ),
        radial-gradient(
            circle at 92% 8%,
            transparent 0 236px,
            rgba(255, 255, 255, 0.05) 237px 238px,
            transparent 239px
        ),
        radial-gradient(
            circle at -4% 96%,
            transparent 0 300px,
            rgba(255, 255, 255, 0.04) 301px 302px,
            transparent 303px
        ),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M20 15v10M15 20h10' stroke='rgba(255,255,255,0.05)' stroke-width='1'/%3E%3C/svg%3E"),
        linear-gradient(var(--line-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
    background-repeat:
        no-repeat, no-repeat, no-repeat, no-repeat, repeat, repeat, repeat;
    background-size:
        auto,
        auto,
        auto,
        auto,
        40px 40px,
        34px 34px,
        34px 34px;
    background-attachment: fixed;
    color: var(--ink);
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
.mono {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
}
button,
input {
    font-family: inherit;
}
a {
    color: inherit;
}
::selection {
    background: var(--teal);
    color: var(--teal-ink);
}
:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

/* ---------- shell layout ---------- */
.shell {
    display: grid;
    grid-template-columns: 236px 1fr;
    grid-template-rows: 52px 1fr;
    height: 100vh;
    position: relative;
    z-index: 1;
}
.shell.collapsed {
    grid-template-columns: 60px 1fr;
}

.topbar {
    grid-column: 1/-1;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0 1rem;
    background: var(--bg-2);
    border-bottom: 1px solid var(--line);
}
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-dim);
    cursor: pointer;
}
.icon-btn:hover {
    background: var(--bg-3);
    color: var(--ink);
    border-color: var(--line);
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.brand .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 8px var(--teal);
}
.brand small {
    color: var(--ink-dim);
    font-weight: 500;
    font-size: 0.8rem;
}
.topbar .spacer {
    flex: 1;
}
.topbar .readout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.74rem;
    color: var(--ink-dim);
    letter-spacing: 0.04em;
}
.topbar .readout b {
    color: var(--ink);
    font-weight: 600;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.32rem 0.6rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-family: "IBM Plex Mono", monospace;
    transition:
        background-color 0.25s ease,
        color 0.25s ease;
}
.pill.ok {
    background: var(--teal);
    color: #fff;
    justify-content: center;
    text-align: center;
    width: 100%;
}
.pill.bad {
    background: var(--red);
    color: #fff;
    justify-content: center;
    text-align: center;
    width: 100%;
}
.pill.warn {
    background: var(--amber);
    color: #fff;
    justify-content: center;
    text-align: center;
    width: 100%;
}
.pill.neutral {
    background: var(--bg-3);
    color: var(--ink-dim);
    border: 1px solid var(--line);
    margin: auto;
}
.pill-btn {
    cursor: pointer;
}
.pill-btn:hover {
    filter: brightness(1.15);
}

/* ---------- control row (manual switches embedded in a page) ---------- */
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 14px;
    padding: 0.9rem 1rem;
}
.control-row .control-copy {
    font-weight: 600;
    font-size: 0.92rem;
}
.control-row .hint {
    text-align: left;
    max-width: none;
    margin-top: 0.25rem;
}
.control-row .control-state {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex: none;
}

/* tracking-error meter */
.bar {
    height: 6px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
}
.bar > i {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--teal);
    width: 0%;
    transition:
        width 0.2s linear,
        background 0.2s linear;
    display: block;
}

/* ---------- sidebar ---------- */
.sidebar {
    grid-row: 2;
    overflow-y: auto;
    background-color: var(--bg-2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='236' height='900'%3E%3Cpath d='M40 260 L118 190' stroke='rgba(140,180,200,0.16)' stroke-width='1'/%3E%3Ccircle cx='40' cy='260' r='2.5' fill='rgba(140,180,200,0.22)'/%3E%3Ccircle cx='118' cy='190' r='3' fill='rgba(140,180,200,0.28)'/%3E%3Cpath d='M150 560 L206 500' stroke='rgba(140,180,200,0.14)' stroke-width='1'/%3E%3Ccircle cx='150' cy='560' r='2.5' fill='rgba(140,180,200,0.2)'/%3E%3Ccircle cx='206' cy='500' r='2' fill='rgba(140,180,200,0.2)'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    border-right: 1px solid var(--line);
    padding: 0.9rem 0 1.5rem;
}
.nav-group {
    margin-bottom: 1.1rem;
}
.nav-label {
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink-faint);
    padding: 0 1rem;
    margin-bottom: 0.5rem;
}
.shell.collapsed .nav-label {
    display: none;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--ink-dim);
    font-size: 0.92rem;
    text-align: left;
    cursor: pointer;
    position: relative;
}
.nav-item svg {
    flex: none;
    width: 16px;
    height: 16px;
    opacity: 0.85;
    color: var(--ink-dim);
}
.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink);
}
.nav-item.active {
    color: var(--ink);
    font-weight: 600;
}
.nav-item.active svg {
    color: var(--teal);
    opacity: 1;
}
.shell.collapsed .nav-item span {
    display: none;
}
.shell.collapsed .nav-item {
    justify-content: center;
    padding: 0.6rem 0;
}

.nav-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 1rem;
}
.shell.collapsed .nav-toggle-row span {
    display: none;
}
.switch {
    width: 34px;
    height: 19px;
    border-radius: 10px;
    background: var(--bg-3);
    border: 1px solid var(--line);
    position: relative;
    cursor: pointer;
    flex: none;
}
.switch i {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--ink-dim);
    transition:
        transform 0.15s ease,
        background 0.15s ease;
}
.switch.on {
    background: rgba(70, 224, 179, 0.18);
    border-color: var(--teal);
}
.switch.on i {
    transform: translateX(15px);
    background: var(--teal);
}

/* ---------- main / pages ---------- */
.main {
    grid-row: 2;
    overflow-y: auto;
    padding: 2rem 2.2rem 3rem;
}
.page {
    display: none;
}
.page.active {
    display: block;
}

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.6rem;
    flex-wrap: wrap;
}
.page-head h1 {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.page-head h1 span {
    margin-left: 0.65rem;
    font-size: 1rem;
    font-weight: 400;
    color: var(--ink-dim);
}
.page-status {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.group-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 1.7rem 0 0.8rem;
}
.group-title:first-child {
    margin-top: 0;
}
.group-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.gallery-panel.hidden {
    display: none;
}
#sciGalleryEmpty.hidden {
    display: none;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
.gallery-item {
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-3);
    text-align: left;
}
.gallery-item img {
    display: block;
    width: 100%;
    height: 80px;
    object-fit: cover;
}
.gallery-item-cap {
    padding: 6px 8px;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--ink-dim);
}
.gallery-item-cap b {
    display: block;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.76rem;
}

/* bracket-cornered telemetry card — the OPS-SAT MCS signature frame.
   No fill: the card is just a corner-bracket outline plus two full-width hairline
   dividers (one under the label, one above the bottom brackets) so the ambient
   grid/glow behind the page shows straight through, same as the reference UI. */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.card {
    position: relative;
    padding: 1rem 1.15rem 1.3rem;
    min-height: 118px;
    text-align: center;
    background-image:
        linear-gradient(var(--card), var(--card)),
        linear-gradient(var(--card), var(--card)),
        linear-gradient(var(--card), var(--card)),
        linear-gradient(var(--card), var(--card)),
        linear-gradient(var(--card), var(--card)),
        linear-gradient(var(--card), var(--card)),
        linear-gradient(var(--card), var(--card)),
        linear-gradient(var(--card), var(--card));
    background-repeat: no-repeat;
    background-size:
        14px 1px,
        1px 14px,
        14px 1px,
        1px 14px,
        14px 1px,
        1px 14px,
        14px 1px,
        1px 14px;
    background-position:
        top 0 left 0,
        top 0 left 0,
        top 0 right 0,
        top 0 right 0,
        bottom 0 left 0,
        bottom 0 left 0,
        bottom 0 right 0,
        bottom 0 right 0;
}
.card::before,
.card::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
}
.card::before {
    top: 2.15rem;
}
.card::after {
    bottom: 1.05rem;
}
.shell.compact .card {
    padding: 0.6rem 0.8rem 0.85rem;
    min-height: 68px;
}
.shell.compact .card::before {
    top: 1.5rem;
}
.shell.compact .card::after {
    bottom: 0.6rem;
}
.card .label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink-dim);
    margin-bottom: 0.9rem;
    display: block;
    text-align: center;
}
.card .value {
    display: inline-block;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    width: 100%;
    color: var(--ink);
}
.shell.compact .card .value {
    font-size: 1.1rem;
}
.card .value .unit {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-dim);
    margin-left: 0.2rem;
}
.card .value.small {
    font-size: 1.1rem;
}

.card-foot {
    margin-top: 1.4rem;
}

/* ---------- 3D orbit stage ---------- */
#orbitStage canvas {
    display: block;
    width: 100%;
    height: 100%;
}
.stage-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--bg-3);
    color: var(--ink-dim);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    transition: opacity 0.4s ease;
}
.stage-loading.hidden {
    opacity: 0;
    pointer-events: none;
}
.stage-spinner {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-top-color: var(--teal);
    animation: stage-spin 0.9s linear infinite;
}
@keyframes stage-spin {
    to {
        transform: rotate(360deg);
    }
}
.stage-legend {
    position: absolute;
    left: 14px;
    bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    align-items: center;
    padding: 0.5rem 0.7rem;
    background: rgba(10, 16, 23, 0.6);
    border: 1px solid var(--line);
    border-radius: 3px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.66rem;
    color: var(--ink-dim);
    pointer-events: none;
}
.stage-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.stage-legend i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.stage-hint-drag {
    color: var(--ink-faint);
}

/* ---------- science: the goal of the game ---------- */
.sci-pill {
    background: rgba(255, 180, 84, 0.16);
    color: var(--amber);
    border: 1px solid rgba(255, 180, 84, 0.4);
    font-weight: 700;
}
.sci-sort-panel {
    padding: 1rem;
}
.sci-sort-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sci-task-prompt {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink);
    margin-top: 0.65rem;
    min-height: 1.5em;
}
.sci-answer-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}
.sci-answer-buttons .btn {
    width: 100%;
}
.sci-answer-numeric {
    display: flex;
    gap: 10px;
}
.sci-answer-numeric input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 0.55rem 0.8rem;
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: 0.05em;
    border-radius: 3px;
}
.sci-answer-numeric input:focus {
    border-color: var(--teal);
}
.sci-answer-numeric.hidden {
    display: none;
}
.sci-sort-feedback.ok {
    color: var(--teal);
}
.sci-sort-feedback.bad {
    color: var(--red);
}
.sci-sort-panel.locked-out .sci-task-prompt {
    opacity: 0.35;
}
.sci-burst-status {
    margin-top: 0.7rem;
    padding: 0.55rem 0.7rem;
    background: rgba(255, 180, 84, 0.08);
    border: 1px solid rgba(255, 180, 84, 0.35);
    border-radius: 3px;
}
.sci-burst-status.hidden {
    display: none;
}
.sci-burst-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    color: var(--amber);
    margin-bottom: 0.4rem;
    font-family: "IBM Plex Mono", monospace;
}

.upgrade-card {
    display: flex;
    flex-direction: column;
}
.upgrade-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.upgrade-status {
    color: var(--ink-dim) !important;
}
.upgrade-bar {
    margin-top: 0.6rem;
}
.upgrade-bar.hidden {
    display: none;
}

/* ---------- signal spectrum + waterfall ---------- */
.spectrum-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 900px) {
    .spectrum-row {
        grid-template-columns: 1fr;
    }
}
.spectrum-panel {
    padding: 0.85rem;
}
.spectrum-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--ink-dim);
}
.spectrum-head .mono {
    color: var(--ink);
}
#ulSpectrumCanvas,
#dlSpectrumCanvas {
    width: 100%;
    height: 120px;
    display: block;
    border: 1px solid var(--line);
    background: #050a0f;
}

/* ---------- orbit / align canvases ---------- */
.panel {
    background: var(--bg-3);
    border: 1px solid var(--line);
    padding: 1rem;
}
.panel canvas {
    width: 100%;
    display: block;
}
.two-col {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 900px) {
    .two-col {
        grid-template-columns: 1fr;
    }
}

.align-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
}
.align-status {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.75rem;
    color: var(--ink-dim);
    text-align: center;
}
.align-status b {
    display: block;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    margin-top: 0.2rem;
}
.hint {
    font-size: 0.78rem;
    color: var(--ink-faint);
    text-align: center;
    max-width: 22rem;
}

/* ---------- SpaCon command console ---------- */
.cmdline-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.cmdline-prompt {
    color: var(--teal);
    font-weight: 600;
    font-size: 0.85rem;
    flex: none;
}
.cmdline-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
    border-radius: 3px;
}
.cmdline-input::placeholder {
    color: var(--ink-faint);
}
.cmdline-input:focus {
    border-color: var(--teal);
}
.cmdline-feedback {
    margin-top: 0.55rem;
    font-size: 0.72rem;
    color: var(--ink-faint);
    min-height: 1em;
}
.cmdline-feedback.ok {
    color: var(--teal);
}
.cmdline-feedback.bad {
    color: var(--red);
}

/* ---------- log list ---------- */
.log {
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    color: var(--ink-dim);
}
.log li {
    padding: 0.4rem 0;
    border-bottom: 1px dashed var(--line);
}
.log li:last-child {
    border-bottom: none;
}
.log li b {
    color: var(--ink);
    font-weight: 600;
}
.stack-list li.stack-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
}
.stack-remove {
    background: transparent;
    border: none;
    color: var(--ink-faint);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    line-height: 1;
    padding: 0.15rem 0.3rem;
}
.stack-remove:hover {
    color: var(--red);
}

/* ---------- table ---------- */
.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--line);
}
table.faults {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
table.faults th,
table.faults td {
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
table.faults thead th {
    background: var(--bg-3);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.66rem;
    letter-spacing: 0.07em;
    color: var(--ink-dim);
    text-transform: uppercase;
}
table.faults tbody tr:last-child td {
    border-bottom: none;
}
.tier-tag {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
}
.tier-tag.t1 {
    background: rgba(70, 224, 179, 0.15);
    color: var(--teal);
}
.tier-tag.t2 {
    background: rgba(255, 180, 84, 0.15);
    color: var(--amber);
}

/* ---------- handbook ---------- */
.handbook {
    max-width: 38rem;
}
.handbook .table-scroll {
    max-width: none;
    width: 100%;
}
.handbook h3 {
    font-size: 1.05rem;
    margin: 1.6rem 0 0.4rem;
}
.handbook h3:first-child {
    margin-top: 0;
}
.handbook p {
    color: var(--ink-dim);
    font-size: 0.92rem;
    margin: 0 0 0.6rem;
}

/* two-tone tag+value badge — same joined-chip language as "Last Update / _"
   and the topbar's SLE / TS readouts in the reference UI */
.last-update {
    margin-top: 1.4rem;
    display: inline-flex;
    align-items: stretch;
    border-radius: 4px;
    overflow: hidden;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
}
.last-update .tag-k {
    background: #7c8fa0;
    color: #fff;
    font-weight: 700;
    padding: 0.38rem 0.7rem;
    white-space: nowrap;
}
.last-update span:last-child {
    background: var(--bg-3);
    color: var(--ink-dim);
    border: 1px solid var(--line);
    border-left: none;
    padding: 0.38rem 0.7rem;
}

/* ---------- star-tracker pattern minigame ---------- */
.seq-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 200px;
    margin: 0 auto;
}
.seq-btn {
    aspect-ratio: 1;
    border: 1px solid var(--line);
    background: var(--bg-3);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-dim);
    cursor: pointer;
}
.seq-btn svg {
    width: 28px;
    height: 28px;
}
.seq-btn.flash {
    background: var(--teal);
    color: var(--teal-ink);
    border-color: var(--teal);
}
.seq-btn.wrong {
    background: rgba(255, 107, 106, 0.22);
    border-color: var(--red);
}
.seq-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.9rem;
}
.seq-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: transparent;
}
.seq-dot.done {
    background: var(--teal);
    border-color: var(--teal);
}

/* ---------- inline event banner (telemetry parity, etc.) ---------- */
.banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: rgba(255, 180, 84, 0.12);
    border: 1px solid var(--amber);
    margin-bottom: 14px;
}
.banner.hidden {
    display: none;
}
.banner .banner-copy {
    font-weight: 600;
    font-size: 0.88rem;
}
.banner .banner-copy small {
    display: block;
    font-weight: 400;
    color: var(--ink-dim);
    margin-top: 0.2rem;
    font-size: 0.78rem;
}

.btn {
    padding: 0.55rem 1.1rem;
    background: var(--teal);
    color: var(--teal-ink);
    border: none;
    border-radius: 3px;
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    cursor: pointer;
    font-family: "IBM Plex Mono", monospace;
    flex: none;
}
.btn:hover {
    filter: brightness(1.1);
}
.btn.ghost {
    background: var(--bg-3);
    color: var(--ink);
    border: 1px solid var(--line);
}
.btn:disabled {
    background: var(--bg-3);
    color: var(--ink-faint);
    cursor: not-allowed;
}
.btn.cooling {
    opacity: 0.45;
    pointer-events: none;
}

/* dimmed while the uplink isn't locked — you can see the controls, just can't use them yet */
#alignCanvas.locked-out {
    opacity: 0.4;
    cursor: not-allowed;
}
.seq-grid.locked-out .seq-btn {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------- handbook drawer ---------- */
/* A slide-out panel instead of a nav page, so checking it never costs you the page you were
   actually on. The pull-tab is a child of the drawer itself, positioned just off its left edge,
   so it slides along with the drawer — sitting flush with the viewport's right edge (looking
   like it's "sticking out") when closed, and moving to the drawer's open left edge to act as
   the close handle once it's out. */
.handbook-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(640px, 92vw);
    z-index: 95;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    /* No overflow/background here — this box only positions things. The tab below sits outside
       it via a negative offset, and `overflow-y: auto` on the scroll wrapper would otherwise
       implicitly force overflow-x to clip too (a CSS quirk), cutting the tab off. */
}
.handbook-drawer.open {
    transform: translateX(0);
}
.handbook-drawer-scroll {
    height: 100%;
    overflow-y: auto;
    background: var(--bg-2);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 1.4rem 1.6rem 3rem;
}
.handbook-tab {
    position: absolute;
    left: -38px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    padding: 0.9rem 0.4rem;
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-right: none;
    border-radius: 6px 0 0 6px;
    color: var(--ink-dim);
    cursor: pointer;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    font-weight: 700;
}
.handbook-tab:hover {
    color: var(--ink);
    background: var(--bg-3-hover);
}
.handbook-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 12, 0.55);
    z-index: 94;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}
.handbook-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
.handbook-close {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink-dim);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    flex: none;
}
.handbook-close:hover {
    color: var(--ink);
    border-color: var(--ink-dim);
}
/* ---------- mission end screen ---------- */
.end-screen {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 12, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 80;
}
.end-screen.hidden {
    display: none;
}
.end-card {
    background: var(--bg-2);
    border: 1px solid var(--line);
    padding: 2.2rem 2.4rem;
    max-width: 27rem;
    width: calc(100% - 2rem);
    text-align: center;
    box-shadow: var(--shadow);
}
.end-card h2 {
    margin: 0 0 0.4rem;
    font-size: 1.6rem;
    color: var(--red);
}
.end-card .sub {
    color: var(--ink-dim);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
}
.end-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 1.4rem;
    text-align: left;
}
.end-stats .stat .label {
    font-size: 0.63rem;
    color: var(--ink-dim);
    letter-spacing: 0.05em;
}
.end-stats .stat .val {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: 0.2rem;
}
.record-note {
    font-size: 0.76rem;
    color: var(--teal);
    margin-bottom: 1.2rem;
    font-family: "IBM Plex Mono", monospace;
}

.name-input {
    display: block;
    width: 100%;
    text-align: center;
    text-transform: uppercase;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 0.7rem;
    font-size: 1.3rem;
    letter-spacing: 0.12em;
    border-radius: 3px;
    margin-bottom: 0.4rem;
}
.name-input:focus {
    border-color: var(--teal);
}
.name-count {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem;
    color: var(--ink-faint);
    margin-bottom: 1.1rem;
}

/* ---------- antenna phase-lock minigame ---------- */
.track-game-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}
.track-game-title {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
}
#trackGameCanvas {
    width: 100%;
    height: 46px;
    display: block;
    border: 1px solid var(--line);
    background: var(--bg);
}
#trackGameCanvas.locked-out {
    opacity: 0.4;
}
.track-game-feedback.ok {
    color: var(--teal);
}
.track-game-feedback.warn {
    color: var(--amber);
}

/* ---------- 3D scene text labels (orbit3d.js, CSS2DRenderer) ---------- */
.orbit-label {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--ink);
    background: rgba(10, 16, 23, 0.72);
    border: 1px solid var(--line);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
}
.orbit-label.station {
    color: var(--red);
}
.orbit-label.satellite {
    color: var(--teal);
}

footer.app-foot {
    grid-column: 1/-1;
    text-align: center;
    padding: 1rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    border-top: 1px solid var(--line);
    background: var(--bg-2);
    display: none;
}

@media (max-width: 760px) {
    .shell {
        grid-template-columns: 1fr;
        grid-template-rows: 52px auto 1fr;
    }
    .sidebar {
        grid-row: 2;
        border-right: none;
        border-bottom: 1px solid var(--line);
        max-height: 44vh;
    }
    .main {
        grid-row: 3;
    }
    .shell.collapsed {
        grid-template-columns: 1fr;
    }
    .shell.collapsed .sidebar {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ---------- voice-line toasts ---------- */
.voice-toasts {
    position: fixed;
    top: 62px;
    right: 14px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 260px;
    pointer-events: none;
}
.voice-toast {
    background: var(--bg-3);
    border: 1px solid var(--line);
    border-left: 3px solid var(--teal);
    border-radius: 4px;
    padding: 0.55rem 0.7rem;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateX(12px);
    transition:
        opacity 0.25s ease,
        transform 0.25s ease;
}
.voice-toast.show {
    opacity: 1;
    transform: translateX(0);
}
.voice-toast-tag {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    color: var(--teal);
    font-weight: 700;
    margin-bottom: 0.15rem;
}
/* fault/error callouts (parity, battery, misalignment, disconnect) read as alarms, not routine status */
.voice-toast.alert {
    border-left-color: var(--red);
}
.voice-toast.alert .voice-toast-tag {
    color: var(--red);
}
.voice-toast-msg {
    font-size: 0.78rem;
    color: var(--ink);
    line-height: 1.3;
}

/* ============================================================
   DEV TOOL — testing aid only, safe to delete this whole block.
   ============================================================ */
.dev-tool {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 70;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    background: rgba(10, 16, 23, 0.9);
    border: 1px dashed var(--amber);
    border-radius: 4px;
}
.dev-tool-label {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    color: var(--amber);
    border: 1px solid var(--amber);
    border-radius: 2px;
    padding: 0.15rem 0.35rem;
}
/* ============================================================
   /DEV TOOL
   ============================================================ */

/* =============================================================================
      Append to style.css — ground-segment image processing + star tracker sky view.
      Uses the existing tokens only (--teal, --amber, --red, --ink, --ink-dim,
      --ink-faint) and the existing .panel / .btn / .pill / .locked-out classes.
      ========================================================================== */

/* ---------------- image processing workbench ---------------- */
.img-panel {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.img-head {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.img-frameid {
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    color: var(--ink-faint);
}

.img-prompt {
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--ink);
    max-width: 46rem;
}

.img-stagebar {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.img-chip {
    font-size: 0.64rem;
    letter-spacing: 0.09em;
    padding: 0.2rem 0.5rem;
    border: 1px solid rgba(125, 147, 163, 0.28);
    border-radius: 3px;
    color: var(--ink-faint);
}
.img-chip.active {
    border-color: var(--teal);
    color: var(--teal);
}
.img-chip.done {
    border-color: rgba(70, 224, 179, 0.35);
    color: rgba(70, 224, 179, 0.55);
}
.img-chip.done::before {
    content: "✓ ";
}

.img-stage-wrap {
    position: relative;
}

#imgCanvas {
    display: block;
    width: 100%;
    height: 420px;
    border: 1px solid rgba(125, 147, 163, 0.2);
    border-radius: 4px;
    background: #050a0f;
    touch-action: none;
    cursor: crosshair;
}

.img-ref {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 132px;
    padding: 0.3rem;
    background: rgba(5, 10, 15, 0.9);
    border: 1px solid rgba(125, 147, 163, 0.3);
    border-radius: 4px;
}
.img-ref span {
    display: block;
    font-size: 0.56rem;
    letter-spacing: 0.1em;
    color: var(--ink-faint);
    margin-bottom: 0.25rem;
}
.img-ref canvas {
    display: block;
    width: 124px;
    height: 124px;
}

.img-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.img-readout {
    font-size: 0.74rem;
    color: var(--ink-dim);
    padding: 0.3rem 0.1rem;
    min-width: 12rem;
}

.img-input {
    flex: 1 1 16rem;
    min-width: 12rem;
    background: #050a0f;
    border: 1px solid rgba(125, 147, 163, 0.3);
    border-radius: 3px;
    color: var(--ink);
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.img-input:focus {
    outline: none;
    border-color: var(--teal);
}

.img-feedback {
    text-align: left;
    max-width: none;
}
.img-feedback.ok {
    color: var(--teal);
}
.img-feedback.bad {
    color: var(--red);
}

/* ---------------- star tracker sky ---------------- */
.st-panel {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

#stSkyCanvas {
    display: block;
    width: 100%;
    height: 420px;
    border: 1px solid rgba(125, 147, 163, 0.2);
    border-radius: 4px;
    background: #02060a;
    cursor: crosshair;
}

.st-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.5rem;
}

.st-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    text-align: left;
    padding: 0.55rem 0.7rem;
    line-height: 1.25;
}
.st-choice b {
    font-size: 0.84rem;
    letter-spacing: 0.02em;
}
.st-choice span {
    font-size: 0.68rem;
    color: var(--ink-faint);
    letter-spacing: 0.04em;
}

@media (max-width: 720px) {
    #imgCanvas,
    #stSkyCanvas {
        height: 320px;
    }
    .img-ref {
        width: 96px;
    }
    .img-ref canvas {
        width: 88px;
        height: 88px;
    }
}
