/* SPHEREx Blink. T124: the sky map is the page's background (fixed); controls and analysis float over
   it as glass panels. Sections: tokens · base · controls · map screen (HUD) · thumbwheel · analysis deck ·
   frame tools · charts (timeline, spectra, unusual spectra) · overlays (tour, discussion) · no-map page. */

:root {
  --bg: #05070d;                         /* the sky behind everything */
  --panel: #101623;                      /* chart backgrounds, solid cards */
  --panel-2: #1a2233;                    /* inputs, wells, hovered rows */
  --glass: rgb(28 28 30 / 0.96);         /* floating panels over the map: solid, no frosted glass */
  --border: rgb(255 255 255 / 0.12);
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --accent: #0a84ff;                     /* system blue, dark appearance */
  --slot-a: #5ad1a4;
  --slot-b: #f29e6d;
  --warn: #f5c04a;
  --error: #ff6b6b;
  --synthetic: #ffb020;
  --nodata-1: #1a1e28;
  --nodata-2: #10131a;
  --r-panel: 18px;                       /* panels */
  --r-ctl: 10px;                          /* buttons, inputs */
  --lift: 0 4px 24px rgb(0 0 0 / 0.35);
  --blur: none;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", Roboto, sans-serif;
  /* titles and readouts: the same system family at display size */
  --font-din: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, "Helvetica Neue", Roboto, sans-serif;
  --wheel-lane: 56px;                    /* room the thumbwheel keeps on the right edge */
  color-scheme: dark;
  accent-color: var(--accent);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font-ui);
}
/* the thumbwheel is the page's scroll control while the map is there */
:root:not(:has(body.no-map)) { scrollbar-width: none; }
:root:not(:has(body.no-map))::-webkit-scrollbar { display: none; }

h1, h2, h3 { margin: 0; font-family: var(--font-din); font-weight: 600; letter-spacing: -0.015em; }
h2 { font-size: 21px; line-height: 1.2; }
h3 { font-size: 15px; margin-bottom: 8px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
code, kbd { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
kbd { border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; background: var(--panel-2); }
a { color: var(--accent); }

/* ---------- controls ---------- */
select, button, input[type="text"], input[type="number"], textarea {
  font: inherit; color: var(--text); background: rgb(255 255 255 / 0.10);
  border: 1px solid transparent; border-radius: var(--r-ctl); padding: 5px 11px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
select { max-width: 60vw; }
select option, select optgroup { background: var(--panel); color: var(--text); }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
button:hover:not(:disabled):not(.link):not(.primary), select:hover { background: rgb(255 255 255 / 0.17); }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; color: var(--accent); padding: 4px 6px; }
button.link:hover:not(:disabled) { text-decoration: underline; }
button:where([aria-pressed="true"]:not(.link)) { background: var(--accent); color: #fff; border-color: var(--accent); }

.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge-synthetic { background: var(--synthetic); color: #1a1200; }
.badge-small { font-size: 10px; padding: 1px 6px; vertical-align: 1px; }

/* a floating panel: the map's panels (.hud-panel) and the analysis panels (.panel) */
.hud-panel, .panel {
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--r-panel);
  box-shadow: var(--lift); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.panel { padding: 14px 16px; min-width: 0; }
.panel p { margin: 0 0 8px; }
details.panel summary { cursor: pointer; font: 600 15px var(--font-din); }

/* ---------- messages, build progress ---------- */
.messages:empty { display: none; }
.messages { display: grid; gap: 6px; }
.msg { padding: 8px 12px; border-radius: 10px; border: 1px solid; box-shadow: var(--lift);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.msg-error { border-color: var(--error); color: var(--error); background: rgb(42 18 21 / 0.88); }
.msg-warn { border-color: var(--warn); color: var(--warn); background: rgb(42 34 16 / 0.88); }

.job { padding: 10px 12px; border-color: var(--accent); min-width: min(360px, 100%); }
.job-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.job-head .link { margin-left: auto; }
.job progress { width: 100%; height: 6px; margin-top: 8px; }
.job p { margin: 6px 0 0; overflow-wrap: anywhere; }
#job-elapsed { font-variant-numeric: tabular-nums; }

/* ---------- the map screen ---------- */
/* #sky is fixed behind the page. .mapstage is the first screen: one viewport of free map, with the panels
   over it. Docks and groups let drags through to the map; only the panels catch the mouse. */
.mapstage { position: relative; height: 100vh; height: 100dvh; }
.mapstage[hidden] { display: none; }
.sky-stage { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--bg); }
.sky-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sky-stage .sky-gl { cursor: grab; outline: none; }
.sky-stage .sky-gl:active { cursor: grabbing; }

.hud-dock { position: absolute; left: 12px; top: 12px; z-index: 10; display: flex; flex-direction: column; align-items: flex-start;
  gap: 8px; max-width: min(600px, calc(100vw - 24px)); pointer-events: none; }
.hud { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: 100%;
  pointer-events: none; margin: 0; }
.hud > * { pointer-events: auto; }
.hud-moved { position: absolute; z-index: 11; max-width: none; }
.hud-panel { padding: 9px 12px; }
.hud-panel:empty, .hud-row:not(:has(> :not([hidden]):not(.hud-grip, .hud-fold))) { display: none; }   /* nothing to show yet */
/* drag handles (hud.js): the grip, or any empty part of a panel, moves its group */
.hud[data-hud] .hud-panel { cursor: grab; touch-action: none; }
.hud-panel input, .hud-panel select, .hud-panel button, .hud-panel label, .hud-panel output { cursor: auto; }
.hud-panel button, .hud-panel select, .hud-panel label, .hud-panel summary { cursor: pointer; }
.hud-grip { cursor: grab !important; background: none; border: none; padding: 0 2px; margin-right: -4px;
  color: var(--muted); font-size: 16px; line-height: 1; letter-spacing: -1px; user-select: none; touch-action: none; }
.hud-grip:hover { color: var(--text); }
.hud-dragging, .hud-dragging .hud-panel, .hud-dragging .hud-grip { cursor: grabbing !important; }
/* T137: folding a group (hud.js): the – after the grip; folded, only its tab (⠿ + name) and its status stay */
.hud-fold, .hud-unfold { background: none; border: none; color: var(--muted); font: inherit; line-height: 1;
  padding: 2px 5px; border-radius: 6px; }
.hud-fold { font-size: 16px; margin-left: 2px; }
.hud-fold:hover, .hud-unfold:hover { color: var(--text); }
.hud-tab { display: flex; align-items: center; gap: 6px; padding: 6px 10px; }
.hud:not(.hud-folded) > .hud-tab, .hud-folded > :not(.hud-tab, .messages, .job) { display: none !important; }
.hud-dragging .hud-panel { box-shadow: 0 1px 0 rgb(255 255 255 / 0.06) inset, 0 20px 48px rgb(0 0 0 / 0.65); }
.hud-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.hud-row label { display: inline-flex; align-items: center; gap: 6px; }
.hud-stack { display: flex; flex-direction: column; align-items: stretch; gap: 9px; }
/* switches as chips: lit while on */
.hud-row > label:has(> input[type="checkbox"]) { position: relative; padding: 3px 11px; border-radius: 999px;
  border: 1px solid transparent; background: rgb(255 255 255 / 0.10); color: var(--text); user-select: none; }
.hud-row > label > input[type="checkbox"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.hud-row > label:has(> input[type="checkbox"]):hover { background: rgb(255 255 255 / 0.17); }
.hud-row > label:has(> input[type="checkbox"]:checked) { color: #fff; background: var(--accent); }
.hud-row > label:has(> input[type="checkbox"]:checked) .muted { color: rgb(255 255 255 / 0.8); }
.hud-row > label:has(> input[type="checkbox"]:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.band { flex: 1 1 100%; flex-wrap: wrap; }
.band input[type="range"] { flex: 1 1 120px; min-width: 90px; }
#explore-band-lam, #lam-at { width: 6.5em; font-variant-numeric: tabular-nums; }

/* where: wordmark + the one coordinate form */
.search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; white-space: nowrap; }
.brand::before { content: ""; width: 17px; height: 11px; flex: none;   /* the two blink slots, A over B */
  background: radial-gradient(circle at 5.5px 50%, var(--slot-a) 0 5px, transparent 5.5px),
              radial-gradient(circle at 11.5px 50%, var(--slot-b) 0 5px, transparent 5.5px); }
.field-form { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.field-form label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.field-form input[type="text"] { width: 13ch; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; padding: 5px 8px; }
.field-form input[type="number"] { width: 6.5ch; padding: 5px 6px; }
.field-form input:invalid:not(:placeholder-shown) { border-color: var(--error); }
.build { display: inline-flex; align-items: center; gap: 8px; padding-left: 10px; border-left: 1px solid var(--border); }
.picker { display: flex; align-items: center; gap: 8px; color: var(--muted); }
#pin-btn { padding: 3px 8px; font-size: 16px; line-height: 1.2; }
.help-btn { width: 28px; height: 28px; padding: 0; border-radius: 50%; font-weight: 700; color: var(--muted); }
.help-btn[aria-expanded="true"] { color: var(--text); border-color: var(--accent); }
/* RA/Dec help bubble (T29); positioned by app.js */
.form-tip {
  position: absolute; z-index: 20; top: 0; left: 0;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 10px;
  width: min(380px, calc(100vw - 32px)); padding: 10px 12px; border-radius: 10px;
  background: #2b3140; color: #fff; border: 1px solid #4c5568;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.55); font-size: 13px; line-height: 1.45;
}
.form-tip::before {
  content: ""; position: absolute; top: -7px; left: var(--arrow-x, 20px);
  width: 12px; height: 12px; background: inherit; transform: rotate(45deg);
  border-left: 1px solid #4c5568; border-top: 1px solid #4c5568;
}
.form-tip-icon {
  flex: none; width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font: 700 14px/1 Georgia, serif; font-style: italic;
}
.form-tip p { flex: 1 1 calc(100% - 40px); margin: 0; min-width: 0; }   /* the button wraps below */
.form-tip-close { margin-left: auto; padding: 3px 10px; font-size: 12px; }
/* T65: why a quick pick is interesting */
.pick-why { margin: 0; max-width: 520px; border-left: 3px solid var(--accent); color: var(--muted); }
.pick-why strong { color: var(--text); }

/* "More": base map, tiles, tile outlines */
.more { position: relative; }
.more > summary, .chem-pick > summary { cursor: pointer; list-style: none; white-space: nowrap; padding: 3px 11px;
  border: 1px solid transparent; border-radius: 999px; background: rgb(255 255 255 / 0.10); }
.more > summary::-webkit-details-marker, .chem-pick > summary::-webkit-details-marker { display: none; }
.more > summary::after, .chem-pick > summary::after { content: " ▾"; }
.more[open] > summary::after, .chem-pick[open] > summary::after { content: " ▴"; }
.more[open] > summary, .chem-pick[open] > summary, .more > summary:hover, .chem-pick > summary:hover { background: rgb(255 255 255 / 0.17); }
.more-list, .chem-list { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; display: flex; flex-direction: column;
  min-width: 240px; padding: 10px 12px; background: rgb(36 38 46 / 0.96); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.55); }
.more-list { gap: 8px; }
.more-list label { justify-content: space-between; white-space: nowrap; color: var(--muted); }
.more-list select { max-width: 260px; }
/* an open list lies over the panels below it (each glass panel is a stacking context of its own, T103) */
.hud-panel:has(.chem-pick[open], .more[open]) { position: relative; z-index: 30; }

/* dates of the survey passes / field epochs; the shown one marked, those still loading dimmed */
.explore-epochs { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.explore-epochs button[aria-pressed="true"] { outline: 2px solid currentColor; }
.pass-label { cursor: pointer; padding: 1px 8px; border-radius: 999px; font-size: 12px; opacity: 0.7; white-space: nowrap;
  border: 1px solid transparent; font-variant-numeric: tabular-nums; }
.pass-label.current { opacity: 1; border-color: currentColor; }
.pass-label.loading { opacity: 0.4; }

/* cursor / centre position, north up: bottom left */
.map-readout { position: absolute; left: 12px; bottom: 12px; z-index: 9; display: flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 12px; border-radius: 999px; font: 13px var(--font-din); font-variant-numeric: tabular-nums;
  color: var(--muted); max-width: calc(100vw - 24px - var(--wheel-lane)); white-space: nowrap; }
.map-readout #map-pos { overflow: hidden; text-overflow: ellipsis; }
.map-readout:not(:has(#map-pos:not(:empty))) { display: none; }

/* 📍 marker (cursorpin.js): needle tip on the point, RA/Dec under it; fades 5 s after Go / a pick.
   --pin-tip-y: where the needle tip sits in the glyph (fraction of its height from the top) */
.cursor-pin { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; will-change: transform;
  --pin-tip-y: 94%; transition: opacity 0.8s ease; }
.cursor-pin-fading { opacity: 0; }
.cursor-pin-icon { position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-1 * var(--pin-tip-y)));
  font-size: 28px; line-height: 1; filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.7)); }
body.pin-picking .sky-stage canvas { cursor: crosshair !important; }
.cursor-pin-pill { position: absolute; left: 0; top: 6px; transform: translateX(-50%); white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; padding: 3px 9px; border-radius: 9px;
  font-size: 12px; line-height: 1.35; font-variant-numeric: tabular-nums;
  background: rgb(36 38 46 / 0.9); border: 1px solid var(--border); color: var(--text);
  box-shadow: 0 3px 10px rgb(0 0 0 / 0.5); }
/* hover card of the map names (skylabels.js) */
.paths-tip {
  position: absolute; z-index: 5; max-width: 300px; padding: 8px 10px; border-radius: 10px;
  background: rgb(36 38 46 / 0.94); border: 1px solid var(--border); color: var(--text);
  font-size: 12px; line-height: 1.4; pointer-events: auto; box-shadow: 0 4px 14px rgb(0 0 0 / 0.45);
}
.paths-tip strong { display: block; font-size: 13px; margin-bottom: 4px; color: #ffe2a8; }
.paths-tip dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.paths-tip dt { color: var(--muted); }
.paths-tip dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.paths-tip-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 11px; }

/* buttons on the map, top right: tour (T92), discussion (T120) */
.tour-start, .community-btn { position: absolute; right: 12px; z-index: 7; background: var(--glass); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-weight: 600; box-shadow: var(--lift);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.tour-start { top: 12px; }
.community-btn { top: 54px; }

/* ---------- the thumbwheel (wheel.js) ---------- */
.wheel { position: fixed; right: 10px; top: 50%; transform: translateY(-50%); z-index: 40;
  display: flex; flex-direction: column; align-items: center; gap: 8px; }
.wheel-btn { width: 32px; height: 32px; padding: 0; border-radius: 50%; display: grid; place-items: center; line-height: 1;
  background: var(--glass); box-shadow: var(--lift); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
/* a knurled wheel seen edge-on: the ridges roll with the page (--roll, px), the shading makes it round */
.wheel-knob { position: relative; width: 30px; height: 150px; border-radius: 15px; cursor: ns-resize; touch-action: none;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgb(20 22 28 / 0.9) 0%, rgb(20 22 28 / 0.25) 24%, rgb(255 255 255 / 0.10) 50%, rgb(20 22 28 / 0.25) 76%, rgb(20 22 28 / 0.9) 100%),
    repeating-linear-gradient(180deg, rgb(255 255 255 / 0.34) 0 1px, rgb(255 255 255 / 0.05) 1px 6px),
    var(--glass);
  background-position: 0 0, 0 var(--roll, 0px), 0 0;
  box-shadow: var(--lift); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.wheel-knob:hover, .wheel-knob.rolling { border-color: rgb(255 255 255 / 0.4); }
/* how far down the page is: a mark travelling along the wheel's left side (--p: 0 map … 1 end) */
.wheel-knob::before { content: ""; position: absolute; left: -11px; top: 4px; bottom: 4px; width: 2px; border-radius: 1px;
  background: rgb(255 255 255 / 0.16); }
.wheel-knob::after { content: ""; position: absolute; left: -14px; width: 8px; height: 8px; border-radius: 50%;
  top: calc(4px + var(--p, 0) * (100% - 16px)); background: #fff; }
.wheel-tag { position: absolute; right: calc(100% + 10px); top: calc(32px + 8px + 150px + 8px + 4px); padding: 3px 10px;
  border-radius: 999px; background: var(--glass); border: 1px solid var(--border); font: 600 13px var(--font-din);
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.2s ease; }
.wheel.at-top .wheel-tag { opacity: 1; }
.wheel-wide { display: none; }
body.no-map .wheel { display: none; }

/* ---------- the analysis: panels over the map ---------- */
.deck { position: relative; z-index: 20; container: deck / inline-size; display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 12px; align-content: start;
  margin: 0 var(--wheel-lane) 0 12px; padding: 12px 0 16px; pointer-events: none; }
.deck > *, .layout > *, .side > * { pointer-events: auto; min-width: 0; }
.deck > .layout, .layout > .side { pointer-events: none; }
.deck > .photometry, .deck > .outliers { margin: 0; }
.deck-empty h2 { margin-bottom: 6px; }
.deck-empty p { margin: 0; max-width: 60ch; }
body:not(.map-only) .deck-empty,
.deck:has(> #photometry:not([hidden]), > #outliers:not([hidden]), #viewer-body:not([hidden])) .deck-empty { display: none; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
@container deck (min-width: 940px) {
  .layout { grid-template-columns: minmax(0, 1fr) 380px; }
}
.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; min-width: 0; }
.footer { padding: 2px 6px; width: fit-content; max-width: 100%; text-shadow: 0 1px 3px #000; overflow-wrap: anywhere; }

/* the field: name, frame tools, timeline, spectrum */
.viewer { min-width: 0; }
body.map-only .viewer:has(> #viewer-body[hidden]) { display: none; }
.target-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.target-head h2 { overflow-wrap: anywhere; }
.target-head p { margin: 2px 0 0; }
.target-actions { display: flex; gap: 4px; flex-shrink: 0; }
.target-updates { margin: 4px 0 0; padding: 4px 8px; border-left: 3px solid var(--warn); color: var(--text); }
.target-updates button { margin-left: 6px; }
.empty h2 { margin-bottom: 8px; }
.empty p { margin: 0; max-width: 60ch; }
.empty p + p { margin-top: 8px; }

/* ---------- frame image (?frames=1, offline, ?explore=0) ---------- */
.stage {
  position: relative; width: 100%; max-width: min(100%, 78vh);
  aspect-ratio: var(--ar, 1 / 1);
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
  /* hatched background shows through transparent pixels = no data */
  background: repeating-linear-gradient(45deg, var(--nodata-1) 0 6px, var(--nodata-2) 6px 12px);
}
.frame-stack, .frame-stack img, .overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame-stack img { image-rendering: pixelated; visibility: hidden; user-select: none; -webkit-user-drag: none; }
.frame-stack img.shown { visibility: visible; }
.overlay { pointer-events: none; overflow: visible; }
.stage-label {
  position: absolute; top: 8px; left: 8px; right: 8px; width: fit-content; z-index: 1; padding: 3px 8px; border-radius: 4px;
  background: rgb(0 0 0 / 0.75); color: #fff; font: 600 12px ui-monospace, Menlo, Consolas, monospace;
  border-left: 4px solid var(--muted);
}
.stage-label.is-a { border-left-color: var(--slot-a); }
.stage-label.is-b { border-left-color: var(--slot-b); }
.stage-error {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center;
  color: var(--error); background: rgb(0 0 0 / 0.6);
}
.stage-watermark {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px; text-align: center;
  background: rgb(255 176 32 / 0.85); color: #1a1200; font-weight: 700; font-size: 12px; letter-spacing: 0.08em;
}
/* Map only (default, see app.js): no frame image or what is drawn on it; the frame tools (A/B, blink, A − B,
   play, λ filter, timeline, frame panels) drive the map instead (T81, mapframes.js). ?frames=1 shows it. */
body.map-only #empty, body.map-only #stage, body.map-only #paths-controls, body.map-only #trail-controls,
body.map-only #ph-measure { display: none !important; }
/* T144: a stack is drawn on the frame image, so while one is chosen the map view shows the image (and the objects
   on it, for "along the selected object"). Two classes beat the rule above. */
body.map-only.stack-on #stage { display: block !important; }

/* ---------- frame tools ---------- */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.slot { min-width: 44px; font-weight: 700; }
.slot-a { border-left: 4px solid var(--slot-a); }
.slot-b { border-left: 4px solid var(--slot-b); }
.slot.active { background: rgb(125 185 255 / 0.22); }
.play { min-width: 104px; }
.diff-btn { font-weight: 700; }
.speed { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-left: auto; }
.speed output { min-width: 60px; font-variant-numeric: tabular-nums; color: var(--text); }
.hint { margin: 10px 0 0; font-size: 12px; }
.nodata-swatch {
  display: inline-block; width: 12px; height: 12px; vertical-align: -2px; border: 1px solid var(--border);
  background: repeating-linear-gradient(45deg, var(--nodata-1) 0 3px, var(--nodata-2) 3px 6px);
}
.lam-at, .stack-pick, .stack-motion { display: inline-flex; align-items: center; gap: 4px; }
#lam-at-note { flex-basis: 100%; }
#stack-rate, #stack-pa { width: 5em; }
#film-mode { max-width: 15rem; }
/* T43: difference view A − B */
.diff-canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.stage-diff-label { z-index: 2; border-left-color: var(--accent); }
.diff-note { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.diff-key { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--border); vertical-align: -2px; }
.diff-white { background: #fff; }
.diff-black { background: #000; }
.diff-grey { background: #808080; }
.diff-nodata { background: rgb(64, 84, 140); }

/* T12: wavelength filter, matching, epoch timeline */
.compare { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; color: var(--muted); }
.compare label { display: flex; align-items: center; gap: 6px; }
.compare input[type="number"] { width: 7ch; padding: 5px 6px; }
.timeline { margin-top: 10px; width: 100%; min-height: 136px; }
.tl-svg { display: block; overflow: visible; }
.tl-panel { fill: var(--panel); stroke: var(--border); stroke-width: 1; }
.tl-grid { stroke: var(--border); stroke-width: 1; opacity: 0.6; }
.tl-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tl-title { fill: var(--text); font-size: 11px; font-weight: 600; }
.tl-band { fill: var(--accent); opacity: 0.12; }
.tl-frame { cursor: pointer; }
.tl-hit { fill: transparent; }
.tl-dot { fill: #6da7ec; stroke: var(--panel); stroke-width: 2; paint-order: stroke; pointer-events: none; }   /* the larger .tl-hit takes clicks */
.tl-frame:hover .tl-dot { fill: #9ec5f4; }
.tl-frame.is-a .tl-dot { fill: var(--slot-a); }
.tl-frame.is-b .tl-dot { fill: var(--slot-b); }
.tl-frame.is-shown .tl-dot { r: 6.5; stroke: #fff; stroke-width: 2; }
.tl-frame.is-out { opacity: 0.22; cursor: default; }
.tl-legend { margin: 4px 0 0; }
.tl-key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-left: 8px; }
.tl-key:first-child { margin-left: 0; }
.tl-key-dot { background: #6da7ec; }
.tl-key-a { background: var(--slot-a); }
.tl-key-b { background: var(--slot-b); }
.tl-key-shown { border: 2px solid #fff; }

/* ---------- side panels: shown frame, objects, frames, provenance ---------- */
.info { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table.frames { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.frames th, .frames td { padding: 4px 6px; text-align: left; white-space: nowrap; }
.frames th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-weight: 600; }
.frames tbody tr { cursor: pointer; border-top: 1px solid var(--border); }
.frames tbody tr:hover { background: var(--panel-2); }
.frames tbody tr.shown { background: rgb(125 185 255 / 0.2); }
.frames tbody tr.broken td:nth-child(3) { color: var(--error); }
.frames input[type="radio"] { margin: 0; cursor: pointer; }
.frames input[name="slot-a"] { accent-color: var(--slot-a); }
.frames input[name="slot-b"] { accent-color: var(--slot-b); }

.provenance { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.provenance code { overflow-wrap: anywhere; }

/* T13: objects */
.objects-summary { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.objects-summary:empty { display: none; }
.obj-unknown-text { color: var(--warn); }
.objects-toggle { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.objects { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 280px; overflow: auto; }
.obj-row {
  display: grid; gap: 2px; width: 100%; text-align: left; padding: 6px 8px;
  background: rgb(255 255 255 / 0.05); border: 1px solid transparent; border-radius: var(--r-ctl);
}
.obj-row.is-focus { border-color: var(--warn); }
.obj-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.obj-name { font-weight: 600; overflow-wrap: anywhere; }
.obj-sub { overflow-wrap: anywhere; }
.obj-reason { color: var(--text); opacity: 0.85; overflow-wrap: anywhere; }
.obj-chip { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.obj-unknown { color: var(--warn); border-color: var(--warn); }
.obj-known { color: var(--slot-a); border-color: var(--slot-a); }
.obj-missed { color: var(--muted); border-color: var(--border); }
.obj-artifact { color: var(--muted); border-color: var(--border); border-style: dashed; }
.focus-ring { fill: none; stroke: var(--warn); stroke-width: 2.5; animation: focus-pulse 1.4s ease-in-out infinite; }
@keyframes focus-pulse { 50% { stroke-opacity: 0.35; } }

/* ---------- T49: spectrum and change over time ---------- */
.photometry { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
/* a map click's spectrum sits in the deck as a panel of its own (photometry.js placePanel) */
.deck > .photometry { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-panel); background: var(--glass);
  box-shadow: var(--lift); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); min-width: 0; }
.ph-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ph-head h3 { margin: 0; }
.photometry h4 { margin: 10px 0 4px; font-size: 13px; font-weight: 600; }
.photometry p { margin: 4px 0; }
.ph-svg { display: block; overflow: visible; }
.ph-panel { fill: var(--panel); stroke: var(--border); }
.ph-grid { stroke: var(--border); opacity: 0.6; }
.ph-zero { stroke: var(--muted); stroke-width: 1.5; }
.ph-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ph-title { fill: var(--text); font-size: 11px; font-weight: 600; }
.ph-ghost { fill: var(--muted); opacity: 0.35; }
.ph-dot { fill: #6da7ec; stroke: var(--panel); stroke-width: 2; paint-order: stroke; }
.ph-dot-c { stroke: var(--panel); stroke-width: 2; paint-order: stroke; }
.ph-err { stroke: var(--muted); stroke-width: 1.5; }
.ph-masked { fill: var(--muted); font-size: 12px; }
.ph-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ph-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; }
.ph-catcher { position: absolute; inset: 0; z-index: 3; cursor: crosshair; }
.stage.is-measuring { outline: 2px dashed var(--accent); outline-offset: 2px; }
.ph-marker { fill: none; stroke: var(--warn); stroke-width: 2; }
/* T63: spectrum context */
.ph-toggles { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 2px 0 6px; }
.ph-toggle { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.ph-base { fill: none; stroke: var(--text); stroke-width: 1.5; opacity: 0.75; }
.ph-base-x { stroke-dasharray: 5 4; }
.ph-base-poor .ph-base { opacity: 0.35; }
.ph-flag { fill: none; stroke: var(--warn); stroke-width: 2; }
.ph-feature { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.8; }
.ph-feature-hit { stroke: transparent; stroke-width: 9; }
.ph-feature-g:hover .ph-feature { stroke: var(--text); opacity: 1; }
.ph-context { border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; margin: 8px 0; }
.ph-context h4 { margin: 4px 0; }
.ph-context p { margin: 6px 0; }
.ph-hint-mark { color: var(--warn); }
/* T84: spectral anomalies */
.ph-anom { fill: none; stroke: #e5484d; stroke-width: 2; }
.ph-anomalies .ph-anom-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.ph-anomalies .ph-anom-known { color: #e5484d; }
/* T91: motion measured by SPHEREx */
.ph-motion-big { font: 600 1.5em var(--font-din); margin: 4px 0; }
/* T60: quality flags */
.ph-flag-list { margin: 6px 0; padding-left: 0; list-style: none; display: grid; gap: 4px; }
.ph-flag { display: inline-block; font-family: ui-monospace, monospace; font-size: 0.85em; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border); margin-right: 4px; }
.ph-flag-bad { border-color: var(--error); color: var(--error); }
.ph-flag-warn { border-color: var(--warn); color: var(--warn); }
.ph-flag-info { color: var(--muted); }

/* ---------- T86: unusual spectra in the field ---------- */
.ol-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ol-head h3 { margin: 0 0 6px; }
.ol-list { margin: 8px 0; padding-left: 22px; display: grid; gap: 10px; }
.ol-item { border-bottom: 1px solid var(--border); padding-bottom: 8px; cursor: pointer; border-radius: 4px; }
.ol-item.is-selected { background: rgb(255 255 255 / 0.06); box-shadow: inset 3px 0 0 #3987e5; }
.ol-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ol-detail { align-items: center; margin-top: 4px; flex-wrap: nowrap; }
.ol-detail p { margin: 0; min-width: 0; }
.ol-name { font-weight: 600; }
.ol-score { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.ol-chart { flex: none; background: var(--panel-2); border-radius: 4px; }
.ol-zero { stroke: var(--border); stroke-width: 1; }
.ol-bar { opacity: 0.45; }
.ol-bar.ol-run { opacity: 1; }
.ol-up { fill: var(--slot-b); }
.ol-down { fill: var(--accent); }
.ol-tick { fill: var(--muted); font-size: 8px; }
.ol-caveat { margin: 4px 0 0; }
/* T61: changes brightness */
.ol-var { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 8px; }
.ol-subhead { margin: 0 0 4px; }
.ol-new { color: var(--warn); font-weight: 600; }
.ol-var .ol-item p { margin: 4px 0 0; }
/* colour–colour diagram + the selected source's bands */
.ol-viz { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0 4px; }
.ol-fig { margin: 0; min-width: 0; }
.ol-fig figcaption { margin-bottom: 4px; }
.ol-cc, .ol-shape { display: block; background: var(--panel-2); border-radius: 8px; max-width: 100%; }
.ol-grid { stroke: var(--border); stroke-width: 1; opacity: 0.6; }
.ol-axis { fill: var(--muted); font-size: 10px; }
.ol-dot { fill: #8b93a7; opacity: 0.75; stroke: var(--panel-2); stroke-width: 1; }
.ol-dot-other { fill: none; stroke: #8b93a7; stroke-width: 1.2; }
.ol-dot-odd { opacity: 1; stroke: var(--panel-2); stroke-width: 2; }
.ol-ring { fill: none; stroke-width: 2; }
.ol-hit { fill: transparent; cursor: pointer; }
.ol-env { fill: #8b93a7; opacity: 0.22; }
.ol-model { fill: none; stroke-width: 2; stroke-dasharray: 5 4; }
.ol-src { fill: none; stroke-width: 1.5; opacity: 0.6; }
.ol-pt { stroke: var(--panel-2); stroke-width: 1.5; }
.ol-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 0; }
.ol-key { display: inline-flex; align-items: center; gap: 5px; }
.ol-sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, #8b93a7); }
.ol-sw-ord { background: #8b93a7; opacity: 0.75; }
.ol-sw-sel { background: none; border: 2px solid var(--c); }
.ol-sw-line { width: 16px; height: 0; border-radius: 0; background: none; border-top: 2px dashed var(--c); }
.ol-sw-env { width: 16px; height: 10px; border-radius: 2px; background: #8b93a7; opacity: 0.35; }
.ol-maptoggle { margin-left: auto; color: var(--muted); }
/* T88: an unusual source's card on the map */
.ol-card { position: absolute; z-index: 6; width: min(300px, calc(100% - 16px)); background: rgb(36 38 46 / 0.94);
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.5); }
.ol-card p { margin: 4px 0; }
.ol-card .ol-chart { width: 100%; height: auto; }
.ol-card-head { display: flex; align-items: baseline; gap: 8px; }
.ol-card-head strong { overflow-wrap: anywhere; }
.ol-card-x { margin-left: auto; font-size: 18px; line-height: 1; padding: 0 4px; }
.ol-card-actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; }

/* ---------- T93: chemistry map of the shown field ---------- */
.chem-note { margin: 0; border-left: 3px solid var(--accent); color: var(--muted); max-width: 520px; }
.chem-note strong { color: var(--text); }
/* T128: spots where the chemistry picture's features show */
.chem-cands { margin: 0; border-left: 3px solid var(--accent); color: var(--muted); max-width: 520px; max-height: 42vh; overflow-y: auto; }
.chem-cands p { margin: 0 0 4px; }
.chem-cands strong { color: var(--text); }
.chem-cand-list { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.chem-cand { width: 100%; text-align: left; padding: 3px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.chem-cand:hover { border-color: var(--border); }
.chem-cand[aria-pressed="true"] { border-color: #ffd400; background: color-mix(in srgb, #ffd400 12%, transparent); }
.chem-cand-n { display: inline-block; min-width: 1.4em; font-weight: 700; }
.chem-sigs { display: block; padding-left: 1.6em; }
.chem-sig { margin-right: 8px; color: var(--muted); white-space: nowrap; }
.chem-sig.on { color: var(--text); }
.chem-cats label { white-space: nowrap; margin-right: 6px; }
.chem-tag { font-size: 0.85em; padding: 0 5px; border-radius: 4px; border: 1px solid var(--border); color: var(--muted); }
.chem-tag.new { border-color: #ffd400; color: #ffd400; }
.chem-tag.other, .chem-tag.untyped { border-color: var(--accent); color: var(--text); }
.chem-cand.known { opacity: 0.55; }
.chem-key { display: inline-block; width: 11px; height: 11px; border: 1px solid var(--border); vertical-align: -1px; }
.chem-dark { background: #111; }
.chem-grey { background: #808080; }
.chem-bright { background: #eee; }
.chem-pick { position: relative; }
/* T137: height set by chemistry.js; the rows keep their height and the list scrolls */
.chem-list { gap: 2px; overflow: hidden auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.chem-list > * { flex-shrink: 0; }
.chem-list .chem-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; padding: 2px 0; }
.chem-list .chem-row:has(input:disabled) { opacity: 0.5; }
.chem-list p { order: -1; margin: 0 0 4px; white-space: normal; }
.chem-line { display: block; margin: 2px 0; }
.chem-more summary { cursor: pointer; color: var(--accent); width: fit-content; }   /* T132 */
.chem-more[open] summary { margin-bottom: 2px; }
/* T109: redshift of the object */
.chem-zrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.chem-zrow input { width: 7em; }
.chem-zrow p { flex-basis: 100%; max-width: 300px; margin: 0; }
/* T107: presets at the top of the list */
.chem-presets { display: flex; flex-direction: column; gap: 3px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.chem-preset { text-align: left; white-space: nowrap; padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; }
.chem-preset[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
.chem-presets .chem-group:not(:first-child) { margin-top: 5px; }  /* T127: objects / places */

/* ---------- overlays: guided tour (T92), discussion per map tile (T120) ---------- */
.tour-card, .community { position: fixed; right: calc(var(--wheel-lane) + 4px); background: rgb(36 38 46 / 0.86);
  border: 1px solid var(--border); border-radius: var(--r-panel); padding: 12px 16px 14px; box-shadow: var(--lift);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.tour-card { bottom: 16px; z-index: 50; width: min(380px, calc(100vw - 32px)); }
.tour-card h3 { margin: 4px 0 6px; font-size: 18px; }
.tour-card p { margin: 0 0 10px; line-height: 1.45; }
.tour-head { display: flex; align-items: center; }
.tour-x { margin-left: auto; font-size: 20px; line-height: 1; padding: 0 4px; }
.tour-nav { display: flex; justify-content: space-between; margin-top: 10px; }
.community { top: 16px; z-index: 49; width: min(400px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.community h3 { margin: 8px 0 2px; font-size: 17px; }
.cm-top { display: flex; align-items: center; gap: 12px; }
.cm-tabs { display: flex; gap: 14px; }
.cm-tabs .active { color: var(--text); font-weight: 600; text-decoration: underline; }
.cm-x { margin-left: auto; font-size: 20px; line-height: 1; padding: 0 4px; }
.cm-list, .cm-replies { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 10px; }
.cm-replies { margin: 6px 0 0 14px; padding-left: 10px; border-left: 2px solid var(--border); }
.cm-item { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.cm-text { margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.cm-actions { display: flex; gap: 12px; align-items: center; }
.cm-form { display: grid; gap: 6px; margin-top: 10px; }
.cm-form textarea, .cm-form input[type=text] { width: 100%; }

/* ---------- wide screens: the map's panels stay put on the left, the analysis is a column on the right,
   so the map stays visible between them while the frame tools drive it ---------- */
@media (min-width: 1280px) {
  .mapstage .hud-dock, .mapstage .hud-moved, .mapstage .map-readout { position: fixed; }
  .deck { width: clamp(520px, 46vw, 720px); margin-left: auto; margin-right: calc(var(--wheel-lane) + 4px); }
  body.deck-wide .deck { width: min(1240px, calc(100vw - 2 * var(--wheel-lane) - 24px)); }
  .wheel-wide { display: grid; }
  body.deck-wide .wheel-wide { transform: scaleX(-1); }
}

/* ---------- phones ---------- */
@media (max-width: 600px) {
  :root { --wheel-lane: 46px; }
  .wheel { right: 6px; }
  .wheel-knob { height: 112px; }
  .wheel-tag { top: calc(32px + 8px + 112px + 8px + 4px); }
  .hud-dock { left: 8px; top: 8px; max-width: calc(100vw - 16px); }
  .field-form input[type="text"] { width: 100%; }
  .field-form label:has(input[type="text"]) { flex: 1 1 100%; }
  .field-form label:has(input[type="text"]) input { flex: 1; }
  .build { padding-left: 0; border-left: none; }
  /* T117: lists open inside their panel, full width, instead of running off the right edge */
  .chem-pick[open], .more[open] { flex: 1 1 100%; }
  .chem-list, .more-list { position: static; margin-top: 6px; max-height: 55vh; overflow-y: auto; }
  .chem-list .chem-row, .chem-preset { white-space: normal; }
  .map-readout { left: 8px; bottom: 8px; max-width: calc(100vw - 150px); font-size: 12px; }
  .tour-start, .community-btn { top: auto; right: 8px; }
  .tour-start { bottom: 8px; }
  .community-btn { bottom: 50px; }
  .tour-card { right: 8px; bottom: 8px; width: calc(100vw - 16px); }
  .community { top: auto; bottom: 0; right: 0; width: 100vw; max-height: 75vh; border-radius: var(--r-panel) var(--r-panel) 0 0; }
  .deck { margin-left: 8px; }
  .panel, .deck > .photometry { padding: 12px; }
  body.no-map .deck { padding: 8px; }
  .form-tip { width: min(380px, calc(100vw - 64px)); }
  .ol-detail { flex-wrap: wrap; }
  .ol-chart { width: 100%; }
}

/* ---------- no map (?explore=0, offline ?data=): an ordinary page, the same panels in the flow ---------- */
body.no-map .deck { width: auto; max-width: 1280px; margin: 0 auto; padding: 16px; pointer-events: auto; }
body.no-map .hud { width: 100%; }
body.no-map .hud-panel { cursor: auto; touch-action: auto; }
body.no-map .search #go-btn, body.no-map .search #pin-btn { display: none; }
body.no-map .build { padding-left: 0; border-left: none; }
body.no-map #show-btn { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .focus-ring { animation: none; }
  .wheel-tag, .cursor-pin { transition: none; }
}

/* ---------- T122: the analysed field drawn with the mouse (third button top right, under 💬) ---------- */
.region-btn { position: absolute; right: 12px; top: 96px; z-index: 7; background: var(--glass); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-weight: 600; box-shadow: var(--lift); }
.region-btn.active { background: #ff453a; border-color: #ff453a; color: #fff; }
.sky-stage.region-drawing, .sky-stage.region-drawing canvas { cursor: crosshair; }
.region-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 7; max-width: calc(100% - 32px);
  background: var(--glass); color: var(--text); border: 1px solid #ff453a; border-radius: 999px; padding: 6px 14px;
  font-size: 13px; pointer-events: none; text-align: center; box-shadow: var(--lift); }
@media (min-width: 1280px) { .mapstage .region-hint { position: fixed; } }
@media (max-width: 600px) { .region-btn { top: auto; right: 8px; bottom: 92px; } .region-hint { bottom: 140px; border-radius: 12px; } }

/* ---------- T123: one progress bar for everything that loads or runs ---------- */
.activity { position: fixed; top: 0; left: 0; right: 0; z-index: 60; pointer-events: none; }
.activity[hidden] { display: none; }
.activity-track { height: 3px; background: rgb(255 255 255 / 0.08); overflow: hidden; }
.activity-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
.activity-fill.activity-busy { width: 30%; animation: activity-move 1.3s ease-in-out infinite; }
@keyframes activity-move { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.activity-text { display: inline-block; margin: 6px 0 0 50%; transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--glass); color: var(--text); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 14px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: var(--lift); }
@media (prefers-reduced-motion: reduce) { .activity-fill.activity-busy { animation: none; width: 100%; opacity: 0.5; } }

/* T129: discussions and saved second-look evidence. */
.cm-form label { display: grid; gap: 4px; }
.cm-form label:has(input[type=checkbox]) { display: flex; gap: 7px; align-items: flex-start; }
.cm-form input[type=checkbox] { flex: none; margin-top: 3px; }
.cm-form select { width: 100%; }
.cm-actions { flex-wrap: wrap; }
.cm-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; overflow-wrap: anywhere; }
.cm-item h4, .cm-form h4 { margin: 6px 0; overflow-wrap: anywhere; }
.cm-evidence { line-height: 1.5; overflow-wrap: anywhere; }
.cm-badge { padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; font-size: 11px; }
.cm-highlight { outline: 2px solid var(--accent, #8cb8ff); outline-offset: 3px; border-radius: 3px; }
.cm-tabs { flex-wrap: wrap; gap: 12px; }
.cm-x { align-self: flex-start; }

/* T133: a separate Community workspace, with persistent Explore / Community navigation. */
.app-header { position: fixed; inset: 0 0 auto; height: 54px; z-index: 55; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
.workspace-tabs { display: flex; gap: 4px; padding: 3px; background: var(--panel); border-radius: 11px; }
.workspace-tabs button { padding: 5px 14px; background: transparent; color: var(--muted); }
.workspace-tabs button[aria-selected=true] { color: var(--text); background: var(--panel-2); }
body:has(.app-header) .sky-stage { top: 54px; }
body:has(.app-header) .hud-dock { top: 66px; }
body:has(.app-header) .hud-moved { margin-top: 54px; }
body:has(.app-header) .tour-start { top: 66px; }
body:has(.app-header) .community-btn { top: 108px; }
body:has(.app-header) .region-btn { top: 150px; }
body:has(.app-header) .tour-card, body:has(.app-header) .community { max-height: calc(100dvh - 78px); }
body:has(.app-header) .community { top: 66px; }
body.no-map:has(.app-header) .deck { padding-top: 70px; }
body.community-workspace { overflow: hidden; }
body.community-workspace #explore-workspace { visibility: hidden; }
body.community-workspace .tour-card, body.community-workspace .ol-card { visibility: hidden; }
body.community-workspace #community { inset: 54px 0 0; width: 100%; max-height: none; border: none; border-radius: 0;
  background: var(--bg); padding: 28px max(20px, calc((100vw - 960px) / 2)) 48px; overflow-y: auto; box-shadow: none; }
.cm-workspace-head { margin-bottom: 20px; }
.cm-workspace-head h2 { font-size: 28px; }
.cm-workspace-head p { margin: 8px 0 0; max-width: 65ch; }
.community-workspace .cm-top { position: sticky; top: -28px; z-index: 1; padding: 12px 0; margin-bottom: 12px; background: var(--bg); border-bottom: 1px solid var(--border); }
.community-workspace .cm-item { padding: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.community-workspace .cm-form { padding: 20px; margin-top: 20px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.cm-thread-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.cm-coverage { display: inline-block; font-size: 12px; padding: 3px 7px; border: 1px solid currentColor; border-radius: 6px; margin: 6px 0; }
.cm-coverage-unvisited { color: #a4acba; }
.cm-coverage-light { color: #68b9ff; }
.cm-coverage-moderate { color: #e2b859; }
.cm-coverage-high { color: #78d2a5; }
.cm-coverage-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 20px 0; }
.cm-coverage-card { display: grid; gap: 5px; padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.cm-coverage-card strong { font-size: 26px; }
.cm-coverage-list { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.cm-coverage-list .cm-coverage { display: table; }
.cm-sort { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0; }
body:not(.community-workspace) .cm-coverage-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.community-coverage-label { flex-wrap: wrap; }
#community-coverage-note { flex-basis: 100%; max-width: 400px; }
@media (max-width: 600px) {
  .app-header { padding: 8px; gap: 6px; }
  .app-header .brand { font-size: 14px; }
  .workspace-tabs button { padding: 5px 9px; font-size: 13px; }
  body:has(.app-header) .hud-dock { top: 62px; }
  body:has(.app-header) .tour-start, body:has(.app-header) .community-btn, body:has(.app-header) .region-btn { top: auto; }
  body:has(.app-header):not(.community-workspace) .community { top: auto; max-height: calc(100dvh - 70px); }
  body.community-workspace #community { padding: 18px 12px 32px; }
  .community-workspace .cm-top { top: -18px; }
  .cm-coverage-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .community-workspace .cm-item, .community-workspace .cm-form { padding: 12px; }
}
@media (max-width: 380px) {
  .app-header .brand { font-size: 12px; gap: 5px; }
  .workspace-tabs button { padding: 5px 7px; font-size: 12px; }
}

/* T136: brief analysis labels; evidence/caveats on hover, focus or tap. Popovers escape panel clipping. */
.analysis-note { display: inline-block; max-width: 100%; vertical-align: baseline; }
.analysis-label { border: 0; border-radius: 3px; padding: 0; background: transparent; color: inherit;
  font: inherit; text-align: left; line-height: inherit; cursor: help; box-shadow: none; }
.analysis-label:hover { background: transparent; text-decoration: underline dotted; text-underline-offset: 3px; }
.analysis-info { color: var(--muted); white-space: nowrap; }
.analysis-detail { position: fixed; inset: auto; margin: 0; z-index: 1000; box-sizing: border-box;
  width: max-content; max-height: 45vh; overflow: auto; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--panel); color: var(--text); font: 400 13px/1.5 var(--font-din);
  text-align: left; white-space: normal; overflow-wrap: anywhere; box-shadow: 0 4px 24px rgb(0 0 0 / .35); }
.analysis-detail[hidden] { display: none; }
.ph-context > .analysis-note, .ol-item > .analysis-note { margin: 4px 0; }

.ph-context > .analysis-note { display: block; }

/* T140: two readable questions for selected-position brightness. */
.ph-head h3 { font-size: 17px; flex: 1 1 180px; }
.ph-head button { font-size: 12px; }
.ph-where { overflow-wrap: anywhere; }
.photometry .ph-intro { margin: 10px 0 14px; }
.ph-view-tabs { display: grid; grid-template-columns: 1fr 1.6fr; gap: 4px; padding: 4px; margin: 14px 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px; }
.ph-view-tabs button { min-width: 0; white-space: normal; background: transparent; color: var(--muted); padding: 7px 10px; }
.ph-view-tabs button[aria-selected=true] { background: var(--panel-2); color: var(--text); font-weight: 600; }
.photometry [role=tabpanel] > h4 { font-size: 15px; margin: 14px 0 6px; }
.ph-select { display: grid; gap: 5px; margin: 14px 0 7px; min-width: 0; }
.ph-select select { width: 100%; max-width: 100%; min-width: 0; padding: 7px 9px; text-overflow: ellipsis; }
.photometry .ph-svg { max-width: 100%; margin: 12px 0 0; overflow: hidden; }
.photometry .ph-legend { margin: 6px 0 12px; line-height: 1.5; }
.ph-ghost { opacity: .25; }
.ph-details { margin-top: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.ph-details summary { font-size: 12px; color: var(--muted); font-weight: 600; cursor: pointer; }
.ph-details[open] summary { color: var(--text); margin-bottom: 10px; }
.ph-details p { line-height: 1.55; }
.ph-details .ph-context { border: none; padding: 0; margin: 12px 0; }
.ph-details .ph-toggles { display: grid; gap: 8px; margin: 12px 0; }
.ph-change-summary { padding: 9px 11px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 5px; font-size: 13px; }
.ph-empty { margin: 14px 0; padding: 14px; border: 1px dashed var(--border); border-radius: 10px; line-height: 1.55; }
.ph-empty h4 { margin-top: 0; }
.photometry > #ph-body > .ph-motion { margin-top: 18px; border-top: 1px solid var(--border); }
@media (max-width: 400px) {
  .ph-view-tabs button { padding: 7px 6px; font-size: 12px; }
}

/* T146: comments turned off: the controls stay, muted; a click shows a short toast */
.cm-closed textarea, .cm-closed button, .cm-actions button[aria-disabled=true] { opacity: 0.45; cursor: not-allowed; }
.cm-closed textarea { resize: none; }
.cm-toast { position: fixed; left: 50%; bottom: 24px; z-index: 300; max-width: calc(100vw - 32px); padding: 9px 16px;
  border-radius: 8px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.45); opacity: 0; pointer-events: none; transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s; }
.cm-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* T145: the commit this page runs, next to the title */
.build-info { font-size: 11px; font-weight: 400; color: var(--muted); text-decoration: none; }
.build-info:hover { text-decoration: underline; }
@media (max-width: 480px) { .build-info { display: none; } }
