/* Not TAWS — EO/IR Targeting Explorer
   House palette copied from Not BUILDER (web/css/site.css) — same :root
   tokens/hexes as skew-t / spectrum / space / em-prop. Dark-only. Layout is a
   main stage (tabbed SVG charts) + a right scenario rail that becomes a
   bottom sheet at phone width. Secondary accent --ember for target traces. */

:root {
  color-scheme: dark;
  --void: #02070c;
  --surface: #020a10;
  --surface-2: #05131d;
  --surface-3: #09202b;
  --line: rgba(132, 194, 214, 0.18);
  --line-strong: rgba(132, 220, 235, 0.34);
  --text: #edf8fb;
  --muted: #8da8b3;
  --quiet: #668794;
  --cyan: #29d4e3;
  --cyan-bright: #5ce8f1;
  --amber: #f5c96a;
  --coral: #ff7b78;
  --violet: #a98cff;
  --mint: #76e6a5;
  --ember: #ff9a5c;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --topbar-height: 64px;
  --rail-width: clamp(360px, 31vw, 440px);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
.stage :target, .stage .num-card, .stage .viz-card, .flags .flag { scroll-margin-top: calc(var(--topbar-height) + 12px); }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 14% -12%, rgba(24, 127, 151, 0.2), transparent 38%),
    radial-gradient(circle at 88% 110%, rgba(255, 154, 92, 0.07), transparent 40%),
    var(--void);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

a { color: var(--cyan-bright); }
button { font-family: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -60px; left: 10px; z-index: 100;
  padding: 10px 14px; border-radius: 8px; background: var(--cyan-bright);
  color: #001217; font-weight: 700; text-decoration: none; transition: top 0.15s var(--ease-out);
}
.skip-link:focus { top: 10px; }

/* ---------- top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: var(--topbar-height); padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 10, 16, 0.9);
  position: sticky; top: 0; z-index: 40; backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 38px; height: 38px; }
.brand h1 { margin: 0; font-size: 1.04rem; font-weight: 730; letter-spacing: -0.02em; white-space: nowrap; }

.eyebrow {
  display: block; margin: 0 0 2px; color: var(--cyan);
  font-family: var(--mono); font-size: 0.6rem; font-weight: 600;
  letter-spacing: 0.13em; line-height: 1.2; text-transform: uppercase; white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.header-button, .icon-button {
  display: inline-flex; min-height: 40px; align-items: center; justify-content: center;
  gap: 8px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px;
  color: var(--text); background: rgba(9, 32, 43, 0.55);
  font: inherit; font-size: 0.79rem; font-weight: 600; text-decoration: none; cursor: pointer;
}
.header-button.is-active { color: var(--cyan-bright); border-color: var(--line-strong); background: rgba(24, 89, 103, 0.35); }
.icon-button { width: 40px; padding: 0; border-radius: 50%; font-style: italic; font-weight: 740; color: var(--cyan-bright); }
.header-button:hover, .icon-button:hover { border-color: var(--line-strong); }
.header-button:focus-visible, .icon-button:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--cyan-bright); outline-offset: 2px;
}

/* ---------- app shell: stage + rail ---------- */

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail-width);
  gap: 16px;
  padding: 14px 18px 40px;
  align-items: start;
}

.stage { min-width: 0; }

.stage-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 2px 10px;
}
.stage-title { margin: 0; font-size: 0.95rem; font-weight: 720; letter-spacing: -0.01em; }
.stage-title small { display: block; margin-top: 2px; color: var(--quiet); font-weight: 500; font-size: 0.72rem; }
.scenario-line {
  font-family: var(--mono); font-size: 0.7rem; color: var(--muted); text-align: right; line-height: 1.5;
  max-width: 60%; overflow-wrap: anywhere;
}
.scenario-line strong { color: var(--text); font-weight: 650; }

/* headline (bottom line) row */
.headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 0 10px; }
.headline[hidden] { display: none; }
.headline .num-card { background: rgba(9, 32, 43, 0.7); border-color: var(--line-strong); }
.headline .num-card.polarity .v { font-size: 1.55rem; letter-spacing: 0.02em; }
.headline .num-card.polarity.hot .v { color: var(--ember); }
.headline .num-card.polarity.cold .v { color: var(--cyan-bright); }
.headline .num-card.polarity.crossover .v { color: var(--coral); }
.headline .brief-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 74px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: transparent; color: var(--cyan-bright);
  font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.headline .brief-btn small { color: var(--quiet); font-weight: 500; font-size: 0.64rem; }
.headline .brief-btn:hover:not(:disabled) { background: rgba(24, 89, 103, 0.3); }
.headline .brief-btn:disabled { opacity: 0.6; cursor: wait; }
.brief-card {
  margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--violet);
  border-radius: var(--radius-sm); background: rgba(9, 32, 43, 0.5); color: var(--muted); font-size: 0.82rem; line-height: 1.6;
}
.brief-card[hidden] { display: none; }
.brief-card .brief-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.brief-card .brief-gen { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--violet); }
.brief-card p { margin: 0 0 8px; }
.brief-card p:last-child { margin-bottom: 0; }

textarea {
  width: 100%; min-height: 64px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; resize: vertical;
  color: var(--text); background: var(--surface-3); font: inherit; font-family: var(--mono); font-size: 0.74rem; line-height: 1.4;
}
textarea:focus { outline: none; border-color: var(--line-strong); }
.metar-tokens { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; font-family: var(--mono); font-size: 0.64rem; color: var(--quiet); }
.metar-tokens b { color: var(--text); font-weight: 600; }

/* azimuth rose */
.rose-wrap { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 14px; align-items: center; }
@media (max-width: 560px) { .rose-wrap { grid-template-columns: 1fr; } }
.rose { display: block; width: 100%; height: auto; }
.rose text { font-family: var(--mono); font-size: 10px; fill: var(--muted); }

/* tabs */
.tabs {
  display: flex; gap: 4px; padding: 4px; margin: 0 0 10px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(5, 19, 29, 0.8);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto; min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--muted); font: inherit; font-size: 0.78rem; font-weight: 650;
  cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(24, 89, 103, 0.25); }
.tab[aria-selected="true"] { color: #001217; background: var(--cyan-bright); border-color: var(--cyan-bright); }

.tab-panel[hidden] { display: none; }

.viz-card {
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-2);
  padding: 12px 14px 14px; margin-bottom: 12px;
}
.viz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.viz-title { margin: 0; font-size: 0.82rem; font-weight: 700; color: var(--text); }
.viz-sub { margin: 2px 0 0; color: var(--quiet); font-size: 0.7rem; line-height: 1.45; }
.viz-readout {
  font-family: var(--mono); font-size: 0.7rem; color: var(--cyan-bright); min-height: 1.3em;
  text-align: right; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.viz-readout:empty::before { content: "hover the chart to read values"; color: var(--quiet); }

.chart {
  display: block; width: 100%; height: auto; border-radius: 8px; background: var(--surface);
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.chart:focus-visible { outline: 2px solid var(--cyan-bright); outline-offset: -2px; }
.chart text { font-family: var(--mono); fill: var(--muted); font-size: 11px; }
.chart .axis-label { font-size: 10px; fill: var(--quiet); letter-spacing: 0.06em; text-transform: uppercase; }
.chart .grid { stroke: rgba(132, 194, 214, 0.10); stroke-width: 1; }
.chart .axis { stroke: rgba(132, 194, 214, 0.32); stroke-width: 1; }
.chart .direct-label { font-size: 10.5px; font-weight: 600; }
.chart .crosshair { stroke: rgba(237, 248, 251, 0.45); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .hover-dot { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart .band-night { fill: rgba(10, 20, 40, 0.55); }
.chart .band-astro { fill: rgba(169, 140, 255, 0.08); }
.chart .band-naut { fill: rgba(169, 140, 255, 0.12); }
.chart .band-civil { fill: rgba(245, 201, 106, 0.10); }
.chart .band-xover { fill: rgba(255, 123, 120, 0.18); }
.chart .band-good { fill: rgba(118, 230, 165, 0.12); }
.chart .band-amber { fill: rgba(245, 201, 106, 0.12); }
.chart .band-red { fill: rgba(255, 123, 120, 0.13); }
.chart .req-line { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart .tot-line { stroke: var(--text); stroke-width: 1.2; stroke-dasharray: 2 3; opacity: 0.8; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series.thin { stroke-width: 1.4; }
.chart .tiny { font-size: 9.5px; fill: var(--quiet); }

.legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 2px 0; font-size: 0.7rem; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid currentColor; }
.legend i.dash { border-top-style: dashed; }
.legend i.dot { border-top-style: dotted; border-top-width: 3px; }
.legend i.swatch { width: 11px; height: 11px; border: none; border-radius: 3px; }

/* numeric cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0 0 12px; }
.num-card {
  position: relative; padding: 10px 12px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); min-height: 74px;
}
.num-card .k { display: block; color: var(--quiet); font-size: 0.64rem; letter-spacing: 0.1em; text-transform: uppercase; font-family: var(--mono); }
.num-card .v { display: block; margin-top: 4px; font-family: var(--mono); font-size: 1.25rem; font-weight: 650; color: var(--text); line-height: 1.1; }
.num-card .v small { font-size: 0.7rem; color: var(--muted); font-weight: 500; margin-left: 3px; }
.num-card .s { display: block; margin-top: 3px; font-size: 0.68rem; color: var(--muted); line-height: 1.4; }
.num-card.tone-good { border-color: rgba(118, 230, 165, 0.45); }
.num-card.tone-good .v { color: var(--mint); }
.num-card.tone-amber { border-color: rgba(245, 201, 106, 0.5); }
.num-card.tone-amber .v { color: var(--amber); }
.num-card.tone-red { border-color: rgba(255, 123, 120, 0.5); }
.num-card.tone-red .v { color: var(--coral); }
.num-card.tone-ember .v { color: var(--ember); }
.num-card.tone-mint .v { color: var(--mint); }
.num-card.tone-cyan .v { color: var(--cyan-bright); }
.num-card .why-chip { position: absolute; top: 8px; right: 8px; margin: 0; }
/* The chip is absolutely positioned, so a long uppercase label (e.g.
   "RECOGNITION RANGE @ TOT") ran underneath it and read as truncated.
   Reserve the chip's width in the label's line box instead. */
.num-card:has(.why-chip) .k { padding-right: 46px; }

/* trace / data tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.74rem; min-width: 420px; }
.data-table th, .data-table td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.data-table th { color: var(--quiet); font-family: var(--mono); font-size: 0.62rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; background: var(--surface-2); position: sticky; top: 0; }
.data-table td { color: var(--muted); font-family: var(--mono); }
.data-table td:first-child, .data-table th:first-child { text-align: left; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.is-solution td { color: var(--text); background: rgba(41, 212, 227, 0.08); }
.data-table tr.is-tot td { color: var(--text); background: rgba(255, 154, 92, 0.08); }
.data-table td.pos { color: var(--mint); }
.data-table td.neg { color: var(--coral); }
.data-table .bar-cell { min-width: 160px; }
.delta-bar { position: relative; height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.delta-bar i { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.delta-bar .mid { position: absolute; top: -2px; bottom: -2px; width: 1px; left: 50%; background: var(--line-strong); }
.delta-bar i.neg { background: var(--coral); right: 50%; }
.delta-bar i.pos { background: var(--mint); left: 50%; }

/* gauge (Rytov) */
.gauge { margin: 8px 0 0; }
.gauge-track { position: relative; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--mint), var(--amber) 55%, var(--coral)); opacity: 0.9; }
.gauge-needle { position: absolute; top: -4px; width: 3px; height: 18px; background: var(--text); border-radius: 2px; transform: translateX(-50%); box-shadow: 0 0 0 2px var(--surface-2); }
.gauge-labels { display: flex; justify-content: space-between; margin-top: 4px; font-family: var(--mono); font-size: 0.62rem; color: var(--quiet); }

/* flags strip */
.flags { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.flags:empty { display: none; }
.flag {
  display: flex; align-items: flex-start; gap: 9px; padding: 8px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); border-left-width: 3px; background: rgba(9, 32, 43, 0.5);
  font-size: 0.76rem; color: var(--muted); line-height: 1.5;
}
.flag .flag-icon { flex: none; font-family: var(--mono); font-weight: 800; font-size: 0.7rem; margin-top: 2px; }
.flag.level-warn { border-left-color: var(--amber); }
.flag.level-warn .flag-icon { color: var(--amber); }
.flag.level-info { border-left-color: var(--cyan); }
.flag.level-info .flag-icon { color: var(--cyan); }
.flag.level-bad { border-left-color: var(--coral); }
.flag.level-bad .flag-icon { color: var(--coral); }
.flag a { flex: none; margin-left: auto; font-size: 0.7rem; font-weight: 650; white-space: nowrap; align-self: center; }

.stage-empty {
  padding: 28px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md);
  color: var(--muted); font-size: 0.84rem; line-height: 1.6; text-align: center; background: rgba(5, 19, 29, 0.6);
}
.stage-empty strong { color: var(--text); }
.stage-empty[hidden] { display: none; }

.unclas-banner {
  margin: 0 2px 8px; text-align: center; font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.16em;
  color: var(--amber); text-transform: uppercase;
}

/* ---------- rail ---------- */

.rail { position: sticky; top: calc(var(--topbar-height) + 14px); min-width: 0; z-index: 20; }
.rail-inner {
  display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-height) - 28px);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: rgba(5, 19, 29, 0.94); backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px rgba(0, 7, 13, 0.45);
}
.rail-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); flex: none;
}
.rail-header-label { font-size: 0.88rem; font-weight: 720; }
.rail-header-label small { display: block; color: var(--quiet); font-weight: 500; font-size: 0.66rem; }
.rail-grabber { display: none; }
.rail-collapse-btn {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 0.9rem; display: none;
}
.rail-collapse-btn:hover { color: var(--text); border-color: var(--line-strong); }
.rail-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 20px; }

.rail-card {
  margin: 0 0 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface-2); padding: 13px 14px 15px;
}
.rail-card h2 { margin: 0 0 2px; color: var(--text); font-size: 0.9rem; font-weight: 720; letter-spacing: -0.01em; }
.rail-card .card-sub { margin: 0 0 10px; color: var(--quiet); font-size: 0.72rem; }
.rail-card .hint { color: var(--quiet); font-size: 0.72rem; line-height: 1.45; margin: 5px 0 0; }
.rail-card details.fold { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.rail-card details.fold > summary { cursor: pointer; padding: 8px 11px; font-size: 0.74rem; font-weight: 650; color: var(--muted); list-style-position: inside; }
.rail-card details.fold[open] > summary { color: var(--cyan-bright); border-bottom: 1px solid var(--line); }
.rail-card details.fold .fold-body { padding: 4px 11px 10px; }

.zone-label {
  margin: 2px 2px 8px; color: var(--cyan); font-family: var(--mono);
  font-size: 0.62rem; font-weight: 650; letter-spacing: 0.16em; text-transform: uppercase;
}

/* ---------- form controls ---------- */

.field { margin: 12px 0; }
.field:first-child { margin-top: 0; }
.field-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.field-label { font-size: 0.76rem; font-weight: 650; color: var(--muted); }
.field-readout { font-family: var(--mono); font-size: 0.76rem; color: var(--cyan-bright); font-weight: 650; white-space: nowrap; }
.field-opt { font-size: 0.6rem; color: var(--quiet); font-style: italic; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-track { height: 5px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; margin-top: -6px; border-radius: 50%;
  background: var(--cyan-bright); border: 2px solid #001217; cursor: pointer; box-shadow: 0 0 0 3px rgba(92, 232, 241, 0.18);
}
input[type="range"]::-moz-range-thumb { width: 17px; height: 17px; border-radius: 50%; background: var(--cyan-bright); border: 2px solid #001217; cursor: pointer; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--cyan-bright); outline-offset: 2px; }

input[type="number"], input[type="date"], select, input[type="search"], input[type="text"] {
  width: 100%; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); background: var(--surface-3); font: inherit; font-size: 0.79rem;
  color-scheme: dark;
}
input:focus, select:focus { outline: none; border-color: var(--line-strong); }
input[type="number"] { font-family: var(--mono); }
select { cursor: pointer; }

.field-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; align-items: start; }
.field-two-col > .field { margin: 0; min-width: 0; }
.field-three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 10px; align-items: start; }
.field-three-col > .field { margin: 0; min-width: 0; }
@media (max-width: 430px) { .field-three-col { grid-template-columns: 1fr 1fr; } }

.input-unit { display: flex; gap: 6px; align-items: stretch; }
.input-unit input { flex: 1; min-width: 0; }
.input-unit select { width: auto; flex: none; padding-right: 26px; }

.chip-toggle-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-toggle {
  flex: 1; min-width: 72px; min-height: 40px; text-align: center; padding: 7px 8px; border: 1px solid var(--line); border-radius: 9px;
  background: transparent; color: var(--muted); font: inherit; font-size: 0.74rem; font-weight: 650; cursor: pointer;
}
.chip-toggle[aria-pressed="true"] { color: var(--cyan-bright); border-color: var(--line-strong); background: rgba(24, 89, 103, 0.35); }
.chip-toggle:hover { color: var(--text); }

.lib-plain {
  margin: 6px 0 0; padding: 7px 10px; border-left: 3px solid var(--line-strong); border-radius: 0 8px 8px 0;
  background: rgba(9, 32, 43, 0.5); color: var(--muted); font-size: 0.71rem; line-height: 1.5;
}
.lib-plain:empty { display: none; }
.lib-plain.ember { border-left-color: var(--ember); }
.lib-plain.mint { border-left-color: var(--mint); }
.lib-plain.cyan { border-left-color: var(--cyan); }

/* ---- GFS weather lane (CONTRACTS §11): the model is an offer, never the truth ---- */
.gfs-panel { margin-top: 10px; padding: 10px 11px; border: 1px solid var(--line); border-left: 2px solid var(--violet); border-radius: var(--radius-sm); background: rgba(169, 140, 255, 0.06); }
.gfs-panel .field:first-child { margin-top: 0; }
.gfs-panel #gfs-seaoffer {
  margin-top: 8px; width: 100%; min-height: 40px; padding: 7px 10px; border-radius: 9px;
  border: 1px solid rgba(41, 212, 227, 0.4); background: rgba(41, 212, 227, 0.08);
  color: var(--cyan-bright); font: inherit; font-size: 0.72rem; font-weight: 650; cursor: pointer;
}
.gfs-panel #gfs-seaoffer:hover { border-color: var(--line-strong); color: var(--text); }
.gfs-panel #gfs-seaoffer[hidden] { display: none; }
.gfs-panel .hint em { color: var(--muted); font-style: italic; }
.gfs-panel .hint strong { color: var(--violet); font-weight: 700; }
.prov {
  font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 999px; border: 1px solid var(--line); color: var(--quiet); white-space: nowrap; margin-left: auto;
}
.prov[hidden] { display: none; }
.prov::before { content: "\25CF"; margin-right: 4px; font-size: 0.7em; vertical-align: 1px; }
.prov.is-gfs { color: var(--violet); border-color: rgba(169, 140, 255, 0.45); background: rgba(169, 140, 255, 0.10); }
.prov.is-metar { color: var(--cyan-bright); border-color: rgba(41, 212, 227, 0.4); background: rgba(41, 212, 227, 0.08); }
.prov.is-user { color: var(--quiet); }
.field-row .prov + .field-readout, .field-row .prov + .field-opt { margin-left: 8px; }

.warn-note {
  margin: 6px 0 0; padding: 8px 10px; border-left: 3px solid var(--amber); border-radius: 0 8px 8px 0;
  background: rgba(245, 201, 106, 0.08); color: var(--muted); font-size: 0.71rem; line-height: 1.5;
}
.warn-note strong { color: var(--amber); }
.warn-note.is-info { border-left-color: var(--violet); background: rgba(169, 140, 255, 0.08); }
.warn-note.is-info strong { color: var(--violet); }

/* mini world map */
.worldmap-wrap { margin: 0 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.worldmap-wrap canvas { display: block; width: 100%; height: auto; cursor: crosshair; touch-action: none; }
.worldmap-caption { margin: 4px 2px 0; color: var(--quiet); font-size: 0.64rem; font-family: var(--mono); }

/* compute + TDA */
.compute-btn {
  width: 100%; min-height: 44px; border: 1px solid rgba(92, 232, 241, 0.5); border-radius: 11px;
  background: var(--cyan-bright); color: #001217; font: inherit; font-weight: 730; font-size: 0.85rem; cursor: pointer;
}
.compute-btn:hover { filter: brightness(1.05); }
.compute-btn:disabled { opacity: 0.5; cursor: wait; }
.compute-status { margin: 6px 2px 0; color: var(--quiet); font-size: 0.72rem; min-height: 1.2em; font-family: var(--mono); }
.compute-status.is-error { color: var(--coral); }
.tda-btn {
  width: 100%; min-height: 44px; margin-top: 8px; border: 1px solid var(--line-strong); border-radius: 11px;
  background: var(--surface-3); color: var(--cyan-bright); font: inherit; font-weight: 730; font-size: 0.84rem; cursor: pointer;
}
.tda-btn:hover:not(:disabled) { background: rgba(24, 89, 103, 0.5); }
.tda-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-row .ghost-btn {
  flex: 1; min-height: 40px; border: 1px solid var(--line); border-radius: 9px; background: transparent;
  color: var(--muted); font: inherit; font-size: 0.72rem; font-weight: 650; cursor: pointer;
}
.btn-row .ghost-btn:hover { color: var(--text); border-color: var(--line-strong); }
.rail-footer-note { margin: 8px 2px 0; color: var(--quiet); font-size: 0.66rem; text-align: center; }
.auto-note { margin: 4px 2px 0; color: var(--quiet); font-size: 0.66rem; text-align: center; }

/* ---------- "why?" explainability affordances ---------- */

.why-chip {
  display: inline-flex; align-items: center; flex: none; margin-left: 7px; padding: 1px 8px; min-height: 22px;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(41, 212, 227, 0.08);
  color: var(--cyan-bright); font: inherit; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.02em;
  cursor: pointer; vertical-align: middle; white-space: nowrap;
}
.why-chip:hover, .why-chip:focus-visible { border-color: var(--line-strong); background: rgba(24, 89, 103, 0.4); }

/* ---------- explain dialog ---------- */

.explain-dialog { width: min(94vw, 720px); }
.explain-body { color: var(--muted); font-size: 0.82rem; line-height: 1.62; }
.explain-body p { margin: 0 0 10px; }
.explain-body strong { color: var(--text); }
.explain-body .table-scroll { margin: 8px 0 12px; }
.explain-note { font-size: 0.75rem !important; color: var(--quiet) !important; }
.explain-kv { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: 1fr; gap: 4px; }
.explain-kv li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 9px; border-radius: 7px; background: var(--surface-3); font-size: 0.78rem; }
.explain-kv li span:first-child { color: var(--muted); }
.explain-kv li span:last-child { font-family: var(--mono); color: var(--text); font-weight: 650; white-space: nowrap; }
.explain-kv li.approx span:last-child::after { content: " [APPROX]"; color: var(--amber); font-size: 0.6rem; font-weight: 700; }
.explain-steps { margin: 0 0 12px; padding-left: 20px; font-size: 0.8rem; line-height: 1.6; color: var(--muted); }
.explain-steps li { margin: 4px 0; }
.explain-steps code, .explain-body code { font-family: var(--mono); font-size: 0.74rem; color: var(--cyan-bright); background: rgba(41, 212, 227, 0.08); padding: 1px 5px; border-radius: 4px; }
.explain-learn-link { margin-top: 6px; font-size: 0.8rem !important; }
.explain-learn-link a { font-weight: 650; margin-right: 12px; }
.explain-learn-link[hidden] { display: none; }

#explain-help-button { position: relative; }
.hint-dot {
  position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--coral); box-shadow: 0 0 0 2px var(--surface-2); animation: explainPulse 1.7s ease-in-out infinite;
}
.hint-dot[hidden] { display: none; }
@keyframes explainPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.4); opacity: 0.5; } }

.explain-hint {
  /* The scenario rail owns the right edge on desktop, so anchoring the hint at
     right:16px parked it on top of the form's first fields. Clear the rail. */
  position: fixed; top: calc(var(--topbar-height) + 10px); right: 16px; z-index: 60; max-width: 260px;
  padding: 12px 30px 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); box-shadow: 0 16px 38px rgba(0, 7, 13, 0.45); font-size: 0.74rem; color: var(--muted); line-height: 1.5;
}
/* Desktop: park it at the bottom of the stage. Anchored at the top it covered
   the products context line (target / sensor / weather) that the user needs. */
@media (min-width: 861px) {
  .explain-hint { top: auto; bottom: 16px; right: calc(var(--rail-width) + 20px); }
}
.explain-hint[hidden] { display: none; }
.explain-hint strong { color: var(--text); }
.explain-hint-close {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: none; border-radius: 50%;
  background: transparent; color: var(--quiet); font-size: 0.95rem; cursor: pointer;
}
.explain-hint-close:hover { color: var(--text); background: var(--surface-3); }

/* ---------- dialogs (shared house pattern) ---------- */

.app-dialog {
  width: min(92vw, 640px); padding: 0; border: 1px solid var(--line-strong); border-radius: 12px;
  color: var(--text); background: var(--surface-2); box-shadow: 0 20px 52px rgba(0, 7, 13, 0.42);
}
.app-dialog::backdrop { background: rgba(0, 5, 9, 0.76); backdrop-filter: blur(8px); }
.dialog-shell { max-height: min(88vh, 760px); margin: 0; padding: 24px; overflow-y: auto; border-radius: inherit; }
.dialog-close {
  float: right; width: 34px; height: 34px; margin: -6px -6px 0 8px; border: none; border-radius: 50%;
  background: transparent; color: var(--quiet); font-size: 1.2rem; cursor: pointer;
}
.dialog-close:hover { color: var(--text); background: var(--surface-3); }
.dialog-shell h2 {
  max-width: 520px; margin: 0 0 14px; color: var(--text); font-size: clamp(1.14rem, 3vw, 1.6rem);
  font-weight: 720; letter-spacing: -0.026em; line-height: 1.18;
}
.dialog-shell p { font-size: 0.83rem; line-height: 1.62; color: var(--muted); }
.dialog-shell strong { color: var(--text); }
.dialog-shell ul.plain-list { margin: 6px 0 10px; padding-left: 20px; font-size: 0.8rem; line-height: 1.6; color: var(--muted); }
.about-section { margin-top: 14px; }
.creator-card { margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-3); }
.creator-card > span { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.16em; color: var(--cyan); }
.creator-card p { margin: 6px 0 0; }
.fine-print {
  padding: 10px 11px; border-left: 3px solid var(--cyan); border-radius: 0 8px 8px 0;
  color: var(--quiet) !important; background: rgba(24, 89, 103, 0.14); font-size: 0.69rem !important; line-height: 1.48 !important;
}
.inspiration-line { font-size: 0.7rem !important; color: var(--quiet) !important; }
.dialog-done {
  display: inline-flex; min-height: 42px; align-items: center; justify-content: center; margin-top: 10px; padding: 0 17px;
  border: 1px solid rgba(92, 232, 241, 0.5); border-radius: 10px; color: #001217; background: var(--cyan-bright);
  font: inherit; font-weight: 700; cursor: pointer;
}

.welcome-list { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.welcome-list li { display: flex; gap: 9px; align-items: flex-start; font-size: 0.83rem; line-height: 1.55; color: var(--muted); }
.welcome-bullet { color: var(--ember); margin-top: 3px; flex: none; }
.welcome-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.welcome-dismiss-check { display: flex; align-items: center; gap: 7px; font-size: 0.76rem; color: var(--quiet); }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  :root { --rail-width: clamp(320px, 36vw, 400px); }
}

@media (max-width: 860px) {
  :root { --topbar-height: 108px; }
  .topbar { flex-wrap: wrap; row-gap: 8px; min-height: 0; padding: 10px 14px; }
  .brand { flex: 0 1 auto; }
  .header-actions {
    flex: 1 1 100%; justify-content: flex-start;
    overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
  .header-button, .icon-button { flex: none; min-height: 44px; }
  .icon-button { width: 44px; }

  .app-shell { grid-template-columns: 1fr; padding: 12px 12px 84px; }
  .scenario-line { max-width: 100%; text-align: left; }

  /* rail → bottom sheet */
  .rail { position: fixed; left: 0; right: 0; top: auto; bottom: 0; z-index: 50; }
  .rail-inner {
    max-height: min(84vh, calc(100dvh - 96px)); border-radius: 18px 18px 0 0; border-bottom: none;
    transform: translateY(calc(100% - 60px)); transition: transform 0.24s var(--ease-out);
  }
  .rail.is-expanded .rail-inner { transform: translateY(0); }
  .rail-header { cursor: pointer; min-height: 60px; }
  .rail-grabber { display: block; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 999px; background: var(--line-strong); }
  .rail-collapse-btn { display: inline-flex; align-items: center; justify-content: center; transform: rotate(180deg); min-width: 44px; min-height: 44px; }
  .rail.is-expanded .rail-collapse-btn { transform: none; }

  .why-chip { min-height: 34px; padding: 6px 10px; }
  .dialog-close { width: 40px; height: 40px; }
  .compute-btn, .tda-btn { min-height: 48px; }
  .data-table { min-width: 360px; }
}

@media (max-width: 480px) {
  .brand h1 { font-size: 0.95rem; }
  .brand .eyebrow { display: none; }
  .header-button { font-size: 0.72rem; padding: 0 9px; }
  .explain-hint { left: 12px; right: 12px; max-width: none; top: calc(var(--topbar-height) + 8px); }
  .dialog-shell { padding: 18px 16px; }
  .tab { padding: 0 11px; font-size: 0.74rem; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .num-card .v { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(132, 194, 214, 0.5); --muted: #b8d0da; --quiet: #9ab5c1; }
}
@media print {
  .topbar, .rail, .explain-hint { display: none !important; }
  .app-shell { display: block; padding: 0; }
}
