/* SAT GLOBE — operator theme.
 * Loaded after the inline <style> in index.html; equal-specificity rules here win.
 *
 * Colour: near-black olive panels, OD hairlines, sand text, amber = live/active.
 *   On --panel: text 12.7:1, dim 7.4:1, mute 5.2:1, hi 8.6:1, hi-ink on hi 9.1:1.
 *   MIL-STD-2525 affiliation colours (--fr/--ho/--ne/--uk) are for marks only.
 * Type: two families.
 *   --font  Barlow Condensed 500/600 — labels, buttons, headings, layer names.
 *   --mono  IBM Plex Mono 400        — every number and data string (tabular, slashed zero).
 *   Scale: --fs-1 11px (uppercase micro labels), --fs-2 13px (names, buttons, data),
 *          --fs-3 15px (primary readouts: MGRS, DTG). Nothing smaller than 11px.
 */
:root {
  /* colour */
  --bg: #0b0d09;
  --panel: #12150f;
  --panel-2: #181c14;
  --hover: #1d2318;
  --on: #0b0d09;
  --line: #262e1f;
  --line-hi: #3b4a2f;
  --text: #dcd6c3;
  --dim: #aaa48c;
  --mute: #8c8873;
  --hi: #e3a72f;
  --hi-dim: #8a6516;
  --hi-ink: #0b0d09;
  --track: #222a1b;
  --track-edge: #4a5638;
  --cyan: #80e0ff;
  --ok: #7cc35a;
  --warn: #e3a72f;
  --bad: #ef5350;
  --fr: #80e0ff;  --fr-d: #00a8dc;
  --ho: #ff3031;
  --ne: #aaffaa;  --ne-d: #00e200;
  --uk: #ffff80;
  /* type */
  --font: "Barlow Condensed", system-ui, sans-serif;
  --display: var(--font);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --fs-1: 11px;
  --fs-2: 13px;
  --fs-3: 15px;
  --fw-1: 500;
  --fw-2: 600;
  --track-1: .06em;
  /* motion, layout */
  --ease: 110ms cubic-bezier(.2, 0, 0, 1);
  --attrib-h: 0px; /* attribution lives in the map's (i) control */
  color-scheme: dark;
}

/* ———————————————————————— base ———————————————————————— */
body { background: var(--bg); color: var(--text); font: var(--fw-1) var(--fs-2) var(--font); }
#stars { background: var(--bg); }
#loader { background: var(--bg); color: var(--dim); font: var(--fw-2) var(--fs-2) var(--font); letter-spacing: var(--track-1); text-transform: uppercase; }
.data, #status .val, #status .clock, .lyr-res, .lyr-badge, .lyr-meta, .lyr-val,
#feat-list .meas, .op-cursor .op-val, .orbit-label, .maplibregl-ctrl-scale, #msg, .op-help dt {
  font-family: var(--mono);
  font-weight: 400;
  font-variant-numeric: tabular-nums slashed-zero;
  letter-spacing: 0;
}
:where(button, [role="switch"], input, summary, a, [tabindex]):focus-visible {
  outline: 2px solid var(--hi);
  outline-offset: 1px;
}

/* ———————————————————————— status strip ———————————————————————— */
#status, #dock, #zoomctl, #draw-tray, #sheet, #sheet-head { background: var(--panel); border-color: var(--line); }
#status { border-bottom-color: var(--line-hi); }
#tool-label, #attrib { display: none; }
#status .coords { gap: 0 14px; }
#status .read { gap: 5px; align-items: baseline; }
#status .lab {
  font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase; color: var(--mute);
}
#status .val { font-size: var(--fs-2); color: var(--text); }
#status .val.hi { color: var(--hi); font-size: var(--fs-3); }
#status .clock { font-size: var(--fs-3); color: var(--text); min-width: 0; gap: 1ch; }
#status .clock .dtg-d { color: var(--dim); }
#status .op-copy { cursor: copy; padding: 1px 3px; margin: -1px -3px; border-radius: 2px; }
#status .op-copy:hover { background: var(--hover); }
#status .btns { gap: 2px; }
#status button {
  font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase;
  color: var(--dim); background: transparent;
  height: 26px; min-width: 26px; padding: 0 7px;
  border: 1px solid transparent; border-radius: 2px;
}
#status button.ico { width: 30px; padding: 0; }
#status button.ico svg { width: 16px; height: 16px; display: block; }
#status button:hover { background: var(--hover); color: var(--text); }
#status button.on,
#status button[aria-pressed="true"] { color: var(--hi); background: var(--on); box-shadow: inset 0 0 0 1px var(--hi); }
#status #btn-fmt { color: var(--hi); box-shadow: inset 0 0 0 1px var(--line-hi); background: transparent; }
#status #btn-help { font-family: var(--mono); font-size: var(--fs-2); letter-spacing: 0; }
@media (pointer: coarse) { #status #btn-help { display: none; } }

/* MGRS readout replaces lat/lon; DMS / DD show both halves. */
body[data-fmt="mgrs"] #status .read.ll { display: none; }
body:not([data-fmt="mgrs"]) #status .read.grid { display: none; }

/* ———————————————————————— dock, zoom, tray, toasts ———————————————————————— */
#dock button {
  font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase;
  color: var(--dim); border-right-color: var(--line);
}
#dock button:hover { color: var(--text); background: var(--hover); }
#dock button.active, #dock button.active:hover { color: var(--hi); background: var(--on); }
#dock button.active::before { background: var(--hi); }
#zoomctl button { font: var(--fw-1) var(--fs-3) var(--font); color: var(--dim); }
#zoomctl button:hover { color: var(--text); background: var(--hover); }
#zoomctl button + button { border-top-color: var(--line); }
#draw-tray button { color: var(--dim); border-radius: 2px; }
#draw-tray button:hover { background: var(--hover); color: var(--text); }
#draw-tray button.active { background: var(--on); color: var(--hi); box-shadow: inset 0 0 0 1px var(--hi); }
#draw-tray #btn-wipe { margin-top: 8px; order: 100; } /* last: the Dot select is order 98 */
#draw-tray #btn-wipe[aria-pressed="true"] { background: var(--on); color: var(--hi); box-shadow: inset 0 0 0 1px var(--hi); }
#draw-tray #btn-wipe.warn {
  color: var(--bad);
  box-shadow: inset 0 0 0 1px var(--bad);
  animation: wipe-pulse 0.9s ease-in-out infinite;
}
@keyframes wipe-pulse { 50% { background: rgba(239, 83, 80, 0.18); } }
#reticle::before, #reticle::after { background: var(--hi); }
#reticle::before { box-shadow: 0 14px 0 var(--hi); }
#reticle::after { box-shadow: 14px 0 0 var(--hi); }
#msg { font-size: var(--fs-1); color: var(--text); text-shadow: 0 0 2px var(--bg), 0 0 4px var(--bg); }

/* ———————————————————————— sheet chrome ———————————————————————— */
#sheet-head strong {
  font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase; color: var(--dim);
}
#sheet-head > .sheet-x { color: var(--dim); font: var(--fw-1) var(--fs-3) var(--font); }
#sheet-head > .sheet-x:hover { color: var(--text); background: var(--hover); }
#sheet-actions { border-top-color: var(--line); }
#sheet-actions[hidden] { display: none !important; }
#sheet-actions button {
  font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase;
  color: var(--dim); border-radius: 2px;
}
#sheet-actions button:hover { background: var(--hover); color: var(--text); }
#sheet-actions button.primary { color: var(--hi); }
.empty, #feat-list.empty { color: var(--mute); font: var(--fw-1) var(--fs-1) var(--font); letter-spacing: var(--track-1); }

/* ———————————————————————— layers: presets ———————————————————————— */
.lyr-seg {
  position: sticky; top: 0; z-index: 2;
  display: flex; padding: 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.lyr-seg-btn {
  flex: 1; min-width: 0; height: 28px;
  font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase;
  color: var(--dim); background: var(--panel-2);
  border: 1px solid var(--line-hi); border-left-width: 0; border-radius: 0; cursor: pointer;
  transition: background-color var(--ease), color var(--ease);
}
.lyr-seg-btn:first-child { border-left-width: 1px; border-radius: 2px 0 0 2px; }
.lyr-seg-btn:last-child { border-radius: 0 2px 2px 0; }
.lyr-seg-btn:hover { color: var(--text); background: var(--hover); }
.lyr-seg-btn[aria-pressed="true"] { background: var(--hi); border-color: var(--hi); color: var(--hi-ink); }
.lyr-seg-btn:focus-visible { outline-offset: -2px; position: relative; z-index: 1; }

/* One slider for the whole stack (no per-layer opacity sliders). */
.lyr-oprow {
  position: sticky; top: 44px; z-index: 2;
  display: grid;
  grid-template-columns: 6.5ch minmax(0, 1fr) 4.5ch;
  align-items: center; column-gap: 8px;
  padding: 2px 12px 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.lyr-oplabel {
  font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase; color: var(--mute);
}
.lyr-oprow .lyr-range { grid-area: auto; }
.lyr-oprow .lyr-val { grid-area: auto; }

/* ———————————————————————— layers: sections + rows ———————————————————————— */
.lyr-sec[hidden] { display: none; }
.lyr-sec-h {
  padding: 12px 12px 4px;
  font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase; color: var(--mute);
}
.lyr-row {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto 28px 28px;
  grid-template-areas: "sw name badge res solo caret" ". more more more more more";
  align-items: center;
  column-gap: 6px;
  min-height: 36px;
  padding: 0 4px 0 0;
}
.lyr-row::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 2px;
  background: transparent; transition: background-color var(--ease);
}
.lyr-row[data-on="true"]::before { background: var(--hi); }
.lyr-row:hover { background: var(--hover); }

.lyr-sw {
  grid-area: sw; align-self: stretch;
  display: grid; place-items: center;
  min-height: 36px; padding: 0; background: transparent; border: 0; cursor: pointer;
}
.lyr-sw-track {
  position: relative; display: block; width: 30px; height: 16px;
  background: var(--track); border: 1px solid var(--track-edge); border-radius: 2px;
  transition: background-color var(--ease), border-color var(--ease);
}
.lyr-sw-knob {
  position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 1px;
  background: var(--mute); transition: transform var(--ease), background-color var(--ease);
}
.lyr-sw[aria-checked="true"] .lyr-sw-track { background: var(--hi); border-color: var(--hi); }
.lyr-sw[aria-checked="true"] .lyr-sw-knob { transform: translateX(14px); background: var(--hi-ink); }
.lyr-sw:hover .lyr-sw-track { border-color: var(--dim); }
.lyr-sw[aria-checked="true"]:hover .lyr-sw-track { border-color: var(--hi); }
.lyr-sw:focus-visible { outline: 0; }
.lyr-sw:focus-visible .lyr-sw-track { outline: 2px solid var(--hi); outline-offset: 2px; }

.lyr-name {
  all: unset; grid-area: name; min-width: 0; cursor: pointer;
  font: var(--fw-1) var(--fs-2) var(--font); line-height: 16px;
  color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lyr-row[data-on="true"] .lyr-name { color: var(--text); }
button.lyr-name:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line-hi); }
.lyr-name:focus-visible { outline: 2px solid var(--hi); outline-offset: 1px; }
.lyr-badge {
  grid-area: badge;
  font-size: var(--fs-1); line-height: 14px;
  padding: 0 4px; border: 1px solid var(--warn); border-radius: 2px; color: var(--warn);
}
.lyr-badge[hidden] { display: none; }
.lyr-badge[data-kind="mute"] { border-color: var(--mute); color: var(--dim); }
.lyr-res { grid-area: res; font-size: var(--fs-1); color: var(--mute); text-align: right; white-space: nowrap; }
.lyr-row[data-on="true"] .lyr-res { color: var(--dim); }
/* Cities row: the res cell holds the "Aa" names filter. */
.lyr-lbl {
  grid-area: res; width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center;
  font: var(--fw-2) var(--fs-1) var(--font);
  background: transparent; color: var(--mute);
  border: 1px solid transparent; border-radius: 2px; cursor: pointer;
}
.lyr-lbl:hover { color: var(--text); background: var(--panel-2); }
.lyr-lbl[aria-pressed="true"] { color: var(--hi-ink); background: var(--hi); border-color: var(--hi); }
.lyr-lbl:focus-visible { outline: 2px solid var(--hi); outline-offset: 1px; }

.lyr-solo, .lyr-caret {
  width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center;
  background: transparent; color: var(--mute);
  border: 1px solid transparent; border-radius: 2px; cursor: pointer;
}
.lyr-solo { grid-area: solo; opacity: 0; pointer-events: none; transition: opacity var(--ease); }
.lyr-caret { grid-area: caret; }
.lyr-solo svg, .lyr-caret svg { width: 14px; height: 14px; display: block; }
.lyr-caret svg { transition: transform var(--ease); }
.lyr-caret[aria-expanded="true"] svg { transform: rotate(90deg); }
.lyr-solo:hover, .lyr-caret:hover { color: var(--text); background: var(--panel-2); }
.lyr-row[data-open="true"] .lyr-solo,
.lyr-solo[aria-pressed="true"],
.lyr-solo:focus-visible { opacity: 1; pointer-events: auto; }
@media (hover: hover) {
  .lyr-row:hover .lyr-solo, .lyr-row:focus-within .lyr-solo { opacity: 1; pointer-events: auto; }
}
.lyr-solo[aria-pressed="true"] { color: var(--hi-ink); background: var(--hi); border-color: var(--hi); }

/* Expanded row: the source line (opacity is the single stack slider above). */
.lyr-more {
  grid-area: more; display: none;
  padding: 0 4px 8px 0;
}
.lyr-row[data-open="true"] .lyr-more { display: block; }
.lyr-meta { grid-area: meta; font-size: var(--fs-1); color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lyr-val { grid-area: val; font-size: var(--fs-1); color: var(--dim); text-align: right; }
.lyr-val[hidden] { visibility: hidden; display: block; }
.lyr-range {
  --v: 100%;
  grid-area: op; width: 100%; height: 24px; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
.lyr-range:disabled { cursor: default; opacity: .45; }
.lyr-range:focus-visible { outline: 0; }
.lyr-range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 0;
  background: linear-gradient(to right, var(--hi) 0 var(--v), var(--track) var(--v) 100%);
}
.lyr-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 10px; height: 16px; margin-top: -6px;
  background: var(--panel-2); border: 1px solid var(--text); border-radius: 1px;
}
.lyr-range::-moz-range-track { height: 4px; background: var(--track); border: 0; border-radius: 0; }
.lyr-range::-moz-range-progress { height: 4px; background: var(--hi); }
.lyr-range::-moz-range-thumb {
  width: 10px; height: 16px; box-sizing: border-box;
  background: var(--panel-2); border: 1px solid var(--text); border-radius: 1px;
}
.lyr-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--hi); }
.lyr-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px var(--hi); }
.lyr-range:active::-webkit-slider-thumb { background: var(--text); }

.lyr-extra { grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "sw name res"; }
.lyr-extra .lyr-name { cursor: default; }

/* Dev (Esri) packs: collapsed, flagged as not shipped. */
.lyr-dev > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  color: var(--bad);
}
.lyr-dev > summary::-webkit-details-marker { display: none; }
.lyr-dev > summary::before { content: "▸"; color: var(--mute); }
.lyr-dev[open] > summary::before { content: "▾"; }

/* ———————————————————————— drawings ———————————————————————— */
#feat-list .row { border-top-color: var(--line); min-height: 36px; }
#feat-list .name { font: var(--fw-1) var(--fs-2) var(--font); color: var(--text); }
#feat-list .meas { font-size: var(--fs-1); color: var(--dim); }
#feat-list .del { color: var(--mute); font: var(--fw-1) var(--fs-3) var(--font); }
#feat-list .del:hover { color: var(--bad); background: var(--hover); }
#feat-list input[type="checkbox"] { accent-color: var(--hi); }
#feat-list .aff {
  flex: none; width: 26px; height: 20px; padding: 0;
  font: 400 var(--fs-1) var(--mono);
  background: transparent; border: 1px solid currentColor; border-radius: 2px; cursor: pointer;
}
#feat-list .aff[data-aff="f"] { color: var(--fr); }
#feat-list .aff[data-aff="h"] { color: var(--ho); }
#feat-list .aff[data-aff="n"] { color: var(--ne); }
#feat-list .aff[data-aff="u"] { color: var(--uk); }
#feat-list .aff[data-aff="cm"] { color: var(--hi); cursor: default; opacity: .8; }

/* ———————————————————————— map HUD ———————————————————————— */
.maplibregl-ctrl-bottom-left {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 0 0 10px 10px; pointer-events: none;
}
.maplibregl-ctrl-bottom-left > .maplibregl-ctrl { float: none; clear: none; margin: 0; pointer-events: auto; }
.maplibregl-ctrl-bottom-left .maplibregl-ctrl.op-compass,
.maplibregl-ctrl-bottom-left .maplibregl-ctrl.op-cursor { display: flex !important; }
.maplibregl-ctrl-bottom-left .maplibregl-ctrl.op-cursor[hidden] { display: none !important; }
.maplibregl-ctrl-bottom-left .maplibregl-ctrl.maplibregl-ctrl-scale { display: block !important; }
.maplibregl-ctrl-bottom-right .maplibregl-ctrl.maplibregl-ctrl-attrib { display: block !important; }

.op-compass {
  width: 32px; height: 32px; padding: 0; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line-hi); border-radius: 2px; cursor: pointer;
}
.op-compass svg { width: 18px; height: 18px; transition: transform var(--ease); }
.op-compass .op-n { fill: var(--bad); }
.op-compass .op-s { fill: var(--dim); }
.op-compass span { display: none; }
.op-compass:hover { border-color: var(--dim); }
.maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale {
  height: 20px; line-height: 18px; box-sizing: border-box; padding: 0 6px;
  font-size: var(--fs-1); color: var(--text);
  background: var(--panel); border: 1px solid var(--text); border-top: 0;
}
.op-cursor {
  height: 24px; align-items: center; gap: 6px; padding: 0 8px;
  background: var(--panel); border: 1px solid var(--line-hi); border-radius: 2px; white-space: nowrap;
}
.op-cursor .op-lab { font: var(--fw-2) var(--fs-1) var(--font); letter-spacing: var(--track-1); color: var(--mute); }
.op-cursor .op-val { font-size: var(--fs-2); color: var(--text); }

/* Attribution: MapLibre compact (i), themed. CC BY needs it one tap away. */
.maplibregl-ctrl-bottom-right { padding: 0 10px 10px 0; }
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib {
  margin: 0; background: var(--panel); border: 1px solid var(--line-hi); border-radius: 2px;
  color: var(--dim); font: var(--fw-1) var(--fs-1) var(--font); letter-spacing: .02em;
}
.maplibregl-ctrl-attrib a { color: var(--text); }
.maplibregl-ctrl-attrib.maplibregl-compact { min-height: 24px; }
.maplibregl-ctrl-attrib .maplibregl-ctrl-attrib-button { filter: invert(.86); background-color: transparent; }
.maplibregl-ctrl-attrib.maplibregl-compact-show { padding: 3px 28px 3px 8px; }

/* ———————————————————————— orbit labels ———————————————————————— */
.orbit-label {
  font-size: var(--fs-1); color: var(--text);
  background: rgba(11, 13, 9, .72); padding: 0 4px; border-left: 2px solid var(--hi);
  white-space: nowrap; cursor: default;
}
/* Flipped left of its dot near the right edge: the accent bar stays on the dot side. */
.orbit-label.flip { border-left: 0; border-right: 2px solid var(--hi); }
/* Behind the globe: gone, not just transparent (keeps it out of the a11y tree). */
.orbit-label.maplibregl-marker-covered { visibility: hidden; }

/* ———————————————————————— shortcut card ———————————————————————— */
.op-help {
  position: absolute; z-index: 50;
  top: calc(var(--bar-h) + var(--safe-t) + 12px); left: 50%; transform: translateX(-50%);
  width: min(600px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line-hi); border-radius: 2px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
}
.op-help[hidden] { display: none; }
.op-help-h { display: flex; align-items: center; height: 36px; padding: 0 4px 0 14px; border-bottom: 1px solid var(--line); }
.op-help-h strong {
  flex: 1; font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase; color: var(--dim);
}
.op-help-x {
  width: 32px; height: 32px; background: none; border: 0; border-radius: 2px; cursor: pointer;
  color: var(--dim); font: var(--fw-1) var(--fs-3) var(--font);
}
.op-help-x:hover { color: var(--text); background: var(--hover); }
.op-help-b { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; padding: 8px 14px 14px; }
.op-help h3 {
  margin: 8px 0 6px; font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase; color: var(--mute);
}
.op-help dl { display: grid; grid-template-columns: 9ch 1fr; gap: 5px 10px; align-items: center; }
.op-help dt {
  justify-self: start; font-size: var(--fs-1); color: var(--text);
  padding: 0 5px; border: 1px solid var(--line-hi); border-bottom-width: 2px; border-radius: 2px; background: var(--panel-2);
}
.op-help dd { font: var(--fw-1) var(--fs-2) var(--font); color: var(--dim); }

/* ———————————————————————— night / NVG (nvg.mjs: body.nvg, body.nvg.nvg-dim) ———————————————————————— */
/* Red on black, no white anywhere. Only the map canvas is filtered, so controls and
 * labels keep their (red) tokens and stay legible.
 *   NVG      brightest chrome token #c8452f, map at 16 %
 *   NVG-DIM  brightest chrome token #8a2a18, map at 7 % */
body.nvg {
  --bg: #000; --panel: #040100; --panel-2: #080201; --hover: #120403; --on: #000;
  --line: #1a0704; --line-hi: #3a1209;
  --text: #b8402b; --dim: #8a3020; --mute: #66241a;
  --hi: #c8452f; --hi-dim: #5e1c11; --hi-ink: #000;
  --track: #140503; --track-edge: #3a120a;
  --bad: #c8452f; --ok: #9a3624; --warn: #c8452f;
  --fr: #b8402b; --ho: #c8452f; --ne: #8a3020; --uk: #b8402b; --cyan: #8a3020;
}
body.nvg.nvg-dim {
  --bg: #000; --panel: #000; --panel-2: #050100; --hover: #0c0302;
  --line: #120402; --line-hi: #2a0c06;
  --text: #7a2416; --dim: #5e1c11; --mute: #47150d;
  --hi: #8a2a18; --hi-dim: #3d1209; --track: #0c0302; --track-edge: #2a0c06;
  --bad: #8a2a18; --ok: #6a2012; --warn: #8a2a18;
  --fr: #7a2416; --ho: #8a2a18; --ne: #5e1c11; --uk: #7a2416; --cyan: #5e1c11;
}
body.nvg #stars { display: none; }
body.nvg #map { filter: none; }
body.nvg #map .maplibregl-canvas { filter: grayscale(1) brightness(.16) sepia(1) saturate(3) hue-rotate(-38deg); }
body.nvg.nvg-dim #map .maplibregl-canvas { filter: grayscale(1) brightness(.07) sepia(1) saturate(3) hue-rotate(-38deg); }
body.nvg .op-compass .op-s { fill: var(--mute); }
body.nvg #feat-list .aff { color: var(--text); }
body.nvg .orbit-label, body.nvg .grid-label { background: rgba(0, 0, 0, .85); }
body.nvg .maplibregl-ctrl-attrib .maplibregl-ctrl-attrib-button { filter: invert(.4) sepia(1) saturate(5) hue-rotate(-40deg) brightness(.6); }
body.nvg .gps-mk { filter: grayscale(1) sepia(1) saturate(4) hue-rotate(-38deg) brightness(.7); }
body.nvg.nvg-dim .gps-mk { filter: grayscale(1) sepia(1) saturate(4) hue-rotate(-38deg) brightness(.45); }
body.nvg .info-cls, body.nvg .cls-banner { filter: brightness(.55) saturate(.8); }
body.nvg.nvg-dim .info-cls, body.nvg.nvg-dim .cls-banner { filter: brightness(.38) saturate(.7); }

/* ———————————————————————— classification banner (banner.mjs) ———————————————————————— */
:root { --banner-h: 0px; }
body.has-banner {
  --banner-h: 18px;
  --safe-t: calc(env(safe-area-inset-top, 0px) + var(--banner-h));
  --safe-b: calc(env(safe-area-inset-bottom, 0px) + var(--banner-h));
}
.cls-banner {
  position: fixed; left: 0; right: 0; z-index: 60; height: var(--banner-h);
  display: flex; align-items: center; justify-content: center;
  background: var(--cls-bg, #007a33); color: var(--cls-fg, #fff);
  font: var(--fw-2) var(--fs-1) var(--font); letter-spacing: .14em; text-transform: uppercase;
  pointer-events: none; user-select: none;
}
.cls-top { top: env(safe-area-inset-top, 0px); }
.cls-bottom { bottom: env(safe-area-inset-bottom, 0px); }
@media (min-width: 1100px) {
  /* Desktop chrome that uses literal bottom offsets instead of --safe-b. */
  body.has-banner #zoomctl, body.has-banner #sheet { bottom: var(--banner-h); }
  body.has-banner #draw-tray { bottom: calc(68px + var(--banner-h)); }
}

/* ———————————————————————— sizes ———————————————————————— */
.sheet-grip { display: none; }

/* Desktop: docked layer panel wide enough for one-line rows. */
@media (min-width: 1100px) {
  :root { --panel-w: 288px; }
}

/* Phone: bottom sheet with a grip; status values step down one size to fit 390px. */
@media (max-width: 640px) {
  #status .val.hi, #status .clock { font-size: var(--fs-2); }
  #status .clock .dtg-d { display: none; }
  #status .btns button { height: auto; }
  #status button.ico { width: auto; }
  #sheet { max-height: 60dvh; border-top: 1px solid var(--line-hi); transition: transform var(--ease); will-change: transform; }
  #sheet.dragging { transition: none; }
  .sheet-grip { display: block; flex: none; height: 20px; cursor: grab; touch-action: none; background: var(--panel); }
  .sheet-grip::before {
    content: ""; display: block; width: 40px; height: 4px; margin: 8px auto 0;
    background: var(--line-hi); border-radius: 2px;
  }
  #sheet-head { height: 36px; }
  .lyr-seg { padding: 6px 8px; }
}

/* Touch: 44 px targets. */
@media (pointer: coarse), (max-width: 640px) {
  .lyr-seg-btn { height: 36px; }
  .lyr-row { min-height: 48px; grid-template-columns: 48px minmax(0, 1fr) auto auto 40px 40px; }
  .lyr-extra { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .lyr-sw { min-height: 48px; }
  .lyr-solo, .lyr-caret { width: 40px; height: 44px; }
  .lyr-range { height: 40px; }
  #draw-tray button { width: 44px; height: 44px; }
}

/* Phone / touch: the zoom pair sits in a 2×44 px row at the dock's right edge. */
@media (max-width: 1099px) and (max-width: 640px), (max-width: 1099px) and (pointer: coarse) {
  #dock { padding-right: calc(89px + var(--safe-r)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* ———————————————————————— Settings panel (settings.mjs) ————————————————————————
 * DESIGN.md "Panels": section head 12/600 sentence case dim (16 above, 8 below); rows 32 (44 on
 * touch, --cx-row) with hairline separators; label left, control right. The segmented controls
 * and switches are the #sheet primitives in console.css. */
.set { padding: 0 0 16px; }
.set-grp { padding: 0 var(--cx-pad-panel, 12px); border-top: 1px solid var(--cx-line, rgba(255, 255, 255, .10)); }
.set-grp:first-child { border-top: 0; }
.set-h {
  margin: 16px 0 8px;
  font: 600 12px/1.2 var(--cx-font, "Public Sans", system-ui, sans-serif);
  letter-spacing: 0; text-transform: none; color: var(--cx-dim, #abb3bf);
}
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--cx-row, 32px);
}
.set-row + .set-row { border-top: 1px solid var(--cx-line, rgba(255, 255, 255, .10)); }
.set-lab {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 400 13px/1.35 var(--cx-font, "Public Sans", system-ui, sans-serif); color: var(--cx-ink, #f6f7f9);
}
.set-val {
  min-width: 0; overflow-wrap: anywhere; text-align: right;
  font: 400 12px/1.3 var(--cx-mono, "IBM Plex Mono", ui-monospace, monospace);
  font-variant-numeric: tabular-nums slashed-zero; color: var(--cx-dim, #abb3bf);
}
/* No hook on this device (e.g. no GPS): the label steps down to mute and the control fades. */
.set-row.off .set-lab { color: var(--cx-mute, #8f99a8); }
.set-row.off > :not(.set-lab) { opacity: .4; }
.set-row.off * { cursor: default; }
.lyr-seg.set-seg { position: static; flex: 0 1 auto; min-width: 0; padding: 0; border: 0; background: transparent; }
.set-seg .lyr-seg-btn:disabled { cursor: default; }
.set-acts { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px -8px 0; }
.set-btn {
  height: var(--cx-ctl, 28px); padding: 0 8px;
  font: 500 13px/1 var(--cx-font, "Public Sans", system-ui, sans-serif);
  letter-spacing: 0; text-transform: none;
  color: var(--cx-dim, #abb3bf); background: transparent; border: 0; border-radius: var(--cx-r, 2px); cursor: pointer;
}
.set-btn:hover { color: var(--cx-ink, #f6f7f9); background: var(--cx-hover, #2f343c); }
.set-btn-warn { color: var(--cx-bad, #e76a6e); }
.set-btn-warn:hover { color: var(--cx-bad, #e76a6e); }
.set-note { margin: 4px 0 0; font: 400 12px/1.35 var(--cx-font, "Public Sans", system-ui, sans-serif); color: var(--cx-dim, #abb3bf); }
.set-note[hidden] { display: none; }
/* Classification override: seven values, one full-width segmented row under its label. */
.set-row[data-key="cls"] { flex-wrap: wrap; row-gap: 4px; padding: 6px 0 8px; }
.set-row[data-key="cls"] .set-seg { width: 100%; }
.set-row[data-key="cls"] .set-seg .lyr-seg-btn { flex: 1 1 0; min-width: 0; padding: 0; }

/* ———————————————————————— Information panel (info.mjs) ————————————————————————
 * A status board: key left (sans, dim), value right (mono, ink). Every value cell can shrink
 * (minmax(0, 1fr)) and ends in an ellipsis; the long renderer string wraps in its own block. */
.info { padding: 0 0 16px; }
.info-sec { padding: 0 var(--cx-pad-panel, 12px) 8px; border-top: 1px solid var(--cx-line, rgba(255, 255, 255, .10)); }
.info-sec:first-child { border-top: 0; }
.info-h {
  margin: 16px 0 8px;
  font: 600 12px/1.2 var(--cx-font, "Public Sans", system-ui, sans-serif);
  letter-spacing: 0; text-transform: none; color: var(--cx-dim, #abb3bf);
}
.info-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 12px;
  min-height: 28px;
}
.info-k {
  white-space: nowrap;
  font: 400 13px/1.35 var(--cx-font, "Public Sans", system-ui, sans-serif); color: var(--cx-dim, #abb3bf);
}
.info-v {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: right;
  font: 400 13px/1.3 var(--cx-mono, "IBM Plex Mono", ui-monospace, monospace);
  font-variant-numeric: tabular-nums slashed-zero; color: var(--cx-ink, #f6f7f9);
}
.info-v b { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.info-v.info-big { color: var(--cx-ink, #f6f7f9); }
.info-m { flex: none; font-size: 12px; color: var(--cx-dim, #abb3bf); }
.info-wrap {
  margin: 0; overflow-wrap: anywhere;
  font: 400 12px/1.45 var(--cx-mono, "IBM Plex Mono", ui-monospace, monospace); color: var(--cx-dim, #abb3bf);
}
.info-dot { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--cx-mute, #8f99a8); }
.info-dot[data-s="ok"] { background: var(--cx-ok, #32a467); }
.info-dot[data-s="warn"], .info-dot[data-s="wait"] { background: var(--cx-warn, #ec9a3c); }
.info-dot[data-s="bad"] { background: var(--cx-bad, #e76a6e); }
.info-list { display: grid; }
.info-pack, .info-now {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: 12px;
  min-height: 28px; padding: 5px 0;
}
.info-pack + .info-pack { border-top: 1px solid var(--cx-line, rgba(255, 255, 255, .10)); }
.info-pk {
  min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font: 400 13px/1.35 var(--cx-font, "Public Sans", system-ui, sans-serif); color: var(--cx-ink, #f6f7f9);
}
.info-pm {
  max-width: 16ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: right;
  font: 400 12px/1.3 var(--cx-mono, "IBM Plex Mono", ui-monospace, monospace);
  font-variant-numeric: tabular-nums slashed-zero; color: var(--cx-dim, #abb3bf);
}
.info-now { border-bottom: 1px solid var(--cx-line-hi, rgba(255, 255, 255, .22)); }
.info-now .info-pm { color: var(--cx-ink, #f6f7f9); }
.info-attrib { margin: 6px 0 0; font: 400 12px/1.45 var(--cx-font, "Public Sans", system-ui, sans-serif); color: var(--cx-mute, #8f99a8); }
.info-attrib[hidden] { display: none; }
/* Classification is a marking (uppercase by rule) in the box's own colours; unknown = a dash. */
.info-cls {
  display: block; padding: 4px 8px; border-radius: var(--cx-r, 2px); text-align: center;
  overflow-wrap: anywhere;
  font: 600 11px/1.3 var(--cx-font, "Public Sans", system-ui, sans-serif); letter-spacing: .06em; text-transform: uppercase;
}
.info-cls[data-known="false"] { padding: 0; text-align: left; color: var(--cx-mute, #8f99a8); }
.info-st { margin: 0 0 4px; font: 600 13px/1.3 var(--cx-font, "Public Sans", system-ui, sans-serif); color: var(--cx-ink, #f6f7f9); }
.info-sel .info-v { white-space: normal; overflow-wrap: anywhere; }
.info-empty { margin: 0; padding: 4px 0; font: 400 13px/1.35 var(--cx-font, "Public Sans", system-ui, sans-serif); color: var(--cx-mute, #8f99a8); }
body.nvg .info-cls { filter: brightness(.55); }

/* ———————————————————————— Imagery: AUTO row + Sources (catalog.mjs) ———————————————————————— */
.lyr-auto { grid-template-columns: 40px minmax(0, 1fr) auto auto 28px; grid-template-areas: "sw name badge res caret" "more more more more more"; }
/* DESIGN.md "Tags": neutral, 1px line-strong outline, caption type, dim text, never filled. */
.lyr-auto-tag, .info-now-tag {
  font: 600 11px/1 var(--cx-font, "Public Sans", system-ui, sans-serif); letter-spacing: .06em; text-transform: uppercase;
  color: var(--cx-dim, #abb3bf); background: transparent;
  box-shadow: inset 0 0 0 1px var(--cx-line-hi, rgba(255, 255, 255, .22));
  padding: 2px 4px; border-radius: var(--cx-r, 2px);
}
.lyr-auto-tag { grid-area: sw; justify-self: center; }
.lyr-auto .lyr-name { color: var(--text); cursor: default; }
.lyr-auto .lyr-res { color: var(--dim); }
.lyr-more.lyr-srcs { display: none; padding: 0 0 6px; }
.lyr-auto[data-open="true"] .lyr-more.lyr-srcs { display: block; }
.lyr-srcs-h {
  padding: 4px 4px 2px 46px; font: var(--fw-2) var(--fs-1) var(--font);
  letter-spacing: var(--track-1); text-transform: uppercase; color: var(--mute);
}
.lyr-src {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center;
  column-gap: 6px; min-height: 34px; padding-right: 8px;
}
.lyr-src > * { grid-area: auto; grid-row: 1; }
.lyr-src > .lyr-sw { grid-column: 1; min-height: 34px; }
.lyr-src > .lyr-name { grid-column: 2; }
.lyr-src > .lyr-src-m { grid-column: 3; text-align: right; }
.lyr-src[data-on="true"] .lyr-name { color: var(--text); }
.lyr-src-m {
  font-family: var(--mono); font-size: var(--fs-1); color: var(--dim);
  font-variant-numeric: tabular-nums slashed-zero; white-space: nowrap;
}
.lyr-src[data-on="false"] .lyr-src-m { color: var(--mute); text-decoration: line-through; }
button.lyr-badge { background: transparent; cursor: pointer; }
button.lyr-badge:disabled { cursor: default; }
button.lyr-badge[aria-pressed="true"] { background: var(--warn); color: var(--hi-ink); }
@media (pointer: coarse), (max-width: 640px) {
  .lyr-auto { grid-template-columns: 48px minmax(0, 1fr) auto auto 40px; }
  .lyr-src { grid-template-columns: 48px minmax(0, 1fr) auto; min-height: 44px; }
  .lyr-srcs-h { padding-left: 54px; }
}

/* Status line sits above the bottom-left map HUD (compass, scale, cursor), not on it. */
#msg { bottom: calc(var(--dock-h) + var(--safe-b) + 48px); }
@media (min-width: 1100px) { #msg { bottom: calc(var(--safe-b) + 52px); } }
.info-now-tag { display: inline-block; margin-right: 8px; vertical-align: 1px; }
