/* Clear Horizons — warm "Field Notebook" light theme + a first-class dark
   "Night Mode" for use at the eyepiece. Fully variable-driven so the theme is a
   token swap on [data-theme="dark"]. Mirrors the sibling apps' conventions:
   :root tokens (never hex-in-place), IBM Plex with mono for every number. */
:root {
  --bg: #ebe1cf; --bg2: #f2ead9; --card: #faf4e8; --card2: #f2ead9;
  --ink: #2c2318; --dim: #6b5d47; --line: #e2d6bf; --track: #e6dcc7;
  --accent: #b07bd6; --accent-ink: #5a3580; --accent-wash: #efe4f6; --accent2: #7b57c4;
  --slate: #2f6188; --slate-wash: #dbe7f0; --warn: #7a5710; --live: #c0563a;
  --danger: #9c3320; --danger-dim: #7a2e2e;
  --park: #2b7449;  /* "fits" tier + clear-flag green — contrast-safe text (was an undefined var) */
  /* Tab dock — its own neutral surface with light glyphs, so it can't be
     mistaken for the cards or the page in either theme. */
  --dock: #6a5f7e;
  --dock-line: #4c4360;
  --dock-shadow: 0 1px 2px rgba(30,20,40,.22), 0 8px 18px rgba(30,20,40,.18), 0 22px 44px rgba(30,20,40,.24);
  --dock-lip: inset 0 1px 0 rgba(255,255,255,.16);
  --tab-ink: #efe6f4;
  --tab-ink-active: #f0e6ff;
  /* Type superfamily — IBM Plex (serif = wordmark/titles, sans = chrome,
     mono = every number). */
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: 'IBM Plex Serif', Georgia, "Times New Roman", serif;
  --mono: 'IBM Plex Mono', ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 16px; --tab-h: 60px;
  --col-edge: max(10px, (100% - 760px) / 2 + 12px);
}

/* Night Mode — a deep, low-glare palette for the field (never green). */
[data-theme="dark"] {
  --bg: #12131c; --bg2: #1c1e2c; --card: #191b28; --card2: #23263a;
  --ink: #e9ecf7; --dim: #9aa0bd; --line: #2a2d40; --track: #23263a;
  --accent: #c39be8; --accent-ink: #e6d4f6; --accent-wash: #2a2140; --accent2: #b48ce0;
  --slate: #7fb0da; --slate-wash: #1e2c38; --warn: #e0a94e; --live: #e8795a;
  --danger: #e58b8b; --danger-dim: #7a2e2e;
  --dock: #35304a;
  --dock-line: #4a4468;
  --dock-shadow: 0 1px 2px rgba(0,0,0,.45), 0 8px 20px rgba(0,0,0,.5), 0 22px 46px rgba(0,0,0,.55);
  --dock-lip: inset 0 1px 0 rgba(255,255,255,.08);
  --tab-ink: #d7d2e8;
  --tab-ink-active: #c39be8;
  --park: #88dba7;
}

* { box-sizing: border-box; }
/* Honour reduced-motion (accessibility standing order): no slides/fades/nudges
   for anyone who's asked the OS to calm animations. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .btn:active, .toast-action:active, .about-btn:active, .theme-btn:active { transform: none; }
}
/* Windows High Contrast / forced-colors strips background-color and box-shadow,
   so focus rings built from box-shadow vanish and colour-only "selected"/"active"
   cues are lost. Restore a real outline on focus and on the selected states that
   don't already carry a text badge (accessibility standing order). */
@media (forced-colors: active) {
  .tab:focus-visible, .about-btn:focus-visible, .theme-btn:focus-visible,
  .ng-wrap:focus-visible { outline: 2px solid; outline-offset: 2px; }
  .chip.active { outline: 2px solid; }
  .tab.active { text-decoration: underline; text-underline-offset: 3px; }
}
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.45; }
/* The `hidden` attribute must win over component display rules (e.g. .btn sets
   its own display, which would otherwise override the UA [hidden] style). */
[hidden] { display: none !important; }
/* No element may push the page wider than the viewport — a single overflowing
   row makes mobile Safari load the whole app zoomed-in (reported on-device). */
html { overflow-x: hidden; }
/* Clear the floating dock: its height + 10px float + a little breathing room. */
body { padding-bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
/* padding-top clears the translucent iOS status bar (clock/battery) in the
   installed PWA — the content column, like the floating buttons, must sit
   below the safe-area inset or the h1 renders under the system clock. */
.view { max-width: 760px; margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 12px 24px; }

h1 { font-size: 22px; margin: 0; font-family: var(--serif); font-weight: 600; }
/* The view heading gets tabindex=-1 so navigation can move focus into the
   content for screen readers — but it's a landing target, not an interactive
   control, so it must not show a focus ring. */
[tabindex="-1"]:focus { outline: none; }
h2 { font-size: 16px; margin: 0 0 6px; }
h3 { font-size: 14px; margin: 14px 0 4px; }
a { color: var(--accent-ink); } /* accent-ink, not --accent: links must clear 4.5:1 on cards */
.dim { color: var(--dim); }
.small { font-size: 12px; }
.empty { color: var(--dim); text-align: center; padding: 40px 0; }

/* Numbers are IBM Plex Mono, tabular — wherever they land later. */
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* buttons */
.btn { background: var(--card2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer;
  text-decoration: none; display: inline-block; }
.btn.ghost { background: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #12131c; font-weight: 700; }
.btn:active { transform: translateY(1px); }

/* toast (undo notices etc.) */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 26px);
  transform: translate(-50%, 8px); max-width: 88vw; padding: 10px 16px; z-index: 20;
  background: var(--card2); color: var(--ink); border: 1px solid var(--accent2); border-radius: 999px;
  font-size: 13px; box-shadow: 0 8px 26px rgba(0, 0, 0, .45); opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.has-action { display: inline-flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; pointer-events: auto; }
.toast-action { flex: 0 0 auto; background: var(--accent); color: #12131c; border: 0; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 700; cursor: pointer; }
.toast-action:active { transform: translateY(1px); }

/* tab bar — a floating dock in the same card language as the content. */
.tabs { position: fixed; bottom: calc(10px + env(safe-area-inset-bottom)); left: 0; right: 0;
  margin-inline: auto; width: min(736px, calc(100% - 24px)); height: var(--tab-h);
  background: color-mix(in srgb, var(--dock) 97%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.04); backdrop-filter: blur(12px) saturate(1.04);
  border: 1px solid var(--dock-line); border-radius: var(--r); overflow: hidden;
  box-shadow: var(--dock-shadow), var(--dock-lip);
  /* One column per tab — track the TABS array in main.js (6 since Polar). */
  display: grid; grid-template-columns: repeat(6, 1fr); z-index: 10; }
.tab { background: none; border: 0; color: var(--tab-ink); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; cursor: pointer; font-size: 11px; }
.tab.active { color: var(--tab-ink-active); }
/* The dock clips overflow, so a default outline ring would be cut off — use an
   inset ring that stays inside the tab. */
.tab:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--tab-ink-active); border-radius: 10px; }
.tab-icon { display: flex; align-items: center; justify-content: center; line-height: 0; }

/* Floating corner buttons hug the content column on wide screens, fall back to
   the screen corner on narrow ones. */
.about-btn { position: fixed; top: calc(8px + env(safe-area-inset-top)); right: var(--col-edge); z-index: 8;
  width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card2); color: var(--dim); font-size: 15px; line-height: 1; cursor: pointer;
  display: grid; place-content: center; opacity: .55; transition: opacity .15s, color .15s, border-color .15s; }
.about-btn:hover, .about-btn:focus-visible { opacity: 1; color: var(--accent); border-color: var(--accent); outline: none; }
.about-btn:active { transform: translateY(1px); }

/* Night Mode toggle — floating moon/sun, just left of the About button. */
.theme-btn { position: fixed; top: calc(8px + env(safe-area-inset-top)); right: calc(var(--col-edge) + 38px); z-index: 8;
  width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card2); color: var(--dim); cursor: pointer;
  display: grid; place-content: center; opacity: .55; transition: opacity .15s, color .15s, border-color .15s; }
.theme-btn:hover, .theme-btn:focus-visible { opacity: 1; color: var(--accent); border-color: var(--accent); outline: none; }
.theme-btn:active { transform: translateY(1px); }
.theme-btn svg { display: block; }

/* about modal */
.about-dialog { position: fixed; inset: 0; margin: auto; width: min(92vw, 560px); max-height: 84vh;
  padding: 0; overflow: hidden; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.about-dialog::backdrop { background: rgba(10,8,16,.55); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.about-body { padding: 22px 22px 8px; overflow-y: auto; max-height: calc(84vh - 64px); }
.about-body h2 { font-family: var(--serif); font-size: 19px; }
.about-body p { max-width: 52ch; color: var(--ink); }
.about-credits { font-size: 12px; color: var(--dim); }
.about-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 16px;
  border-top: 1px solid var(--line); }

/* ── Targets view ────────────────────────────────────────────────────────── */
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.filters-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.inst-tag { font-family: var(--mono); font-size: 11px; color: var(--accent-ink);
  background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: 999px; padding: 3px 10px; }
.search { width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 10px 12px; font-size: 15px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card2); border: 1px solid var(--line); color: var(--dim);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #12131c; font-weight: 600; }
.chip[disabled] { opacity: .5; cursor: not-allowed; }
.filters-row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.filters-labelrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fl { font-size: 12px; color: var(--dim); min-width: 56px; }
.fld { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--dim); }
.sel { background: var(--bg2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 6px 8px; font-size: 14px; font-family: var(--mono); }
.count { font-family: var(--mono); font-size: 12px; color: var(--dim); margin: 2px 0 6px; }

.target-list { display: flex; flex-direction: column; gap: 6px; }
.target-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.fav { flex: 0 0 auto; width: 40px; height: 40px; border: 0; background: none; cursor: pointer;
  color: var(--dim); font-size: 18px; line-height: 1; border-radius: 8px; }
.fav.on { color: var(--accent); }
.target-main { flex: 1 1 auto; min-width: 0; }
.target-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mbadge { font-family: var(--mono); font-size: 11px; font-weight: 700; color: #12131c;
  background: var(--accent); border-radius: 6px; padding: 1px 6px; }
.tname { font-weight: 600; }
.tsub { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.target-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; font-size: 12px; color: var(--dim); }
.target-meta .tnum { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tier { flex: 0 0 auto; font-family: var(--mono); font-size: 12px; font-weight: 600;
  border-radius: 999px; padding: 3px 10px; }
.tier.fits { color: var(--park); background: color-mix(in srgb, #5fae79 16%, var(--card));
  border: 1px solid color-mix(in srgb, #5fae79 34%, transparent); }
.tier.mosaic { color: var(--accent-ink); background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }

/* Per-line preview image — a prominent square on the left (Seestar-style),
   itself the tap target for the details page. */
.target-thumb { flex: 0 0 auto; width: 64px; height: 64px; padding: 0; border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; background: #05070d; cursor: pointer;
  display: grid; place-items: center; }
.target-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tthumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.target-thumb.broken { background: var(--accent-wash); }
.tthumb-ph { color: var(--accent-ink); font-size: 22px; line-height: 1; }
/* The name reads as ink but is a real, focusable link to the details page. */
.target-name .tname.linklike { color: var(--ink); text-decoration: none; }
.target-name .tname.linklike:hover { text-decoration: underline; }

/* ── Target details page (Seestar-style: image → name → prose → curve → coords) */
.td-head { margin-bottom: 4px; }
/* Large, prominent image on black, like the Seestar object page. */
.td-image { position: relative; width: 100%; aspect-ratio: 16 / 10; margin: 6px 0 12px;
  border-radius: var(--r); overflow: hidden; background: #05070d; border: 1px solid var(--line); }
.td-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.td-image.broken { background: var(--card2); }
/* Framing overlay: decorative FOV rectangle(s) over the image; the caption
   below is the accessible channel. */
.td-frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.td-frame-cap { margin: -8px 0 12px; }

/* Terrain-horizon map view (#/horizon/map) */
.tm-map { width: 100%; height: 340px; max-height: 48vh; border-radius: var(--r);
  overflow: hidden; border: 1px solid var(--line); background: var(--card2); margin: 8px 0; }
.tm-summary { font-size: 13px; margin: 6px 0; }
.tm-summary:empty { display: none; }
#tm-progress:empty { display: none; }
.td-img-ph { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center; text-align: center; }
.td-img-ph-mark { font-size: 40px; color: var(--accent-ink); line-height: 1; }
.td-sub { margin: -4px 0 8px; }
.td-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.td-tags .ttype { color: var(--dim); }
.td-tags .tnum { color: var(--dim); font-variant-numeric: tabular-nums; }
.td-desc { margin: 0 0 14px; }
.td-prose { line-height: 1.5; }
.tiny { font-size: 11px; }
.dim.tiny { color: var(--dim); }
.td-sec { margin: 0 0 16px; }
.td-sec h2 { font-family: var(--serif); margin-bottom: 8px; }
.td-curnow { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; }
.td-curalt { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.td-curve-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.td-curve { width: 100%; height: 150px; display: block; }
.td-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
.td-facts dt { color: var(--dim); }
.td-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
/* Prominent full-width primary action, like the Seestar CTA. */
.td-cta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 8px; }
.btn.block { flex: 1 1 auto; text-align: center; padding: 12px 16px; font-size: 15px; font-weight: 600; }

/* ── Settings view ───────────────────────────────────────────────────────── */
.settings-block { margin: 14px 0 20px; }
.settings-block h2 { font-family: var(--serif); }
.inst-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 8px; }
.inst-card { background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; display: flex; flex-direction: column; }
.inst-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.inst-pick { text-align: left; background: none; border: 0; padding: 12px 14px;
  cursor: pointer; color: var(--ink); flex: 1 1 auto; border-radius: 12px; }
.inst-card-actions { display: flex; justify-content: flex-end; padding: 0 10px 10px; }
.sensor-row { display: flex; gap: 8px; }
.sensor-row .fld { flex: 1 1 0; min-width: 0; }
.fov-preview { font-family: var(--mono); margin: 0; }
.toggle-row.small-gap { font-size: 13px; }
.inst-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.inst-name { font-weight: 600; font-size: 15px; }
.inst-active { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: #12131c; background: var(--accent); border-radius: 999px; padding: 2px 8px; }
.inst-specs { display: flex; flex-direction: column; gap: 3px; }
.spec { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.spec-k { color: var(--dim); }
.spec-v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.toggle-row { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.settings-foot { color: var(--dim); font-size: 12px; margin-top: 10px; }

/* ── Horizon editor ──────────────────────────────────────────────────────── */
.hz-head { display: flex; align-items: baseline; gap: 12px; }
.hz-max { color: var(--dim); font-size: 12px; }
.hz-wrap { margin: 6px 0 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* pan-y: the chart at large scrolls the page (drags start only on handles,
   which opt back out via touch-action:none below) — device pass 2026-07-18. */
.hz-svg { width: 100%; min-width: 480px; height: auto; display: block; touch-action: pan-y;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.hz-grid { stroke: var(--line); stroke-width: 1; }
/* The 0° line is the true horizon: obstruction above, downhill below. */
.hz-grid-zero { stroke: var(--dim); stroke-width: 1.5; stroke-dasharray: 4 3; }
.hz-axlabel, .hz-azlabel { fill: var(--dim); font-family: var(--mono); font-size: 11px; }
.hz-area { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: none; }
.hz-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.hz-handle { fill: var(--accent); stroke: var(--card); stroke-width: 1.5; cursor: ns-resize; touch-action: none; }
.hz-handle:focus { outline: none; stroke: var(--ink); stroke-width: 2; }
/* Enlarged invisible touch target over each handle — fingers get ~3× the
   visible dot without changing the look. */
.hz-hit { fill: transparent; stroke: none; cursor: ns-resize; touch-action: none; }
.hz-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hz-readout { font-family: var(--mono); font-size: 12px; color: var(--accent-ink); margin-left: auto; }
.hz-dialog { position: fixed; inset: 0; margin: auto; width: min(92vw, 480px); max-height: 84vh;
  padding: 18px; background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.hz-dialog::backdrop { background: rgba(10,8,16,.55); }
.hz-dialog h2 { font-family: var(--serif); }
.hz-import { width: 100%; margin: 8px 0; background: var(--bg2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-family: var(--mono); font-size: 13px; }
.hz-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Night graph (Tonight) ───────────────────────────────────────────────── */
.ng-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ng-head-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ng-datenav { display: flex; gap: 6px; flex-wrap: wrap; }
.ng-datenav .btn { min-width: 64px; text-align: center; }
/* Premier feature CTA — full-width, accent-filled, unmissable at the top of
   Tonight. Ink is #12131c on --accent (the validated primary-button pair). */
.ng-sky-hero { display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 12px;
  padding: 12px 16px; border: 0; border-radius: 14px; cursor: pointer; text-align: left;
  background: var(--accent); color: #12131c;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 35%, transparent); }
.ng-sky-hero:hover { filter: brightness(1.04); }
.ng-sky-hero:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }
.ng-sky-hero-icon { font-size: 26px; line-height: 1; flex: 0 0 auto; }
.ng-sky-hero-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.ng-sky-hero-title { font-family: var(--serif); font-size: 19px; font-weight: 700; line-height: 1.1; }
.ng-sky-hero-sub { font-size: 12.5px; font-weight: 600; color: #12131c; }
.ng-sky-hero-arrow { font-size: 22px; font-weight: 700; flex: 0 0 auto; }
@media (forced-colors: active) {
  .ng-sky-hero { border: 2px solid ButtonText; }
  .ng-sky-hero:focus-visible { outline: 3px solid Highlight; }
}
/* Nudges on Tonight: set a real location, or measure the horizon. */
.ng-approx, .ng-flat { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 8px 0 4px; padding: 8px 10px; border-radius: 10px;
  background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
/* A text button that reads as an inline link (keyboard-focusable, real button). */
.linklike { background: none; border: 0; padding: 0; color: var(--accent-ink);
  font: inherit; text-decoration: underline; cursor: pointer; }
.linklike:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.ng-wrap { position: relative; width: 100%; height: 320px; border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; background: #0d1018; }
.ng-base, .ng-over { position: absolute; inset: 0; display: block; }
.ng-over { touch-action: none; cursor: crosshair; }
.ng-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ng-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0; font-size: 12px; color: var(--dim); }
/* Cloud-forecast strip riding directly under the graph, same hour axis. */
.ng-cloud { margin-top: 4px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); padding: 4px 0 0; overflow: hidden; }
.ng-cloud-canvas { display: block; width: 100%; }
.ng-cloud-sum { padding: 3px 10px 6px; }
.ng-leg { display: inline-flex; align-items: center; gap: 6px; }
.ng-leg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ng-leg-dot.moon { width: 10px; height: 10px; border-radius: 50%; background: #cfd6e6;
  border: 1px dashed #8a93ad; }
.ng-readout { min-height: 40px; margin: 4px 0 8px; padding: 8px 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.ng-ro-time { font-family: var(--mono); font-weight: 600; margin-bottom: 4px; }
.ng-ro-row { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.ng-ro-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.ng-ro-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ng-ro-alt { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ng-ro-flag { font-size: 11px; font-family: var(--mono); }
.ng-ro-flag.ok { color: var(--park); }
.ng-ro-flag.no { color: var(--dim); }

/* location dialog */
.loc-dialog { position: fixed; inset: 0; margin: auto; width: min(92vw, 420px);
  padding: 18px; background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.loc-dialog::backdrop { background: rgba(10,8,16,.55); }
.loc-dialog h2 { font-family: var(--serif); }
.loc-grid { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.loc-in { background: var(--bg2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 8px; font-size: 15px; }

/* ── Visibility table (Tonight) ──────────────────────────────────────────── */
.vis-section { margin: 14px 0 6px; }
.vis-section h2 { font-family: var(--serif); }
.vis-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; list-style: none; padding: 0; }
/* Marker shapes (colour-independent series identity) in legend / table / scrub. */
.ng-mark { display: inline-flex; flex: 0 0 auto; }
.ng-mark svg { display: block; }
.vis-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.vis-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.vis-main { flex: 1 1 auto; min-width: 0; }
.vis-name { font-weight: 600; }
.vis-sub { font-size: 12px; display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 1px; }
.vis-sub .dim { font-family: var(--mono); }
.vis-flag { font-family: var(--mono); font-size: 11px; color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent); border-radius: 999px; padding: 0 7px; }
.vis-moon { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.vis-moon.warn { color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent); border-radius: 999px; padding: 0 7px; }
/* Shrinkable + wrap: effective-window text can be several ranges long; it must
   never force the row (and the page) wider than the viewport. */
.vis-eff { flex: 0 1 auto; min-width: 0; text-align: right; display: flex; flex-direction: column; gap: 1px; }
.vis-eff-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); }
.vis-eff-win { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--accent-ink); overflow-wrap: anywhere; }
.vis-none { font-family: var(--mono); font-size: 12px; color: var(--dim); }

/* ── Sites manager ───────────────────────────────────────────────────────── */
.sites-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.site-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.site-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.site-row.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.site-main { flex: 1 1 auto; min-width: 0; text-align: left; background: none; border: 0;
  color: var(--ink); cursor: pointer; padding: 4px 0; }
.site-name { display: flex; align-items: baseline; gap: 8px; font-weight: 600; }
.site-active { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: #12131c; background: var(--accent); border-radius: 999px; padding: 2px 8px; }
.site-meta { font-size: 12px; color: var(--dim); margin-top: 1px; }
.site-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.btn.small.danger { border-color: var(--danger-dim); color: var(--danger); background: none; }

/* ── Capture (measure horizon) ───────────────────────────────────────────── */
.cap-live { display: flex; gap: 18px; font-size: 24px; font-weight: 600; margin: 4px 0 8px; }
.cap-live .mono { font-variant-numeric: tabular-nums; }
.cap-offset { max-width: 140px; }
.cap-cover { display: flex; align-items: flex-end; gap: 2px; margin-top: 8px; }
.cap-seg { flex: 1 1 0; height: 6px; border-radius: 2px; background: var(--track); }
/* Filled segments differ by HEIGHT + inset ring, not colour alone. */
.cap-seg.on { height: 11px; background: var(--accent); box-shadow: inset 0 0 0 1px rgba(0,0,0,.28); }
#cap-rec.rec { background: var(--live); border-color: var(--live); color: #fff; }

/* ── Live-camera AR capture ──────────────────────────────────────────────── */
.lc-root { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.lc-controls { min-width: 0; max-width: 100%; }
.lc-btns { min-width: 0; }
.lc-btns .btn { min-width: 0; }
/* The viewfinder: video fills it, the overlay canvas + text scrims sit over. */
.lc-stage { position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 62vh;
  margin: 6px 0 12px; border-radius: var(--r); overflow: hidden; background: #000;
  border: 1px solid var(--line); }
.lc-video, .lc-canvas, .lc-reticle-focus { position: absolute; inset: 0; width: 100%; height: 100%; }
.lc-video { object-fit: cover; }
.lc-canvas { pointer-events: none; }
/* Focusable reticle region — keyboard path to aim + mark; visible ring on focus. */
.lc-reticle-focus { background: transparent; }
.lc-reticle-focus:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
/* Text over the camera image carries its own dark scrim so it reads on any sky. */
.lc-readout { position: absolute; left: 10px; top: 10px; z-index: 2; max-width: calc(100% - 20px);
  box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 5px 9px; border-radius: 8px; font-size: 15px; font-weight: 600;
  color: #fff; background: rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.lc-hint { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 2;
  margin: 0; padding: 6px 9px; border-radius: 8px; color: #fff; background: rgba(0,0,0,.6); }
.lc-hint:empty { display: none; }
/* No-camera fallback: dim the black stage, let the status message carry. */
.lc-stage.lc-nocam { aspect-ratio: auto; min-height: 96px; background: var(--card2); }
.lc-stage.lc-nocam .lc-readout { position: static; background: var(--track); color: var(--ink); }
.lc-stage.lc-nocam .lc-hint { position: static; background: transparent; color: var(--ink); margin-top: 6px; }
.lc-controls { display: flex; flex-direction: column; gap: 8px; }
.lc-btns { display: flex; flex-wrap: wrap; gap: 8px; }
#lc-rec.rec { background: var(--live); border-color: var(--live); color: #fff; }
@media (forced-colors: active) {
  .lc-reticle-focus:focus-visible { outline: 3px solid Highlight; }
  .lc-readout, .lc-hint { background: Canvas; color: CanvasText; border: 1px solid CanvasText; }
}

/* ── Sky (AR arcs-across-the-sky) view ───────────────────────────────────── */
.sky-root { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
/* Flat az/alt fallback: drop the portrait camera aspect, give the chart room. */
.lc-stage.sky-flat { aspect-ratio: auto; height: 300px; max-height: 56vh; background: var(--card); }
.sky-flatcanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.sky-scrub { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; min-width: 0; }
.sky-time { flex: 0 0 auto; min-width: 3.5em; color: var(--accent-ink); font-size: 13px; }
.sky-range { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); }
.sky-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.sky-listwrap { margin-top: 8px; }
.sky-listhead { font-family: var(--serif); font-size: 15px; margin-bottom: 6px; }
.sky-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sky-li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.sky-li-name { font-weight: 600; }
.sky-li-pos { font-size: 12px; color: var(--dim); }
.sky-tag { margin-left: auto; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 999px; padding: 2px 8px; }
.sky-tag.ok { color: var(--accent-ink); background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.sky-tag.no { color: var(--dim); border: 1px solid var(--line); }
/* Actionable notices ABOVE the stage (never hidden under the viewfinder). */
.sky-notices { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 8px; }
.sky-notices:empty { display: none; }
.sky-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 10px;
  border-radius: 10px; font-size: 13px; color: var(--ink);
  background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
/* On-camera compass call-to-action — centred over the viewfinder, dark scrim so
   it reads over any video, hidden by [hidden] once the compass fix arrives. */
.sky-cta { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px;
  background: rgba(9, 11, 18, .58); }
.sky-cta[hidden] { display: none; }
.sky-cta-icon { font-size: 40px; line-height: 1; }
.sky-cta-msg { color: #fff; font-size: 15px; max-width: 22em; margin: 0; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
@media (forced-colors: active) {
  .sky-range:focus-visible { outline: 3px solid Highlight; }
  .sky-tag, .sky-notice { border: 1px solid CanvasText; }
  .sky-cta { background: Canvas; }
  .sky-cta-msg { color: CanvasText; text-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { .ng-sky-hero { transition: none; } }

/* ── Location search + welcome ───────────────────────────────────────────── */
.geo-row { display: flex; gap: 8px; align-items: stretch; margin: 6px 0; }
.geo-row .loc-in { flex: 1 1 auto; min-width: 0; }
.geo-results { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px;
  max-height: 44vh; overflow-y: auto; }
.geo-hit { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; text-align: left; }
.geo-name { font-weight: 600; }
.welcome-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.btn.block { text-align: center; }
.loc-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* Header action rows kept clear of the floating corner buttons. */
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.ng-site { margin-left: auto; }
.hz-actions .ng-site { margin-left: 0; }

/* ── Polar Align ─────────────────────────────────────────────────────────── */
.pa-head { margin-bottom: 6px; }
.pa-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; margin: 12px 0; }
.pa-card h2 { font-family: var(--serif); margin-bottom: 10px; }

/* Verdict banner — the horizon-aware headline. */
.pa-banner { border-radius: var(--r); padding: 12px 16px; margin: 12px 0;
  border: 1px solid var(--line); }
.pa-banner.ok { background: var(--slate-wash); border-color: color-mix(in srgb, var(--slate) 40%, transparent); }
.pa-banner.warn { background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pa-banner-title { font-family: var(--serif); font-weight: 600; font-size: 16px; }
.pa-banner.ok .pa-banner-title { color: var(--slate); }
.pa-banner.warn .pa-banner-title { color: var(--warn); }
.pa-banner-body { margin: 4px 0 0; font-size: 13px; max-width: 60ch; }
.pa-banner .card-actions { margin-top: 8px; }

/* Spec rows (aim + star). */
.pa-specs { display: flex; flex-direction: column; gap: 8px; }
.pa-spec { display: grid; grid-template-columns: 92px auto; align-items: baseline; gap: 4px 12px; }
.pa-spec-k { color: var(--dim); font-size: 12px; }
.pa-spec-v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.pa-spec-hint { grid-column: 2; color: var(--dim); font-size: 12px; }

/* Reticle clock. */
.pa-reticle { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pa-dial { flex: 0 0 auto; }
.pa-dial svg { display: block; }
.pa-ring { fill: none; stroke: var(--line); stroke-width: 2; }
.pa-tick { stroke: var(--dim); stroke-width: 1.5; }
.pa-tick.major { stroke: var(--ink); stroke-width: 2; }
.pa-12 { fill: var(--dim); font-family: var(--mono); font-size: 11px; }
.pa-cross { stroke: var(--dim); stroke-width: 1.5; }
.pa-radial { stroke: color-mix(in srgb, var(--accent) 50%, transparent); stroke-width: 1.5; }
.pa-star { fill: var(--accent); stroke: var(--card); stroke-width: 1.5; }
.pa-reticle-info { flex: 1 1 180px; min-width: 160px; display: flex; flex-direction: column; gap: 6px; }
.pa-ro { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.pa-ro-k { color: var(--dim); font-size: 12px; }
.pa-ro-v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent-ink); }
.pa-flag { font-size: 12px; color: var(--warn); font-family: var(--mono); margin: 6px 0 0; }
