/* Mission Control: a satellite-operations screen. The map of the take leads; the flow, the take, the neural
   score and the counts sit around it. Self-contained (system fonts, no external files); works from 375 px. */
:root {
  --ground: #0b0e13;
  --panel: #12161d;
  --panel-2: #171c24;
  --raise: #1d232d;
  --line: rgba(148, 163, 184, 0.13);
  --line-strong: rgba(148, 163, 184, 0.28);
  --ink: #e5e9ef;
  --muted: #9aa5b4;
  --faint: #7c8796;
  --geo: #a78bfa;                 /* the take's geometry: footprint, track, the satellite */
  --geo-soft: rgba(167, 139, 250, 0.16);
  --live: #60a5fa;                /* the step in progress, actions */
  --live-ink: #06142a;
  --good: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line-strong) var(--ground); }
body {
  margin: 0; background: var(--ground); color: var(--ink); min-height: 100vh;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: anywhere;
}
::selection { background: rgba(167, 139, 250, 0.35); color: #fff; }
:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
a { color: var(--live); text-underline-offset: 2px; }
h2 { font-size: 0.8rem; font-weight: 650; letter-spacing: 0.02em; margin: 0; color: var(--ink); }

/* the demo banner: fixed at the top, never covered, says what this screen is */
.demo-banner {
  position: sticky; top: 0; z-index: 10; margin: 0; padding: 3px 12px; text-align: center;
  background: #f5c84c; color: #1c1404; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em;
}
.demo-banner strong { text-transform: uppercase; letter-spacing: 0.08em; margin-right: 2px; }

/* the bar */
.bar {
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.mark { width: 24px; height: 24px; color: var(--geo); }
.brand-name { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); padding-left: 8px; border-left: 1px solid var(--line-strong); }
.status { flex: 1 1 20rem; margin: 0; color: var(--muted); font-size: 0.85rem; min-width: 0; }
.controls { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field-label { font-size: 0.7rem; color: var(--muted); }
select, button { font: inherit; min-height: 34px; border-radius: 6px; }
select {
  width: 15rem; max-width: 100%; padding: 4px 28px 4px 9px; color: var(--ink); appearance: none; -webkit-appearance: none;
  border: 1px solid var(--line-strong); background-color: var(--ground);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);   /* a chevron (CSP: no data: images) */
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
#neural { width: 20rem; }
option { background: var(--panel); color: var(--ink); }
button { padding: 4px 14px; border: 1px solid transparent; font-weight: 650; cursor: pointer; }
#start { background: var(--live); color: var(--live-ink); }
#start:hover:not(:disabled) { background: #93c5fd; }
button:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }
.clock { margin: 0; font-family: var(--mono); font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.clock span { color: var(--ink); }
.error { margin: 10px 16px 0; padding: 8px 12px; border: 1px solid rgba(248, 113, 113, 0.5); border-radius: 6px;
  background: rgba(248, 113, 113, 0.1); color: #fecaca; font-weight: 600; }

/* the console */
.console { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; padding: 12px 16px 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap;
  margin-bottom: 8px; }
.meta { margin: 0; color: var(--muted); font-size: 0.78rem; font-family: var(--mono); }
.purpose { flex-basis: 100%; margin: 2px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.flow .purpose { margin: 0 0 4px; }
.rail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.note { color: var(--faint); font-size: 0.76rem; line-height: 1.45; margin: 8px 0 0; }

/* the map */
.map-panel { display: flex; flex-direction: column; }
.map-box { position: relative; flex: none; height: clamp(440px, calc(100vh - 205px), 820px); border-radius: 6px; overflow: hidden;
  background: #080b10; border: 1px solid var(--line); }
.map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map .grid line { stroke: rgba(148, 163, 184, 0.09); stroke-width: 1; }
.map .grid text { fill: var(--faint); font: 10px var(--mono); }
.map .city circle { fill: var(--muted); }
.map .city text { fill: #cbd5e1; font: 11px system-ui, sans-serif; paint-order: stroke; stroke: #080b10;
  stroke-width: 3px; stroke-linejoin: round; }
.map .city circle { stroke: #080b10; stroke-width: 1.5px; }
.map .track { stroke: var(--geo); stroke-width: 1.5; stroke-dasharray: 6 5; fill: none; opacity: 0.75; }
.map .track-take { stroke: var(--geo); stroke-width: 3; fill: none; }
.map .beam { stroke: var(--geo); stroke-width: 1; opacity: 0.35; }
.map .footprint { fill: var(--geo-soft); stroke: var(--geo); stroke-width: 1.5; }
.map .sat circle { fill: var(--geo); }
.map .sat .ring { fill: none; stroke: var(--geo); stroke-width: 1; opacity: 0.5; }
.map .label { fill: var(--ink); font: 600 12px system-ui, sans-serif; paint-order: stroke; stroke: #080b10; stroke-width: 3px; }
.map .label-sub { fill: var(--muted); font: 10px var(--mono); paint-order: stroke; stroke: #080b10; stroke-width: 3px; }
.map-empty { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); margin: 0; max-width: 24rem;
  text-align: center; color: var(--muted); }

/* the flow, along the foot of the map */
.flow { position: absolute; left: 10px; right: 10px; bottom: 10px; padding: 10px 12px 8px; border-radius: 8px;
  background: rgba(11, 14, 19, 0.86); border: 1px solid var(--line-strong); }
.current { margin: 0 0 8px; font-size: 0.86rem; min-height: 1.45em; }
.chain, .tiers { list-style: none; margin: 0; padding: 0; display: flex; align-items: stretch; min-width: 0; }
.tiers { gap: 6px; flex: 1 1 auto; }
.link { flex: 0 1 26px; min-width: 8px; align-self: center; height: 1px; background: var(--line-strong); }
.gate { flex: 3 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 4px 5px 5px;
  border: 1px dashed var(--line-strong); border-radius: 7px; }
.gate-name { font-size: 0.68rem; color: var(--muted); padding-left: 2px; }
.node { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 7px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel-2); transition: border-color 0.25s, background 0.25s; }
.node .dot { grid-row: 1 / span 2; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.node .name { font-weight: 650; font-size: 0.85rem; }
.node .sub { font-size: 0.7rem; color: var(--muted); }
.node.on { border-color: var(--live); }
.node.on .dot { background: var(--live); box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25); }
.node.pass .dot { background: var(--good); }
.node.stop { border-color: var(--bad); background: rgba(248, 113, 113, 0.1); }
.node.stop .dot { background: var(--bad); border-radius: 1px; transform: rotate(45deg); }
.node.flag { border-color: rgba(251, 191, 36, 0.7); }
.node.flag .dot { background: var(--warn); border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.progress { margin-top: 8px; height: 2px; background: var(--line); border-radius: 1px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--live); transition: width 0.5s ease-out; }

/* the take */
.views { display: inline-flex; padding: 3px; gap: 2px; background: var(--ground); border: 1px solid var(--line);
  border-radius: 6px; }
.view { min-height: 26px; padding: 2px 9px; font-size: 0.75rem; font-weight: 600; color: var(--muted); background: none; }
.view:hover { color: var(--ink); }
.view[aria-pressed="true"] { background: var(--raise); color: var(--ink); }
.take { margin: 0; aspect-ratio: 1500 / 953; border-radius: 6px; overflow: hidden; background: #080b10;
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.take img { width: 100%; height: 100%; object-fit: contain; display: block; }
.take.has-picture .take-empty { display: none; }
.take-empty { margin: 0; color: var(--faint); font-size: 0.8rem; }
.caption { margin: 6px 0 0; color: var(--muted); font-size: 0.76rem; }
.picture-note { margin: 4px 0 0; color: var(--warn); font-size: 0.78rem; font-weight: 600; }

/* the neural score chart */
.chart { display: block; width: 100%; height: 120px; }
.chart .bar { fill: #64748b; }
.chart .bar.alarm { fill: var(--warn); }
.chart .bar.kept { fill: var(--bad); }
.chart .bar.none { fill: #334155; }
.chart .bar.wait { fill: rgba(148, 163, 184, 0.08); }
.chart .bar.now { stroke: var(--live); stroke-width: 1; }
.chart .thr { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.8; }
.chart .thr-label { fill: var(--ink); font: 9px var(--mono); }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.legend { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 0.75rem; color: var(--muted); }
.key { display: inline-block; width: 8px; height: 8px; border-radius: 1px; margin-right: 5px; vertical-align: 0; }
.key-score { background: #64748b; } .key-alarm { background: var(--warn); }
.key-kept { background: var(--bad); } .key-none { background: #334155; }

/* the counts: one panel, a 3-column grid of figures */
.counts { margin: 8px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.counts > div { padding: 8px 6px 7px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.counts dt { order: 1; font-size: 0.75rem; color: var(--muted); line-height: 1.25; }
.counts dd { order: 2; margin: 2px 0 0; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.counts .unit { order: 3; font-size: 0.68rem; color: var(--faint); }
.counts > div.bad dd { color: var(--bad); }
.counts > div.warn dd { color: var(--warn); }
.result { margin: 10px 0 0; padding: 8px 10px; font-size: 0.8rem; font-weight: 600; border-radius: 6px; border: 1px solid; }
.result.good { color: #a7f3d0; border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.result.bad { color: #fecaca; border-color: rgba(248, 113, 113, 0.45); background: rgba(248, 113, 113, 0.08); }

/* the logs: one entry per capture, newest first */
.logs { margin: 12px 16px 0; }
.logs .panel-head { margin-bottom: 10px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 72vh; overflow: auto; border: 1px solid var(--line);
  border-radius: 6px; scrollbar-color: var(--line-strong) var(--panel); }
.log:empty { display: none; }
.entry { padding: 10px 14px 11px; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry.lv-critical { background: rgba(248, 113, 113, 0.09); }
.entry.lv-alert { background: rgba(248, 113, 113, 0.045); }
.entry.lv-caution { background: rgba(251, 191, 36, 0.045); }
.log.alerts-only .entry[data-level="normal"] { display: none; }
.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.sev { display: inline-flex; align-items: center; gap: 7px; min-width: 8rem; font-weight: 700; font-size: 0.82rem; }
.sym { width: 9px; height: 9px; flex: none; }
.lv-normal .sev { color: var(--good); }
.lv-normal .sym { background: var(--good); border-radius: 50%; }
.lv-caution .sev { color: var(--warn); }
.lv-caution .sym { background: var(--warn); clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 10px; }
.lv-alert .sev { color: var(--bad); }
.lv-alert .sym { background: var(--bad); transform: rotate(45deg); width: 8px; height: 8px; }
.lv-critical .sev { color: #ff8a8a; }
.lv-critical .sym { background: #ff5c5c; border-radius: 1px; }
.time { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.seq { font-family: var(--mono); font-size: 0.78rem; color: var(--faint); }
.subject { font-weight: 650; }
.attack { font-family: var(--mono); font-size: 0.76rem; padding: 0 6px; border-radius: 4px; color: var(--ink);
  background: var(--raise); border: 1px solid var(--line); }
.why { margin: 5px 0 0; max-width: 90ch; color: var(--ink); font-size: 0.86rem; line-height: 1.45; }
.why strong { font-weight: 650; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 3px 18px; margin: 8px 0 0;
  font-size: 0.78rem; }
.facts > div { display: flex; gap: 8px; min-width: 0; }
.facts dt { flex: none; width: 7.5rem; color: var(--faint); }
.facts dd { margin: 0; min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.facts .mono { font-family: var(--mono); }
.empty { margin: 0; padding: 12px; color: var(--muted); }

/* the packet inspector of an entry */
.entry-actions { margin-top: 8px; }
.inspect-btn { min-height: 28px; padding: 2px 10px; font-size: 0.78rem; color: var(--ink); background: var(--raise);
  border: 1px solid var(--line-strong); }
.inspect-btn:hover { border-color: var(--live); }
.inspector { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--ground); }
.insp-sum { margin: 0 0 8px; font-size: 0.82rem; color: var(--ink); }
.pk-box { overflow-x: auto; }
.pk { border-collapse: collapse; width: 100%; min-width: 52rem; font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.pk th, .pk td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pk th { color: var(--faint); font-weight: 600; }
.pk td { font-family: var(--mono); color: var(--muted); }
.pk td.why-cell { font-family: inherit; white-space: normal; color: var(--ink); }
.pk tbody tr { cursor: pointer; }
.pk tbody tr:hover td { background: rgba(148, 163, 184, 0.05); }
.pk tbody tr.sel td { background: rgba(96, 165, 250, 0.1); }
.hex { margin-top: 10px; }
.hex-title { margin: 8px 0 4px; font-size: 0.76rem; color: var(--muted); }
.hex-label { margin: 0 0 2px; font-size: 0.72rem; color: var(--faint); }
.hexpair { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 12px; }
.hexrows { font-family: var(--mono); font-size: 0.74rem; line-height: 1.55; overflow-x: auto; }
.hexline { white-space: nowrap; }
.hexoff { color: var(--faint); margin-right: 10px; white-space: pre; }
.oct { display: inline-block; width: 2.2ch; margin-right: 0.5ch; color: var(--muted); }
.oct.diff { color: #1c0a0a; background: var(--bad); border-radius: 2px; font-weight: 700; }
.hexrows.orig .oct.diff { background: var(--good); color: #04140d; }

.foot { padding: 16px 16px 24px; color: var(--faint); font-size: 0.78rem; }
.foot p { margin: 3px 0; }
.credit { color: var(--muted); }

[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .console { grid-template-columns: 1fr; }
  .rail { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
}
@media (max-width: 720px) {
  .bar { padding: 10px 12px; }
  .status { order: 3; flex-basis: 100%; }
  .controls, .field { width: 100%; }
  select, #neural { width: 100%; }
  #start { flex: 1 1 100%; min-height: 40px; }
  .console { padding: 10px 12px 0; }
  .logs { margin: 10px 12px 0; }
  .facts dt { width: 6.5rem; }
  .map-box { height: auto; display: flex; flex-direction: column; }
  .map { position: static; height: auto; aspect-ratio: 1000 / 600; }
  .flow { position: static; border-radius: 0; border-width: 1px 0 0; }
  .chain { flex-wrap: wrap; gap: 6px; }
  .link { display: none; }
  .gate { flex: 1 1 100%; order: 1; }
  .chain > .node:not([data-node="satellite"]) { order: 2; }
  .chain > .node { flex: 1 1 30%; }
  .node .sub { display: none; }
  .counts { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .node, .progress span { transition: none; }
}
