/* DuckQuest HUD: mission control over a colony. Glass panels on the 3D view, one teal
   signal color for the agents and the comms, amber for warnings, red for what is failing.

   Theming is token-only (the Izzy Tools standard): :root holds the light values, which are
   the default; one body.dark block re-declares the same tokens; High Visibility rides the
   hr-hivis class on <html> and re-declares inks, line widths and the text scale. Every
   rule below reads tokens, so it works in every combination. Sizes are written as
   calc(Npx * var(--fs)) so High Visibility can scale them. */
:root {
  /* Brand */
  --signal: #0e7466;
  --signal-strong: #0a5c51;
  --on-signal: #ffffff;
  --amber: #9a5c00;
  --red: #b8322a;
  --on-red: #ffffff;
  --good: #2c7f25;

  /* Surfaces */
  --glass: rgba(246, 249, 248, 0.88);
  --glass-strong: rgba(250, 252, 251, 0.96);
  --bar-top: rgba(250, 252, 251, 0.97);
  --bar-bottom: rgba(240, 246, 244, 0.92);
  --edge: rgba(14, 116, 102, 0.24);
  --edge-strong: rgba(14, 116, 102, 0.55);
  --hover: rgba(14, 116, 102, 0.08);
  --selected: rgba(14, 116, 102, 0.12);
  --field: rgba(255, 255, 255, 0.9);
  --track: rgba(0, 0, 0, 0.1);
  --shadow: rgba(16, 32, 30, 0.18);
  --overlay-in: #eef4f2;
  --overlay-out: #cfdcd8;
  /* Text over space on the landing globe: space is dark in every mode, so these stay as they are. */
  --orbit-ink: #e8f2ef;
  --orbit-dim: #cfdcd8;
  --orbit-glass: rgba(6, 12, 16, 0.72);
  --orbit-glass-strong: rgba(6, 12, 16, 0.92);
  --orbit-hint: rgba(6, 12, 16, 0.6);
  --orbit-edge: rgba(201, 209, 208, 0.45);
  --orbit-open: #5fd4c4;

  /* Ink */
  --ink: #14211f;
  --ink-dim: #3c514b;
  --ink-faint: #607169;

  /* Type */
  --font-ui: "Bahnschrift", "DIN Alternate", "Avenir Next Condensed", "Segoe UI", system-ui, sans-serif;
  --font-data: "Cascadia Mono", "Consolas", "SF Mono", ui-monospace, monospace;
  --fs: 1;              /* text scale: 1, or larger under High Visibility */
  --sw: 1px;            /* line width: borders, rules, focus rings */

  /* Layout */
  --radius: 4px;
  --bar-h: calc(46px * var(--fs));
  --gap: 12px;
  --side-w: calc(270px * var(--fs));
  --agents-w: calc(300px * var(--fs));
  --feed-w: 228px;
  --feed-h: 142px;
  --comms-h: calc(236px * var(--fs));
  color-scheme: light;
}

body.dark {
  --signal: #5fd4c4;
  --signal-strong: #1f7f74;
  --on-signal: #ffffff;
  --amber: #f2b84b;
  --red: #ff6b5b;
  --on-red: #10181b;
  --good: #8fdc7a;
  --glass: rgba(9, 17, 21, 0.78);
  --glass-strong: rgba(7, 13, 16, 0.92);
  --bar-top: rgba(5, 10, 12, 0.95);
  --bar-bottom: rgba(8, 15, 18, 0.82);
  --edge: rgba(126, 214, 199, 0.22);
  --edge-strong: rgba(126, 214, 199, 0.5);
  --hover: rgba(126, 214, 199, 0.06);
  --selected: rgba(126, 214, 199, 0.1);
  --field: rgba(0, 0, 0, 0.35);
  --track: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.35);
  --overlay-in: #13242a;
  --overlay-out: #070d0f;
  --ink: #e4efec;
  --ink-dim: #9fb4ae;
  --ink-faint: #6c837d;
  color-scheme: dark;
}

/* High Visibility: bigger text, heavier lines, solid panels, no faint ink. The scale sits on
   the root, where the layout tokens built from it are computed; the inks sit on body, beside
   the theme's. */
:root.hr-hivis {
  --fs: 1.25;
  --sw: 2px;
}
.hr-hivis body {
  --glass: rgba(255, 255, 255, 0.98);
  --glass-strong: #ffffff;
  --bar-top: #ffffff;
  --bar-bottom: #ffffff;
  --edge: rgba(0, 0, 0, 0.55);
  --edge-strong: #000000;
  --signal: #005a4e;
  --signal-strong: #004a40;
  --amber: #7a4600;
  --red: #9c1b13;
  --on-red: #ffffff;
  --ink: #000000;
  --ink-dim: #111a18;
  --ink-faint: #26332f;
}
.hr-hivis body.dark {
  --glass: rgba(0, 0, 0, 0.96);
  --glass-strong: #000000;
  --bar-top: #000000;
  --bar-bottom: #000000;
  --edge: rgba(255, 255, 255, 0.6);
  --edge-strong: #ffffff;
  --signal: #7ff0e0;
  --signal-strong: #1f8f83;
  --amber: #ffd27a;
  --red: #ff8f82;
  --on-red: #000000;
  --ink: #ffffff;
  --ink-dim: #f0f4f3;
  --ink-faint: #d4dedb;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--overlay-out);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: calc(14px * var(--fs));
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: calc(var(--sw) * 2) solid var(--signal); outline-offset: 2px; }

#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* UI size (U5): the HUD, its cards and the landing screen's panels zoom together, 50% to 150%
   (--ui, set by js/ui/settings.js). The colony and the globe behind them never do, nor do the
   globe's labels, which sit on the planet. */
:root { --ui: 1; }
#hud, .mission-card, .landing-pick, .landing-site, .landing-hint, .landing-tabs { zoom: var(--ui); }

/* Above the landing screen, a later layer of its own, so the menu and its flyouts open over its
   panels rather than under them (G3). */
#hud { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
#hud .topbar, #hud .panel, #hud .feed, #hud .menu { pointer-events: auto; }

.panel {
  background: var(--glass);
  border: var(--sw) solid var(--edge);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 30px var(--shadow);
}
.panel-title {
  margin: 0;
  padding: 8px 12px 6px;
  font-size: calc(12px * var(--fs));
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-bottom: var(--sw) solid var(--edge);
}
.chip {
  font-family: var(--font-data); font-size: calc(10px * var(--fs)); padding: 1px 6px; border-radius: 3px;
  border: var(--sw) solid var(--edge); color: var(--ink-dim);
}
.chip.off { text-decoration: line-through; color: var(--ink-faint); border-style: dashed; }
.chip.gate { border-color: var(--amber); color: var(--amber); }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--bar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 14px;
  background: linear-gradient(to bottom, var(--bar-top), var(--bar-bottom));
  border-bottom: var(--sw) solid var(--edge);
}
.brand { display: flex; align-items: center; gap: 8px; flex: none; }
.brand-mark { width: calc(40px * var(--fs)); height: calc(40px * var(--fs)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-size: calc(17px * var(--fs)); font-weight: 700; letter-spacing: 0.03em; }
.brand-sub { font-size: calc(10px * var(--fs)); letter-spacing: 0.08em; text-transform: uppercase; color: var(--signal); white-space: nowrap; }

/* The readings. Selecting them opens Colony status. When they do not fit, the bar gives up room
   in steps (hud.js fitBar), each keeping the ones before. */
.resources { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex: 1; min-width: 0; overflow: hidden; cursor: pointer; }
.topbar.tight-1 .brand-text { display: none; }
.topbar.tight-2 .res .sub { display: none; }
.topbar.tight-3 .res .label { display: none; }
.topbar.tight-4 .res.minor { display: none; }
.topbar.tight-5 .sol { display: none; }
.topbar.tight-6 .resources { gap: 2px; }
.topbar.tight-6 .res { gap: 4px; padding: 2px 4px 2px 2px; }
.topbar.tight-6 .res svg { width: calc(18px * var(--fs)); height: calc(18px * var(--fs)); }
.res {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 6px;
  border: var(--sw) solid transparent; border-radius: var(--radius);
  white-space: nowrap;
}
.res:hover { border-color: var(--edge); background: var(--hover); }
.res svg { width: calc(22px * var(--fs)); height: calc(22px * var(--fs)); flex: none; color: var(--signal); }
.res .val { font-family: var(--font-data); font-size: calc(14px * var(--fs)); font-variant-numeric: tabular-nums; }
.res .sub { font-size: calc(11px * var(--fs)); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.res .label { display: block; font-size: calc(10px * var(--fs)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.res.warn .val { color: var(--amber); }
.res.crit .val { color: var(--red); }
.res.good .sub { color: var(--good); }

.clock { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.sol { font-size: calc(12px * var(--fs)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.time { font-family: var(--font-data); font-size: calc(16px * var(--fs)); font-variant-numeric: tabular-nums; min-width: calc(44px * var(--fs)); }
.speed { display: flex; border: var(--sw) solid var(--edge); border-radius: var(--radius); overflow: hidden; }
.speed button {
  background: transparent; border: 0; padding: 5px 9px; font-size: calc(12px * var(--fs)); color: var(--ink-dim);
  border-right: var(--sw) solid var(--edge);
}
.speed button:last-child { border-right: 0; }
.speed button[aria-pressed="true"] { background: var(--signal-strong); color: var(--on-signal); }

.menu-btn {
  display: grid; place-items: center;
  width: calc(36px * var(--fs)); height: calc(32px * var(--fs));
  background: transparent; border: var(--sw) solid var(--edge); border-radius: var(--radius); color: var(--ink);
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--hover); border-color: var(--edge-strong); }
.menu-btn svg { width: calc(18px * var(--fs)); height: calc(18px * var(--fs)); }

/* Hide UI: an eye beside the menu button. Its words show only once the UI is hidden, when it
   is the one thing left, at the top right over the colony. */
.hide-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: calc(36px * var(--fs)); height: calc(32px * var(--fs)); padding: 0 8px;
  background: transparent; border: var(--sw) solid var(--edge); border-radius: var(--radius); color: var(--ink);
}
.hide-btn:hover { background: var(--hover); border-color: var(--edge-strong); }
.hide-btn svg { width: calc(18px * var(--fs)); height: calc(18px * var(--fs)); flex: none; }
.hide-btn .eye-on, .ui-hidden .hide-btn .eye-off { display: none; }
.ui-hidden .hide-btn .eye-on { display: block; }
.hide-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ui-hidden .hide-text { position: static; width: auto; height: auto; overflow: visible; clip: auto; font-size: calc(13px * var(--fs)); font-weight: 600; }
.hide-new {
  padding: 0 7px; border-radius: 10px; font-family: var(--font-data); font-size: calc(11px * var(--fs));
  background: var(--signal-strong); color: var(--on-signal); white-space: nowrap;
}
.hide-new[hidden] { display: none; }

/* The speaker beside it mutes the agents' voices: waves while they speak, a cross once muted. */
.voice-btn .spk-off, .voice-btn[aria-pressed="true"] .spk-on { display: none; }
.voice-btn[aria-pressed="true"] .spk-off { display: block; }
.voice-btn[aria-pressed="true"] { background: var(--selected); border-color: var(--edge-strong); }
.voice-btn:disabled { opacity: 0.5; cursor: default; }
/* The satellite (W4): pressed while its window is open. */
.sat-btn[aria-expanded="true"] { background: var(--selected); border-color: var(--edge-strong); }

/* Never taller than the screen below the top bar: on a short screen, or at a large UI size, it
   scrolls to its last item (user, 2026-10-26: "Main menu is off bottom of screen"). */
.menu {
  position: absolute; top: calc(var(--bar-h) + 4px); right: 10px; z-index: 40;      /* above every window */
  min-width: calc(240px * var(--fs)); padding: 6px;
  max-height: calc(100% - var(--bar-h) - 12px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  display: flex; flex-direction: column;
  background: var(--glass-strong);
}
.menu > * { flex: none; }
/* Settings and Docs (U6): flyouts beside the menu, placed by js/ui/menu.js; the arrow points
   where they open. */
.submenu { min-width: calc(190px * var(--fs)); z-index: 41; }
#menu-settings-list { min-width: calc(250px * var(--fs)); }
.menu .sub-arrow { flex: none; width: calc(14px * var(--fs)); height: calc(14px * var(--fs)); color: var(--ink-dim); }
.menu [aria-haspopup="menu"][aria-expanded="true"] { background: var(--hover); }
.menu[hidden] { display: none; }
.menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 7px 10px; border: 0; border-radius: var(--radius); background: transparent;
  text-align: left; color: var(--ink);
}
.menu button:hover, .menu button:focus-visible { background: var(--hover); }
.menu .state { font-family: var(--font-data); font-size: calc(11px * var(--fs)); padding: 1px 8px; border-radius: 10px; border: var(--sw) solid var(--edge-strong); color: var(--signal); }
/* The UI size slider (U5): its name and value on a line, the slider under them. */
.menu-range { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; padding: 7px 10px 9px; }
.menu-range label { color: var(--ink); }
.menu-range output { font-family: var(--font-data); font-size: calc(11px * var(--fs)); padding: 1px 8px; border-radius: 10px; border: var(--sw) solid var(--edge-strong); color: var(--signal); }
.menu-range input { grid-column: 1 / -1; width: 100%; margin: 4px 0 0; accent-color: var(--signal-strong); }
.menu-model { display: flex; flex-direction: column; gap: 4px; padding: 9px 10px 7px; margin-top: 2px; }   /* no rule above it: the menu has none (U6) */
.menu-model label { font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.menu-model select {
  padding: 5px 6px; border-radius: var(--radius); border: var(--sw) solid var(--edge-strong);
  background: var(--field); color: var(--ink); font-size: calc(12px * var(--fs));
}

/* ---------------------------------------------------------------- mission card, alerts */
/* The left column, stopping above the comms console. */
.side {
  position: absolute; top: calc(var(--bar-h) + var(--gap)); left: var(--gap); width: var(--side-w);
  max-height: calc(100% - var(--bar-h) - var(--gap) * 3 - var(--comms-h));
  display: flex; flex-direction: column; gap: 8px;
}
.mission { flex: none; position: relative; }
.mission .panel-head .inline-btn:disabled { opacity: 0.5; }
.mission-body { padding: 6px 12px 9px; display: flex; flex-direction: column; gap: 2px; }
.mission-name { font-size: calc(15px * var(--fs)); font-weight: 600; }
.mission-time { font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.objectives { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.obj { display: grid; grid-template-columns: calc(14px * var(--fs)) 1fr; gap: 0 6px; font-size: calc(12px * var(--fs)); line-height: 1.3; }
.obj-mark { font-weight: 700; text-align: center; color: var(--ink-faint); }
.obj-state { grid-column: 2; font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.obj.holding .obj-mark, .obj.on-track .obj-mark, .obj.met .obj-mark { color: var(--good); }
.obj.not-yet .obj-mark, .obj.not-yet .obj-state { color: var(--amber); }
.obj.failed .obj-mark, .obj.failed .obj-state { color: var(--red); }
/* The satellite view (W4): a window under the top bar, between the mission card and the feeds
   until it is moved. The picture fills what room is left over the controls and the forecast. */
.sat {
  position: absolute; top: calc(var(--bar-h) + var(--gap)); left: calc(var(--side-w) + var(--gap) * 2);
  width: min(calc(520px * var(--fs)), calc(100% - var(--side-w) - var(--gap) * 3));
  height: min(calc(700px * var(--fs)), calc(100% - var(--bar-h) - var(--gap) * 2));
  min-width: calc(300px * var(--fs)); min-height: calc(320px * var(--fs));
  display: flex; flex-direction: column;
}
.sat[hidden] { display: none; }
.sat-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 10px; }
.sat-pic { flex: 1 1 auto; min-height: calc(120px * var(--fs)); display: grid; place-items: center; overflow: hidden; }
.sat-pic canvas { display: block; border-radius: var(--radius); border: var(--sw) solid var(--edge-strong); }
.sat-controls { flex: none; display: flex; align-items: center; gap: 8px; }
.sat-controls .inline-btn { margin-left: 0; }
.sat-ahead { flex: 1; display: flex; }
.sat-ahead input { flex: 1; min-width: 0; accent-color: var(--signal); }
#sat-when { min-width: calc(110px * var(--fs)); font-family: var(--font-data); font-size: calc(12px * var(--fs)); color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.sat-list { flex: none; max-height: 36%; overflow-y: auto; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin; }
.sat-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: calc(12px * var(--fs)); line-height: 1.35; }
.sat-kind {
  font-family: var(--font-data); font-size: calc(10px * var(--fs)); letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0 5px; border-radius: 3px; border: var(--sw) solid var(--amber); color: var(--amber);
}
.sat-strength { color: var(--ink-faint); }
.sat-times { flex-basis: 100%; color: var(--ink-dim); }
.sat-item.clear, .sat-item.sun { color: var(--ink-dim); }
.sat-item.pass { font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.sat-note { flex: none; margin: 0; font-size: calc(11px * var(--fs)); color: var(--ink-faint); line-height: 1.35; }

/* The blueprint (E1): a window like the satellite view. Unit chips over a plan of the colony,
   what the pointer or the cross is over, the plans in order and the hold on off plan builds. Its
   class is its own: the comms log's plan messages are li.msg.plan. */
.blueprint {
  position: absolute; top: calc(var(--bar-h) + var(--gap)); left: calc(var(--side-w) + var(--gap) * 2);
  width: min(calc(520px * var(--fs)), calc(100% - var(--side-w) - var(--gap) * 3));
  height: min(calc(760px * var(--fs)), calc(100% - var(--bar-h) - var(--gap) * 2));
  min-width: calc(300px * var(--fs)); min-height: calc(360px * var(--fs));
  display: flex; flex-direction: column;
}
.blueprint[hidden] { display: none; }

/* Generate URL/State (H2, H3, H9, H10): a window like Colony status, as tall as what it holds (user: "Generate
   URL/State window is HUGE!"): the code as a link or bare, Copy, its length, and under them the box that
   loads one, open at first and folding away like the landing screen's (.share-load-box). */
.share {
  position: absolute; top: calc(var(--bar-h) + var(--gap)); left: calc(var(--side-w) + var(--gap) * 2);
  width: min(calc(360px * var(--fs)), calc(100% - var(--side-w) - var(--gap) * 3));
  max-height: calc(100% - var(--bar-h) - var(--gap) * 2);
  min-width: calc(260px * var(--fs)); min-height: calc(160px * var(--fs));
  display: flex; flex-direction: column;
}
.share[hidden] { display: none; }
.share-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 10px; scrollbar-width: thin; }
.share-note, .share-hint { margin: 0; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.4; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.share-row .inline-btn { margin-left: 0; }
.share-row .inline-btn[aria-pressed="true"] { background: var(--selected); border-color: var(--signal); }
.share-copied { font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.share-text {
  width: 100%; box-sizing: border-box; resize: vertical; padding: 6px 8px; background: var(--field); color: var(--ink);
  border: var(--sw) solid var(--edge); border-radius: var(--radius); font: calc(11px * var(--fs)) / 1.35 var(--font-data); word-break: break-all;
}
.share-len { margin: 0; font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.share-msg { margin: 0; font-size: calc(12px * var(--fs)); color: var(--ink); line-height: 1.4; }
.share-msg.bad { color: var(--red); }
.share-msg:empty { display: none; }
.share-sub { margin: 2px 0 0; font-size: calc(13px * var(--fs)); }
.share-load-box > .share-load { margin-top: 6px; }
.share-load { display: flex; flex-direction: column; gap: 6px; }
.share-label { font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.share-choice { display: flex; flex-direction: column; gap: 6px; }
.share-choice[hidden] { display: none; }
.share-warn { margin: 0; font-size: calc(12px * var(--fs)); color: var(--amber); line-height: 1.4; }
.share-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.share-buttons .dlg-btn { padding: 6px 14px; }
/* On the landing screen the box folds away under the setup until it is wanted, and in the window under the code. */
.share-load-box { margin: 10px 0 0; }
.share-body .share-load-box { margin: 0; }
.share-load-box > summary { cursor: pointer; margin: 0 0 6px; }
.plan-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 10px; }
.plan-kinds { flex: none; display: flex; flex-wrap: wrap; gap: 4px; }
.plan-kind {
  padding: 3px 8px; border-radius: var(--radius); border: var(--sw) solid var(--edge); background: transparent; color: var(--ink);
  font: inherit; font-size: calc(12px * var(--fs)); line-height: 1.3; cursor: pointer;
}
.plan-kind small { color: var(--ink-faint); font-family: var(--font-data); font-size: calc(10px * var(--fs)); margin-left: 4px; }
.plan-kind:hover { background: var(--hover); }
.plan-kind[aria-pressed="true"] { background: var(--selected); border-color: var(--signal); box-shadow: inset 0 0 0 var(--sw) var(--signal); }
.plan-pic { flex: 1 1 auto; min-height: calc(140px * var(--fs)); display: grid; place-items: center; overflow: hidden; }
.plan-pic canvas { display: block; border-radius: var(--radius); border: var(--sw) solid var(--edge-strong); cursor: crosshair; touch-action: none; }
.plan-pic canvas:focus-visible { outline: calc(var(--sw) * 2) solid var(--signal); outline-offset: 2px; }
.plan-say, .plan-sum, .plan-note { flex: none; margin: 0; line-height: 1.35; }
.plan-say { min-height: 1.35em; font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.plan-say.bad { color: var(--red); }
.plan-sum { font-size: calc(12px * var(--fs)); color: var(--ink); }
.plan-list { flex: none; max-height: 30%; overflow-y: auto; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; scrollbar-width: thin; }
.plan-row { display: flex; align-items: baseline; gap: 8px; font-size: calc(12px * var(--fs)); line-height: 1.35; }
.plan-n { flex: none; min-width: 2.2em; font-family: var(--font-data); color: var(--signal); }
.plan-what { flex: 1; min-width: 0; }
.plan-state { flex: none; color: var(--ink-faint); }
.plan-row.built .plan-state { color: var(--good); }
.plan-row.busy .plan-state { color: var(--amber); }
.plan-row .inline-btn { flex: none; margin-left: 0; }
.plan-empty { font-size: calc(12px * var(--fs)); color: var(--ink-faint); }
.plan-hold { flex: none; display: flex; align-items: center; gap: 6px; font-size: calc(12px * var(--fs)); color: var(--ink); }
.plan-hold input { accent-color: var(--signal); }
.plan-note { font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.mission-foot { padding: 0 12px 10px; }
.mission-foot[hidden] { display: none; }
.mission-foot .inline-btn { margin-left: 0; }

/* The mission card's title bar (U7): Mission opens the briefing, Alerts the alerts with their
   count beside it. Alerts flashes red while a critical alert stands (steady red when the system
   asks for less motion). */
.mission-head { gap: 6px; padding-top: 4px; padding-bottom: 4px; }
.head-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--radius);
  border: var(--sw) solid var(--edge-strong); background: transparent; color: var(--ink);
  font-size: calc(12px * var(--fs)); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
}
.head-btn:hover { background: var(--hover); }
.mission-head .win-grip + .head-btn { margin-left: 2px; }
.alerts-btn { margin-right: auto; }
.alert-count { font-family: var(--font-data); font-size: calc(11px * var(--fs)); font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink-faint); }
.alert-count.some { padding: 0 7px; border-radius: 10px; border: var(--sw) solid var(--amber); color: var(--amber); }
.alerts-btn.alarm { color: var(--red); border-color: var(--red); animation: alarm 1.2s steps(2) infinite; }
.alerts-btn.alarm .alert-count { color: inherit; border-color: currentColor; }
@keyframes alarm { 50% { background: var(--red); color: var(--on-red); } }

/* The briefing and the alerts (U7): windows that move, resize and close, right of the mission
   card until they are moved. Each body scrolls. */
.brief, .alerts {
  position: absolute; top: calc(var(--bar-h) + var(--gap)); left: calc(var(--side-w) + var(--gap) * 2);
  width: min(calc(560px * var(--fs)), calc(100% - var(--side-w) - var(--gap) * 3));
  height: min(calc(600px * var(--fs)), calc(100% - var(--bar-h) - var(--gap) * 2));
  min-width: calc(300px * var(--fs)); min-height: calc(180px * var(--fs));
  display: flex; flex-direction: column;
}
.alerts { width: min(calc(460px * var(--fs)), calc(100% - var(--side-w) - var(--gap) * 3)); height: min(calc(500px * var(--fs)), calc(100% - var(--bar-h) - var(--gap) * 2)); }
.brief[hidden], .alerts[hidden] { display: none; }
.brief-body, .alerts-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--edge-strong) transparent; }
.brief-body .card-head { padding: 10px 14px 8px; }
.brief-body .card-head h2 { font-size: calc(20px * var(--fs)); }
.brief-body .card-body { padding: 2px 14px 12px; overflow: visible; font-size: calc(13px * var(--fs)); }
.alerts-body { padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.alerts-summary { margin: 0; font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.alerts-section { display: flex; flex-direction: column; gap: 8px; }
.alerts-section > h3 { margin: 6px 0 0; font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.alert {
  flex: none; display: grid; grid-template-columns: 6px 1fr; gap: 10px;
  padding: 9px 12px 9px 0;
  background: var(--glass-strong); border: var(--sw) solid var(--edge); border-radius: var(--radius);
}
.alert::before { content: ""; border-radius: var(--radius) 0 0 var(--radius); background: var(--signal); }
.alert.warn::before { background: var(--amber); }
.alert.crit::before { background: var(--red); }
.alert.cleared::before { background: var(--edge-strong); }
.alert-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 3px; }
.alert-level {
  font-family: var(--font-data); font-size: calc(10px * var(--fs)); letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0 5px; border-radius: 3px; border: var(--sw) solid var(--signal); color: var(--signal);
}
.alert.warn .alert-level { color: var(--amber); border-color: var(--amber); }
.alert.crit .alert-level { color: var(--red); border-color: var(--red); }
.alert.cleared .alert-level { color: var(--ink-faint); border-color: var(--edge-strong); }
.alert h3 { margin: 0; font-size: calc(14px * var(--fs)); font-weight: 600; }
.alert.cleared h3 { color: var(--ink-dim); }
.alert p { margin: 0 0 3px; font-size: calc(13px * var(--fs)); line-height: 1.4; color: var(--ink-dim); }
.alert .when { font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--ink-faint); }

/* ---------------------------------------------------------------- agent panel */
/* Below the feeds, down to the bottom gutter. The comms console stays to its left. It resizes
   (U7) down to room for its title bar, a few rows and the start of the selected agent's controls. */
.agents {
  position: absolute; right: var(--gap); top: calc(var(--bar-h) + var(--gap) * 2 + var(--feed-h) + 26px * var(--fs));
  width: var(--agents-w);
  max-height: calc(100% - var(--bar-h) - var(--gap) * 3 - var(--feed-h) - 26px * var(--fs));
  display: flex; flex-direction: column; min-height: 140px; min-width: calc(240px * var(--fs));
}
.panel-head { display: flex; align-items: center; border-bottom: var(--sw) solid var(--edge); padding-right: 8px; }
.panel-head .panel-title { border-bottom: 0; flex: 1; }
.panel-head .inline-btn { margin-left: 0; }
.panel-head .inline-btn:disabled { opacity: 0.5; cursor: default; }
.agent-tree { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1 1 auto; min-height: calc(90px * var(--fs)); }
.agent-tree ul { list-style: none; margin: 0 0 0 14px; padding: 0 0 0 10px; border-left: var(--sw) dashed var(--edge); }
.agent {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 4px 8px; align-items: center;
  padding: 7px 8px; border-radius: var(--radius); cursor: pointer;
}
.agent:hover { background: var(--hover); }
.agent.selected { background: var(--selected); box-shadow: inset 0 0 0 var(--sw) var(--edge-strong); }
.agent .dot, .detail-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
/* A callsign never breaks at its hyphen: when a long state leaves no room, the role drops
   under the callsign and, in the narrow layout, the state wraps between its words. */
.agent .name { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; }
.agent .callsign, .detail-head .callsign { font-family: var(--font-data); font-size: calc(13px * var(--fs)); letter-spacing: 0.04em; white-space: nowrap; }
.agent > .state-chip { white-space: normal; text-align: center; }
.agent .role { font-size: calc(10px * var(--fs)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.agent .task { grid-column: 2 / 4; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.3; }
.agent .limits, .agent .tool-line { grid-column: 2 / 4; font-family: var(--font-data); font-size: calc(10px * var(--fs)); color: var(--ink-faint); line-height: 1.4; }
.agent .limits > span, .tool-line b, .tool-line .keep { white-space: nowrap; }
.tool-line b { font-weight: 400; color: var(--ink-dim); }
.tool-line b.gate { color: var(--amber); }
.tool-line b.off { text-decoration: line-through; }
.tool-line b.pending { opacity: 0.6; }
.agent .meters { grid-column: 2 / 4; display: flex; gap: 10px; align-items: center; font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.agent .meters .spend { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.meter { position: relative; flex: 1; height: calc(4px * var(--fs)); background: var(--track); border-radius: 2px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--good); }
.meter.low > span { background: var(--amber); }
.meter .reserve { position: absolute; top: 0; bottom: 0; width: calc(var(--sw) * 2); margin-left: calc(var(--sw) * -1); background: var(--ink); }
.agent .row-sending { grid-column: 2 / 4; justify-self: start; margin-left: 0; }

/* A state in a word: what the agent is doing, or why it is not. */
.state-chip {
  font-size: calc(10px * var(--fs)); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
  padding: 1px 6px; border-radius: 3px; border: var(--sw) solid var(--edge); color: var(--ink-faint);
}
.state-chip.busy { color: var(--signal); border-color: var(--edge-strong); }
.state-chip.ask { color: var(--amber); border-color: var(--amber); }
.state-chip.warn { color: var(--amber); border-color: var(--amber); }
.state-chip.bad { color: var(--red); border-color: var(--red); }

/* The selected agent's controls, under the tree. */
.agent-detail {
  flex: 0 1 auto; max-height: 62%; overflow: auto; padding: 8px 12px 10px;
  border-top: var(--sw) solid var(--edge); background: var(--glass-strong);
  display: flex; flex-direction: column; gap: 8px; font-size: calc(12px * var(--fs));
}
.detail-empty { margin: 0; color: var(--ink-faint); }
.detail-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-actions { margin-left: auto; display: flex; gap: 6px; }
.detail-actions .inline-btn { margin-left: 0; }
.detail-actions .inline-btn:disabled { opacity: 0.6; cursor: default; }
.detail-block { display: flex; flex-direction: column; gap: 5px; }
.detail-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.detail-label, .detail-field label, .detail-limits label { font-size: calc(10px * var(--fs)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.detail-block .tools { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-btn { background: var(--field); cursor: pointer; padding: 2px 7px; }
.chip-btn:hover { border-color: var(--edge-strong); color: var(--ink); }
.chip.pending { border-style: dotted; opacity: 0.75; animation: pend 1s ease-in-out infinite alternate; }
@keyframes pend { to { opacity: 0.4; } }
.legend { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; color: var(--ink-faint); }
.legend .chip { font-size: calc(9px * var(--fs)); }
/* Area, Budget and Reserve each take a row, their labels in one column wide enough for the
   longest, and each select as wide as its longest choice, so "No limit" shows whole at every size. */
.detail-field { display: grid; grid-template-columns: calc(58px * var(--fs)) 1fr auto; gap: 6px; align-items: center; }
.detail-limits { display: grid; grid-template-columns: calc(58px * var(--fs)) 1fr; gap: 6px; align-items: center; }
.detail-field input, .detail-limits select {
  min-width: 0; padding: 4px 8px; font-family: var(--font-data); font-size: calc(12px * var(--fs));
  background: var(--field); color: var(--ink); border: var(--sw) solid var(--edge); border-radius: var(--radius);
}
.detail-limits select { justify-self: start; max-width: 100%; }
.detail-limits select.pending { border-style: dotted; color: var(--amber); }
.detail-field .inline-btn { margin-left: 0; }
.detail-note { margin: -4px 0 0 calc(58px * var(--fs) + 6px); color: var(--ink-faint); line-height: 1.35; }
.detail-note.bad { color: var(--red); }
.detail-spend { margin: -4px 0 0; font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--ink-dim); }
.detail-sending { margin: 0; padding: 0; list-style: none; font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--amber); }

/* ---------------------------------------------------------------- feeds */
/* The feed's picture, with its static and scanlines, is drawn into the 3D canvas under
   .feed-view by render/feeds.js, so the view stays clear here. */
.feeds {
  position: absolute; top: calc(var(--bar-h) + var(--gap)); right: var(--gap);
  display: flex; align-items: flex-start; gap: 8px;      /* a minimized feed keeps only its caption */
}
.feed {
  position: relative; width: var(--feed-w); margin: 0; cursor: pointer;
  border: var(--sw) solid var(--edge); border-radius: var(--radius);
  background: transparent; overflow: hidden;
  box-shadow: 0 8px 30px var(--shadow);
}
.feed:hover { border-color: var(--edge-strong); }
.feed.speaking { border-color: var(--signal); box-shadow: 0 0 0 var(--sw) var(--signal), 0 8px 30px var(--shadow); }
.on-air { display: none; gap: 2px; align-items: flex-end; height: 10px; }
.feed.speaking .on-air { display: inline-flex; }
.on-air i { width: 3px; background: var(--signal); animation: air 0.6s ease-in-out infinite alternate; }
.on-air i:nth-child(2) { animation-delay: 0.2s; }
.on-air i:nth-child(3) { animation-delay: 0.4s; }
@keyframes air { from { height: 3px; } to { height: 10px; } }
.feed-overlay {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 3px 10px; border-radius: 3px; background: rgba(0, 0, 0, 0.6);
  font-family: var(--font-data); font-size: calc(11px * var(--fs)); letter-spacing: 0.12em; color: #fff;
}
.feed-overlay[hidden] { display: none; }
.feed-head {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--glass-strong);
  font-family: var(--font-data); font-size: calc(11px * var(--fs)); letter-spacing: 0.04em; color: var(--ink-dim);
  border-bottom: var(--sw) solid var(--edge);
}
.feed-head .rec { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: rec 1.6s steps(2) infinite; }
/* The callsign never breaks; the signal reading gives way first when the caption is tight. */
.feed-head .feed-callsign { white-space: nowrap; }
.feed-head .sig { margin-left: auto; min-width: 0; overflow: hidden; color: var(--ink-faint); white-space: nowrap; }
.feed-view { position: relative; height: var(--feed-h); }
.feed-foot {
  position: absolute; left: 6px; bottom: 4px; font-family: var(--font-data); font-size: calc(10px * var(--fs));
  color: rgba(255, 255, 255, 0.9); text-shadow: 0 1px 2px #000;
}
@keyframes rec { 50% { opacity: 0.15; } }

/* ---------------------------------------------------------------- comms console */
/* Centered in the space left of the agent panel, never under it. It resizes (U3) down to room
   for its tabs, a few lines of the log and the command box. */
.comms {
  position: absolute; bottom: var(--gap);
  left: calc(50% - (var(--agents-w) + var(--gap)) / 2); transform: translateX(-50%);
  width: min(calc(760px * var(--fs)), calc(100% - var(--gap) * 3 - var(--agents-w)));
  height: var(--comms-h);
  min-width: calc(360px * var(--fs)); min-height: calc(150px * var(--fs));
  display: flex; flex-direction: column;
}
.comms-head { display: flex; align-items: center; border-bottom: var(--sw) solid var(--edge); }
.channels { display: flex; overflow-x: auto; }
.channel {
  background: transparent; border: 0; border-right: var(--sw) solid var(--edge);
  padding: 7px 12px; font-family: var(--font-data); font-size: calc(12px * var(--fs)); color: var(--ink-dim);
  white-space: nowrap;
}
.channel[aria-selected="true"] { color: var(--ink); background: var(--selected); box-shadow: inset 0 calc(var(--sw) * -2) 0 var(--signal); }
.channel .unread { display: inline-block; min-width: 16px; margin-left: 6px; padding: 0 4px; border-radius: 8px; background: var(--signal-strong); color: var(--on-signal); font-size: calc(10px * var(--fs)); }
.delay { margin-left: auto; padding: 0 12px; font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--amber); white-space: nowrap; }

.log { list-style: none; margin: 0; padding: 8px 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.msg { display: grid; grid-template-columns: calc(52px * var(--fs)) 1fr; gap: 8px; font-size: calc(13px * var(--fs)); line-height: 1.4; }
.msg .t { font-family: var(--font-data); font-size: calc(10px * var(--fs)); color: var(--ink-faint); padding-top: 3px; font-variant-numeric: tabular-nums; }
.msg .who { font-family: var(--font-data); font-size: calc(12px * var(--fs)); color: var(--signal); margin-right: 6px; }
.msg.you .who, .msg.control .who { color: var(--amber); }
.msg.control { font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.msg.sys .who { color: var(--ink-faint); }
.msg .body { min-width: 0; overflow-wrap: anywhere; }
.msg.pending .body { color: var(--ink-dim); }
.msg.action { font-size: calc(12px * var(--fs)); }
.msg.action .act { font-family: var(--font-data); color: var(--ink-faint); }
.msg.note .note-text { color: var(--ink-dim); font-style: italic; }
.msg.question { background: var(--selected); border-radius: var(--radius); padding: 4px 6px; margin: 0 -6px; }
.radio-tag, .q-tag, .ctl-tag {
  font-family: var(--font-data); font-size: calc(10px * var(--fs)); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0 5px; border-radius: 3px; border: var(--sw) solid var(--edge-strong); color: var(--signal);
}
.q-tag, .ctl-tag { color: var(--amber); border-color: var(--amber); }
.intercept-tag {
  font-family: var(--font-data); font-size: calc(10px * var(--fs)); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 0 5px; border-radius: 3px; border: var(--sw) dashed var(--red); color: var(--red);
}
.msg.intercept .body { color: var(--ink-dim); }
.chip.sending { margin-left: 8px; color: var(--amber); border-color: var(--amber); }
.inline-btn {
  margin-left: 8px; padding: 2px 10px; border-radius: var(--radius); border: var(--sw) solid var(--edge-strong);
  background: transparent; color: var(--ink); font-size: calc(12px * var(--fs));
}
.inline-btn:hover { background: var(--hover); }
.inline-btn.primary { background: var(--signal-strong); border-color: var(--signal-strong); color: var(--on-signal); }

.card { margin-top: 4px; padding: 8px 10px; border: var(--sw) solid var(--edge-strong); border-radius: var(--radius); background: var(--glass-strong); }
.approval-card { border-color: var(--amber); }
.card-title { font-weight: 600; }
.card-text { font-family: var(--font-data); font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.card-warn { color: var(--red); font-size: calc(12px * var(--fs)); margin-top: 2px; }
.steps { margin: 6px 0; padding-left: 20px; font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.card-actions .inline-btn { margin-left: 0; }
.card-input {
  flex: 1; min-width: calc(120px * var(--fs)); padding: 3px 8px; font-size: calc(12px * var(--fs));
  background: var(--field); border: var(--sw) solid var(--edge); border-radius: var(--radius);
}
.chip.outcome.approved { color: var(--good); border-color: var(--good); }
.chip.outcome.rejected { color: var(--red); border-color: var(--red); }
.chip.outcome.changed { color: var(--amber); border-color: var(--amber); }
.card-reason { font-size: calc(12px * var(--fs)); color: var(--ink-dim); }

.command { display: flex; align-items: center; gap: 8px; padding: 8px; border-top: var(--sw) solid var(--edge); }
.command .to { font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--ink-faint); white-space: nowrap; }
.command input {
  flex: 1; min-width: 0; padding: 8px 10px; background: var(--field);
  border: var(--sw) solid var(--edge); border-radius: var(--radius);
}
.command input::placeholder { color: var(--ink-faint); }
.command input:disabled, .command button:disabled { opacity: 0.55; cursor: default; }
.command button {
  padding: 8px 16px; border: var(--sw) solid var(--signal); border-radius: var(--radius);
  background: var(--signal-strong); color: var(--on-signal); font-weight: 600; letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- windows (U3)
   Every panel and feed is a window (js/ui/windows.js): its title bar drags it, the grip at its
   start takes the arrow keys, and the button at its end minimizes it to the title bar. A moved
   window is fixed where it was put, always whole on the screen. */
[data-win-head] { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.win-dragging, .win-dragging [data-win-head] { cursor: grabbing; }
.win-dragging { box-shadow: 0 14px 40px var(--shadow); }
.channels { touch-action: pan-x; }           /* the console's tabs still scroll on a touch screen */
.win-grip, .win-min-btn, .win-close {
  flex: none; display: grid; place-items: center; padding: 0;
  background: transparent; border: var(--sw) solid transparent; border-radius: var(--radius); color: var(--ink-faint);
}
.win-grip { align-self: stretch; width: calc(18px * var(--fs)); margin-left: 2px; cursor: grab; touch-action: none; }
.win-grip svg { width: calc(14px * var(--fs)); height: calc(14px * var(--fs)); }
.win-min-btn, .win-close { width: calc(24px * var(--fs)); height: calc(22px * var(--fs)); margin-left: 6px; color: var(--ink-dim); }
.win-close { margin-left: 2px; }
.win-min-btn svg, .win-close svg { width: calc(14px * var(--fs)); height: calc(14px * var(--fs)); }
.win-grip:hover, .win-grip:focus-visible, .win-min-btn:hover, .win-close:hover { color: var(--ink); border-color: var(--edge-strong); background: var(--hover); }
.panel-head .win-grip + .panel-title { padding-left: 4px; }
.comms-head .win-min-btn { margin: 0 6px; }
.feed-head .win-grip { width: calc(12px * var(--fs)); margin: -2px 0 -2px -6px; }
.feed-head .win-grip svg { width: calc(12px * var(--fs)); height: calc(12px * var(--fs)); }
.feed-head .win-min-btn { width: calc(20px * var(--fs)); height: calc(18px * var(--fs)); margin: -2px -6px -2px 0; }

#hud [data-placed] {
  position: fixed; right: auto; bottom: auto; transform: none; margin: 0;
  max-width: calc(100% - 8px); max-height: calc(100% - var(--bar-h) - 8px);
}
.mission[data-placed] { width: var(--side-w); }

/* Minimized: the title bar alone. */
#hud .win-min > :not([data-win-head]) { display: none; }
#hud [data-window].win-min { height: auto; min-height: 0; }

/* Resizing (the comms console): an edge on every side and corner, wider than it looks, and a
   grip drawn in the bottom right corner that also takes the arrow keys. A resized window keeps
   its size in --win-w and --win-h, which a minimized one ignores. */
#hud [data-sized] { width: var(--win-w); height: var(--win-h); }
.win-edge { position: absolute; z-index: 2; touch-action: none; }
.win-edge[data-edge="top"], .win-edge[data-edge="bottom"] { left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.win-edge[data-edge="left"], .win-edge[data-edge="right"] { top: 10px; bottom: 10px; width: 8px; cursor: ew-resize; }
.win-edge[data-edge="top"] { top: -4px; }
.win-edge[data-edge="bottom"] { bottom: -4px; }
.win-edge[data-edge="left"] { left: -4px; }
.win-edge[data-edge="right"] { right: -4px; }
.win-edge[data-edge~="left"][data-edge~="top"], .win-edge[data-edge~="left"][data-edge~="bottom"],
.win-edge[data-edge~="right"][data-edge~="top"], .win-edge[data-edge~="right"][data-edge~="bottom"] { width: 14px; height: 14px; }
.win-edge[data-edge="top left"] { top: -4px; left: -4px; cursor: nwse-resize; }
.win-edge[data-edge="top right"] { top: -4px; right: -4px; cursor: nesw-resize; }
.win-edge[data-edge="bottom left"] { bottom: -4px; left: -4px; cursor: nesw-resize; }
.win-edge[data-edge="bottom right"] { bottom: -4px; right: -4px; cursor: nwse-resize; }
.win-resize {
  position: absolute; right: 1px; bottom: 1px; z-index: 3; display: grid; place-items: center;
  width: calc(12px * var(--fs)); height: calc(12px * var(--fs)); padding: 0;
  background: transparent; border: 0; border-radius: var(--radius); color: var(--ink-faint);
  cursor: nwse-resize; touch-action: none;
}
.win-resize svg { width: 100%; height: 100%; }
.win-resize:hover, .win-resize:focus-visible { color: var(--ink); }
.win-resizing, .win-resizing * { user-select: none; -webkit-user-select: none; }
.win-resizing { box-shadow: 0 14px 40px var(--shadow); }
.comms .command { padding-right: calc(8px + 12px * var(--fs)); }      /* Send clear of the grip */

/* Hide UI: the colony and the button that brings everything back, nothing else. */
#hud.ui-hidden > :not(.topbar) { display: none; }
#hud.ui-hidden .topbar { visibility: hidden; }
#hud.ui-hidden #hide-ui {
  visibility: visible; position: fixed; top: 8px; right: 10px; z-index: 40;
  height: calc(34px * var(--fs)); padding: 0 12px;
  background: var(--glass-strong); border-color: var(--edge-strong); box-shadow: 0 6px 20px var(--shadow);
}

/* ---------------------------------------------------------------- Colony status (U4)
   Every reading of the top bar in full and what lies behind it, as a window: under the top bar,
   right of the left column, until it is moved. Each row a label, its value and a line under it. */
.status {
  position: absolute; top: calc(var(--bar-h) + var(--gap)); left: calc(var(--side-w) + var(--gap) * 2);
  width: calc(340px * var(--fs)); max-height: calc(100% - var(--bar-h) - var(--gap) * 2);
  min-width: calc(260px * var(--fs)); min-height: calc(160px * var(--fs));
  display: flex; flex-direction: column;
}
.status[hidden] { display: none; }
/* Mission Objectives (U14): a window like Colony status. What the outcome needs, then each objective
   in full: its mark and words, a Critical tag, when it is judged and how it stands. */
.aims {
  position: absolute; top: calc(var(--bar-h) + var(--gap)); left: calc(var(--side-w) + var(--gap) * 2);
  width: calc(380px * var(--fs)); max-height: calc(100% - var(--bar-h) - var(--gap) * 2);
  min-width: calc(260px * var(--fs)); min-height: calc(160px * var(--fs));
  display: flex; flex-direction: column;
}
.aims[hidden] { display: none; }
.aims-body { min-height: 0; overflow-y: auto; padding: 8px 12px 12px; scrollbar-width: thin; }
.aims-lead { margin: 0 0 8px; font-size: calc(13px * var(--fs)); font-weight: 600; color: var(--ink); line-height: 1.4; }
.aims-summary { margin: -4px 0 10px; padding-left: 10px; border-left: calc(3px * var(--fs)) solid var(--good); font-size: calc(13px * var(--fs)); color: var(--ink); line-height: 1.4; }
.aims-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.aim { padding: 8px 10px; border: var(--sw) solid var(--edge); border-radius: var(--radius); background: var(--field); }
.aim-top { display: flex; align-items: baseline; gap: 8px; }
.aim-text { flex: 1; font-size: calc(13px * var(--fs)); color: var(--ink); line-height: 1.4; }
.aim-critical {
  flex: none; font-family: var(--font-data); font-size: calc(10px * var(--fs)); letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0 5px; border-radius: 3px; border: var(--sw) solid var(--red); color: var(--red);
}
.aim-when, .aim-state { margin: 3px 0 0 calc(18px * var(--fs)); font-size: calc(12px * var(--fs)); line-height: 1.4; }
.aim-when { color: var(--ink-dim); }
.aim-state { font-family: var(--font-data); color: var(--ink-dim); }
.aim.holding .obj-mark, .aim.on-track .obj-mark, .aim.met .obj-mark, .aim.met .aim-state { color: var(--good); }
.aim.not-yet .obj-mark, .aim.not-yet .aim-state { color: var(--amber); }
.aim.failed .obj-mark, .aim.failed .aim-state { color: var(--red); }
.aims-note { margin: 0 0 6px; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.4; }
.status-body { min-height: 0; overflow-y: auto; padding: 0 12px 10px; scrollbar-width: thin; }
.status-section h3 {
  margin: 10px 0 4px; font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-dim);
}
.status-rows { display: grid; grid-template-columns: calc(132px * var(--fs)) 1fr; gap: 4px 12px; margin: 0; font-size: calc(12px * var(--fs)); line-height: 1.35; }
.status-rows dt { color: var(--ink-dim); }
.status-rows dd { margin: 0; min-width: 0; }
.status-value { font-family: var(--font-data); font-size: calc(13px * var(--fs)); font-variant-numeric: tabular-nums; color: var(--ink); }
.status-sub { display: block; font-size: calc(11px * var(--fs)); color: var(--ink-faint); overflow-wrap: anywhere; }
.status-rows dd.warn .status-value { color: var(--amber); }
.status-rows dd.crit .status-value { color: var(--red); }

/* ---------------------------------------------------------------- briefing and debrief */
.mission-card {
  width: min(calc(720px * var(--fs)), calc(100% - 32px)); max-height: calc(100% - 48px);
  padding: 0; border: var(--sw) solid var(--edge-strong); border-radius: var(--radius);
  background: var(--glass-strong); color: var(--ink); box-shadow: 0 18px 60px var(--shadow);
  font-size: calc(13px * var(--fs));
}
.mission-card[open] { display: flex; flex-direction: column; }
.mission-card::backdrop { background: rgba(8, 14, 16, 0.45); }
.debrief { width: min(calc(960px * var(--fs)), calc(100% - 32px)); height: calc(100% - 48px); }
.card-head { padding: 16px 22px 12px; border-bottom: var(--sw) solid var(--edge); }
.card-head .kicker { display: block; font-size: calc(11px * var(--fs)); letter-spacing: 0.16em; text-transform: uppercase; color: var(--signal); }
.card-head h2 { margin: 2px 0 0; font-size: calc(26px * var(--fs)); letter-spacing: 0.02em; }
.card-head .where { font-family: var(--font-data); font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.card-head.success h2 { color: var(--good); }
.card-head.partial h2 { color: var(--amber); }
.card-head.failure h2 { color: var(--red); }
.outcome-line { margin: 4px 0 0; color: var(--ink-dim); line-height: 1.4; }
.continued-line { margin: 4px 0 0; color: var(--amber); font-size: calc(13px * var(--fs)); line-height: 1.4; }     /* a run taken on from a share code (H8) */
.card-body { padding: 4px 22px 8px; overflow-y: auto; min-height: 0; }
.card-section h3 {
  margin: 12px 0 4px; font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-dim);
}
.card-section p { margin: 0 0 6px; line-height: 1.45; }
.card-section > ol, .card-section > ul { margin: 0; padding-left: 20px; line-height: 1.45; }
.card-section .objectives { padding-left: 0; }
.card-section .obj { font-size: calc(13px * var(--fs)); }
.crew { list-style: none; padding-left: 0 !important; display: flex; flex-direction: column; gap: 3px; }
.crew li { display: grid; grid-template-columns: calc(118px * var(--fs)) calc(54px * var(--fs)) 1fr; gap: 8px; align-items: baseline; }
.crew .callsign { font-family: var(--font-data); font-size: calc(12px * var(--fs)); }
.crew .role { font-size: calc(10px * var(--fs)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.tips li, .setup-lines li { color: var(--ink-dim); }
.card-foot {
  display: flex; align-items: center; gap: 12px; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 22px; border-top: var(--sw) solid var(--edge);
}
.card-foot .ends { margin: 0 auto 0 0; flex: 1 1 260px; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.4; }
.dlg-btn {
  padding: 8px 18px; border-radius: var(--radius); border: var(--sw) solid var(--edge-strong);
  background: transparent; color: var(--ink); font-weight: 600; letter-spacing: 0.04em;
}
.dlg-btn:hover { background: var(--hover); }
.dlg-btn.primary { background: var(--signal-strong); border-color: var(--signal-strong); color: var(--on-signal); }

/* Getting Started and Help (G1): the briefing's card, with a close button in its head. */
.guide-card .card-head { position: relative; padding-right: calc(64px * var(--fs)); }
/* The welcome card wears the logo beside its title. */
.card-head.has-logo { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center; }
.card-head.has-logo .kicker { align-self: end; }
.card-head.has-logo h2 { align-self: start; }
.card-logo { grid-row: 1 / 3; width: calc(64px * var(--fs)); height: calc(64px * var(--fs)); }
.card-close {
  position: absolute; top: 14px; right: 16px; display: grid; place-items: center;
  width: calc(32px * var(--fs)); height: calc(32px * var(--fs)); padding: 0;
  border: var(--sw) solid var(--edge); border-radius: var(--radius); background: transparent; color: var(--ink-dim);
}
.card-close:hover { background: var(--hover); color: var(--ink); border-color: var(--edge-strong); }
.guide-steps li { margin-bottom: 6px; }
/* Getting Started's way into the tutorial (N4), and the first visit's question. */
.guide-tutorial { margin-top: 10px; padding: 8px 12px 10px; border-left: calc(3px * var(--fs)) solid var(--signal); background: var(--selected); border-radius: var(--radius); }
.guide-tutorial h3 { margin-top: 0; }
.tutorial-ask { width: min(calc(520px * var(--fs)), calc(100% - 32px)); }
.tutorial-ask .card-body p { margin: 10px 0 0; line-height: 1.45; }
.guide-figure { margin: 12px 0 8px; }
.guide-figure img { display: block; width: 100%; height: auto; border: var(--sw) solid var(--edge); border-radius: var(--radius); }
.guide-figure figcaption { margin-top: 4px; font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.guide-more { margin: 6px 0 4px; font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
/* Getting Started's "Show at the start of every game" (G6), at the left of its foot. */
.guide-again { margin: 0 auto 0 0; display: flex; align-items: center; gap: 8px; font-size: calc(13px * var(--fs)); color: var(--ink-dim); cursor: pointer; }
.guide-again input { margin: 0; width: calc(16px * var(--fs)); height: calc(16px * var(--fs)); accent-color: var(--signal); cursor: pointer; }
.ref { display: grid; grid-template-columns: calc(118px * var(--fs)) 1fr; gap: 5px 14px; margin: 0 0 6px; line-height: 1.45; }
.ref dt { font-weight: 600; }
.ref dd { margin: 0; color: var(--ink-dim); }
.guide-card kbd {
  display: inline-block; min-width: 1.6em; padding: 0 5px; text-align: center;
  font-family: var(--font-data); font-size: 0.9em; font-weight: 400;
  border: var(--sw) solid var(--edge-strong); border-radius: 3px; background: var(--field);
}
@media (max-width: 560px) {
  .ref { grid-template-columns: 1fr; gap: 0; }
  .ref dd { margin-bottom: 6px; }
}
.lessons { width: 100%; border-collapse: collapse; font-size: calc(12px * var(--fs)); }
.lessons th, .lessons td { text-align: left; vertical-align: top; padding: 5px 8px 5px 0; border-bottom: var(--sw) solid var(--edge); }
.lessons thead th { font-size: calc(10px * var(--fs)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.lessons tbody th { font-weight: 600; white-space: nowrap; }
.lessons .why { color: var(--ink-dim); line-height: 1.4; }
/* The lesson a mission was built around: its row marked, its name tagged. */
.lessons tr.focus th, .lessons tr.focus td { background: var(--selected); }
.lessons tr.focus th { box-shadow: inset calc(var(--sw) * 3) 0 0 var(--signal); padding-left: 8px; }
.focus-tag { display: block; margin-top: 2px; font-size: calc(10px * var(--fs)); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--signal); }
.lesson-about { margin: 0; line-height: 1.5; }
.mission-lesson { margin: 0 0 4px; font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--signal); }
.verdict {
  display: inline-block; font-size: calc(10px * var(--fs)); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
  padding: 1px 6px; border-radius: 3px; border: var(--sw) solid var(--edge); color: var(--ink-faint);
}
.verdict.met { color: var(--good); border-color: var(--good); }
.verdict.partly { color: var(--amber); border-color: var(--amber); }
.verdict.missed { color: var(--red); border-color: var(--red); }
.verdict.untested { border-style: dashed; }
.totals { margin: 10px 0 4px; font-family: var(--font-data); font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.5; }
.past-list li { color: var(--ink-dim); font-size: calc(12px * var(--fs)); }

/* ---------------------------------------------------------------- mission report tabs and charts
   Charts are SVG drawn at the panel's width, so 1 unit is 1 px and text takes the same scale
   as everything else. Marks carry a 2px ring in the card's color so they stay legible where
   they cross; the one teal signal color is the agents' work, amber waits on the operator,
   red is what went wrong, and every chart has a list or table beside it. */
.report-tabs {
  display: flex; gap: 2px; padding: 0 22px; border-bottom: var(--sw) solid var(--edge); overflow-x: auto;
}
.report-tab {
  padding: 8px 14px; border: 0; border-bottom: calc(var(--sw) * 2) solid transparent; background: transparent;
  color: var(--ink-dim); font-weight: 600; letter-spacing: 0.04em; font-size: calc(12px * var(--fs)); white-space: nowrap;
}
.report-tab:hover { color: var(--ink); background: var(--hover); }
.report-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--signal); }
.debrief .card-body { flex: 1 1 auto; scrollbar-gutter: stable; }   /* the charts are drawn to a width that does not change when it scrolls */
.tab-panel { padding-top: 6px; }
.report-note { margin: 8px 0; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.45; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.viz { position: relative; margin: 6px 0 10px; }
.viz:focus-visible { outline: calc(var(--sw) * 2) solid var(--signal); outline-offset: 3px; border-radius: var(--radius); }
.viz svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 3px 14px; margin: 4px 0; font-size: calc(11px * var(--fs)); color: var(--ink-dim); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.line-key { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--ink-dim); vertical-align: middle; margin-right: 6px; }
.legend-item .line-key { margin-right: 0; }
.line-key.made, .line-key.battery, .line-key.calls { border-color: var(--signal); }
.swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.swatch.short-key { background: color-mix(in srgb, var(--red) 22%, transparent); }
.swatch.storm-key { background: var(--track); }
.swatch.span-key.thinking { background: color-mix(in srgb, var(--signal) 35%, transparent); }
.swatch.span-key.acting { background: var(--signal); }
.swatch.span-key.waiting { background: var(--amber); }
.swatch.span-key.paused { background: color-mix(in srgb, var(--ink-faint) 50%, transparent); }
.mark-key { flex: none; overflow: visible; }

.viz text { font-family: var(--font-ui); fill: var(--ink-dim); font-size: calc(11px * var(--fs)); }
.viz .tick-label { fill: var(--ink-faint); font-family: var(--font-data); font-size: calc(10px * var(--fs)); }
.viz .chart-title { fill: var(--ink); font-weight: 600; letter-spacing: 0.02em; }
.viz .grid { stroke: var(--track); stroke-width: 1; }
.viz .moment { stroke: var(--ink-faint); stroke-width: 1; }
.viz .storm-band { fill: var(--track); }
.viz .lane-stripe { fill: var(--hover); }
.viz .lane-label { cursor: pointer; }
.viz .lane-name { fill: var(--ink); font-family: var(--font-data); }
.viz .lane-label:hover .lane-name { text-decoration: underline; }
.viz .span.thinking { fill: var(--signal); fill-opacity: 0.35; }
.viz .span.acting { fill: var(--signal); }
.viz .span.waiting { fill: var(--amber); }
.viz .span.paused { fill: var(--ink-faint); fill-opacity: 0.5; }
.viz .span.error { fill: var(--red); }
.viz .tick, .mark-key .tick { fill: var(--ink-faint); }
.mk { stroke: var(--glass-strong); stroke-width: 2; paint-order: stroke; }
.mk.message, .mk.control { fill: var(--signal-strong); }
.mk.watch { fill: none; stroke: var(--ink-dim); stroke-width: 1.5; }
.mk.report { fill: var(--ink-dim); }
.mk.claim { fill: var(--red); }
.mk.untrusted { fill: var(--glass-strong); stroke: var(--red); stroke-width: 2; }
.mk.gate { fill: var(--amber); }
.mk.fault { fill: none; stroke: var(--red); stroke-width: 2.2; stroke-linecap: round; }
.mk.step { fill: var(--ink-faint); }
.viz .sel-ring { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.viz .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz .line.made, .viz .line.battery, .viz .line.calls { stroke: var(--signal); }
.viz .line.used { stroke: var(--ink-dim); }
.viz .area.battery { fill: var(--signal); fill-opacity: 0.1; }
.viz .short-area { fill: var(--red); fill-opacity: 0.18; }
.viz .strip-track { fill: var(--track); }
.viz .strip.gen-on { fill: var(--signal); }
.viz .strip.ls-lost { fill: var(--red); }
.viz .strip-note { fill: var(--ink-faint); font-size: calc(10px * var(--fs)); }
.viz .cross-line { stroke: var(--ink-dim); stroke-width: 1; }
.viz .cross-dot, .viz .end-dot { stroke: var(--glass-strong); stroke-width: 2; fill: var(--signal); }
.viz .cross-dot.used { fill: var(--ink-dim); }
.viz .par { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 5 4; }

.viz-tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 120px; max-width: min(340px, 90%); padding: 6px 9px;
  background: var(--glass-strong); border: var(--sw) solid var(--edge-strong); border-radius: var(--radius);
  box-shadow: 0 6px 18px var(--shadow); font-size: calc(12px * var(--fs)); line-height: 1.4;
}
.tip-row { white-space: nowrap; color: var(--ink-dim); }
.tip-row b, .tip-time { color: var(--ink); font-weight: 600; }
.tip-time { font-family: var(--font-data); }
.tip-text { color: var(--ink-dim); }
.tip-gap { color: var(--red); }

.report-filters { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin: 8px 0 2px; font-size: calc(12px * var(--fs)); }
.report-filters select {
  padding: 3px 6px; background: var(--field); color: var(--ink); font-size: calc(12px * var(--fs));
  border: var(--sw) solid var(--edge); border-radius: var(--radius);
}
.report-filters .check { display: inline-flex; align-items: center; gap: 6px; }
.list-count { margin: 4px 0; font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.event-list { list-style: none; margin: 0; padding: 0; max-height: calc(300px * var(--fs)); overflow-y: auto; border-top: var(--sw) solid var(--edge); }
.event-list .ev {
  display: grid; grid-template-columns: calc(44px * var(--fs)) calc(132px * var(--fs)) 1fr; gap: 8px; width: 100%;
  padding: 4px 6px; border: 0; border-bottom: var(--sw) solid var(--edge); background: transparent; color: var(--ink);
  text-align: left; font-size: calc(12px * var(--fs)); line-height: 1.4;
}
.event-list .ev:hover { background: var(--hover); }
.event-list .sel .ev { background: var(--selected); }
.ev-time { font-family: var(--font-data); color: var(--ink-faint); }
.ev-who { font-family: var(--font-data); white-space: nowrap; }
.ev-text { color: var(--ink-dim); overflow-wrap: anywhere; }
.ev.claim .ev-text, .ev.fault .ev-text { color: var(--ink); }
.ev-gap { display: block; color: var(--red); }
.agent-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.numbers summary { cursor: pointer; margin: 4px 0; font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.num-table { border-collapse: collapse; margin: 6px 0; font-family: var(--font-data); font-size: calc(11px * var(--fs)); font-variant-numeric: tabular-nums; }
.num-table th, .num-table td { padding: 3px 14px 3px 0; text-align: right; border-bottom: var(--sw) solid var(--edge); }
.num-table thead th { font-family: var(--font-ui); color: var(--ink-faint); font-weight: 600; }
.num-table th:first-child { text-align: left; }

.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.stat {
  display: flex; flex-direction: column; flex: 1 1 150px; padding: 8px 12px;
  border: var(--sw) solid var(--edge); border-radius: var(--radius);
}
.stat-label { font-size: calc(10px * var(--fs)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.stat-value { font-size: calc(24px * var(--fs)); font-weight: 600; color: var(--ink); }
.stat-sub { font-size: calc(11px * var(--fs)); color: var(--ink-dim); }
.viz-title { margin: 12px 0 6px; font-size: calc(12px * var(--fs)); font-weight: 600; letter-spacing: 0.02em; color: var(--ink); }
.spend-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.spend-rows li {
  display: grid; grid-template-columns: calc(210px * var(--fs)) 1fr calc(150px * var(--fs)); gap: 10px; align-items: center;
  font-size: calc(12px * var(--fs));
}
.spend-name { font-family: var(--font-data); white-space: nowrap; }
.spend-rows li.drone .spend-name { padding-left: 16px; }
.spend-sub { font-family: var(--font-ui); font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.spend-track { height: calc(14px * var(--fs)); }
.spend-bar { display: block; height: 100%; background: var(--signal); border-radius: 0 4px 4px 0; }
.spend-value { font-family: var(--font-data); font-variant-numeric: tabular-nums; color: var(--ink-dim); }

.table-scroll { overflow-x: auto; }
.past-runs { width: 100%; border-collapse: collapse; font-size: calc(12px * var(--fs)); }
.past-runs th, .past-runs td { padding: 5px 8px 5px 0; text-align: left; vertical-align: middle; border-bottom: var(--sw) solid var(--edge); }
.past-runs thead th { font-size: calc(10px * var(--fs)); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; white-space: nowrap; }
.past-runs .lesson-col, .past-runs .lesson-cell { width: calc(18px * var(--fs)); padding-right: 2px; text-align: center; }
.past-runs tr.shown { background: var(--selected); }
.past-runs .when, .past-runs .num { font-family: var(--font-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.run-title { display: block; font-weight: 600; }
.run-sub { display: block; font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.grade-chip {
  display: inline-block; padding: 1px 6px; border-radius: 3px; border: var(--sw) solid var(--edge); white-space: nowrap;
  font-size: calc(10px * var(--fs)); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink);
}
.grade-chip.success { border-color: var(--good); }
.grade-chip.partial { border-color: var(--amber); }
.grade-chip.failure { border-color: var(--red); }
.cell { font-size: calc(13px * var(--fs)); font-weight: 600; }
.cell.met { color: var(--good); }
.cell.partly { color: var(--amber); }
.cell.missed { color: var(--red); }
.cell.untested { color: var(--ink-faint); }
.showing { font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.key-title { margin: 10px 0 2px; font-size: calc(10px * var(--fs)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.lesson-key { margin: 0; padding-left: 24px; columns: 2; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.5; }

/* ---------------------------------------------------------------- landing screen
   The globe fills the screen behind; the planets and sites on the left, the picked site's
   ratings and missions on the right, glass panels like the colony HUD's. Only the brand and
   the menu stay in the top bar. */
.landing #hud .resources, .landing #hud .clock > :not(.menu-btn), .landing #hud .side, .landing #hud .feeds,
.landing #hud .agents, .landing #hud .comms, .landing #hud .status, .landing #hud .brief, .landing #hud .alerts,
.landing #hud .sat, .landing #hud .blueprint, .landing #hud .share, .landing #hud .aims, .landing #hud .sector-tip { display: none; }
.landing #hud .clock { margin-left: auto; }
#landing { position: fixed; inset: var(--bar-h) 0 0 0; pointer-events: none; }
#landing[hidden] { display: none; }
#landing .panel, #landing .landing-hint { pointer-events: auto; }
.landing-pick, .landing-site { position: absolute; top: 12px; z-index: 1; max-height: calc(100% - 64px); overflow-y: auto; padding: 12px 14px 14px; }
.landing-pick { left: 12px; width: calc(300px * var(--fs)); }
.landing-site { right: 12px; width: calc(370px * var(--fs)); }
.landing-title { margin: 0 0 10px; font-size: calc(18px * var(--fs)); letter-spacing: 0.02em; }
.landing-sub { margin: 14px 0 6px; font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
/* The planet and the landing site, each a pull down (user, 2026-10-31), its choices naming their
   difficulty; under the planet's, its color, tagline and range, and under the site's, its line.
   The site's missions are one too (user, 2026-11-01), its choices naming how long each runs.
   The range drops under the tagline, at the right, when the two do not fit side by side. */
.landing-select {
  display: block; width: 100%; padding: 7px 8px; border-radius: var(--radius); border: var(--sw) solid var(--edge-strong);
  background: var(--field); color: var(--ink); font: inherit; font-size: calc(14px * var(--fs)); font-weight: 600;
}
.landing-pick label.landing-sub { display: block; }
.planet-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 8px; }
.planet-summary .planet-tagline { flex: 1 1 8em; min-width: 0; }
.planet-summary .level-chip { margin-left: auto; }
.planet-dot { flex: none; width: calc(16px * var(--fs)); height: calc(16px * var(--fs)); border-radius: 50%; box-shadow: inset -3px -3px 6px var(--shadow); }
.planet-tagline { font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.level-chip {
  font-size: calc(10px * var(--fs)); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
  padding: 1px 6px; border-radius: 3px; border: var(--sw) solid var(--edge-strong); color: var(--ink);
}
.level-chip.level-1, .level-chip.level-2 { border-color: var(--good); }
.level-chip.level-3 { border-color: var(--amber); }
.level-chip.level-4, .level-chip.level-5 { border-color: var(--red); }
.planet-blurb { margin: 10px 0 0; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.45; }
.site-meta { margin: 6px 0 0; font-size: calc(12px * var(--fs)); color: var(--ink-dim); }

.site-head .kicker { display: block; font-size: calc(11px * var(--fs)); letter-spacing: 0.16em; text-transform: uppercase; color: var(--signal); }
.site-head h2 { margin: 2px 0 0; font-size: calc(22px * var(--fs)); }
.site-head .where { font-family: var(--font-data); font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.site-blurb { margin: 8px 0; font-size: calc(13px * var(--fs)); line-height: 1.45; }
.difficulty { margin: 8px 0 4px; padding: 8px 10px; border: var(--sw) solid var(--edge); border-left-width: calc(var(--sw) * 4); border-radius: var(--radius); }
.difficulty.level-1, .difficulty.level-2 { border-left-color: var(--good); }
.difficulty.level-3 { border-left-color: var(--amber); }
.difficulty.level-4, .difficulty.level-5 { border-left-color: var(--red); }
.diff-top { display: flex; align-items: center; gap: 10px; }
.diff-kicker { font-size: calc(10px * var(--fs)); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.diff-label { font-size: calc(17px * var(--fs)); font-weight: 600; margin-right: auto; }
/* The difficulty's four parts, each with what it adds, and the sum the level comes from. */
.diff-parts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 6px 0 0; font-size: calc(12px * var(--fs)); line-height: 1.4; }
.diff-parts dt { color: var(--ink-dim); }
.diff-parts dd { margin: 0; display: flex; gap: 8px; }
.diff-parts .part-text { margin-right: auto; }
.diff-parts .part-points { font-family: var(--font-data); font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.diff-parts .sum { margin-top: 2px; padding-top: 3px; border-top: var(--sw) solid var(--edge); font-weight: 600; color: var(--ink); }
.diff-parts dd.sum .part-points { color: var(--ink); }

/* The setup on the landing screen: a row of choices for each, the picked one marked. */
.setup { display: flex; flex-direction: column; gap: 10px; }
.setup-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.setup-group legend { padding: 0; margin-bottom: 4px; font-size: calc(12px * var(--fs)); font-weight: 600; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: var(--sw) solid var(--edge-strong); border-radius: var(--radius); overflow: hidden; }
.seg { position: relative; display: block; padding: 5px 4px; text-align: center; font-size: calc(12px * var(--fs)); cursor: pointer; }
.seg + .seg { border-left: var(--sw) solid var(--edge); }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg:hover { background: var(--hover); }
.seg:has(input:checked) { background: var(--selected); font-weight: 600; box-shadow: inset 0 calc(var(--sw) * -3) 0 var(--signal); }
.seg:has(input:focus-visible) { outline: calc(var(--sw) * 2) solid var(--signal); outline-offset: calc(var(--sw) * -2); }
.setup-note { margin: 4px 0 0; font-size: calc(11px * var(--fs)); color: var(--ink-dim); line-height: 1.4; }
.setup-level { display: flex; align-items: baseline; gap: 6px; margin: 0 0 6px; font-size: calc(13px * var(--fs)); }
.site-section h3 { margin: 12px 0 4px; font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.ratings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.rating { display: grid; grid-template-columns: 1fr auto calc(74px * var(--fs)); align-items: center; gap: 10px; font-size: calc(13px * var(--fs)); }
.r-word { font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: calc(16px * var(--fs)); height: calc(8px * var(--fs)); border-radius: 2px; background: var(--track); }
.rating.hazard .pips i.on { background: var(--amber); }
.rating.resource .pips i.on { background: var(--signal); }
.pips.five i.on { background: var(--ink-dim); }
.planet-facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; font-size: calc(13px * var(--fs)); }
.planet-facts dt { color: var(--ink-dim); }
.planet-facts dd { margin: 0; font-family: var(--font-data); }
.mission-select { margin: 0 0 8px; }
.site-section h3 label { cursor: pointer; }
.missions { display: flex; flex-direction: column; gap: 8px; }
.mission-item, .random-item { padding: 10px 12px; border: var(--sw) solid var(--edge-strong); border-radius: var(--radius); background: var(--glass-strong); }
/* An open colony's mission card (E0): what the colony has, where a mission lists its objectives. */
.colony-lines { list-style: none; margin: 6px 0 0; padding: 0; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.5; }
/* A site's open colony (E0): no objectives and no end, a save kept in this browser. */
.open-item { padding: 10px 12px; border: var(--sw) dotted var(--edge-strong); border-radius: var(--radius); background: var(--glass-strong); }
.open-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.open-buttons .land-btn { flex: 1; }
/* The class missions an instructor posted (I2), above the planets: a pull down (user, 2026-11-01)
   and the picked one under it, the signal color's edge marking them out. */
.class-missions { margin: 0 0 4px; }
.class-missions[hidden] { display: none; }
.class-missions .landing-sub { margin-top: 0; }
.class-pulldown { margin: 0 0 8px; border-color: var(--signal); }
.class-item { padding: 10px 12px; border: var(--sw) solid var(--signal); border-radius: var(--radius); background: var(--glass-strong); }
/* A site's random mission (R1): dashed, since it is a new mission every time, with a code to fly a shared one. */
.random-item { border-style: dashed; }
.code-row { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.code-label { font-size: calc(12px * var(--fs)); color: var(--ink-dim); white-space: nowrap; }
.code-input {
  flex: 1; min-width: 0; padding: 5px 8px; background: var(--field); color: var(--ink); border: var(--sw) solid var(--edge);
  border-radius: var(--radius); font: calc(13px * var(--fs)) var(--font-data); text-transform: uppercase; letter-spacing: 0.06em;
}
.code-input::placeholder { text-transform: none; letter-spacing: 0; color: var(--ink-faint); }
.code-note { margin: 0 0 6px; font-size: calc(12px * var(--fs)); color: var(--red); line-height: 1.4; }
.code-note:empty { display: none; }
.mission-code { margin: 10px 0 0; font-size: calc(13px * var(--fs)); color: var(--ink-dim); line-height: 1.45; }
.mission-code strong { font-family: var(--font-data); color: var(--ink); letter-spacing: 0.06em; }
.mission-summary { margin: 0 0 6px; font-size: calc(13px * var(--fs)); line-height: 1.45; }
.mission-meta { margin: 0 0 8px; font-size: calc(12px * var(--fs)); color: var(--ink-dim); line-height: 1.4; }
.land-btn { width: 100%; }
.globe-labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.globe-label {
  position: absolute; left: 0; top: 0; padding: 2px 8px; border-radius: var(--radius); white-space: nowrap;
  font-size: calc(12px * var(--fs)); font-weight: 600; color: var(--orbit-ink); background: var(--orbit-glass);
  border: var(--sw) solid var(--orbit-edge);
}
.globe-label.open { border-color: var(--orbit-open); }
.globe-label.picked, .globe-label.hover { background: var(--orbit-glass-strong); border-color: var(--orbit-open); }
.globe-label[hidden] { display: none; }
.landing-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; padding: 5px 12px; border-radius: 14px;
  font-size: calc(12px * var(--fs)); color: var(--orbit-dim); background: var(--orbit-hint); white-space: nowrap;
}
@media (max-width: 1100px) {
  .landing-pick { width: calc(250px * var(--fs)); }
  .landing-site { width: calc(320px * var(--fs)); }
  .landing-hint { display: none; }
}

/* ---------------------------------------------------------------- plain pages (I1)
   The instructor totals page and its sign-in page: no 3D world behind them, so they scroll,
   on the page color the loading screen uses, with the game's top bar, panels and charts. */
body.page { overflow: auto; background: var(--overlay-in); }
.page-bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  min-height: var(--bar-h); padding: 6px 16px;
  background: linear-gradient(to bottom, var(--bar-top), var(--bar-bottom));
  border-bottom: var(--sw) solid var(--edge);
}
.page-bar .spacer { flex: 1; }
.page-bar .inline-btn {
  margin-left: 0; padding: 4px 10px; display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; white-space: nowrap;
}
.page-bar .state { font-family: var(--font-data); font-size: calc(11px * var(--fs)); padding: 0 7px; border-radius: 10px; border: var(--sw) solid var(--edge-strong); color: var(--signal); }
.page-bar form { margin: 0; }
.page-who { font-size: calc(12px * var(--fs)); color: var(--ink-dim); }
.page-main { max-width: 1120px; margin: 0 auto; padding: 14px 16px 40px; }
.page-lede { margin: 4px 0 10px; max-width: 75ch; line-height: 1.5; color: var(--ink-dim); }
.page-error { margin: 12px 0; color: var(--red); font-weight: 600; }
.page-section, .page-stats .stat { background: var(--glass-strong); }
.page-section {
  margin-top: 14px; padding: 10px 14px 12px;
  border: var(--sw) solid var(--edge); border-radius: var(--radius);
}
.page-title {
  margin: 0 0 4px; font-size: calc(12px * var(--fs)); font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim);
}
.page-foot { margin-top: 14px; }
.viz .bar { fill: var(--signal); }
.viz .hover-band { fill: var(--hover); }
.viz .baseline { stroke: var(--edge-strong); stroke-width: 1; }
.data-table { width: 100%; border-collapse: collapse; font-size: calc(12px * var(--fs)); }
.data-table th, .data-table td {
  padding: 5px 0 5px 14px; text-align: right; vertical-align: top; white-space: nowrap;
  font-family: var(--font-data); font-variant-numeric: tabular-nums; border-bottom: var(--sw) solid var(--edge);
}
.data-table th:first-child, .data-table td:first-child { padding-left: 0; text-align: left; font-family: var(--font-ui); font-weight: 400; white-space: normal; }
.by-day-table tbody th { white-space: nowrap; }
.data-table thead th {
  font-family: var(--font-ui); font-size: calc(10px * var(--fs)); font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-faint); vertical-align: bottom;
}
.data-table tr.group th {
  padding-top: 10px; font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--signal);
}
.data-table tr.idle td, .data-table tr.idle .cell-title { color: var(--ink-faint); }
.data-table tr.focus th, .data-table tr.focus td { font-weight: 600; color: var(--signal); }
/* The class missions on the totals page (I2): the form that posts one, then a card for each. */
.class-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 8px 12px; align-items: end; margin: 8px 0 10px; }
.class-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.class-field[hidden] { display: none; }
.class-field-label { font-size: calc(11px * var(--fs)); font-weight: 600; color: var(--ink-dim); }
.class-select, .class-input {
  min-width: 0; padding: 5px 8px; background: var(--field); color: var(--ink); border: var(--sw) solid var(--edge);
  border-radius: var(--radius); font: calc(13px * var(--fs)) var(--font-ui);
}
.class-form .inline-btn { margin-left: 0; justify-self: start; padding: 6px 18px; }
.class-form .code-note { grid-column: 1 / -1; margin: 0; }
.class-card { margin-top: 10px; padding: 10px 12px; border: var(--sw) solid var(--edge-strong); border-radius: var(--radius); }
.class-head { display: flex; align-items: flex-start; gap: 10px; }
.class-head > div { flex: 1; min-width: 0; }
.class-head .cell-sub { margin: 0; }
.class-head .inline-btn { margin-left: 0; }
.class-title { margin: 0 0 2px; font-size: calc(15px * var(--fs)); }
.class-line { margin: 6px 0 0; font-size: calc(13px * var(--fs)); }
.class-card .table-scroll { margin-top: 6px; }
.data-table td.empty { color: var(--ink-faint); font-style: italic; }
.cell-title { display: block; font-weight: 600; color: var(--ink); }
.cell-sub { display: block; font-size: calc(11px * var(--fs)); color: var(--ink-faint); }
.signin { display: grid; place-items: center; padding: 48px 16px; }
.signin-card {
  max-width: 520px; padding: 18px 22px; line-height: 1.5;
  background: var(--glass-strong); border: var(--sw) solid var(--edge); border-radius: var(--radius);
  box-shadow: 0 8px 30px var(--shadow);
}
.signin-card h1 { margin: 0 0 8px; font-size: calc(20px * var(--fs)); }
.signin-card a { color: var(--signal); }
.signin-bad { color: var(--red); font-weight: 600; }
.signin-ok { color: var(--good); font-weight: 600; }
.signin-card .btn-primary {
  display: inline-block; padding: 7px 16px; border-radius: var(--radius); text-decoration: none; font-weight: 600;
  background: var(--signal-strong); color: var(--on-signal);
}
@media (max-width: 640px) {
  .page-bar .brand { min-width: 0; }
  .page-bar .spacer { display: none; }
  .page-main { padding: 10px 16px 32px; }
}

/* ---------------------------------------------------------------- sector tip, loading */
.sector-tip {
  position: absolute; z-index: 41; padding: 4px 8px; border-radius: var(--radius);
  background: var(--glass-strong); border: var(--sw) solid var(--edge);
  font-family: var(--font-data); font-size: calc(11px * var(--fs)); color: var(--ink); pointer-events: none;
  transform: translate(14px, 14px); white-space: nowrap;
}
.sector-tip .dim { color: var(--ink-faint); }

.loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at center, var(--overlay-in) 0%, var(--overlay-out) 70%);
  transition: opacity 0.6s ease;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-card { text-align: center; }
.loading-mark { width: calc(180px * var(--fs)); height: calc(180px * var(--fs)); }
.loading-name { font-size: calc(34px * var(--fs)); font-weight: 700; letter-spacing: 0.06em; }
.loading-text { margin-top: 6px; font-size: calc(12px * var(--fs)); letter-spacing: 0.2em; text-transform: uppercase; color: var(--signal); }
.loading-bar { margin: 16px auto 0; width: 240px; height: 3px; background: var(--track); }
.loading-bar span { display: block; height: 100%; width: 0; background: var(--signal); transition: width 0.2s; }

@media (max-width: 1100px) {
  :root { --side-w: calc(220px * var(--fs)); --feed-w: 180px; --feed-h: 112px; --agents-w: calc(250px * var(--fs)); }
  .feed-head { gap: 4px; padding: 4px 6px; }       /* the narrow feeds' captions: the grip, callsign, signal and minimize */
  .feed-head .rec { display: none; }
}
/* ---------------------------------------------------------------- tab layouts (U8, U9)
   On a phone <html> carries .mobile and .tabbed (js/ui/settings.js: Layout in Settings, Auto on a
   narrow screen or a short touch one); Layout's Tabs gives a larger screen .tabbed alone (U9). In
   a mission the colony fills the screen and a tab bar along the bottom shows one panel at a time
   as a sheet over it (js/ui/mobile.js): Comms, Agents, Feeds, Mission and Alerts. No window moves,
   resizes or minimizes. On a phone the sheets and the tab bar run the screen's width, Colony
   status, the briefing and the satellite view open between the two bars, and held upright the
   top bar takes two rows, the readings under the clock; held sideways it keeps one and the
   sheets stand at the right. On a larger screen the top bar is the desktop's, and the tab bar,
   the sheets and those three share a column at the right. On a phone's landing screen the globe
   takes the top of the screen and the panels show one at a time under two tabs. The desktop
   layout shows none of this. */
.tabbar, .sheet-grip, .landing-tabs { display: none; }

/* The top bar: the logo without its words, then the clock and the buttons. The sol, the
   satellite button (Satellite view is in the menu) and Hide UI give way. */
html.mobile .topbar { gap: 8px; padding: 0 8px; }
html.mobile .brand-text, html.mobile #hud .sol, html.mobile #hide-ui, html.mobile #sat-btn { display: none; }
html.mobile .brand-mark { width: calc(34px * var(--fs)); height: calc(34px * var(--fs)); }
html.mobile .clock { gap: 6px; margin-left: auto; }
html.mobile .speed { flex: none; }              /* never clipped: what does not fit gives way (fitBar) */
html.mobile .speed button { padding: 6px 8px; }
html.mobile .res { padding: 2px 6px 2px 2px; gap: 5px; }
/* Readings still too wide once the bar has given up all it can: the row scrolls sideways, so
   Spend today is never cut off at the edge. */
html.mobile .resources { overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
html.mobile .resources::-webkit-scrollbar { display: none; }
/* The menu no wider than the screen: a long model name in the picker is cut short, rather than
   the picker widening the menu until its items run off the left edge. */
html.mobile .menu { right: 8px; max-width: calc(100% - 16px); }
html.mobile .menu-model select { width: 0; min-width: 100%; }
/* Held upright: the logo and the clock on the top row, the readings under them. Where the clock
   does not fit, the logo, the speaker and the speed buttons' padding give way (hud.js fitBar). */
@media (orientation: portrait) {
  html.mobile body:not(.landing) { --bar-h: calc(88px * var(--fs)); }
  html.mobile body:not(.landing) .topbar { display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: center; row-gap: 4px; }
  html.mobile body:not(.landing) .clock { grid-column: 2; grid-row: 1; min-width: 0; margin-left: 0; justify-content: flex-end; }
  html.mobile body:not(.landing) .resources { grid-column: 1 / -1; grid-row: 2; }
}
html.mobile .topbar.drop-brand .brand, html.mobile .topbar.drop-voice #voice-btn { display: none; }
html.mobile .topbar.drop-pad .speed button { padding: 6px 4px; }

/* The sheets, above the tab bar: a little over half the room, or nearly all of it with the
   grip. While the keyboard is up the tab bar steps aside and the sheet sits on the keyboard. */
html.tabbed #hud {
  --tab-h: calc(54px * var(--fs));
  --safe-b: env(safe-area-inset-bottom, 0px);
  --below: calc(var(--tab-h) + var(--safe-b));
  --room: calc(100% - var(--bar-h) - var(--below));
  --sheet-h: calc(var(--room) * 0.56);
}
html.tabbed #hud.sheet-tall, html.tabbed.kb-open #hud { --sheet-h: calc(var(--room) - 26px * var(--fs)); }
html.tabbed.kb-open #hud { --below: calc(var(--kb, 0px) / var(--ui)); }
html.tabbed #hud :is(.side, .agents, .comms, .feeds, .alerts) {
  position: absolute; left: 0; right: 0; top: auto; bottom: var(--below);
  width: auto; height: var(--sheet-h); max-width: none; max-height: none; min-width: 0; min-height: 0;
  transform: none; margin: 0;
}
html.tabbed #hud :is(.side, .agents, .comms, .feeds) { display: none; }
html.tabbed #hud :is(.side, .agents, .comms).sheet-on { display: flex; }
html.tabbed #hud :is(.agents, .comms, .alerts, .side > .mission) {
  border-radius: 12px 12px 0 0; border-width: var(--sw) 0 0; box-shadow: 0 -8px 30px var(--shadow);
}
html.tabbed .side > .mission { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
html.tabbed .mission-head .alerts-btn { display: none; }      /* the Alerts tab instead */
/* The feeds: as many across as fit, the colony showing between them, since each picture is
   drawn in the 3D canvas under its frame and a background would hide it. */
html.tabbed #hud .feeds.sheet-on {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(150px * var(--fs)), 1fr)); align-content: start;
  gap: 8px; padding: 8px; overflow-y: auto; overscroll-behavior: contain; pointer-events: auto;
}
html.tabbed .feed { width: auto; }
html.tabbed .feed-view { height: auto; aspect-ratio: 16 / 10; }
/* Colony status, the briefing and the satellite view: the whole room between the two bars. */
html.tabbed #hud :is(.status, .aims, .brief, .sat, .blueprint, .share) {
  position: absolute; left: 0; right: 0; top: var(--bar-h); bottom: var(--below);
  width: auto; height: auto; max-width: none; max-height: none; min-width: 0; min-height: 0;
  border-radius: 0; border-width: 0;
}
/* Nothing to move, resize or minimize. */
html.tabbed #hud :is(.win-grip, .win-min-btn, .win-edge, .win-resize) { display: none; }
html.tabbed [data-win-head] { cursor: default; touch-action: auto; user-select: auto; -webkit-user-select: auto; }
html.tabbed .panel-head .panel-title { padding-left: 12px; }
html.tabbed .comms .command { padding-right: 8px; }
html.mobile .comms .command { flex-wrap: wrap; row-gap: 4px; }
html.mobile .command .to { flex-basis: 100%; }  /* who it goes to on a line of its own, the box the full width */
html.tabbed #menu-windows { display: none; }
html.mobile .sub-arrow { transform: rotate(-90deg); }          /* the flyouts drop down (menu.js) */
/* Text boxes at 16 px or more, so a phone does not zoom the page when one is touched. */
html.mobile :is(#hud input:not([type="range"]), #hud select, .code-input, .landing-select) { font-size: max(calc(14px * var(--fs)), calc(16px / var(--ui))); }

/* Hide UI (the larger screen's tabs, U9) takes the tab bar and the sheet too. */
html.tabbed body:not(.landing) #hud.ui-hidden > :not(.topbar) { display: none; }

/* The tab bar, clear of a home bar or a rounded corner. */
html.tabbed body:not(.landing) #hud .tabbar {
  display: flex; position: absolute; left: 0; right: 0; bottom: 0; z-index: 35; pointer-events: auto;
  height: var(--below); padding-bottom: var(--safe-b);
  background: linear-gradient(to top, var(--bar-top), var(--bar-bottom)); border-top: var(--sw) solid var(--edge);
}
html.tabbed.kb-open body:not(.landing) #hud .tabbar { display: none; }
.tab {
  flex: 1 1 0; min-width: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 4px 2px; background: transparent; border: 0; color: var(--ink-dim);
  font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.04em;
}
.tab svg { width: calc(22px * var(--fs)); height: calc(22px * var(--fs)); flex: none; }
.tab[aria-expanded="true"] { color: var(--signal); background: var(--selected); box-shadow: inset 0 calc(var(--sw) * 3) 0 var(--signal); }
.tab-badge {
  position: absolute; top: 3px; left: calc(50% + 6px); min-width: calc(18px * var(--fs)); padding: 0 5px; border-radius: 9px;
  border: var(--sw) solid var(--signal-strong); background: var(--signal-strong); color: var(--on-signal);
  font-family: var(--font-data); font-size: calc(10px * var(--fs)); font-weight: 400; line-height: 1.5; text-align: center;
}
.tab-badge[hidden] { display: none; }
.tab[data-tab="alerts"] .tab-badge { background: var(--glass-strong); border-color: var(--amber); color: var(--amber); }
.tab.alarm { color: var(--red); animation: alarm 1.2s steps(2) infinite; }
.tab.alarm .tab-badge { border-color: var(--red); color: var(--red); }

/* The grip on the sheet's top edge. */
html.tabbed #hud.sheet-open .sheet-grip {
  display: grid; place-items: center; position: absolute; z-index: 36; pointer-events: auto;
  left: 50%; bottom: calc(var(--below) + var(--sheet-h) - var(--sw)); transform: translateX(-50%);
  width: calc(64px * var(--fs)); height: calc(24px * var(--fs)); padding: 0;
  background: var(--glass-strong); border: var(--sw) solid var(--edge); border-bottom: 0; border-radius: 10px 10px 0 0; color: var(--ink-dim);
}
.sheet-grip svg { width: calc(22px * var(--fs)); height: calc(22px * var(--fs)); }

/* Held sideways: one row of top bar, a lower tab bar with the names beside the icons, and the
   sheets standing at the right from the top bar down. */
@media (orientation: landscape) {
  html.mobile #hud { --tab-h: calc(42px * var(--fs)); }
  html.mobile #hud :is(.side, .agents, .comms, .feeds, .alerts) { left: auto; top: var(--bar-h); height: auto; width: min(58%, calc(440px * var(--fs))); }
  html.mobile #hud :is(.agents, .comms, .alerts, .side > .mission) { border-radius: 12px 0 0 0; border-width: var(--sw) 0 0 var(--sw); }
  html.mobile .tab { flex-direction: row; gap: 6px; }
  html.mobile .tab-badge { position: static; }
  html.mobile #hud.sheet-open .sheet-grip { display: none; }
}

/* The larger screen's tabs (U9): the desktop's top bar, and a column at the right holding the
   tab bar and, over it, the sheet showing, from the top bar down, as are Colony status, the
   briefing, the satellite view, the blueprint and Generate URL/State (H10: those two were left out
   and filled the screen). The grip on the column's left edge makes it twice as wide, as far as
   leaving the colony a strip. */
html.tabbed:not(.mobile) #hud {
  --tab-h: calc(44px * var(--fs));
  --col-w: min(calc(460px * var(--fs)), 45%);
}
html.tabbed:not(.mobile) #hud.sheet-wide { --col-w: max(min(calc(920px * var(--fs)), calc(100% - 200px)), min(calc(460px * var(--fs)), 45%)); }
html.tabbed:not(.mobile) #hud :is(.side, .agents, .comms, .feeds, .alerts, .status, .aims, .brief, .sat, .blueprint, .share) {
  left: auto; top: var(--bar-h); bottom: var(--below); height: auto; width: var(--col-w);
}
html.tabbed:not(.mobile) #hud :is(.agents, .comms, .alerts, .side > .mission, .status, .aims, .brief, .sat, .blueprint, .share) {
  border-radius: 12px 0 0 0; border-width: var(--sw) 0 0 var(--sw); box-shadow: -8px 0 30px var(--shadow);
}
html.tabbed:not(.mobile) body:not(.landing) #hud .tabbar { left: auto; width: var(--col-w); border-left: var(--sw) solid var(--edge); }
html.tabbed:not(.mobile) #hud:not(.sheet-open) .tabbar { border-radius: 12px 0 0 0; }
html.tabbed:not(.mobile) .tab { flex-direction: row; gap: 6px; font-size: calc(12px * var(--fs)); }
html.tabbed:not(.mobile) .tab-badge { position: static; }
html.tabbed:not(.mobile) #hud.sheet-open .sheet-grip {
  left: auto; right: calc(var(--col-w) - var(--sw)); bottom: auto; top: calc((100% + var(--bar-h) - var(--below)) / 2); transform: translateY(-50%);
  width: calc(24px * var(--fs)); height: calc(64px * var(--fs));
  border: var(--sw) solid var(--edge); border-right: 0; border-radius: 10px 0 0 10px;
}
html.tabbed:not(.mobile) .sheet-grip svg { transform: rotate(90deg); }

/* The cards (briefing, report, Getting Started, Help) nearly edge to edge. */
html.mobile .mission-card { width: calc(100% - 16px); max-width: calc(100% - 16px); max-height: calc(100% - 16px); }   /* past the browser's own margin for a modal dialog */
html.mobile .debrief { height: calc(100% - 16px); }
html.mobile .card-head { padding: 12px 14px 10px; }
html.mobile .card-head h2 { font-size: calc(22px * var(--fs)); }
html.mobile .card-body { padding: 4px 14px 8px; }
html.mobile .card-foot { padding: 10px 14px; }
html.mobile .report-tabs { padding: 0 6px; gap: 0; }       /* the report's five tabs across a phone */
html.mobile .report-tab { flex: 1 1 auto; padding: 8px 6px; letter-spacing: 0; }
html.mobile .spend-rows li { grid-template-columns: auto minmax(calc(40px * var(--fs)), 1fr) auto; }
html.mobile :is(.num-table th, .num-table td) { padding-right: 8px; }

/* The landing screen: the globe above (js/ui/landing.js fits it there), the panels below under
   their two tabs, or beside it when held sideways. */
html.mobile #landing { --globe: 42%; --ltab-h: calc(42px * var(--fs)); }
html.mobile #landing .landing-tabs {
  display: flex; position: absolute; left: 0; right: 0; top: var(--globe); height: var(--ltab-h); z-index: 2; pointer-events: auto;
  background: var(--glass-strong); border-top: var(--sw) solid var(--edge-strong); border-radius: 12px 12px 0 0; overflow: hidden;
}
.landing-tab {
  flex: 1 1 0; min-width: 0; padding: 0 10px; background: transparent; border: 0; border-bottom: var(--sw) solid var(--edge);
  color: var(--ink-dim); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.landing-tab[aria-selected="true"] { color: var(--ink); background: var(--selected); box-shadow: inset 0 calc(var(--sw) * -3) 0 var(--signal); }
html.mobile #landing :is(.landing-pick, .landing-site) {
  left: 0; right: 0; top: calc(var(--globe) + var(--ltab-h)); bottom: 0; width: auto; max-height: none;
  border-radius: 0; border-width: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
html.mobile #landing[data-panel="site"] .landing-pick, html.mobile #landing[data-panel="pick"] .landing-site { display: none; }
@media (orientation: landscape) {
  html.mobile #landing { --side: 44%; }
  html.mobile #landing .landing-tabs { top: 0; left: var(--side); border-radius: 12px 0 0 0; }
  html.mobile #landing :is(.landing-pick, .landing-site) { top: var(--ltab-h); left: var(--side); }
}

/* The tutorial's cards (N1): a card beside the part of the screen it is about, over every window and the
   tab bar but under the menu, and a ring round that part. Both are in the HUD, so Hide UI takes them too. */
.tut-card {
  position: absolute; z-index: 38; pointer-events: auto; box-sizing: border-box;
  width: calc(340px * var(--fs)); max-width: calc((100vw - 24px) / var(--ui));
  max-height: calc((100vh - 96px) / var(--ui)); overflow-y: auto;
  padding: 10px 14px 12px; background: var(--glass-strong); border: var(--sw) solid var(--edge-strong);
  border-left: calc(4px * var(--fs)) solid var(--signal); box-shadow: 0 14px 44px var(--shadow);
  color: var(--ink); font-size: calc(13px * var(--fs)); line-height: 1.45;
}
.tut-head { display: flex; align-items: center; gap: 8px; min-height: calc(28px * var(--fs)); }
/* N6: the card's top drags it, as a window's title bar does; the grip takes the arrow keys. */
.tut-head, .tut-title { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.tut-dragging, .tut-dragging :is(.tut-head, .tut-title) { cursor: grabbing; }
.tut-grip {
  flex: none; display: grid; place-items: center; align-self: stretch; width: calc(18px * var(--fs)); margin-left: -6px; padding: 0;
  background: transparent; border: var(--sw) solid transparent; border-radius: var(--radius); color: var(--ink-faint); cursor: grab; touch-action: none;
}
.tut-grip svg { width: calc(14px * var(--fs)); height: calc(14px * var(--fs)); }
.tut-grip:hover, .tut-grip:focus-visible { color: var(--ink); border-color: var(--edge-strong); background: var(--hover); }
.tut-head .kicker { flex: 1; font-size: calc(11px * var(--fs)); letter-spacing: 0.14em; text-transform: uppercase; color: var(--signal); }
.tut-head .card-close { position: static; flex: none; width: calc(28px * var(--fs)); height: calc(28px * var(--fs)); }
.tut-title { margin: 2px 0 6px; font-size: calc(17px * var(--fs)); letter-spacing: 0.02em; }
.tut-body p { margin: 0 0 7px; }
.tut-act { padding: 6px 9px; border-left: calc(3px * var(--fs)) solid var(--signal); background: var(--selected); border-radius: var(--radius); }
.tut-act.done { border-left-color: var(--good); }
.tut-act.done strong { color: var(--good); }
.tut-live { color: var(--ink-dim); font-family: var(--font-data); font-size: calc(12px * var(--fs)); }
.tut-example { display: grid; gap: 6px; justify-items: start; margin: 0 0 7px; padding: 7px 9px; border: var(--sw) dashed var(--edge-strong); border-radius: var(--radius); }
.tut-example q { font-style: italic; color: var(--ink-dim); }
.tut-example .dlg-btn { padding: 4px 12px; }
.tut-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tut-foot .dlg-btn { padding: 6px 14px; }
.tut-ring {
  position: absolute; z-index: 37; pointer-events: none; box-sizing: border-box;
  border: calc(3px * var(--fs)) solid var(--signal); border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 0 0 calc(3px * var(--fs)) var(--glass), 0 0 18px var(--signal); animation: tut-pulse 1.6s ease-in-out infinite;
}
@keyframes tut-pulse { 50% { box-shadow: 0 0 0 calc(3px * var(--fs)) var(--glass), 0 0 4px var(--signal); } }
/* The tutorial's debrief: how to read one, above the tabs' panels. */
.report-guide { margin: 10px 0 4px; padding: 8px 12px; border-left: calc(3px * var(--fs)) solid var(--signal); background: var(--selected); border-radius: var(--radius); }
.report-guide h3 { margin: 0 0 4px; font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); }
.report-guide ul { margin: 0; padding-left: 18px; line-height: 1.45; }

@media (prefers-reduced-motion: reduce) {
  .tut-ring { animation: none; }
  .feed-head .rec, .on-air i, .chip.pending { animation: none; }
  .alerts-btn.alarm, .tab.alarm { animation: none; background: var(--red); color: var(--on-red); }
  .loading { transition: none; }
}
