/* =============================================================================
 * Theodolite — Mission Control aesthetic
 * Palette + idioms adapted from the Clarity Orbital CRM reference
 * (dark atmospheric gradient, chamfered panels, HUD blue + mono headers).
 * =============================================================================
 */

:root {
  --bg: #04070e;
  --bg-soft: #08111f;
  --well: rgba(3, 8, 18, 0.6);
  --panel: rgba(9, 18, 34, 0.82);
  --panel-strong: rgba(7, 14, 28, 0.94);
  --panel-edge: rgba(80, 140, 220, 0.14);
  --panel-edge-strong: rgba(100, 170, 255, 0.28);
  --line: rgba(140, 190, 255, 0.07);
  --text: #d9e6ff;
  --text-strong: #f2f7ff;
  --muted: #7d96be;
  --blue: #6eb3ff;
  --blue-dim: #3a74c9;
  --amber: #f2c56a;
  --green: #5be2b8;
  --red: #ff7e8d;
  --violet: #93a5ff;
  --radius: 8px;
  --radius-sm: 6px;
  --corner: 10px;
  --shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  --sans: "Inter", "SF Pro Display", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: auto; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(50, 100, 200, 0.10), transparent 45%),
    radial-gradient(ellipse at 90% 110%, rgba(60, 80, 200, 0.06), transparent 50%),
    linear-gradient(180deg, #02050c 0%, #050913 40%, #030710 100%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

input, select, textarea, button { font: inherit; color: inherit; }

/* ---------- Banner (placeholder warning) ---------- */

.banner {
  background:
    linear-gradient(180deg, rgba(242, 197, 106, 0.12), rgba(242, 197, 106, 0.05));
  border-bottom: 1px solid rgba(242, 197, 106, 0.28);
  color: var(--amber);
  padding: 10px 24px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}
.banner strong {
  color: #ffd98a;
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 6px;
}
.banner code {
  font-family: var(--mono);
  color: #ffe4a8;
  background: rgba(242, 197, 106, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ---------- Header (mission control strip) ---------- */

header {
  padding: 18px 24px 6px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
header h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
header h1::before {
  content: "◉";
  color: var(--blue);
  margin-right: 8px;
  font-size: 11px;
  vertical-align: 1px;
}
header .sub {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}
header .sub::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 1px;
  background: var(--panel-edge-strong);
  vertical-align: middle;
  margin-right: 10px;
}

.muted { color: var(--muted); }

/* ---------- Panels (the chamfered HUD card) ---------- */

.panel {
  position: relative;
  margin: 14px 24px;
  padding: 18px 22px;
  background: linear-gradient(180deg, rgba(10, 20, 38, 0.90), rgba(5, 10, 22, 0.94));
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  clip-path: polygon(
    var(--corner) 0%, calc(100% - var(--corner)) 0%,
    100% var(--corner), 100% calc(100% - var(--corner)),
    calc(100% - var(--corner)) 100%, var(--corner) 100%,
    0% calc(100% - var(--corner)), 0% var(--corner)
  );
}
.panel::before {
  content: "";
  position: absolute;
  top: 0; left: var(--corner); right: var(--corner);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(140, 200, 255, 0.30) 30%, rgba(140, 200, 255, 0.30) 70%, transparent);
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.panel h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.22em;
}
.panel h2::before {
  content: "› ";
  color: var(--blue);
  margin-right: 2px;
}

/* ---------- Boot indicator ---------- */

.boot {
  margin: 12px 24px;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(15, 35, 70, 0.6), rgba(8, 18, 40, 0.9));
  border: 1px solid rgba(100, 170, 255, 0.22);
  border-radius: var(--radius);
  color: var(--blue);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 0 24px rgba(110, 179, 255, 0.08) inset;
}
.boot::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(110, 179, 255, 0.25);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}
.boot.ready {
  color: var(--green);
  border-color: rgba(91, 226, 184, 0.38);
  background: linear-gradient(180deg, rgba(20, 60, 48, 0.55), rgba(8, 24, 20, 0.9));
}
.boot.ready::before {
  content: "✓";
  border: none; animation: none;
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
  line-height: 14px;
  text-align: center;
}
.boot.err {
  color: var(--red);
  border-color: rgba(255, 126, 141, 0.45);
  background: linear-gradient(180deg, rgba(60, 18, 26, 0.6), rgba(20, 6, 10, 0.9));
}
.boot.err::before {
  content: "✕";
  border: none; animation: none;
  color: var(--red);
  font-weight: 700;
  font-size: 14px;
  line-height: 14px;
  text-align: center;
}
.boot.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Session grid ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

label.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
label.inline > span { color: var(--muted); }
label.inline input, label.inline select { width: auto; }

.session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 18px;
}
.session-grid .full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; }
.field > span {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ---------- Form controls ---------- */

input[type="text"], input[type="number"], select, textarea {
  padding: 7px 10px;
  background: var(--well);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  font-family: var(--mono);
  font-size: 12.5px;
  transition: border-color 120ms, box-shadow 120ms, background 120ms;
}
textarea { font-family: var(--sans); font-size: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--panel-edge-strong);
  box-shadow: 0 0 0 3px rgba(110, 179, 255, 0.12);
  background: rgba(3, 8, 18, 0.85);
}
input.invalid {
  border-color: rgba(255, 126, 141, 0.55);
  background: rgba(60, 18, 26, 0.4);
  color: var(--red);
}
select option {
  background: var(--bg);
  color: var(--text);
}

::placeholder { color: rgba(125, 150, 190, 0.5); }

/* ---------- Buttons ---------- */

button {
  padding: 7px 14px;
  background: linear-gradient(180deg, rgba(110, 179, 255, 0.22), rgba(60, 120, 200, 0.12));
  border: 1px solid rgba(110, 179, 255, 0.38);
  color: #e6f1ff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background 120ms, border-color 120ms, box-shadow 120ms, color 120ms;
}
button:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(110, 179, 255, 0.34), rgba(80, 140, 220, 0.18));
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 0 16px rgba(110, 179, 255, 0.18);
}
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(80, 100, 140, 0.12);
  border-color: rgba(80, 100, 140, 0.25);
  color: var(--muted);
  box-shadow: none;
}
button.secondary {
  background: rgba(12, 24, 44, 0.6);
  border-color: var(--panel-edge);
  color: var(--text);
}
button.secondary:hover:not(:disabled) {
  background: rgba(20, 40, 72, 0.7);
  border-color: var(--panel-edge-strong);
  color: var(--text-strong);
}

#reduce-btn {
  padding: 10px 24px;
  font-size: 12.5px;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(110, 179, 255, 0.35), rgba(60, 120, 200, 0.20));
  border-color: var(--blue);
  box-shadow: 0 0 18px rgba(110, 179, 255, 0.22), inset 0 1px 0 rgba(200, 230, 255, 0.18);
}
#reduce-btn:not(:disabled):hover {
  box-shadow: 0 0 24px rgba(110, 179, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ---------- Tables ---------- */

.table-scroll {
  overflow-x: auto;
  /* right-edge fade hints at horizontal overflow */
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
          mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
}
.table-scroll.no-overflow {
  -webkit-mask-image: none;
          mask-image: none;
}

.data-table td.dc-cell {
  font-variant-numeric: tabular-nums;
  min-width: 82px;
  white-space: nowrap;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.data-table th {
  padding: 8px 10px;
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  background: rgba(10, 20, 38, 0.5);
  border-bottom: 1px solid var(--panel-edge);
  white-space: nowrap;
}
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }

.data-table td input {
  width: 100%;
  min-width: 70px;
  padding: 5px 8px;
  font-size: 12px;
}
.data-table td input.narrow { min-width: 44px; width: 64px; text-align: right; }
.data-table td input.wide   { min-width: 140px; }
.data-table td.sec-cell, .data-table td.dms-ref { white-space: nowrap; }
.vectors-table th[colspan] { text-align: center; letter-spacing: 0.08em; }
.data-table td.id-cell input { width: 48px; min-width: 40px; text-align: center; font-weight: 600; color: var(--blue); }
.data-table td.remove-cell { text-align: right; width: 40px; }
.data-table td.remove-cell button {
  padding: 3px 9px;
  font-size: 11px;
  background: transparent;
  color: var(--red);
  border-color: transparent;
  letter-spacing: 0;
  text-transform: none;
}
.data-table td.remove-cell button:hover:not(:disabled) {
  background: rgba(255, 126, 141, 0.08);
  border-color: rgba(255, 126, 141, 0.38);
  box-shadow: none;
  color: var(--red);
}

.data-table tr.fail-row td { background: rgba(255, 126, 141, 0.06); }
.data-table tr.fail-row:hover td { background: rgba(255, 126, 141, 0.12); }
.data-table tr.pass-row td { background: rgba(91, 226, 184, 0.04); }
.data-table tr.pass-row:hover td { background: rgba(91, 226, 184, 0.09); }
.data-table tr.selected td {
  outline: 1px solid var(--blue);
  outline-offset: -1px;
  background: rgba(110, 179, 255, 0.08);
}

/* ---------- Actions / errors ---------- */

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.error {
  color: var(--red);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* ---------- Summary grid ---------- */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 20px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.summary-grid .k {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 4px;
}
.summary-grid .v {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-strong);
  word-break: break-word;
}

/* ---------- Pills ---------- */

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  background: rgba(125, 150, 190, 0.12);
  color: var(--muted);
  border: 1px solid rgba(125, 150, 190, 0.22);
}
.pill.ok {
  background: rgba(91, 226, 184, 0.12);
  color: var(--green);
  border-color: rgba(91, 226, 184, 0.38);
  box-shadow: 0 0 12px rgba(91, 226, 184, 0.14);
}
.pill.bad {
  background: rgba(255, 126, 141, 0.12);
  color: var(--red);
  border-color: rgba(255, 126, 141, 0.42);
  box-shadow: 0 0 12px rgba(255, 126, 141, 0.14);
}

/* ---------- Results split ---------- */

.results-split {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 960px) {
  .results-split { grid-template-columns: 1fr; }
}

.results-table tr { cursor: pointer; }

/* ---------- Sketch ---------- */

.sketch-wrap {
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 10px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(30, 80, 160, 0.06), transparent 70%),
    linear-gradient(180deg, rgba(4, 10, 20, 0.9), rgba(2, 6, 14, 0.95));
  box-shadow: inset 0 0 40px rgba(110, 179, 255, 0.04);
}
.sketch-caption {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
#sketch {
  width: 100%;
  height: 280px;
  display: block;
  background:
    linear-gradient(180deg, rgba(8, 18, 36, 0.7), rgba(3, 8, 18, 0.85));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.sketch-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.sketch-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.sketch-legend .dot.station { background: var(--blue); box-shadow: 0 0 6px var(--blue); }
.sketch-legend .dot.axis-x { background: var(--red); box-shadow: 0 0 6px rgba(255,126,141,0.6); }
.sketch-legend .dot.axis-y { background: var(--green); box-shadow: 0 0 6px rgba(91,226,184,0.6); }
.sketch-legend .dot.axis-z { background: var(--blue); box-shadow: 0 0 6px rgba(110,179,255,0.6); }
.sketch-legend .dot.ray { background: var(--green); box-shadow: 0 0 6px rgba(91,226,184,0.5); }
.sketch-legend .dot.target { background: var(--red); box-shadow: 0 0 6px var(--red); }
.sketch-legend { flex-wrap: wrap; }

/* ---------- History ---------- */

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  max-height: 200px;
  overflow-y: auto;
}
.history-list li {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.history-list li:hover { background: rgba(110, 179, 255, 0.05); }
.history-list li:last-child { border-bottom: none; }
.history-list .hl-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  margin-left: auto;
}

/* ---------- Raw panel ---------- */

.raw-panel {
  margin: 14px 24px 28px;
  background: var(--panel-strong);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  overflow: hidden;
}
.raw-panel summary {
  padding: 10px 18px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
}
.raw-panel summary::-webkit-details-marker { display: none; }
.raw-panel summary::before {
  content: "▸ ";
  color: var(--blue);
  margin-right: 6px;
  transition: transform 120ms;
  display: inline-block;
}
.raw-panel[open] summary::before { transform: rotate(90deg); }
.raw-panel pre {
  margin: 0;
  padding: 14px 18px;
  background: var(--well);
  border-top: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow: auto;
}

/* ---------- Scrollbar (subtle) ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(110, 179, 255, 0.15);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(110, 179, 255, 0.28); }

/* ---------- Small: tighten table scroll wrapper in panels ---------- */

.panel .table-scroll { margin: 0 -4px; padding: 0 4px; }

/* ---------- Help block (Subject/Primary explainer) ---------- */

.help-block {
  margin: 0 0 14px;
  padding: 0;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  background: rgba(10, 22, 42, 0.55);
  overflow: hidden;
}
.help-block[open] { background: rgba(12, 26, 50, 0.75); }
.help-block > summary {
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--blue);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.help-block > summary::-webkit-details-marker { display: none; }
.help-block > summary::before {
  content: "▸";
  color: var(--blue);
  transition: transform 140ms;
  display: inline-block;
}
.help-block[open] > summary::before { transform: rotate(90deg); }
.help-body {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  padding: 4px 18px 16px;
  border-top: 1px solid var(--line);
}
@media (max-width: 820px) {
  .help-body { grid-template-columns: 1fr; }
}
.help-text p { margin: 10px 0; color: var(--text); line-height: 1.55; }
.help-text code {
  font-family: var(--mono);
  background: rgba(110, 179, 255, 0.08);
  color: var(--blue);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.help-text strong { color: var(--text-strong); }
.help-text em { color: var(--amber); font-style: normal; }
.conv-list {
  margin: 10px 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.6;
}
.conv-list li { margin: 4px 0; }
.conv-list strong { color: var(--text-strong); }

.help-diagram {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}
.setup-svg, .conv-svg {
  width: 100%;
  height: auto;
  max-height: 240px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(30, 80, 160, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(4, 10, 20, 0.7), rgba(2, 6, 14, 0.85));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.help-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.help-legend .legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  vertical-align: middle;
  border-radius: 2px;
}
.help-legend .legend-swatch.subj { background: var(--blue); box-shadow: 0 0 6px var(--blue); }
.help-legend .legend-swatch.prim { background: var(--amber); box-shadow: 0 0 6px rgba(242, 197, 106, 0.6); }
.help-legend .legend-swatch.ref { background: var(--muted); opacity: 0.7; }

/* ---------- Sparkline (live σ preview next to sec samples) ---------- */

.sec-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sec-cell .sec-input { flex: 1 1 auto; }
.sparkline {
  flex: 0 0 auto;
  display: block;
}
.sparkline-axis { stroke: rgba(140, 190, 255, 0.18); stroke-width: 1; }
.sparkline-mean { stroke: var(--blue); stroke-width: 1; opacity: 0.7; }
.sparkline-dot { fill: var(--blue); }
.sparkline-dot.over { fill: var(--red); }
.sparkline-label {
  font-family: var(--mono);
  font-size: 8px;
  fill: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Tolerance bar (replaces plain PASS cell) ---------- */

.tol-cell { min-width: 100px; }
.tol-bar { display: block; }
.tol-bar-track { fill: rgba(125, 150, 190, 0.12); stroke: rgba(125, 150, 190, 0.32); stroke-width: 1; }
.tol-bar-fill.pass { fill: var(--green); opacity: 0.78; }
.tol-bar-fill.fail { fill: var(--red); opacity: 0.82; }
.tol-bar-tick { stroke: var(--amber); stroke-width: 1; opacity: 0.85; }

/* ---------- Results narrative (headline + detail over the grid) ---------- */

.results-narrative { margin-bottom: 14px; }
.narrative-headline {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.narrative-headline.ok {
  color: var(--green);
  background: rgba(91, 226, 184, 0.08);
  border-color: rgba(91, 226, 184, 0.28);
}
.narrative-headline.bad {
  color: var(--red);
  background: rgba(255, 126, 141, 0.08);
  border-color: rgba(255, 126, 141, 0.32);
}
.narrative-detail {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 4px 14px;
}

/* ---------- Facility frame SVG (3D-ish vector plot) ---------- */

#facility-svg {
  width: 100%;
  height: 280px;
  display: block;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(30, 80, 160, 0.10), transparent 70%),
    linear-gradient(180deg, rgba(6, 14, 28, 0.9), rgba(2, 6, 14, 0.95));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.facility-sphere {
  fill: none;
  stroke: rgba(110, 179, 255, 0.10);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}
.facility-axis { stroke-width: 1.2; }
.facility-axis.x { stroke: rgba(255, 126, 141, 0.75); }
.facility-axis.y { stroke: rgba(91, 226, 184, 0.65); }
.facility-axis.z { stroke: rgba(110, 179, 255, 0.75); }
.facility-axis-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
}
.facility-axis-label.x { fill: var(--red); }
.facility-axis-label.y { fill: var(--green); }
.facility-axis-label.z { fill: var(--blue); }
.facility-vec {
  stroke-width: 2;
  fill: none;
}
.facility-vec.pass { stroke: var(--green); }
.facility-vec.fail { stroke: var(--red); }
.facility-arrow-pass { fill: var(--green); }
.facility-arrow-fail { fill: var(--red); }
.facility-vec-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  paint-order: stroke;
  stroke: rgba(3, 8, 18, 0.9);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.facility-vec-label.pass { fill: var(--green); }
.facility-vec-label.fail { fill: var(--red); }

/* ---------- Tour (header button + spotlight overlay) ---------- */

header .tour-btn {
  margin-left: auto;
  position: relative;
}
header .tour-btn.pulse {
  animation: tour-pulse 2.2s ease-in-out infinite;
  border-color: var(--blue);
}
@keyframes tour-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(110, 179, 255, 0.45); }
  50%      { box-shadow: 0 0 0 10px rgba(110, 179, 255, 0); }
}

body.tour-active {
  overflow: hidden;
}

.tour-shield {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: transparent;
  pointer-events: auto;
}

.tour-ring {
  position: fixed;
  z-index: 9500;
  border: 2px solid var(--blue);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(2, 5, 12, 0.72),
              0 0 24px 2px rgba(110, 179, 255, 0.5) inset,
              0 0 24px 2px rgba(110, 179, 255, 0.35);
  pointer-events: none;
  transition: left 220ms ease, top 220ms ease, width 220ms ease, height 220ms ease;
}
.tour-ring.no-target {
  border-color: transparent;
  box-shadow: 0 0 0 9999px rgba(2, 5, 12, 0.78);
}

.tour-card {
  position: fixed;
  z-index: 10000;
  width: 360px;
  max-width: calc(100vw - 28px);
  padding: 16px 18px 14px;
  background: linear-gradient(180deg, rgba(14, 28, 52, 0.98), rgba(6, 14, 28, 0.99));
  border: 1px solid var(--panel-edge-strong);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), 0 0 28px rgba(110, 179, 255, 0.12);
  color: var(--text);
  transition: left 220ms ease, top 220ms ease;
}
.tour-card .tour-progress {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.tour-card .tour-title {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: 0.01em;
}
.tour-card .tour-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 14px;
}
.tour-card .tour-body code {
  font-family: var(--mono);
  background: rgba(110, 179, 255, 0.10);
  color: var(--blue);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.tour-card .tour-body strong { color: var(--text-strong); }
.tour-card .tour-body em { color: var(--amber); font-style: normal; }

.tour-card .tour-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.tour-card .tour-buttons .tour-action {
  margin-right: auto;
  background: linear-gradient(180deg, rgba(242, 197, 106, 0.25), rgba(180, 130, 40, 0.12));
  border-color: rgba(242, 197, 106, 0.5);
  color: #ffe4a8;
}
.tour-card .tour-buttons .tour-action:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(242, 197, 106, 0.38), rgba(180, 130, 40, 0.2));
  border-color: var(--amber);
  box-shadow: 0 0 16px rgba(242, 197, 106, 0.22);
  color: #fff2c6;
}
.tour-card .tour-skip {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 2px 9px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
}
.tour-card .tour-skip:hover {
  color: var(--text-strong);
  background: rgba(125, 150, 190, 0.08);
  border-color: var(--panel-edge);
  box-shadow: none;
}
