/* ==========================================================================
   Sunray Sequence — field UI
   No framework. Custom properties only. Two themes: AMOLED and red-light.
   ========================================================================== */

:root {
  --bg: #000000;          /* AMOLED pure black: unlit pixels, no light leak */
  --panel: #0a0a0a;
  --line: #242424;
  --line-hi: #5d5d5d;   /* 3:1 on both bg and panel — WCAG 1.4.11 */
  --fg: #f2f2f2;
  --fg-dim: #9a9a9a;
  --accent: #ff7a1a;
  --ok: #3ddc84;
  --warn: #ffd166;
  --crit: #ff4d4d;
  --tap: 48px;            /* minimum touch target, gloved use */
  --gap: 12px;
  --radius: 2px;
  /* Type scale. Seven styles, and nothing outside them.
     An audit found thirteen distinct size/weight/family combinations in body
     content — 14px and 15px one-offs sitting beside 13px and 16px — which is
     what made the app feel assembled from parts rather than designed.

       display  32/700 sans   page title
       head     19/700 sans   section heading
       sub      15/700 sans   sub-heading inside a sheet or card
       body     16/400 sans   prose
       small    13/400 sans   secondary prose
       data     16/400 mono   values, inputs, anything read aloud
       label    11/600 mono   uppercase field labels and eyebrows           */
  --fs-display: 32px;
  --fs-head: 19px;
  --fs-sub: 15px;
  --fs-body: 16px;
  --fs-sm: 13px;
  --fs-xs: 11px;
  /* Same faces as the rest of Rasembli, self-hosted and precached with the
     shell so they are present with the radio off. The system stacks stay as
     fallbacks: if a face has not arrived yet the app is still legible. */
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ==========================================================================
   Shared design contract with the rest of the site.
   --------------------------------------------------------------------------
   Sunray and Gridnorth are the same product and should read as it. What is
   shared, and what deliberately is not:

   SHARED   typeface (IBM Plex Sans / Mono), 2px radius, 48px minimum tap
            target, monospace for anything read aloud or transcribed.

   DIVERGES background and accent. The site sits on #10191D with a #B8650F
            accent; Sunray sits on pure #000000 so unlit AMOLED pixels emit
            nothing, and takes a brighter #FF7A1A because the site accent
            measures 4.91:1 on black where the brighter one measures 8.05:1.
            The red-light theme has no counterpart on the site at all. These
            are operational requirements — light discipline and night
            legibility — not stylistic drift, and scripts/test-contrast.mjs
            holds both themes to the measured floors.
   ========================================================================== */

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/IBMPlexMono-SemiBold-Latin1.woff2") format("woff2");
  font-weight: 600 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/IBMPlexSans-Regular-Latin1.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}

/* Red light: monochromatic, preserves scotopic adaptation and NVG use.
 *
 * Pure red on black tops out at 5.25:1, so the entire usable band for AA body
 * text is #EB0000 to #FF0000. Dimming by luminance is therefore not available
 * here: an earlier build used #A10000 for every field label, which measures
 * 2.52:1 and is unreadable in the one mode meant for darkness. Hierarchy in
 * this theme comes from weight and letter-spacing instead, and the colours
 * below are the measured floors:
 *
 *   --fg      #FF0000  body text
 *   --fg-dim  #ED0000  secondary text, still AA
 *   --line-hi #B90000  interactive borders (WCAG 1.4.11 non-text)
 *   --line    #6B0000  decorative rules only, never a control boundary
 *
 * Every figure is measured against --panel as well as the page background,
 * since the panel is marginally lighter and lowers the ratio. --line is the
 * one token exempt from 1.4.11: it draws grouping rules and card edges, never
 * the boundary of a control. scripts/test-contrast.mjs enforces the rest.
 */
:root[data-theme="red"] {
  --bg: #000000;
  --panel: #0c0000;
  --line: #6b0000;
  --line-hi: #b90000;
  --fg: #ff0000;
  --fg-dim: #ed0000;
  --accent: #ff0000;
  --ok: #ff0000;
  --warn: #ff0000;
  --crit: #ff0000;
}

/* Luminance cannot carry hierarchy in a monochrome theme, so restore it with
   weight and tracking: secondary text reads as secondary without going dim. */
:root[data-theme="red"] .dim,
:root[data-theme="red"] label.f,
:root[data-theme="red"] .cite,
:root[data-theme="red"] .kv dt,
:root[data-theme="red"] .home-k { letter-spacing: .13em; font-weight: 400; }
:root[data-theme="red"] .hdr-clock b,
:root[data-theme="red"] .home-v,
:root[data-theme="red"] h1,
:root[data-theme="red"] h2,
:root[data-theme="red"] .badge { font-weight: 700; }
:root[data-theme="red"] img,
:root[data-theme="red"] svg { filter: grayscale(1) sepia(1) hue-rotate(-50deg) saturate(6); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font: var(--fs-body)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
}

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.22; }
h1 { font-size: var(--fs-display); letter-spacing: -0.015em; }
h2 { font-size: var(--fs-head); }
h3 { font-size: var(--fs-sub); }
p { margin: 0 0 .6em; }
button, input, select, textarea { font: inherit; color: inherit; }

.wrap { max-width: 900px; margin: 0 auto; padding: 0 12px; }
.mono { font-family: var(--mono); }
.dim { color: var(--fg-dim); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ------------------------------------------------------------ header */
.hdr {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.hdr-row { display: flex; align-items: center; gap: 8px; min-height: 56px; }
.hdr-clock { font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.25; flex: 1; min-width: 0; }
.hdr-clock b { color: var(--fg); font-weight: 700; }
.hdr-clock span { color: var(--fg-dim); }
.hdr-next { color: var(--accent); }
.hdr-next.is-late { color: var(--crit); }

.seg { display: flex; border: 1px solid var(--line-hi); border-radius: var(--radius); overflow: hidden; }
.seg button {
  min-width: 44px; min-height: 44px; padding: 0 10px;
  background: transparent; border: 0; font-family: var(--mono); font-size: var(--fs-xs);
  letter-spacing: .08em; color: var(--fg-dim); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); font-weight: 700; }

/* ------------------------------------------------------------- tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  min-height: var(--tap); min-width: 0; background: transparent; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .02em;
  color: var(--fg-dim); border-top: 2px solid transparent; padding: 6px 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--fg); border-top-color: var(--accent); }
.tabs svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------ blocks */
.view { padding: 14px 0 24px; }
.view[hidden] { display: none; }

.card { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); margin-bottom: var(--gap); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px; min-height: var(--tap); }
.card-b { padding: 0 12px 12px; }

.acc { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); margin-bottom: 8px; }
.acc > summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  min-height: var(--tap); padding: 10px 12px; list-style: none;
}
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: "+"; margin-left: auto; font-family: var(--mono); color: var(--fg-dim); }
.acc[open] > summary::after { content: "\2212"; }
.acc-b { padding: 4px 12px 14px; border-top: 1px solid var(--line); }

.badge {
  font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .08em;
  padding: 3px 7px; border: 1px solid var(--line-hi); border-radius: var(--radius);
  color: var(--fg-dim); white-space: nowrap; text-transform: uppercase;
}
.badge.s-draft { color: var(--warn); border-color: var(--warn); }
.badge.s-done { color: var(--ok); border-color: var(--ok); }
.badge.s-crit { color: var(--crit); border-color: var(--crit); }

.step-n {
  font-family: var(--mono); font-size: var(--fs-sm); font-weight: 700;
  min-width: 2.2em; color: var(--accent);
}
.cite {
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-dim);
  border-left: 2px solid var(--line-hi); padding: 4px 0 4px 8px; margin: 8px 0;
}
.cite b { color: var(--fg); font-weight: 600; }

/* ------------------------------------------------------------ inputs */
label.f { display: block; margin: 8px 0 3px; font-family: var(--mono); font-size: var(--fs-xs);
  letter-spacing: .1em; text-transform: uppercase; color: var(--fg-dim); }
.f-in, select.f-in, textarea.f-in {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  background: #000; border: 1px solid var(--line-hi); border-radius: var(--radius);
  color: var(--fg); font-family: var(--mono);
}
textarea.f-in { min-height: 88px; resize: vertical; line-height: 1.45; }
/* A growing field opens at one line and takes only the height it needs. Five
   empty SITREP boxes used to cost 440px before a word was typed. */
textarea.f-in.grow { min-height: 44px; height: 44px; overflow-y: hidden; resize: none; }
.f-in:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }

.btn {
  min-height: var(--tap); width: 100%; padding: 10px 14px; cursor: pointer;
  background: transparent; border: 1px solid var(--line-hi); border-radius: var(--radius);
  color: var(--fg); font-family: var(--mono); font-size: var(--fs-sm);
  letter-spacing: .1em; text-transform: uppercase;
}
.btn-p { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 700; }
.btn-row { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-top: 10px; }

/* --------------------------------------------------------- comms out */
.tx {
  border: 1px solid var(--accent); background: #000; border-radius: var(--radius);
  padding: 12px; margin-top: 12px;
  font-family: var(--mono); font-size: var(--fs-body); line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}
.tx-line { display: flex; gap: 10px; }
.tx-n { color: var(--accent); min-width: 2.4em; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.kv:first-child { border-top: 0; }
.kv dt { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .08em;
  text-transform: uppercase; color: var(--fg-dim); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; }
.kv dd b { font-size: var(--fs-head); }

/* ------------------------------------------------------- delivery mode */
.deliver { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; flex-direction: column; }
.deliver[hidden] { display: none; }
.deliver-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.deliver-b { flex: 1; overflow-y: auto; padding: 18px 16px; }
.deliver-b h2 { font-family: var(--mono); font-size: var(--fs-sub); letter-spacing: .12em;
  color: var(--accent); text-transform: uppercase; margin-bottom: 12px; }
.deliver-b .txt { font-size: 24px; font-weight: 700; line-height: 1.45; white-space: pre-wrap; }
.deliver-f { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center;
  padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); }
.deliver-f .pos { font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-dim); text-align: center; }

/* ------------------------------------------------------------- split */
.split { display: grid; gap: 10px; }
.split.on { grid-template-columns: 1fr 1fr; }
.split .pane-l[data-lang] h3 { font-size: var(--fs-sm); }
@media (max-width: 700px) { .split.on { grid-template-columns: 1fr; } }

.pane { border: 1px solid var(--line); background: var(--panel); padding: 10px; border-radius: var(--radius); }
.pane > .tag { font-family: var(--mono); font-size: var(--fs-xs); color: var(--fg-dim);
  letter-spacing: .12em; display: block; margin-bottom: 6px; }

/* ------------------------------------------------------------ drawer */
.drawer { position: fixed; inset: auto 0 0 0; z-index: 90; background: var(--panel);
  border-top: 1px solid var(--accent); max-height: 72vh; overflow-y: auto;
  padding: 14px 14px calc(20px + env(safe-area-inset-bottom)); }
.drawer[hidden] { display: none; }
.drawer-x { position: absolute; top: 8px; right: 8px; min-width: var(--tap); min-height: var(--tap);
  background: transparent; border: 1px solid var(--line-hi); border-radius: var(--radius); cursor: pointer; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 80; }
.scrim[hidden] { display: none; }

.srch { width: 100%; min-height: var(--tap); padding: 10px 12px; background: #000;
  border: 1px solid var(--line-hi); border-radius: var(--radius); font-family: var(--mono); margin-bottom: 10px; }

.note { border-left: 2px solid var(--warn); padding: 8px 10px; margin: 10px 0;
  font-size: var(--fs-sm); color: var(--fg-dim); background: rgba(255,209,102,.05); }
:root[data-theme="red"] .note { background: transparent; }

ul.tight { margin: 6px 0; padding-left: 20px; }
ul.tight li { margin: 4px 0; }
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.t th, table.t td { text-align: left; padding: 7px 6px; border-top: 1px solid var(--line); vertical-align: top; }
table.t th { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-dim); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ------------------------------------------------ master brief additions */


.sticky-tools { position: sticky; top: 56px; z-index: 30; background: var(--bg);
  padding: 8px 0; border-bottom: 1px solid var(--line); margin-bottom: 10px; }

.btn-next { min-height: 56px; font-size: var(--fs-sm); margin-top: 12px; }

/* Bottom sheet — thumb reachable, swipe down to dismiss. */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
  background: var(--panel); border-top: 2px solid var(--accent);
  border-radius: 10px 10px 0 0; max-height: 78vh; overflow-y: auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(0); transition: transform .18s ease-out; }
.sheet[hidden] { display: none; }
.sheet-grip { width: 44px; height: 4px; border-radius: 2px; background: var(--line-hi);
  margin: 6px auto 12px; }
.sheet h2 { font-size: var(--fs-head); margin-bottom: 8px; }
.sheet .hint { font-size: var(--fs-xs); font-family: var(--mono); color: var(--fg-dim);
  text-align: center; margin-top: 14px; }

/* Wait-state divider between call-for-fire transmissions. */
.waitbar { border: 2px solid var(--warn); color: var(--warn); border-radius: var(--radius);
  padding: 12px; margin: 12px 0; text-align: center; font-family: var(--mono);
  font-size: var(--fs-sm); letter-spacing: .1em; text-transform: uppercase;
  animation: pulse 1.6s ease-in-out infinite; }
:root[data-theme="red"] .waitbar { border-color: var(--fg); color: var(--fg); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .42; } }

/* 9-liner numeric pad. */
.padgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0; }
.padgrid button { min-height: 48px; font-family: var(--mono); font-size: var(--fs-head); font-weight: 700;
  background: transparent; color: var(--fg); border: 1px solid var(--line-hi);
  border-radius: var(--radius); cursor: pointer; }
.padgrid button[data-filled="1"] { border-color: var(--ok); color: var(--ok); }
.padgrid button[aria-current="true"] { background: var(--fg); color: var(--bg); }
.optgrid { display: grid; gap: 8px; margin: 8px 0; }
.optgrid button { min-height: 52px; text-align: left; padding: 10px 14px;
  background: transparent; color: var(--fg); border: 1px solid var(--line-hi);
  border-radius: var(--radius); cursor: pointer; font-size: var(--fs-sm); }
.optgrid button[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); font-weight: 700; }

/* Readiness modal. */
.ready { position: fixed; inset: 0; z-index: 110; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; }
.ready[hidden] { display: none; }
.ready h2 { font-size: var(--fs-display); margin-bottom: 10px; }
.ready .big { width: 100%; max-width: 420px; min-height: 64px; font-size: 16px; margin-top: 20px; }

/* Toast. */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 120; background: var(--panel); border: 1px solid var(--warn);
  border-radius: var(--radius); padding: 14px; font-size: var(--fs-sm);
  /* The panel must never swallow a tap meant for what is underneath it. */
  pointer-events: none; }
.toast .btn { pointer-events: auto; }
.toast[hidden] { display: none; }
:root[data-theme="red"] .toast { border-color: var(--fg); }

/* Skeleton mode. */
.skel h3 { font-family: var(--mono); font-size: var(--fs-sm); letter-spacing: .08em;
  text-transform: uppercase; margin-top: 14px; }
.skel .plus { border: 1px solid var(--line-hi); border-radius: var(--radius);
  min-width: 32px; min-height: 32px; background: transparent; color: var(--fg); cursor: pointer; }
.skel ul { margin: 6px 0 0; padding-left: 18px; color: var(--fg-dim); font-size: var(--fs-sm); }

.slot { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; margin: 6px 0; }
.slot .lead { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .08em;
  color: var(--accent); white-space: nowrap; }
:root[data-theme="red"] .slot .lead { color: var(--fg-dim); }
.slot .f-in { min-height: 44px; }

/* ==========================================================================
   Brand strip, home panel, reference chrome, and the utility classes that
   replace inline style attributes.

   The production CSP is `style-src 'self'` with no 'unsafe-inline', so a
   `style="..."` attribute is dropped by the browser before it ever applies.
   Everything static therefore has to be a class; only genuinely dynamic
   values (the progress bar) are set through CSSOM from JS, which CSP allows.
   ========================================================================== */

/* ------------------------------------------------------------ brand strip
   Built so it cannot overflow. The wordmark is the only flexible item and it
   is allowed to shrink and wrap; everything else is a fixed 44px control. An
   earlier version fitted four competing items with 5px to spare at 412px, and
   a font fallback on first paint was enough to push the settings control off
   the screen and give the whole app a horizontal scroll. */
.brand { border-bottom: 1px solid var(--line); background: var(--bg); }
.brand-row {
  display: flex; align-items: center; gap: 8px; min-height: 52px;
  padding-top: env(safe-area-inset-top);
}
.brand-id {
  display: flex; align-items: center; gap: 9px; min-height: 44px;
  text-decoration: none; color: var(--fg);
  flex: 1 1 0; min-width: 0;          /* shrinks before anything else does */
}
.brand-mark { width: 24px; height: 20px; flex: 0 0 24px; color: var(--fg); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-txt b {
  font-family: var(--mono); font-size: var(--fs-sm); letter-spacing: .12em;
  text-transform: uppercase; font-weight: 700;
  overflow-wrap: anywhere; line-height: 1.15;
}
.brand-txt i {
  font-family: var(--mono); font-size: 9px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--fg-dim); font-style: normal; margin-top: 2px;
  white-space: nowrap;
}

/* Offline state is a dot. The words are its accessible name, its tooltip, and
   a line in Settings — none of which take horizontal space in the chrome. */
.off {
  flex: 0 0 18px; width: 18px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-dim);
}
.off::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.off[data-state="ready"], .off[data-state="off"] { color: var(--ok); }
.off[data-state="bad"] { color: var(--crit); }
.off[data-state="none"] { color: var(--warn); }
.off[data-state="prep"] { color: var(--fg-dim); }
:root[data-theme="red"] .off { color: var(--fg-dim); }
:root[data-theme="red"] .off[data-state="ready"],
:root[data-theme="red"] .off[data-state="off"] { color: var(--fg); }

.chip { min-height: 34px; padding: 0 12px; background: transparent; cursor: pointer;
  border: 1px solid var(--line-hi); border-radius: var(--radius); color: var(--fg-dim);
  font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .1em;
  text-transform: uppercase; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 600; }
#install { color: var(--fg); border-color: var(--accent); flex: 0 0 auto; }
:root[data-theme="red"] #install { border-color: var(--fg); }

/* Standalone header buttons (clock pause, timeline help). */
.seg-x {
  min-width: 44px; min-height: 44px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; cursor: pointer;
  border: 1px solid var(--line-hi); border-radius: var(--radius);
  color: var(--fg); font-family: var(--mono); font-size: var(--fs-xs);
}
#clk-toggle { color: var(--fg-dim); }

/* -------------------------------------------------------------- home panel */
.home { border: 1px solid var(--line-hi); background: var(--panel);
  border-radius: var(--radius); padding: 12px; margin-bottom: var(--gap); }
.home-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; }
.home-k { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .1em;
  text-transform: uppercase; color: var(--fg-dim); }
.home-v { font-family: var(--mono); font-size: var(--fs-body); font-weight: 700; text-align: right; }
.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 10px 0 12px; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; }
.home-hint { font-size: var(--fs-sm); color: var(--fg-dim); margin: 12px 0 0; }
.home .btn-p { margin-top: 2px; }

/* ------------------------------------------------------------ comms lines */
/* Every line of a report stays on the page. The line the pad points at is
   the only one that expands to glove-sized option buttons. */
.ln { border-left: 2px solid transparent; padding-left: 8px; margin-left: -10px; }
.ln.is-on { border-left-color: var(--accent); background: rgba(255,122,26,.04); }
:root[data-theme="red"] .ln.is-on { border-left-color: var(--fg); background: transparent; }

.txgrp { border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px 10px; margin: 10px 0; }
.txgrp-h { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); padding: 8px 0 2px; }
:root[data-theme="red"] .txgrp-h { color: var(--fg-dim); }

/* -------------------------------------------------------- reference chrome */
.chips { display: flex; gap: 6px; padding-bottom: 10px; }
.backlist li { margin: 10px 0; }
.foot { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 14px;
  font-size: var(--fs-sm); }
.foot p { margin: 0 0 6px; }
.foot b { font-family: var(--mono); font-weight: 600; letter-spacing: .06em; }
.foot a { color: var(--accent); }
:root[data-theme="red"] .foot a { color: var(--fg); }
.foot .mono { font-size: var(--fs-xs); }

/* ------------------------------------------------------------- utilities */
.u-m0 { margin: 0; }
.u-mt8 { margin-top: 8px; }
.u-mt10 { margin-top: 10px; }
.u-mt12 { margin-top: 12px; }
.u-mt18 { margin-top: 18px; }
.u-mt20 { margin-top: 20px; }
.u-mb8 { margin-bottom: 8px; }
.u-fs11 { font-size: var(--fs-xs); }
.u-fs13 { font-size: var(--fs-sm); }
.u-fs14 { font-size: var(--fs-sub); }
.u-fs15 { font-size: var(--fs-body); }
.u-flex1 { flex: 1; min-width: 0; }
.u-left { text-align: left; }
.u-cap { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.u-slope { margin: 10px 0 18px; }
.t-key { width: 34%; }
.btn-auto { width: auto; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.chk input { width: 24px; height: 24px; }
.toast p { margin: 0 0 10px; }
.skel h3 { display: flex; align-items: center; gap: 8px; }

/* Header fit at 390px: the clock is the operational readout and must not be
   squeezed into three wrapped lines by the controls beside it. Language lives
   in the brand strip (set once); theme stays here (needed fast, at night). */
.hdr-clock > b,
.hdr-clock > span { display: inline; }
.hdr-clock { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-clock .hdr-next { display: block; overflow: hidden; text-overflow: ellipsis; }

/* A plan old enough to be dangerous says so in the one place you look first. */
.home-v.is-stale { color: var(--warn); }
:root[data-theme="red"] .home-v.is-stale { color: var(--fg); text-decoration: underline; }

/* ---------------------------------------------- coded option lines (9-liner)
   The code letter is the target; the legend under it keeps every option
   readable without tapping through them. Replaces a stacked list of full-text
   buttons that cost 257px for four choices. */
.codes { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.codes button {
  min-width: 48px; min-height: 48px; flex: 0 0 auto; padding: 0 12px;
  background: transparent; color: var(--fg); cursor: pointer;
  border: 1px solid var(--line-hi); border-radius: var(--radius);
  font-family: var(--mono); font-size: var(--fs-head); font-weight: 700;
}
.codes button[aria-pressed="true"] { background: var(--ok); color: var(--bg); border-color: var(--ok); }
:root[data-theme="red"] .codes button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

.legend { margin: 0 0 4px; font-size: var(--fs-sm); color: var(--fg-dim); line-height: 1.5; }
.legend span { display: inline-block; margin-right: 10px; }
.legend span b { font-family: var(--mono); }
.legend span.on { color: var(--ok); font-weight: 700; }
:root[data-theme="red"] .legend span.on { color: var(--fg); text-decoration: underline; }

/* ------------------------------------------------------- compact line rows
   A closed nine-liner line: number, what it is, what you put in it. Tapping
   opens the editor in place. Nine open editors were 1307px of scrolling. */
.lnrow {
  display: grid; grid-template-columns: 2em 1fr auto; align-items: center; gap: 10px;
  width: 100%; min-height: 48px; padding: 6px 8px; margin: 2px 0;
  background: transparent; color: var(--fg); cursor: pointer; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
}
.lnrow-n { font-family: var(--mono); font-size: var(--fs-body); font-weight: 700; color: var(--accent); }
:root[data-theme="red"] .lnrow-n { color: var(--fg); }
.lnrow-l {
  font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-dim); line-height: 1.3;
}
.lnrow-v {
  font-family: var(--mono); font-size: var(--fs-sm); text-align: right;
  max-width: 44%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lnrow-v.is-empty { color: var(--fg-dim); }
.ln.is-on { padding: 6px 8px 10px; margin: 2px 0; }

/* Source and standing caveats: one line, open on demand. Always-on they cost
   about 160px at the head of every report. */
.src { margin: 0 0 6px; }
.src > summary {
  display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer;
  list-style: none; font-family: var(--mono); font-size: var(--fs-xs);
  letter-spacing: .04em; color: var(--fg-dim);
}
.src > summary::-webkit-details-marker { display: none; }
.src > summary::before { content: "\2139"; font-size: 13px; }
.src > summary::after { content: "+"; margin-left: auto; }
.src[open] > summary::after { content: "\2212"; }
.src .note { margin-top: 6px; }

/* The header tucks away on the way down and returns on the way up. The tab
   bar never moves: it is the control you reach for without looking. */
.hdr { transition: transform .18s ease-out; will-change: transform; }
.hdr[data-tucked="true"] { transform: translateY(-100%); }
@media (prefers-reduced-motion: reduce) {
  .hdr { transition: none; }
  .hdr[data-tucked="true"] { transform: none; }
}

/* Once offline-ready has been read, it becomes a dot. Tap for the words. */
.off { border: 0; background: transparent; cursor: pointer; padding: 0 6px; min-height: 44px; }

/* A grid handed over from Gridnorth: one tap to take it, never applied on its
   own. Transcribing a grid under pressure is how the wrong one gets sent. */
.offer {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px;
  margin-top: 6px; padding: 6px 10px; cursor: pointer; text-align: left;
  background: transparent; color: var(--fg);
  border: 1px dashed var(--accent); border-radius: var(--radius);
}
:root[data-theme="red"] .offer { border-color: var(--fg-dim); }
.offer-k {
  font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); white-space: nowrap;
}
:root[data-theme="red"] .offer-k { color: var(--fg-dim); }
.offer-v { font-family: var(--mono); font-size: var(--fs-sm); font-weight: 700; }

/* Export preview: a look at what leaves, before it leaves. */
.export-preview {
  max-height: 34vh; overflow: auto; margin: 10px 0 0; padding: 10px;
  background: #000; border: 1px solid var(--line-hi); border-radius: var(--radius);
  font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
#dl-elapsed { margin-left: auto; color: var(--fg-dim); }

/* -------------------------------------------------- unit planning figures */
.uf { margin-bottom: 2px; }
.uf-veh { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.basis {
  display: inline-block; font-family: var(--mono); font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--fg-dim);
}
.uf-veh .basis { display: block; margin-top: 4px; font-size: var(--fs-xs);
  letter-spacing: .04em; text-transform: none; line-height: 1.4; }
.basis-unit { color: var(--ok); }
.basis-uncertain, .basis-none { color: var(--warn); }
:root[data-theme="red"] .basis-unit,
:root[data-theme="red"] .basis-uncertain,
:root[data-theme="red"] .basis-none { color: var(--fg); }

/* A caveat you can act on rather than only read. */
.note .linkish {
  display: inline; margin-left: 4px; padding: 0; min-height: 0;
  background: none; border: 0; cursor: pointer; color: var(--accent);
  font: inherit; text-decoration: underline; text-underline-offset: 2px;
}
:root[data-theme="red"] .note .linkish { color: var(--fg); }

/* The sixteen steps fall into four bands. Without them the list reads as a
   checklist worked top to bottom, which is the one thing it is not. */
.band {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 18px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line-hi);
  font-family: var(--mono); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--accent);
}
.band span { font-weight: 400; letter-spacing: .08em; color: var(--fg-dim); }
:root[data-theme="red"] .band { color: var(--fg); }

/* ------------------------------------------------------- settings & reset */
#open-settings svg { width: 19px; height: 19px; }
.seg-wide { display: grid; grid-template-columns: 1fr 1fr; margin: 6px 0; }
.seg-wide button { min-height: 48px; font-size: var(--fs-sm); letter-spacing: .06em; }

/* Destructive actions look destructive, in both themes. */
.btn-danger { border-color: var(--crit); color: var(--crit); }
.btn-danger:active { background: var(--crit); color: var(--bg); }
:root[data-theme="red"] .btn-danger { border-color: var(--fg); color: var(--fg); }
.note-danger { border-left-color: var(--crit); background: rgba(255,77,77,.06);
  color: var(--fg); font-weight: 700; }
:root[data-theme="red"] .note-danger { border-left-color: var(--fg); background: transparent; }

/* ------------------------------------------------------------ step detail
   Purpose, procedure and the named failure. Body copy, not a callout: this is
   the content of the step, not commentary beside it. */
.detail { margin-bottom: 12px; }
.detail-p { margin: 0 0 8px; font-size: var(--fs-body); line-height: 1.5; }
.detail-k {
  font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .1em;
  text-transform: uppercase; color: var(--fg-dim);
}
.detail-l { margin: 0 0 8px; padding-left: 18px; font-size: var(--fs-sm); line-height: 1.55; }
.detail-l li { margin: 5px 0; }
.detail-f {
  margin: 0; padding: 8px 10px; font-size: var(--fs-sm); line-height: 1.5;
  border-left: 2px solid var(--warn); background: rgba(255,209,102,.05);
}
:root[data-theme="red"] .detail-f { border-left-color: var(--fg-dim); background: transparent; }

/* Step body order: where you are, what the step is, the tool, then the source. */
.step-phase { margin-bottom: 8px; }
.step-tool { margin: 0 0 8px; font-size: var(--fs-sm); color: var(--fg-dim); }
.acc-b > .src { margin-bottom: 10px; }
