#handheld-summary-key {
    position: absolute;
    z-index: 2;
    top: max(5px, env(safe-area-inset-top));
    left: max(7px, env(safe-area-inset-left));
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 10px;
    color: #e4d9c6;
    background: #101718dc;
    border: 1px solid #756a55;
    border-radius: 5px;
    font: 600 .8rem var(--sans);
    touch-action: manipulation;
}
#handheld-summary-key svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
#handheld-summary-key[data-signal] { color: #ffda9e; border-color: #c19965; }
#handheld-summary-key[data-urgent] { color: #ffddc8; background: #502b25; border-color: #f59e87; }
.signal-count b { padding: 2px 5px; border-radius: 3px; background: #ebc38b; color: #201b14; }
.signal-count b, .signal-deadline { font: 650 .75rem var(--mono); font-variant-numeric: tabular-nums; }
.signal-label { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 400px) {
    #handheld-summary-key:has(.signal-deadline:not([hidden])) > svg + span {
        position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden;
    }
}

#flight[data-handheld] .heading-tape:not([hidden]) {
    display: block;
    top: max(8px, env(safe-area-inset-top));
    width: min(20vw, 110px);
}
#flight[data-handheld].is-docking .heading-tape { display: none; }
#flight[data-handheld] .scene-bottom {
    inset: auto max(11px, env(safe-area-inset-right)) 8px max(11px, env(safe-area-inset-left));
    align-items: baseline;
    gap: 8px;
    pointer-events: none;
}
#flight[data-handheld] .scene-bottom > div {
    min-width: 0; padding: 0; border: 0; background: none; box-shadow: none;
}
#flight[data-handheld] #glass-target:not([hidden]) {
    display: flex; align-items: baseline; gap: 5px; color: #f3d5a0;
    font: 600 .78rem var(--mono); text-shadow: 0 1px 2px #070b0e, 0 0 6px #070b0e;
}
#flight[data-handheld] .scene-bottom #station-label { display: none; }
#flight[data-handheld] .velocity {
    min-width: 0; padding: 0; border: 0; color: #f4daa9; background: none; box-shadow: none;
    font: 630 1rem var(--mono); text-shadow: 0 1px 2px #070b0e, 0 0 6px #070b0e;
}

#handheld-summary.is-open { display: flex; flex-direction: column; }
#handheld-summary .rail-heading { flex: none; }
.handheld-bulletins {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.handheld-bulletins > * { flex: none; }
#handheld-summary .flight-calls {
    position: static; max-width: none; max-height: none; align-items: stretch; overflow: visible;
}
#handheld-summary .dispatch-call { width: 100%; max-width: none; }
#handheld-summary .pilot-call { width: 100%; }
#handheld-summary :is(.dispatch-call, .pilot-call, .flight-guide) :is(button, summary) { min-height: 44px; }
#handheld-summary .pilot-dismiss { min-width: 44px; }
#handheld-summary .scene-heading {
    display: grid; position: static; align-self: stretch; max-width: none; color: #e6ebe4;
}
#handheld-summary .flight-guide {
    display: flex; flex-wrap: wrap; padding: 10px; gap: 5px 12px;
    border: 1px solid #3e595b; border-radius: 4px;
}
#handheld-summary .flight-guide > div { flex: 1 1 200px; }
#handheld-summary .flight-guide p, #handheld-summary #dock-prompt { font-size: .86rem; line-height: 1.4; }
#handheld-summary #mode, #handheld-summary #spin-rate { margin: 0; color: #bed3d0; }
#flight:not(.is-docking) #handheld-summary #dock-prompt { display: none; }

/* Contextual controls take one row away from the glass only while needed. */
#handheld-status {
    grid-area: 2 / 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 2px 8px;
    max-height: 38dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-inline: max(7px, env(safe-area-inset-left)) max(7px, env(safe-area-inset-right));
    color: #d8e5df;
    background: #101c20;
}
#handheld-status > * { max-width: 100%; min-width: 0; margin: 0; }
#handheld-status :is(#missile-alert, #station-docking, #departure-controls, .flight-local-actions, #toast) {
    position: static; inset: auto; transform: none;
}
#handheld-status #missile-alert {
    order: -1; flex: 1 0 100%; justify-content: center; gap: 7px;
    white-space: normal; font-size: .79rem;
}
#handheld-status button { min-height: 44px; }
#handheld-status kbd, #handheld-status .dock-thrust, #handheld-status .fire:disabled { display: none; }
#handheld-status #station-docking {
    gap: 1px 8px; max-width: 100%;
    padding: 3px 7px; border-radius: 0; background: none;
}
#handheld-status #station-docking :is(h2, output) { font-size: .76rem; }
#handheld-status #dock-clearance {
    grid-column: 1 / -1; pointer-events: auto; min-height: 44px; padding: 4px 9px;
}
#flight[data-handheld] .action-buttons:has(> #dock-clearance:not([hidden])) #flight-main { display: none; }
#flight[data-handheld] .action-buttons > #dock-clearance {
    grid-area: main; align-self: stretch; justify-self: stretch; min-width: 0; min-height: 44px;
    margin: 0; padding: 4px; border: 1px solid #c69a5d; border-radius: 5px;
    color: #ffdaa1; background: linear-gradient(#5e4122, #302419);
    font: 600 clamp(.75rem, 2.8vw, .86rem)/1.12 var(--sans); overflow-wrap: anywhere;
    touch-action: manipulation;
}
#handheld-depart-hint { display: none; }
#handheld-status #handheld-depart-hint:not([hidden]) { display: block; color: #b3edcd; }
#handheld-status #departure-controls {
    display: flex; flex-wrap: wrap; justify-content: center;
    width: auto; padding: 2px 0; border: 0; background: none; box-shadow: none;
}
#handheld-status #dock-attitude {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1px 6px;
    padding: 2px 7px; border: 0; background: none; font-size: .69rem;
}
#handheld-status #dock-attitude :is(output, #dock-door) { grid-column: 1; }
#handheld-status .dock-bank-controls { grid-area: 1 / 2 / span 3; display: flex; gap: 3px; }
#handheld-status .dock-bank-controls button { width: 44px; }
#handheld-status :is(.fire-laser,.fire) { gap: 5px; margin: 0; padding-inline: 10px; }
#handheld-status #toast {
    width: 100%; max-width: none; padding: 4px 8px; border-radius: 0; box-shadow: none;
    font-size: .78rem; line-height: 1.25; text-align: center;
}
