:root {
  --bg: #0b1220;
  --panel: rgba(10, 17, 30, 0.82);
  --panel-solid: #0f1828;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.35);
  --text: #e6edf6;
  --muted: #94a3b8;
  --dim: #64748b;
  --accent: #22d3ee;
  --accent-ink: #062a33;
  --good: #4ade80;
  --warn: #fbbf24;
  --crit: #f43f5e;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.4 var(--sans); }
#app { position: fixed; inset: 0; }
#stage, #view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#view { outline: none; touch-action: none; }
body[data-view="overhead"] #view { cursor: grab; }
button, select, input { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: rgba(255,255,255,0.05); color: var(--text); white-space: nowrap; }

button {
  background: rgba(30, 41, 59, 0.85); border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 11px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s; white-space: nowrap;
}
button:hover { background: rgba(51, 65, 85, 0.95); border-color: var(--muted); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.primary:hover { filter: brightness(1.08); }
button.sm { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
select, input[type="text"], input:not([type]), input[type="number"] {
  background: rgba(15, 23, 42, 0.9); border: 1px solid var(--line-strong); border-radius: 6px; padding: 5px 8px; min-width: 0;
}
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- top bar ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px; padding: 8px 12px;
  background: linear-gradient(180deg, rgba(5, 10, 20, 0.92), rgba(5, 10, 20, 0.7)); border-bottom: 1px solid var(--line); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; letter-spacing: 0.2px; }
.brand svg { width: 24px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 2.2; }
.brand .name { font-size: 16px; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; padding: 2px 7px; border-radius: 99px; background: rgba(34, 211, 238, 0.15); color: var(--accent); border: 1px solid rgba(34, 211, 238, 0.4); }
.badge[data-demo="1"] { background: rgba(251, 191, 36, 0.15); color: var(--warn); border-color: rgba(251, 191, 36, 0.5); }
.status { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.pill { font-size: 11px; font-weight: 700; letter-spacing: 0.4px; padding: 4px 9px; border-radius: 99px; background: rgba(51, 65, 85, 0.7); border: 1px solid var(--line-strong); color: var(--muted); }
.pill.strong { color: var(--text); background: rgba(34, 211, 238, 0.12); border-color: rgba(34, 211, 238, 0.45); }
.pill[data-state="good"] { color: #052e16; background: var(--good); border-color: var(--good); }
.pill[data-state="warn"] { color: #3a2500; background: var(--warn); border-color: var(--warn); }
.pill[data-state="crit"] { color: #fff; background: var(--crit); border-color: var(--crit); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.55; } }
.reg { display: flex; align-items: center; gap: 6px; white-space: nowrap; flex: none; padding: 3px 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: #f8fafc; color: #0b1220; font-weight: 750; }
.reg .lbl { font-size: 10px; letter-spacing: 0.8px; color: #475569; }
.tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: nowrap; justify-content: flex-end; }
.tools .ico { margin-right: 5px; color: var(--accent); }
.vr-btn { background: #7c3aed; border: 1px solid #a78bfa; border-radius: 6px; padding: 6px 11px; color: #fff; font-weight: 650; cursor: pointer; }
#demo-banner { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); z-index: 4; padding: 5px 14px; border-radius: 0 0 8px 8px; background: rgba(251, 191, 36, 0.92); color: #3a2500; font-weight: 650; font-size: 12px; }

/* ---------- panels ---------- */
.panel {
  position: absolute; top: 60px; left: 12px; width: 300px; max-height: calc(100% - 140px); overflow: auto; z-index: 3;
  background: var(--panel); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius);
  scrollbar-width: thin;
}
.panel.right { left: auto; right: 12px; width: 310px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel-solid); z-index: 1; }
.panel-head h2 { margin: 0; font-size: 12px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.collapse { padding: 0 8px; font-size: 14px; line-height: 20px; }
.panel.collapsed .panel-body { display: none; }
.panel-body { padding: 10px; }
.panel section + section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.panel h3 { margin: 0 0 7px; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--dim); }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.row.wrap { flex-wrap: wrap; }
.row > label:first-child:not(.chk) { color: var(--muted); min-width: 64px; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.note { color: var(--muted); font-size: 12px; margin: 6px 0; }

#heading-tape { width: 100%; height: 24px; display: block; border-radius: 4px; margin-bottom: 8px; }
.att-row { display: flex; gap: 10px; align-items: center; }
#attitude { width: 132px; height: 132px; flex: none; }
.att-side { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tel { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.tel label { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; color: var(--dim); min-width: 42px; }
.tel b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tel u { text-decoration: none; color: var(--muted); font-size: 11px; white-space: nowrap; }
.tel.big b { font-size: 20px; }
.tel.big label { min-width: 26px; }
.tel b.sm { font-size: 13px; margin-left: 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; margin-top: 6px; }
.grid .wide { grid-column: span 2; }
.mode-detail { margin: 8px 0 2px; padding: 5px 8px; border-radius: 6px; background: rgba(34, 211, 238, 0.08); border: 1px solid rgba(34, 211, 238, 0.2); color: var(--text); font-size: 12px; }
.batt { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); }
.batt-bar { height: 6px; border-radius: 3px; background: rgba(148, 163, 184, 0.2); overflow: hidden; margin: 5px 0; }
.batt-bar i { display: block; height: 100%; background: var(--good); transition: width 0.3s; }
.batt-bar i[data-level="warn"] { background: var(--warn); }
.batt-bar i[data-level="crit"] { background: var(--crit); }
.tel[data-level="warn"] b { color: var(--warn); }
.tel[data-level="crit"] b { color: var(--crit); }
.batt-sub { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; font-family: var(--mono); }
.motors { display: flex; gap: 8px; margin-top: 9px; height: 46px; }
.motor-bar { flex: 1; position: relative; background: rgba(148, 163, 184, 0.14); border-radius: 4px; overflow: hidden; }
.motor-bar i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(0deg, #0891b2, var(--accent)); }
.motor-bar span { position: absolute; top: 2px; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 700; color: var(--text); mix-blend-mode: difference; }

.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; padding: 5px 4px; font-size: 12px; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.stats { display: grid; gap: 3px; margin-top: 8px; }
.stats > div { display: flex; justify-content: space-between; gap: 8px; }
.stats span { color: var(--muted); }
.stats b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.score { margin-top: 8px; display: flex; align-items: baseline; gap: 6px; padding: 7px 9px; border-radius: 6px; background: rgba(34, 211, 238, 0.1); border: 1px solid rgba(34, 211, 238, 0.3); }
.score span { flex: 1; color: var(--muted); }
.score b { font-size: 22px; font-family: var(--mono); color: var(--accent); }
.legend { margin: 4px 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.legend .grad { display: block; width: 100%; height: 8px; border-radius: 4px; }
.legend .grad.alt { background: linear-gradient(90deg, #3b82f6 0%, #22d3ee 20%, #4ade80 40%, #facc15 60%, #ef4444 100%); }
.legend .grad.spd { background: linear-gradient(90deg, hsl(240 90% 55%), hsl(120 90% 55%), hsl(0 90% 55%)); }
.legend .ticks { display: flex; justify-content: space-between; width: 100%; color: var(--muted); font-size: 10px; font-family: var(--mono); }
.legend .ticks i { font-style: normal; }
.chip { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; color: #0b1220; }
.chip[data-m="STABILIZE"] { background: #22d3ee; } .chip[data-m="ALT_HOLD"] { background: #a3e635; } .chip[data-m="LOITER"] { background: #facc15; }
.chip[data-m="ACRO"] { background: #f97316; } .chip[data-m="RTL"] { background: #f43f5e; } .chip[data-m="LAND"] { background: #c084fc; }
.chip[data-m="AUTO"] { background: #818cf8; }
.captures { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.captures a { display: block; color: var(--muted); text-decoration: none; font-size: 10px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.captures img { display: block; width: 100%; }
.captures span { display: block; padding: 2px 5px; }

/* ---------- bottom bar ---------- */
#bottombar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 14px; padding: 8px 12px; z-index: 5;
  background: linear-gradient(0deg, rgba(5, 10, 20, 0.92), rgba(5, 10, 20, 0.7)); border-top: 1px solid var(--line);
}
.modes { display: flex; gap: 5px; flex-wrap: wrap; }
.modes button { display: inline-flex; align-items: center; gap: 6px; }
.modes button kbd { padding: 0 4px; font-size: 10px; }
.modes button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.modes button.auto.active { background: var(--warn); border-color: var(--warn); color: #3a2500; }
.armctl { display: flex; gap: 6px; }
#btn-arm { min-width: 86px; font-weight: 750; letter-spacing: 0.6px; background: #166534; border-color: var(--good); }
#btn-arm.armed { background: #7f1d1d; border-color: var(--crit); }
#btn-estop { font-weight: 800; background: #b91c1c; border-color: #fca5a5; color: #fff; letter-spacing: 0.6px; }
#sticks { width: 170px; height: 74px; margin-left: auto; flex: none; }

/* ---------- messages / overlays ---------- */
#messages { position: absolute; left: 324px; bottom: 70px; z-index: 4; display: flex; flex-direction: column; gap: 4px; max-width: min(560px, calc(100% - 660px)); pointer-events: none; }
.msg { padding: 5px 10px; border-radius: 6px; background: rgba(10, 17, 30, 0.85); border-left: 3px solid var(--accent); font-size: 12.5px; transition: opacity 1s; }
.msg .t { font-family: var(--mono); color: var(--dim); margin-right: 8px; font-size: 11px; }
.msg.good { border-color: var(--good); }
.msg.warn { border-color: var(--warn); color: #fde68a; }
.msg.crit { border-color: var(--crit); color: #fecdd3; background: rgba(60, 10, 20, 0.9); font-weight: 650; }
.msg.fade { opacity: 0; }
#pause-overlay { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; z-index: 4; background: rgba(5, 10, 20, 0.35); pointer-events: none; }
#pause-overlay div { font-size: 40px; font-weight: 800; letter-spacing: 6px; }
#pause-overlay small { color: var(--muted); }
#pause-overlay[hidden] { display: none; }
#overhead-scale { position: absolute; left: 324px; top: 62px; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; background: rgba(10, 17, 30, 0.8); font-size: 12px; }
#overhead-scale .bar i { display: block; height: 6px; border: 1.5px solid #fff; background: linear-gradient(90deg, #fff 50%, transparent 50%); }
#overhead-scale .north { color: #f43f5e; font-weight: 800; }
#overhead-scale .hint { color: var(--dim); font-size: 11px; }
#challenge-hud { position: absolute; top: 62px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100% - 680px)); min-width: 300px; z-index: 4; padding: 9px 12px; border-radius: var(--radius); background: rgba(10, 17, 30, 0.9); border: 1px solid rgba(34, 211, 238, 0.45); }
.ch-top { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); }
.ch-top .ch-name { font-weight: 700; color: var(--accent); letter-spacing: 0.4px; text-transform: uppercase; }
.ch-top button { margin-left: auto; }
#ch-title { font-size: 15px; font-weight: 700; margin-top: 4px; }
#ch-instr { color: var(--muted); font-size: 12.5px; margin: 2px 0 6px; }
.ch-prog { height: 6px; background: rgba(148, 163, 184, 0.2); border-radius: 3px; overflow: hidden; }
.ch-prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
#ch-live { margin-top: 5px; font-family: var(--mono); font-size: 12px; }

body.clean .panel, body.clean #messages, body.clean #challenge-hud { display: none; }

/* ---------- mission planner ---------- */
.dlg.mission { width: min(1320px, calc(100% - 24px)); }
.dlg-body.mp { display: grid; gap: 10px; }
.mp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.mp-tools label, .mp-survey label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.mp-tools input[type="number"] { width: 66px; }
.mp-tools .seg button { padding: 5px 12px; }
.mp-survey { display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px; border: 1px dashed rgba(34, 211, 238, 0.5); border-radius: 6px; }
.mp-main { display: grid; grid-template-columns: minmax(0, 1fr) 410px; gap: 12px; }
.mp-map { position: relative; height: min(64vh, 620px); min-height: 320px; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.mp-map canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.mp-map canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mp-hint { position: absolute; top: 8px; left: 8px; right: 48px; padding: 4px 8px; border-radius: 5px; background: rgba(10, 17, 30, 0.75); color: var(--muted); font-size: 11.5px; pointer-events: none; }
.mp-side { display: flex; flex-direction: column; gap: 8px; height: min(64vh, 620px); min-height: 320px; min-width: 0; }
.mp-side .row { margin: 0; }
.mp-side .row > input { flex: 1; }
.mp-add .note { margin: 0; }
.mp-items { flex: 1; min-height: 120px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; scrollbar-width: thin; }
.mp-empty { padding: 10px 12px; }
.mp-row { padding: 6px 8px 7px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mp-row:hover { background: rgba(148, 163, 184, 0.06); }
.mp-row.sel { background: rgba(34, 211, 238, 0.1); box-shadow: inset 3px 0 0 var(--accent); }
.mp-row.live .mp-n { color: var(--warn); }
.mp-l1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mp-n { flex: none; width: 22px; text-align: right; font-family: var(--mono); font-weight: 700; color: var(--muted); }
.mp-l1 select { padding: 3px 6px; font-size: 12px; }
.mp-pos { flex: 1; min-width: 0; font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-acts { display: flex; gap: 3px; flex: none; }
.mp-acts button { padding: 1px 7px; font-size: 12px; line-height: 18px; }
.mp-l2 { display: flex; flex-wrap: wrap; gap: 5px 10px; margin: 6px 0 0 28px; }
.mp-f { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11.5px; }
.mp-f input { width: 52px; padding: 3px 5px; font-size: 12px; }
.mp-side .stats { margin-top: 0; }
.mp-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; max-height: 128px; overflow: auto; font-size: 12px; scrollbar-width: thin; }
.mp-issues li { padding: 3px 8px; border-radius: 4px; border-left: 3px solid var(--warn); background: rgba(251, 191, 36, 0.08); color: #fde68a; }
.mp-issues li.err { border-color: var(--crit); background: rgba(244, 63, 94, 0.1); color: #fecdd3; }
.mp-issues li.ok { border-color: var(--good); background: rgba(74, 222, 128, 0.08); color: #bbf7d0; }
.mp-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#mp-status { margin: 0 auto 0 0; }
#mp-status[data-level="warn"] { color: var(--warn); }
#mp-status[data-level="crit"] { color: var(--crit); }
#mp-status[data-level="good"] { color: var(--good); }

/* ---------- dialogs ---------- */
.dlg { padding: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel-solid); color: var(--text); width: min(820px, calc(100% - 32px)); max-height: calc(100% - 48px); }
.dlg.wide { width: min(1000px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(2, 6, 12, 0.6); backdrop-filter: blur(2px); }
.dlg header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel-solid); z-index: 1; }
.dlg header h2 { margin: 0; font-size: 16px; }
.dlg .x { font-size: 20px; line-height: 1; padding: 2px 10px; }
.dlg-body { padding: 14px 16px 18px; }
.dlg-body.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 12px; margin: 0; min-width: 0; }
.dlg fieldset.span2 { grid-column: span 2; }
.dlg legend { padding: 0 6px; color: var(--accent); font-weight: 650; font-size: 12px; letter-spacing: 0.4px; text-transform: uppercase; }
.dlg fieldset > label:not(.chk) { display: grid; gap: 4px; margin: 8px 0; color: var(--muted); font-size: 12px; }
.dlg fieldset > label output { float: right; color: var(--text); font-family: var(--mono); }
.dlg fieldset > label { position: relative; }
.pid-grid { display: grid; grid-template-columns: 110px repeat(3, 1fr); gap: 6px 8px; align-items: center; }
.pid-grid b { color: var(--muted); font-size: 11px; text-align: center; }
.pid-grid span { color: var(--muted); }
.content-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.content-grid div { display: grid; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
.content-grid b { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.6px; }

.ctl-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.ctl-cols h3, .dlg h4 { margin: 12px 0 6px; font-size: 11px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--dim); }
.chan-list, .raw-list { display: grid; gap: 4px; }
.chan { display: grid; grid-template-columns: 64px 1fr 42px; gap: 8px; align-items: center; font-size: 12px; }
.chan b { font-family: var(--mono); text-align: right; }
.chan .bar { position: relative; height: 10px; border-radius: 5px; background: rgba(148, 163, 184, 0.16); overflow: hidden; }
.chan .bar::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line-strong); }
.chan .bar.uni::after { display: none; }
.chan .bar i { position: absolute; top: 0; bottom: 0; background: var(--accent); }
.btn-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.btn-list span { font-family: var(--mono); font-size: 11px; min-width: 24px; text-align: center; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; color: var(--dim); }
.btn-list span.on { background: var(--accent); color: var(--accent-ink); }
.wizard { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(34, 211, 238, 0.04); }
.wizard p { margin: 4px 0 8px; }
.wz-step { font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; }
.warn { color: var(--warn); }
.map-grid { display: grid; gap: 4px; }
.map-grid label:not(.chk) { display: grid; gap: 4px; color: var(--muted); font-size: 12px; margin: 4px 0; }
.map-grid label output { float: right; }
.map-row { display: grid; grid-template-columns: 1fr 1fr 50px; gap: 8px; align-items: center; text-transform: capitalize; }
.map-row.head span { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.6px; }
.profiles { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.profiles li { display: grid; grid-template-columns: 80px 1fr; gap: 2px 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.profiles small { grid-column: 2; color: var(--muted); }
.tag { grid-row: span 2; align-self: start; font-size: 10px; font-weight: 700; text-align: center; padding: 2px 6px; border-radius: 4px; background: rgba(148, 163, 184, 0.2); color: var(--muted); }
.tag.ok { background: var(--good); color: #052e16; }
details summary { cursor: pointer; color: var(--accent); margin-top: 14px; }

.steps { padding-left: 20px; }
.steps li { margin: 6px 0; }
.steps span { color: var(--muted); }
.result { display: flex; align-items: baseline; gap: 14px; padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; }
.result.pass { background: rgba(74, 222, 128, 0.12); border: 1px solid var(--good); }
.result.fail { background: rgba(244, 63, 94, 0.12); border: 1px solid var(--crit); }
.result b { font-size: 20px; letter-spacing: 1px; }
.result span { font-size: 24px; font-family: var(--mono); font-weight: 700; }
.result small { margin-left: auto; color: var(--muted); }
table.res { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.res th, table.res td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.res th { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
table.res td:nth-child(2) { font-family: var(--mono); font-weight: 700; }
table.res tr.failed td { color: var(--crit); }
.help-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.help h3 { margin: 14px 0 6px; color: var(--accent); font-size: 13px; }
.help table { width: 100%; border-collapse: collapse; }
.help td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.help td:first-child { width: 42%; }
.help ul { padding-left: 18px; }
.help li { margin: 4px 0; }

@media (max-width: 1500px) {
  #topbar { gap: 10px; }
  .tools button { padding: 5px 8px; font-size: 12px; }
  #st-input { display: none; }
}
@media (max-width: 1280px) {
  .panel { width: 270px; }
  .panel.right { width: 280px; }
  #messages { left: 292px; max-width: calc(100% - 600px); }
}
@media (max-width: 980px) {
  #topbar { flex-wrap: wrap; }
  .tools { margin-left: 0; flex-wrap: wrap; }
  .panel { top: auto; bottom: 64px; max-height: 40%; }
  .panel.right { display: none; }
  #messages { left: 12px; bottom: auto; top: 110px; max-width: calc(100% - 24px); }
  #challenge-hud { top: 120px; width: calc(100% - 24px); min-width: 0; }
  #overhead-scale { left: 12px; top: 120px; }
  #overhead-scale .hint { display: none; }
  .dlg-body.cols, .ctl-cols, .mp-main { grid-template-columns: 1fr; }
  .mp-side { height: auto; }
  .mp-items { max-height: 320px; }
  .dlg fieldset.span2 { grid-column: auto; }
  #sticks { display: none; }
}

/* ---------- scenes, sensors, minimap, payload camera ---------- */
.badge[data-pro="1"] { background: rgba(167, 139, 250, 0.18); color: #c4b5fd; border-color: rgba(167, 139, 250, 0.55); }
.sensors { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.sens-head { display: flex; justify-content: space-between; align-items: center; font-size: 10px; font-weight: 700; letter-spacing: 0.6px; color: var(--dim); }
.sens-head b { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: rgba(148, 163, 184, 0.2); color: var(--muted); }
.sens-head b[data-state="good"] { background: rgba(74, 222, 128, 0.2); color: var(--good); }
.sens-head b[data-state="crit"] { background: var(--crit); color: #fff; }
.sens-body { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.sens-grid { display: grid; grid-template-columns: 42px 30px 42px; grid-template-rows: 22px 30px 22px; place-items: center; flex: none; }
.sens-grid span { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 1px 4px; border-radius: 4px; background: rgba(148, 163, 184, 0.14); color: var(--muted); min-width: 34px; text-align: center; }
.sens-grid span[data-level="ok"] { color: var(--good); }
.sens-grid span[data-level="warn"] { background: rgba(251, 191, 36, 0.25); color: var(--warn); }
.sens-grid span[data-level="crit"] { background: var(--crit); color: #fff; }
.s-f { grid-column: 2; grid-row: 1; }
.s-l { grid-column: 1; grid-row: 2; }
.s-r { grid-column: 3; grid-row: 2; }
.s-b { grid-column: 2; grid-row: 3; }
.s-drone { grid-column: 2; grid-row: 2; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 14px solid var(--accent); }
.sens-side { display: grid; gap: 3px; min-width: 0; flex: 1; }
.sens-side .tel b { font-size: 13px; }
.sens-side #sens-near { font-size: 11px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#minimap { position: absolute; right: 12px; bottom: 66px; width: 190px; height: 190px; z-index: 4; border-radius: var(--radius); border: 1px solid var(--line-strong); background: #1b2616; cursor: pointer; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35); }
.panel.right { max-height: calc(100% - 340px); }
#gimbal-view { position: absolute; right: 214px; bottom: 66px; width: 384px; height: 216px; z-index: 4; border-radius: var(--radius); border: 1px solid var(--line-strong); pointer-events: none; overflow: hidden; }
.gv-top { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; padding: 4px 8px; font-family: var(--mono); font-size: 11px; background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent); text-shadow: 0 1px 2px #000; }
.gv-top b { color: var(--accent); }
.gv-cross { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 1.5px solid rgba(255, 255, 255, 0.75); border-radius: 50%; }
.gv-cross::before, .gv-cross::after { content: ""; position: absolute; background: rgba(255, 255, 255, 0.75); }
.gv-cross::before { left: 50%; top: -8px; bottom: -8px; width: 1.5px; margin-left: -0.75px; }
.gv-cross::after { top: 50%; left: -8px; right: -8px; height: 1.5px; margin-top: -0.75px; }
.gv-scale { position: absolute; right: 8px; bottom: 22px; display: flex; align-items: center; gap: 4px; font: 700 9px var(--mono); color: #fff; text-shadow: 0 1px 2px #000; }
.gv-scale i { display: block; width: 90px; height: 7px; border-radius: 3px; background: linear-gradient(90deg, #00000d, #4d008c, #d91a40, #ff8c00, #ffffbf); }
.gv-keys { position: absolute; left: 8px; bottom: 4px; font: 10px var(--mono); color: rgba(255, 255, 255, 0.75); text-shadow: 0 1px 2px #000; }
body.gimbal-on #messages { max-width: calc(100% - 940px); }

#loading { position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 10px; background: rgba(5, 10, 20, 0.82); backdrop-filter: blur(4px); }
#loading b { font-size: 20px; }
#loading small { color: var(--muted); }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(34, 211, 238, 0.2); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.scene-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.scene-card { display: grid; gap: 6px; text-align: left; padding: 0 0 10px; overflow: hidden; border-radius: 10px; background: rgba(30, 41, 59, 0.7); white-space: normal; }
.scene-card .art { display: block; height: 96px; }
.scene-card b, .scene-card small, .scene-card em { padding: 0 12px; }
.scene-card b { font-size: 14px; }
.scene-card small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.scene-card em { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; color: var(--accent); text-transform: uppercase; }
.scene-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.scene-card.locked { opacity: 0.6; }
.scene-card.locked em { color: #c4b5fd; }
.scene-card.locked .art { filter: grayscale(0.7); }
.seg button:disabled { opacity: 0.35; }

@media (max-width: 1280px) {
  #gimbal-view { width: 288px; height: 162px; right: 186px; }
  #minimap { width: 164px; height: 164px; }
}
@media (max-width: 980px) {
  #minimap { width: 120px; height: 120px; }
  #gimbal-view { right: 140px; width: 224px; height: 126px; }
}

[hidden] { display: none !important; }
