:root {
  color-scheme: dark;
  --void: #030402;
  --screen: #090a04;
  --screen-hi: #111006;
  --phosphor: #ffc72c;
  --phosphor-hi: #ffe27a;
  --phosphor-dim: #8e6c13;
  --phosphor-low: #3e310d;
  --danger: #ff6a32;
  --good: #b7ff3c;
  --line: rgba(255, 199, 44, .78);
  --hairline: rgba(255, 199, 44, .3);
  --glow: 0 0 7px rgba(255, 190, 28, .42);
  --mono: "Courier New", "Lucida Console", Monaco, monospace;
}

* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: hidden; background: var(--void); }
body {
  margin: 0;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(74, 61, 12, .14), transparent 55%),
    linear-gradient(180deg, #050603, var(--void));
  color: var(--phosphor);
  font: 700 14px/1.25 var(--mono);
  letter-spacing: .025em;
  text-shadow: var(--glow);
}
body::before {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.022) 0, rgba(255,255,255,.022) 1px, transparent 1px, transparent 4px);
  content: "";
  pointer-events: none;
  mix-blend-mode: screen;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .34; filter: saturate(.4); }
.shell { width: min(860px, 100%); max-width: 100%; min-height: 100vh; margin: 0 auto; overflow-x: clip; }
[hidden] { display: none !important; }

.login-screen { min-height: 100vh; display: grid; align-items: center; padding: 20px; }
.terminal-frame, .terminal-panel { border: 1px solid var(--line); background: linear-gradient(180deg, rgba(19,17,5,.92), rgba(5,6,2,.96)); box-shadow: inset 0 0 24px rgba(255,186,16,.035), 0 0 26px rgba(0,0,0,.8); }
.login-console { width: min(440px, 100%); margin: auto; padding: 18px; }
.terminal-kicker, .masthead, .panel-title, .alarm-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.terminal-kicker { padding-bottom: 9px; border-bottom: 3px double var(--line); color: var(--phosphor-hi); }
.brand-line { margin: 16px 0 7px; color: var(--phosphor-dim); font-size: .7rem; letter-spacing: .12em; }
h1 { margin: 0 0 20px; color: var(--phosphor-hi); font-size: clamp(2rem, 10vw, 3.2rem); line-height: .9; letter-spacing: -.065em; }
.terminal-copy { color: #c89b25; font-size: .78rem; line-height: 1.55; text-shadow: none; }
label { display: block; margin: 22px 0 6px; color: var(--phosphor-hi); font-size: .72rem; }
input[type="password"] { width: 100%; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 0; outline: 0; background: #020300; color: var(--phosphor-hi); padding: 14px; box-shadow: inset 0 0 16px rgba(255,199,44,.06); }
input[type="password"]:focus { border-color: var(--phosphor-hi); box-shadow: inset 0 0 16px rgba(255,199,44,.06), 0 0 0 2px rgba(255,199,44,.18); }
.boot-line { margin: 20px -18px -18px; padding: 9px 18px; background: var(--phosphor); color: #1a1300; font-size: .65rem; text-shadow: none; }
.error { min-height: 1.25em; margin: 9px 0 0; color: var(--danger); font-size: .72rem; }

.command-header { position: sticky; top: 0; z-index: 10; max-width: 100%; padding: max(4px, env(safe-area-inset-top)) 6px 0; overflow: hidden; background: rgba(3,4,2,.97); box-shadow: 0 8px 24px rgba(0,0,0,.9); }
.masthead { min-height: 21px; padding: 0 2px 3px; }
.system-name { display: inline; color: var(--phosphor-hi); font-size: .82rem; letter-spacing: .08em; }
.system-version { display: none; }
#system-clock { color: var(--phosphor-hi); font-size: .58rem; }
.always-status { display: grid; grid-template-columns: .92fr .92fr 1.35fr; width: 100%; height: 30px; border: 1px solid var(--line); overflow: hidden; background: var(--hairline); gap: 1px; }
.status-cell { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px; min-width: 0; height: 28px; padding: 2px 4px; overflow: hidden; background: #090a04; }
.status-cell.scene-readout { grid-column: auto; border-top: 0; }
.status-label { display: block; min-width: 0; margin: 0; color: var(--phosphor-dim); font-size: .43rem; letter-spacing: .04em; }
.status-cell strong { display: flex; align-items: center; min-width: 0; overflow: hidden; color: var(--phosphor-hi); font-size: .54rem; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.status-cell small { display: none; }
.scene-readout strong { font-size: .54rem; letter-spacing: -.02em; }
.lamp { display: inline-block; flex: 0 0 auto; width: 5px; height: 5px; margin: 0 3px 0 0; border: 1px solid var(--phosphor-dim); border-radius: 50%; background: transparent; box-shadow: none; }
.lamp.good { border-color: var(--good); background: var(--good); box-shadow: 0 0 7px rgba(183,255,60,.8); }
.lamp.warn { border-color: var(--danger); background: var(--danger); box-shadow: 0 0 7px rgba(255,106,50,.8); }
.alarm-line { min-height: 18px; margin-top: 2px; padding: 2px 5px; overflow: hidden; background: var(--phosphor); color: #1c1400; font-size: .48rem; text-overflow: ellipsis; text-shadow: none; white-space: nowrap; }
.alarm-line span { opacity: .65; }
.alarm-line.warn { background: var(--danger); color: #170400; }
.alarm-line.live { background: var(--good); color: #0c1600; }

.console-body { width: 100%; min-width: 0; max-width: 100%; padding: 6px 6px calc(82px + env(safe-area-inset-bottom)); overflow: hidden; }
.tab-page { min-width: 0; max-width: 100%; }
.mode-banner { margin-bottom: 8px; border: 1px solid var(--line); padding: 8px 10px; color: var(--phosphor-hi); font-size: clamp(1rem, 5.5vw, 1.4rem); text-align: center; letter-spacing: .04em; }
.terminal-panel { min-width: 0; max-width: 100%; margin-bottom: 7px; padding: 8px; overflow: hidden; }
.panel-title { min-width: 0; margin: -8px -8px 8px; border-bottom: 1px solid var(--line); padding: 6px 7px; color: var(--phosphor-hi); font-size: .58rem; letter-spacing: .04em; }
.panel-title > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-title > span:last-child { color: var(--phosphor-dim); }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 9px; }
.presets button, .text-command { min-height: 38px; border: 1px solid var(--hairline); border-radius: 0; background: transparent; color: var(--phosphor); font-size: .65rem; text-shadow: var(--glow); }
.presets button:active, .presets button:hover { border-color: var(--line); background: rgba(255,199,44,.1); }
.destination { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 6px; min-width: 0; min-height: 54px; margin-bottom: 6px; border: 1px solid var(--hairline); padding: 7px; overflow: hidden; background: rgba(0,0,0,.32); }
.destination input { appearance: none; width: 19px; height: 19px; margin: 0; border: 1px solid var(--line); border-radius: 0; background: transparent; }
.destination input:checked { background: var(--phosphor); box-shadow: inset 0 0 0 4px #090a04, var(--glow); }
.destination input:disabled { opacity: .25; }
.destination strong, .destination small { display: block; }
.destination strong { overflow: hidden; color: var(--phosphor-hi); font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.destination small { margin-top: 3px; color: var(--phosphor-dim); font-size: .56rem; text-shadow: none; }
.pill { border: 1px solid var(--hairline); padding: 4px 5px; color: var(--phosphor-dim); font-size: .52rem; text-shadow: none; }
.pill.active { border-color: var(--good); color: var(--good); box-shadow: 0 0 6px rgba(183,255,60,.22); }
.launch-stack { display: grid; gap: 6px; margin-top: 10px; }
.command { min-height: 45px; border: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--phosphor-hi); padding: 10px 12px; text-align: center; text-decoration: none; text-shadow: var(--glow); }
.command.primary { background: var(--phosphor); color: #1a1200; font-weight: 900; text-shadow: none; }
.command.danger { border-color: rgba(255,106,50,.64); color: var(--danger); }
.command:active:not(:disabled) { transform: translateY(1px); filter: brightness(1.15); }
.live-glyph { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: currentColor; }
.scene-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.scene-button { min-height: 52px; border: 1px solid var(--hairline); border-radius: 0; background: #050602; color: var(--phosphor-dim); padding: 7px; font-size: .66rem; text-shadow: none; }
.scene-button.selected { border-color: var(--phosphor-hi); background: var(--phosphor); color: #1a1200; text-shadow: none; }
.microcopy { margin: 10px 0 0; color: var(--phosphor-dim); font-size: .52rem; line-height: 1.5; text-shadow: none; }

.readiness { color: var(--danger) !important; }
.readiness.ready { color: var(--good) !important; }
.checklist { display: grid; gap: 5px; }
.check { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; min-height: 38px; border-bottom: 1px dotted var(--hairline); color: var(--phosphor-dim); font-size: .65rem; }
.check::after { content: "FAIL"; color: var(--danger); }
.check span { color: var(--danger); }
.check.pass { color: var(--phosphor-hi); }
.check.pass::after { content: "READY"; color: var(--good); }
.check.pass span { color: var(--good); }
.text-command { min-height: auto; border: 0; padding: 0; }
.telemetry-grid { display: grid; margin: 0; }
.telemetry-grid div { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 58%); min-width: 0; min-height: 42px; align-items: center; border-bottom: 1px dotted var(--hairline); }
.telemetry-grid dt { color: var(--phosphor-dim); font-size: .58rem; }
.telemetry-grid dd { overflow: hidden; margin: 0; color: var(--phosphor-hi); font-size: .65rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.activity { margin: 0; padding: 0; list-style: none; counter-reset: log; }
.activity li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; min-width: 0; border-bottom: 1px dotted var(--hairline); padding: 9px 0; font-size: .63rem; counter-increment: log; }
.activity li::before { grid-column: 1 / -1; content: "LOG/0" counter(log); color: var(--phosphor-dim); font-size: .5rem; }
.activity li span:last-child { color: var(--phosphor-dim); text-align: right; text-shadow: none; }
.download-command { display: block; margin-top: 12px; }
.moblin-tool { margin-top: 14px; border-top: 1px dotted var(--hairline); padding-top: 12px; }
.moblin-tool .status-label { margin-bottom: 5px; }
.moblin-tool .command { width: 100%; }
.secret-output { margin-top: 10px; border: 1px solid var(--danger); padding: 8px; background: rgba(255,106,50,.06); }
.secret-output label { margin: 0 0 6px; color: var(--danger); }
.secret-output textarea { display: block; width: 100%; resize: vertical; border: 1px solid var(--hairline); border-radius: 0; outline: 0; background: #020300; color: var(--phosphor-hi); padding: 8px; font-size: .58rem; line-height: 1.35; overflow-wrap: anywhere; text-shadow: none; }
.secret-output .command { margin-top: 7px; }
.secret-output p { margin: 7px 0 0; color: var(--danger); font-size: .52rem; line-height: 1.4; text-shadow: none; }
.session-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.session-panel strong { display: block; color: var(--phosphor-hi); font-size: .64rem; }
.session-panel .command { min-height: 38px; font-size: .6rem; }

.tab-bar { position: fixed; right: 0; bottom: 0; left: 0; z-index: 12; display: grid; grid-template-columns: repeat(3, 1fr); width: min(860px, 100%); margin: auto; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(3,4,2,.98); box-shadow: 0 -8px 24px rgba(0,0,0,.9); }
.tab-bar button { min-height: 59px; border: 0; border-right: 1px solid var(--hairline); background: transparent; color: var(--phosphor-dim); font-size: .64rem; text-shadow: none; }
.tab-bar button:last-child { border-right: 0; }
.tab-bar button span { display: block; margin-bottom: 2px; font-size: .5rem; }
.tab-bar button.active { background: var(--phosphor); color: #1a1200; text-shadow: none; }
.toast { position: fixed; right: 10px; bottom: calc(70px + env(safe-area-inset-bottom)); left: 10px; z-index: 15; max-width: 840px; margin: auto; border: 1px solid var(--line); background: #0a0a03; color: var(--phosphor-hi); padding: 11px; font-size: .65rem; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .15s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (min-width: 600px) {
  body { font-size: 15px; }
  .command-header { padding-inline: 18px; }
  .console-body { padding: 14px 18px 90px; }
  .destinations { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .destination { grid-template-columns: 24px minmax(0, 1fr); margin: 0; }
  .destination .pill { grid-column: 2; justify-self: start; }
  .scene-actions { grid-template-columns: repeat(4, 1fr); }
  .checklist, .telemetry-grid { grid-template-columns: repeat(2, 1fr); column-gap: 18px; }
  .launch-stack { grid-template-columns: 2fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
