/* The canopy and its retractable side display share a grid cell. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { height: 100dvh; display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); }
.topbar { min-height: 48px; padding-inline: clamp(12px,2.2vw,36px); align-items: stretch; gap: clamp(14px,3vw,50px); }
.brandmark { width: 31px; height: 31px; }
.brand > span { font-size: .67rem; }
.brand > span > span:last-child { font-size: .6rem; margin-top: 3px; }
.layout { position: relative; display: grid; grid-template-columns: minmax(0,1fr); min-height: 0; max-width: none; margin: 0; }
.workspace, .screen { min-height: 0; height: 100%; }
.flight { display: grid; grid-template: minmax(0,1fr) auto auto auto / minmax(0,1fr); }
.flight > .window, .flight > .sidebar { grid-area: 1 / 1; }
.flight-dashboard, .flight-navigation-actions, .thrust-controls { display: contents; }
.flight-dashboard > .flight-actions { grid-area: 3 / 1; }
.flight-dashboard > .console { grid-area: 4 / 1; }
.flight .window, .is-in-station .window { flex: 1 1 0; height: auto; min-height: 0; }
.scene-heading, .station-heading {
    top: clamp(14px,2.2vw,30px); left: clamp(14px,2.2vw,30px);
    max-width: calc(100% - 124px); padding: 6px 10px; border-left: 2px solid var(--amber);
    background: linear-gradient(90deg,#0a141cd9,#0a141c60); text-shadow: 0 1px 4px #000;
}
.scene-heading { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 2px 8px; align-items: center; }
.scene-heading svg { grid-row: 1 / 3; height: 18px; width: 18px; fill: none; stroke: var(--amber); stroke-width: 1.4; }
.scene-heading h1, .station-heading h1 { margin: 0; font: 640 clamp(.9rem,1.2vw,1.1rem)/1.15 var(--sans); letter-spacing: .005em; }
.sector-status, #station-system { color: #c1c9ca; margin: 2px 0 0; font: 450 .7rem/1.2 var(--sans); }
.station-heading { align-self: start; width: fit-content; }
.scene-bottom { left: clamp(16px,2.3vw,34px); right: clamp(16px,2.3vw,34px); bottom: clamp(14px,2vw,24px); }
.scene-bottom .location { font-size: clamp(.78rem,1.2vw,1rem); }
.scene-bottom .velocity { font-size: clamp(1.1rem,2vw,1.65rem); }
.window-tools { top: clamp(14px,2.2vw,30px); right: clamp(14px,2.2vw,30px); }
.window-tools .icon-button { width: 32px; height: 32px; }

.station-interior { padding: clamp(14px,2.2vw,30px); }
.station-interior::after { background: linear-gradient(180deg,#060d1460,transparent 22%,transparent 57%,#03090ed9); }
.station-services {
    display: flex; align-items: stretch; flex-wrap: wrap; gap: 5px; padding: 7px; width: fit-content;
    max-width: 100%; border: 1px solid #9eacaf51; border-radius: 5px; background: #09131be8;
}
.station-services button { gap: 7px; padding: 9px 14px; min-height: 39px; border: 1px solid #69797861; background: #18232ace; font-size: .84rem; }
.station-services button svg { width: 18px; height: 18px; }
#station-partner, #offer-alert { border: 1px solid #627a72; padding: 5px 9px; margin-top: 6px; border-radius: 3px; background: #192925; color: var(--teal); font-size: .77rem; }

.flight-actions {
    flex: none; gap: 12px; min-height: 48px; padding: 5px clamp(10px,1.75vw,25px);
    background: linear-gradient(100deg,#16232b,#0d171e 80%); border-color: #30424a;
}
.flight-actions .action-buttons { display: flex; align-items: stretch; justify-content: flex-end; gap: 4px; flex-wrap: nowrap; max-width: none; }
.flight-actions button { min-height: 35px; }
.deck-key { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 10px; border: 1px solid transparent; color: #afc0c9; border-radius: 3px; font-size: .81rem; }
.deck-key svg { width: 16px; height: 16px; }
.deck-key[aria-expanded=true] { border-color: #567973; background: #233b3b; color: #acf3df; }
.deck-key:hover { background-color: #24343d; }
#flight-main { margin-inline-start: 7px; padding: 6px 13px; }
.window .flight-guide {
    position: absolute; z-index: 2; inset-block-end: 90px; inset-inline-start: 3%;
    max-width: min(560px,94%); border: 1px solid #405356; border-radius: 4px;
    min-height: 0; gap: 10px; padding: 6px clamp(12px,2vw,30px);
}
.flight-guide p { font-size: .8rem; }
.flight-guide strong { font-size: .66rem; }
.flight-guide button { padding: 4px 8px; min-height: 30px; font-size: .75rem; }
.console {
    flex: none; min-height: 0; grid-template-columns: minmax(90px,.9fr) minmax(100px,1fr) minmax(215px,1.25fr);
    background: linear-gradient(110deg,#101d25,#0b151d); padding: 0 max(0px,calc((100vw - 1460px) / 2)); 
}
.instrument { padding: 10px clamp(8px,1.6vw,26px); }
.instrument-heading { margin-bottom: 7px; font-size: .63rem; }
#radar { height: 64px; }
.level { margin-bottom: 5px; }
.level-value, .level-name { font-size: .69rem; }
.throttle { display: grid; grid-template-columns: minmax(0,1fr) 66px; align-content: center; column-gap: 8px; }
.throttle .instrument-heading { grid-column: 1 / -1; }
.throttle .thrust-lever { grid-column: 1 / -1; width: 100%; }
.throttle .steer-pad { grid-template-columns: repeat(6,minmax(0,1fr)); }
.throttle .steer-pad [data-key^=Bracket] { grid-column: auto; }
.throttle .steer-pad button { padding: 0; height: 30px; }
.throttle .steer-pad #invert-steering {
    grid-column: 1 / -1;
    padding-inline: 4px;
    font-size: .7rem;
    line-height: 1.15;
}
.throttle .steer-pad #invert-steering[aria-pressed="true"] {
    background: #234541;
    color: var(--teal);
    border-color: var(--teal);
}
.throttle .fire { margin: 0; }
.missile-rack {
    grid-column: 1 / -1; display: flex; align-items: center; gap: 7px;
    margin-top: 5px; color: #c6d5d8; font-size: .72rem;
}
.missile-rack select {
    min-width: 0; padding: 4px 6px; color: inherit; background: #101d24;
    border: 1px solid #48616a; border-radius: 2px; font: inherit;
}
#missile-charge { margin-inline-start: auto; }
#missile-alert {
    position: absolute; z-index: 2; left: 50%; bottom: 12%; transform: translateX(-50%);
    display: flex; align-items: center; gap: .55rem; padding: 5px 8px;
    color: #ffcf91; background: #201714ed; border: 1px solid #aa7652; border-radius: 3px;
    font: 600 .78rem var(--sans); white-space: nowrap;
}
#missile-alert button { font-size: inherit; min-height: 32px; }
#missile-alert[hidden], .missile-rack[hidden] { display: none; }
.sidebar {
    position: relative; z-index: 3; justify-self: end; align-self: stretch; min-height: 0;
    width: clamp(310px,28vw,420px); margin: 57px clamp(9px,1.6vw,24px) 14px 0;
    display: block;
}
.sidebar > .side-block:not(.is-open) { display: none !important; }
.sidebar > .side-block.is-open { width: 100%; height: 100%; min-height: 0; padding: 16px; border: none; }
.sidebar .rail-heading { min-height: 32px; margin: 0 38px 8px 0; color: var(--teal); }
.sidebar .rail-heading svg { color: inherit; }
.drawer-close { position: absolute; z-index: 2; top: 14px; right: 12px; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 4px; font: 1.3rem var(--mono); color: #cedbda; background: #101c24; }
.toast { pointer-events: none; }
.crew-shortcuts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.crew-shortcuts:not(:has(button:not([hidden]))) { display: none; }
#assignment #station-followup:not([hidden]) { margin: 10px 0 0; }
@media(max-width: 690px) {
    .topbar { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 0; padding-inline: 10px; min-height: 0; }
    .brand, .account { min-height: 35px; }
    .brandmark { width: 24px; height: 24px; }
    .brand > span, .brand > span > span:last-child { font: 650 .65rem/1 var(--sans); letter-spacing: .07em; margin: 0; }
    .navigation { overflow: visible; min-width: 0; gap: 0; margin: 0; }
    .navigation button { flex: 1 1 0; justify-content: center; padding-inline: 2px; min-height: 33px; font-size: .72rem; }
    .navigation button svg { display: block; height: 13px; width: 13px; }
    .flight-actions { padding: 4px 7px; min-height: 43px; }
    .flight-actions .action-buttons { width: 100%; gap: 2px; }
    .action-buttons .deck-key { flex: 1; min-width: 0; min-height: 39px; padding: 3px 1px; gap: 3px; flex-direction: column; font-size: clamp(.55rem,2.4vw,.67rem); }
    .deck-key svg { width: 14px; height: 14px; }
    #flight-main { flex: 0 0 clamp(98px,29%,128px); margin-inline-start: 3px; padding: 5px 4px; font-size: .73rem; overflow-wrap: break-word; }
    .is-in-station #flight-main { flex-basis: clamp(110px,34%,144px); }
    .station-services { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; max-width: 440px; gap: 4px; padding: 5px; }
    .station-services button { min-height: 35px; padding: 6px 8px; font-size: .76rem; }
    .scene-heading, .station-heading { max-width: calc(100% - 95px); }
    .console { grid-template-columns: minmax(0,.8fr) minmax(0,1fr); padding: 0; }
    .instrument { padding: 6px 9px; }
    .instrument-heading { font-size: .59rem; margin-bottom: 4px; }
    #radar { height: 48px; }
    .level { margin-bottom: 3px; }
    .level-head { margin-bottom: 2px; }
    .level-name, .level-value { font-size: .58rem; }
    .track { height: 3px; }
    .throttle { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr minmax(138px,2fr) auto; align-items: center; gap: 3px 7px; border-top: 1px solid var(--line); }
    .throttle .instrument-heading { display: flex; grid-column: 1; margin: 0; }
    .throttle .thrust-lever { grid-column: 1; grid-row: 2; }
    .throttle .steer-pad, .throttle .weapon-actions { grid-row: 1 / 3; }
    .throttle .steer-pad { grid-column: 2; grid-template-columns: repeat(4,minmax(0,1fr)); }
    .throttle .steer-pad button { height: 35px; }
    .throttle .steer-pad [data-key^=Bracket] { grid-column: span 2; }
    .throttle .weapon-actions { grid-column: 3; }
    .throttle :is(.fire-laser,.fire) { font-size: .63rem; padding: 4px 5px; }
    .flight-guide { flex-wrap: nowrap; gap: 6px; }
    .flight-guide p { font-size: .71rem; line-height: 1.25; }
    .flight-guide > svg { display: none; }
}
@media(max-height: 500px) and (min-width: 510px) {
    .topbar { display: flex; align-items: stretch; gap: 12px; min-height: 34px; }
    .topbar .brand { min-height: 0; }
    .brand > span { display: none; }
    .navigation { border: none; }
    .navigation button { min-height: 34px; }
    .account .net span { display: none; }
    .station-services { display: flex; max-width: 100%; }
    .throttle .steer-pad { grid-template-columns: repeat(6,minmax(0,1fr)); }
    .throttle .steer-pad [data-key^=Bracket] { grid-column: auto; }
    .station-services button { min-height: 32px; }
    .window-tools { top: 9px; right: 9px; }
    .scene-heading, .station-heading { top: 10px; left: 12px; }
    .scene-bottom { bottom: 9px; }
    .flight-actions { min-height: 37px; padding-block: 2px; }
}

@media(max-width: 365px) {
    .topbar { padding-inline: 7px; }
    .navigation button svg { display: none; }
    .brand { gap: 3px; }
    .brand > span, .brand > span > span:last-child { font-size: .58rem; }
    .account { gap: 4px; }
    .account .balance { padding-inline-start: 4px; }
}

@media(max-width: 690px) {
    .sidebar { width: min(365px,calc(100% - 16px)); margin: 54px 8px 7px 0; }
}
@media(max-height: 690px) and (max-width: 690px), (max-height: 520px) {
    /* Keep enough reading height when the touch instruments are extended. */
    .flight > .sidebar { grid-row: 1 / 3; margin-block: 5px; }
}
@media(max-height: 420px) {
    .flight > .sidebar { grid-row: 1 / -1; margin-block: 5px; }
}
