/*
 * UpstreamWX component styles — STYLE_GUIDE.md §7. Tokens come from tokens.css.
 * Mobile-first; the column caps at --app-max-width and centers on desktop.
 */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--color-brand-strong);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.app {
  max-width: var(--app-max-width);
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  overflow: hidden;
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

@media (min-width: 1024px) {
  body {
    background: #06080c;
  }
  .app {
    box-shadow: 0 0 0 1px var(--color-border), var(--shadow-pop);
  }
}

/* ── Eyebrow / caption ─────────────────────────────────────────────── */
.eyebrow {
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ── 7.1 App header ────────────────────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.brand__mark {
  width: 28px;
  height: 28px;
  color: var(--color-brand);
}

.brand__logo {
  height: 38px;
  width: auto;
  display: block;
  border-radius: var(--radius-sm);
}

.brand__name {
  font-size: var(--text-label);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand__tagline {
  display: block;
  font-size: 9px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.app-header__spacer {
  flex: 1;
}

.activity-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.activity-pill__icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}

.header-reload {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  padding: 0;
  flex-shrink: 0;
}
.header-reload:hover, .header-reload:focus-visible {
  color: var(--color-text);
  background: var(--color-surface-2);
}
.header-reload__icon { width: 18px; height: 18px; }

/* ── 7.2 Tab bar ───────────────────────────────────────────────────── */
.tab-bar {
  flex-shrink: 0;
  display: flex;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-2) var(--space-1);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-caption);
  letter-spacing: 0.02em;
  transition: color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}

.tab__icon {
  width: 20px;
  height: 20px;
}

.tab[aria-selected="true"] {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
  background: var(--color-brand-dim);
}

/* ── View body ─────────────────────────────────────────────────────── */
.view {
  flex: 1;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.view[hidden] {
  display: none;
}

.section-title {
  font-size: var(--text-h2);
  line-height: var(--lh-h2);
  font-weight: 620;
  margin: 0;
}

/* ── Card primitive ────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-4);
}

/* ── 7.3 Mission card ──────────────────────────────────────────────── */
.mission-card {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.mission-card__main {
  flex: 1;
  min-width: 0;
}

.mission-card__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-h1);
  line-height: var(--lh-h1);
  font-weight: 650;
  margin: 2px 0 var(--space-1);
}

.mission-card__edit {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  background: none;
  border: none;
  padding: 0;
}

.mission-card__meta {
  font-size: var(--text-label);
  color: var(--color-text-secondary);
}

.mission-card__meta .mono {
  font-family: var(--font-mono);
}

.mission-card__posture {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
  text-align: right;
}

/* ── 7.4 Posture chip ──────────────────────────────────────────────── */
/* Equal-width pills: dot left-justified, label centered (display only). */
.posture-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--pill-w);
  padding: 4px var(--space-4);
  border-radius: var(--radius-pill);
  font-size: var(--text-label);
  font-weight: 650;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  background: var(--color-surface-2);
  color: var(--color-text-secondary);
}


.posture-chip.is-lg {
  width: var(--pill-w-lg);
  font-size: 14px;
  padding: var(--space-2) var(--space-4);
}

/* severity variants */
.sev-minimal { background: var(--sev-minimal-wash); color: var(--sev-minimal-text); }
.sev-elevated { background: var(--sev-elevated-wash); color: var(--sev-elevated-text); }
.sev-high { background: var(--sev-high-wash); color: var(--sev-high-text); }
.sev-extreme { background: var(--sev-extreme-wash); color: var(--sev-extreme-text); }

/* heat category variants */
.heat-caution { background: rgba(227, 192, 26, 0.16); color: var(--heat-caution); }
.heat-extreme_caution { background: rgba(240, 160, 32, 0.16); color: var(--heat-ext-caution); }
.heat-danger { background: rgba(236, 106, 44, 0.16); color: var(--heat-danger); }
.heat-extreme_danger { background: rgba(218, 54, 51, 0.18); color: var(--heat-ext-danger); }

/* ── 7.5 Confidence indicator (signal-bar style) ───────────────────── */
/* Three SVG bars whose tops share a single computed diagonal, so junctions are
   seamless. 1 bar filled = low, 2 = moderate, 3 = high (FR-36).
   Width is pill − corner-rounding diameter (26 px) so bars align with the pill's
   flat inner area. */
.confidence {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: var(--pill-w);
}
.confidence.is-lg { width: var(--pill-w-lg); }

/* SVG element sized to the pill's flat inner area, centred beneath the pill. */
.confidence__bars {
  display: block;
  width: calc(100% - 26px);
  height: 18px;
  margin: 0 auto;
}

.confidence__label {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  text-align: center;
  white-space: nowrap;
}

/* ── 7.6 Metric card ───────────────────────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (min-width: 768px) {
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
}

.metric-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.metric-card__label {
  display: flex;
  align-items: center;
  gap: 5px;
}

.metric-card__label .eyebrow { color: var(--color-text-secondary); }

.metric-card__icon { width: 14px; height: 14px; color: var(--color-text-muted); }

.metric-card__value {
  font-family: var(--font-mono);
  font-size: var(--text-display);
  line-height: var(--lh-display);
  font-weight: 700;
  margin-top: var(--space-1);
}

.metric-card__sub {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

/* ── 7.7 Hazard line (overview) ────────────────────────────────────── */
.hazard-list { display: flex; flex-direction: column; }

.hazard-line {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) 0;
  background: none;
  border: none;
  border-top: 1px solid var(--color-border);
  text-align: left;
}

.hazard-line:first-child { border-top: none; }

.hazard-line__icon {
  width: 24px;
  height: 24px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.hazard-line__body { flex: 1; min-width: 0; }

.hazard-line__name { font-weight: 600; }

.hazard-line__window {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.hazard-line__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

/* ── 7.8 Phase strip ───────────────────────────────────────────────── */
.phase-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.phase-seg {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.phase-seg__name {
  font-size: var(--text-caption);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.phase-seg__time {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.phase-seg__lead { font-size: var(--text-label); font-weight: 600; }

.phase-seg__hazards {
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.phase-seg__note {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: var(--space-2);
}

/* ── Summary prose ─────────────────────────────────────────────────── */
.summary {
  font-size: var(--text-body);
  color: var(--color-text);
}
.summary .framed-by,
.hazard-detail__body > .framed-by {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}
.risk-discussion-loading {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ── 7.9 Hazard timeline / Gantt ───────────────────────────────────── */
.timeline { overflow-x: auto; }

.timeline__phases {
  display: grid;
  grid-template-columns: 96px 1fr 1fr 1fr;
  align-items: center;
}

.timeline__phase-head {
  font-size: var(--text-caption);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  text-align: center;
  padding: var(--space-2) var(--space-1);
  border-left: 1px solid var(--color-border);
}

.timeline__row {
  display: grid;
  grid-template-columns: 96px 1fr 1fr 1fr;
  align-items: center;
  border-top: 1px solid var(--color-border);
  min-height: 44px;
}

.timeline__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-label);
  padding-right: var(--space-2);
}
.timeline__label svg { width: 18px; height: 18px; color: var(--color-text-secondary); }

.timeline__cell {
  height: 100%;
  padding: var(--space-2) var(--space-1);
  border-left: 1px solid var(--color-border);
  display: flex;
  align-items: center;
}

.timeline__bar {
  height: 16px;
  width: 100%;
  border-radius: var(--radius-sm);
}
/* windowed: partial-width bar encodes an acute/time-bounded window */
.timeline__bar.is-windowed { width: 55%; }
.timeline__bar.is-na { background: none; }

/* severity fill */
.bar-minimal { background: var(--sev-minimal); }
.bar-elevated { background: var(--sev-elevated); }
.bar-high { background: var(--sev-high); }
.bar-extreme { background: var(--sev-extreme); }
.bar-caution { background: var(--heat-caution); }
.bar-extreme_caution { background: var(--heat-ext-caution); }
.bar-danger { background: var(--heat-danger); }
.bar-extreme_danger { background: var(--heat-ext-danger); }

/* confidence fill: striped transparency for low, dim for moderate */
.conf-low {
  -webkit-mask-image: repeating-linear-gradient(-45deg, black 0 5px, transparent 5px 8px);
  mask-image: repeating-linear-gradient(-45deg, black 0 5px, transparent 5px 8px);
}
.conf-moderate { opacity: var(--confidence-mod-opacity); }

@media (prefers-reduced-motion: no-preference) {
  .timeline__bar { transition: width var(--dur) var(--ease); }
}

/* legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}
.legend__item { display: inline-flex; align-items: center; gap: 5px; }
.legend__swatch { width: 14px; height: 10px; border-radius: 2px; }
.legend__swatch--conf-low {
  -webkit-mask-image: repeating-linear-gradient(-45deg, black 0 5px, transparent 5px 8px);
  mask-image: repeating-linear-gradient(-45deg, black 0 5px, transparent 5px 8px);
}

/* ── 7.10 Hazard detail row ────────────────────────────────────────── */
.hazard-detail {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}

.hazard-detail__summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  cursor: pointer;
  list-style: none;
}
.hazard-detail__summary::-webkit-details-marker { display: none; }
.hazard-detail__summary svg.icon { width: 22px; height: 22px; color: var(--color-text-secondary); }
.hazard-detail__name { flex: 1; font-weight: 600; }
.hazard-detail__chev { width: 18px; height: 18px; color: var(--color-text-muted); transition: transform var(--dur-fast) var(--ease); }
details[open] .hazard-detail__chev { transform: rotate(180deg); }

.hazard-detail__body {
  padding: 0 var(--space-3) var(--space-3);
  border-top: 1px solid var(--color-border);
}
/* Line the confidence bar up under the summary's posture pill: right-aligned,
   clearing the chevron (18px) + its gap so the two equal-width pills stack. */
.hazard-detail__confidence {
  display: flex;
  justify-content: flex-end;
  padding-right: calc(18px + var(--space-3));
  margin-top: var(--space-3);
}
.hazard-detail__body h4 {
  font-size: var(--text-caption);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: var(--space-3) 0 var(--space-1);
}
.hazard-detail__body ul { margin: 0; padding-left: var(--space-4); }
.hazard-detail__body li { font-size: var(--text-label); color: var(--color-text-secondary); margin: 2px 0; }
.hazard-detail__body .logic-list { margin-top: var(--space-2); }
.hazard-detail__body .logic-list li { margin: var(--space-1) 0; }

.assumption {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding: 3px var(--space-2);
  background: rgba(217, 165, 20, 0.08);
  border-left: 2px solid var(--color-warn);
  border-radius: var(--radius-sm);
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  color: var(--color-text-secondary);
}
.assumption svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--color-warn);
}

/* ── Forecast table & charts ───────────────────────────────────────── */
.forecast-tabs { display: flex; gap: var(--space-2); }
.forecast-tabs button {
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}
.forecast-tabs button[aria-selected="true"] {
  background: var(--color-brand-dim);
  color: var(--color-brand);
  border-color: transparent;
}

/* Hourly table scrolls horizontally for long trip windows; right-edge cue shows there's more. */
.fc-scroll { position: relative; }
.fc-scroll__viewport { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fc-scroll__viewport .fc-table { min-width: max-content; }
.fc-scroll__more {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: flex-end;
  width: 40px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--color-surface) 75%);
}
.fc-scroll.is-scrollable .fc-scroll__more { display: flex; }
.fc-scroll__chev {
  width: 18px;
  height: 18px;
  color: var(--color-text-secondary);
  transform: rotate(-90deg);
}

.fc-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); }
.fc-table th, .fc-table td {
  padding: var(--space-2) var(--space-1);
  text-align: center;
  font-size: var(--text-caption);
  border-bottom: 1px solid var(--color-border);
}
.fc-table th:first-child, .fc-table td:first-child {
  text-align: left;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  white-space: nowrap;
}
.fc-table thead th { color: var(--color-text-muted); }

.chart { width: 100%; height: auto; display: block; touch-action: none; cursor: crosshair; }
.chart-caption { font-size: var(--text-caption); color: var(--color-text-muted); text-align: center; }

/* ── 7.11 Map ──────────────────────────────────────────────────────── */
#view-map {
  padding: 0;
  gap: 0;
  height: 100%;
}

#leaflet-map {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--color-surface-2);
}

/* Dark-mode MapLibre chrome: zoom + attribution controls. */
.maplibregl-ctrl-group {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border-strong) !important;
  box-shadow: var(--shadow-pop) !important;
}
.maplibregl-ctrl-group button {
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
}
.maplibregl-ctrl-group button:hover {
  background: var(--color-surface-2) !important;
}
.maplibregl-ctrl-attrib {
  background: var(--color-overlay) !important;
  color: var(--color-text-muted) !important;
  backdrop-filter: blur(6px);
}
.maplibregl-ctrl-attrib a { color: var(--color-text-secondary) !important; }

/* MapLibre canvas fills its flex container. */
.maplibregl-map { width: 100%; height: 100%; }

/* Click popups for the mission point + watershed (FR — selectable map features). */
.map-popup .maplibregl-popup-content {
  background: var(--color-overlay);
  backdrop-filter: blur(6px);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-caption);
}
.map-popup .maplibregl-popup-tip { border-top-color: var(--color-overlay) !important; }
.map-popup .maplibregl-popup-close-button { color: var(--color-text-muted); }
.map-pop__title { font-weight: 650; font-size: var(--text-label); margin-bottom: var(--space-1); }
.map-pop__row { font-size: var(--text-caption); color: var(--color-text-secondary); margin: 2px 0; }
.map-pop__row .mono { font-family: var(--font-mono); color: var(--color-text); }
.map-pop__btn {
  margin-top: var(--space-2);
  width: 100%;
  padding: 6px 10px;
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--color-brand);
  background: var(--color-brand-dim);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Layer-switcher control: stacked text buttons, active entry highlighted. */
.map-layer-switcher { display: flex; flex-direction: column; min-width: 72px; }
.map-layer-switcher button {
  display: block; width: 100%; padding: 5px 10px;
  border: none; border-radius: 0;
  background: var(--color-surface) !important;
  color: var(--color-text-muted) !important;
  font-family: var(--font-sans); font-size: var(--text-caption);
  text-align: left; cursor: pointer;
}
.map-layer-switcher button:hover { color: var(--color-text) !important; }
.map-layer-switcher button.active { color: var(--sev-high) !important; font-weight: 600; }

/* POI marker on the briefing map: dot + label above (anchor: bottom of dot). */
.map-poi-marker { display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none; }
.map-poi-marker__dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fbbf24; border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.55); pointer-events: all; cursor: pointer;
}
.map-poi-marker__label {
  order: -1;
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  color: var(--color-text); background: rgba(0,0,0,.65);
  padding: 1px 5px; border-radius: var(--radius-sm);
  white-space: nowrap; pointer-events: none;
}

/* Planner mission-point marker: same structure, orange dot. */
.mp-marker { display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: none; }
.mp-marker__dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--sev-high); border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.55); pointer-events: all; cursor: grab;
}
.mp-marker__dot:active { cursor: grabbing; }
.mp-marker__label {
  order: -1;
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  color: var(--color-text); background: rgba(0,0,0,.65);
  padding: 1px 5px; border-radius: var(--radius-sm);
  white-space: nowrap; pointer-events: none;
}

/* ── Map legend (watershed / excluded / RoC key) ─────────────────── */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}
.map-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.map-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.map-legend__swatch--watershed {
  background: rgba(56, 189, 248, 0.2);
  border: 1.5px solid #38bdf8;
}
.map-legend__swatch--excluded {
  border: 1px dashed #64748b;
  background: rgba(56, 189, 248, 0.05);
}
.map-legend__roc-line {
  width: 20px;
  height: 0;
  border-top: 1.5px dashed var(--sev-high);
  flex-shrink: 0;
}
.map-legend__laoc-line {
  width: 20px;
  height: 0;
  border-top: 1.5px solid #facc15;
  flex-shrink: 0;
}

/* ── 7.12 Resources ────────────────────────────────────────────────── */
.resource-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: left;
  text-decoration: none;
  color: inherit;
  margin-bottom: var(--space-2);
}
.resource-link svg { width: 20px; height: 20px; color: var(--color-text-secondary); flex-shrink: 0; }
.resource-link__body { flex: 1; min-width: 0; }
.resource-link__title { font-weight: 600; font-size: var(--text-label); overflow-wrap: anywhere; }
.resource-link__sub { font-size: var(--text-caption); color: var(--color-text-muted); overflow-wrap: anywhere; }
.resource-link__ext { color: var(--color-text-muted); }

.btn-primary {
  width: 100%;
  padding: var(--space-3);
  background: var(--color-brand);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 650;
}

/* ── 7.13 Disclaimer footer ────────────────────────────────────────── */
.disclaimer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  color: var(--color-text-secondary);
}

/* ── 7.13a Risk analysis inputs badges ─────────────────────────────── */
.ri-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.ri-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}
.ri-badge--warn {
  border-color: var(--sev-extreme);
  color: var(--sev-extreme);
}
.ri-badge--watch {
  border-color: var(--sev-high);
  color: var(--sev-high);
}

/* ── 7.14 Status / currency line ───────────────────────────────────── */
.status-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  /* Right and bottom respect iPhone safe-area insets (viewport-fit=cover). */
  padding: var(--space-2) max(var(--space-4), env(safe-area-inset-right, 0px))
           max(var(--space-2), env(safe-area-inset-bottom, 0px)) var(--space-4);
  background: var(--color-bg);
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}
.status-line__content {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}
/* Persistent settings gear, pinned to the status bar's top-right (always reachable).
   padding: 4px gives the SVG breathing room near iPhone screen corners. */
.status-line__gear {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 4px;
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.status-line__gear:hover { color: var(--color-text); }
.status-line__gear:focus-visible { outline: 2px solid var(--sev-high); outline-offset: 2px; }
.status-line__gear svg { width: 20px; height: 20px; }
/* Add-to-Home-Screen pill: appears (next to the gear) only when the browser exposes
   an install prompt, so the status bar gains a one-tap install when one is available. */
.status-line__install {
  flex-shrink: 0;
  margin-left: auto;
  padding: 4px var(--space-3);
  border: 1px solid var(--color-brand);
  border-radius: var(--radius-pill);
  background: var(--color-brand-dim);
  color: var(--color-brand);
  font-size: var(--text-caption);
  font-weight: 650;
  cursor: pointer;
}
.status-line__install:hover { background: var(--color-brand); color: var(--color-text-inverse); }
.status-line__install:focus-visible { outline: 2px solid var(--sev-high); outline-offset: 2px; }
/* When the install pill is present it owns the left-auto margin; the gear then just
   sits beside it rather than re-pushing to the far right. */
.status-line__install:not([hidden]) ~ .status-line__gear { margin-left: var(--space-1); }
.status-line__currency { font-family: var(--font-mono); }
.cached-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border: 1px solid var(--color-offline);
  border-radius: var(--radius-pill);
  color: var(--color-offline);
  font-weight: 600;
  font-size: 10px;
  line-height: 1.3;
  text-align: center;
}
.degraded-note { color: var(--color-warn); }

/* ── 7.14a Update-available banner (stale-client nudge) ────────────────
   Non-dismissible: a newer release is live while this tab runs old code.
   Fixed to the top, above every view (docs/deployment-workflow.md). */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: max(var(--space-2), env(safe-area-inset-top, 0px))
           max(var(--space-4), env(safe-area-inset-right, 0px))
           var(--space-2)
           max(var(--space-4), env(safe-area-inset-left, 0px));
  background: var(--sev-high);
  color: var(--color-bg);
  font-size: var(--text-caption);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.update-banner[hidden] { display: none; }
.update-banner__btn {
  flex-shrink: 0;
  padding: 4px var(--space-3);
  border: 1px solid var(--color-bg);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-bg);
  font-weight: 700;
  font-size: var(--text-caption);
  cursor: pointer;
}
.update-banner__btn:hover { background: rgba(0, 0, 0, 0.14); }
.update-banner__btn:focus-visible { outline: 2px solid var(--color-bg); outline-offset: 2px; }

/* ── 7.15 First-run acknowledgment ─────────────────────────────────── */
.ack-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(4, 6, 10, 0.85);
}
.ack-modal[hidden] { display: none; }
.ack-card {
  max-width: 440px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: var(--space-5);
}
.ack-card h2 { margin: 0 0 var(--space-3); font-size: var(--text-h2); }
.ack-card p { font-size: var(--text-label); color: var(--color-text-secondary); }
.ack-card .btn-primary { margin-top: var(--space-4); }

/* ── Mission editor buttons (FR-33) ────────────────────────────────── */
.btn-ghost {
  flex: 1;
  padding: var(--space-3);
  background: none;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-weight: 600;
}

/* ── 7.16 Mission planner (map-based mission editor; FR-1/FR-9/FR-33) ── */
.mp-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 10, 0.85);
}
.mp-modal[hidden] { display: none; }
.mp-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  height: 100dvh;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 768px) {
  .mp-sheet {
    height: 90dvh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
  }
}
.mp-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.mp-bar__title { margin: 0; font-size: var(--text-h2); }
.mp-bar__close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 22px;
  line-height: 1;
  padding: var(--space-1);
  cursor: pointer;
}
.mp-search { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4) var(--space-2); }
.mp-search__input {
  flex: 1;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 16px; /* ≥16px suppresses iOS auto-zoom on focus */
}
.mp-search__go {
  padding: var(--space-2) var(--space-3);
  background: var(--color-brand-dim);
  color: var(--color-brand);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
}
.mp-search__status {
  min-height: var(--lh-caption);
  padding: 0 var(--space-4);
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}
.mp-search__status.is-error { color: var(--color-warn); }
.mp-map {
  flex: 1;
  min-height: 0;
  margin: var(--space-2) var(--space-4) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  overflow: visible;
}
.mp-hint {
  margin: 0;
  padding: var(--space-2) var(--space-4) 0;
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  color: var(--color-text-muted);
}
.mp-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4) 0;
}
.mp-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
}
.mp-fields select,
.mp-fields input[type="datetime-local"] {
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 16px; /* ≥16px suppresses iOS auto-zoom on focus */
}
.mp-fields__check { flex-direction: row; align-items: center; gap: var(--space-2); }
.mp-fields__check input { width: auto; }

/* Radius of Concern (FR-3): discrete, non-linear slider above the actions. */
.mp-roc { padding: var(--space-3) var(--space-4) 0; }
.mp-roc__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.mp-roc__label { font-size: var(--text-caption); color: var(--color-text-secondary); }
.mp-roc__value {
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--sev-high);
}
.mp-roc__slider {
  width: 100%;
  margin: var(--space-2) 0 4px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
.mp-roc__slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--color-border-strong);
}
.mp-roc__slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--color-border-strong);
}
.mp-roc__slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  margin-top: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sev-high);
  border: 2px solid var(--color-bg);
}
.mp-roc__slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sev-high);
  border: 2px solid var(--color-bg);
}
.mp-roc__slider:focus-visible { outline: 2px solid var(--sev-high); outline-offset: 4px; }
.mp-roc__ticks {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}
.mp-roc__hint {
  margin: 4px 0 0;
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  color: var(--color-text-muted);
}

.mp-actions { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.mp-actions .btn-ghost,
.mp-actions .btn-primary { flex: 1; margin: 0; }

/* Settings modal — reuses the mp-sheet/mp-roc chrome; the LAoC slider is yellow to match
   its map ring (distinct from the orange RoC/phase sliders). Yellow is scoped by ID so the
   approach/egress sliders remain orange. */
.settings-body { padding-bottom: var(--space-2); }
#settings-laoc-value { color: #facc15; }
#settings-laoc::-webkit-slider-thumb { background: #facc15; }
#settings-laoc::-moz-range-thumb { background: #facc15; }
#settings-laoc:focus-visible { outline-color: #facc15; }

/* Mission name field — sits above the search bar, separated by a thin rule. */
.mp-name-field {
  padding: var(--space-3) var(--space-4) var(--space-2);
}
.mp-name-field__label {
  display: block;
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}
.mp-name-field__input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 16px; /* ≥16px suppresses iOS auto-zoom on focus */
}
/* Italic grey state shown when the name hasn't been user-set yet (cleared on focus). */
.mp-name-field__input.is-placeholder-name {
  color: var(--color-text-secondary);
  font-style: italic;
}
.mp-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0 var(--space-4);
}

/* ── 7.13 Acronym glossary (Resources card + tap-to-define) ─────────── */
/* Inline term: reads as body text with a dotted brand underline cueing a tap. */
.glossary-term {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-decoration-color: var(--color-brand);
  text-underline-offset: 2px;
}
.glossary-term:hover { text-decoration-style: solid; }

.glossary-pop {
  position: fixed;
  z-index: 200;
  max-width: 280px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: var(--space-3);
}
.glossary-pop[hidden] { display: none; }
.glossary-pop__acr {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-brand);
}
.glossary-pop__term {
  font-size: var(--text-label);
  font-weight: 600;
  margin-top: 1px;
}
.glossary-pop__def {
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
}

.section-title__icon { width: 20px; height: 20px; color: var(--color-text-secondary); }

.glossary-list { display: flex; flex-direction: column; }
.glossary-item {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border);
}
.glossary-item:first-child { border-top: none; padding-top: 0; }
.glossary-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
}
.glossary-item__acr {
  font-weight: 700;
  font-size: var(--text-label);
  letter-spacing: 0.02em;
  color: var(--color-brand);
}
.glossary-item__term {
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--color-text);
}
.glossary-item__def {
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

/* ── 7.14 About / methodology (FR-20 reference sub-page) ───────────── */
.about-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: left;
}
.about-link > svg:first-child { width: 24px; height: 24px; color: var(--color-brand); flex-shrink: 0; }
.about-link__chev { width: 18px; height: 18px; color: var(--color-text-muted); transform: rotate(-90deg); flex-shrink: 0; }

.about-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  align-self: flex-start;
  padding: 0;
  background: none;
  border: none;
  color: var(--color-brand);
  font-size: var(--text-label);
  font-weight: 600;
}
.about-back__icon { width: 18px; height: 18px; }

.about-title { font-size: var(--text-h1); line-height: var(--lh-h1); font-weight: 650; margin: 0; }
.about-lede { font-size: var(--text-body); color: var(--color-text-secondary); margin: 0; }
.about-p { font-size: var(--text-label); line-height: var(--lh-body); color: var(--color-text-secondary); margin: var(--space-2) 0 0; overflow-wrap: break-word; }
.about-list { margin: var(--space-2) 0 0; padding-left: var(--space-4); }
.about-list li { font-size: var(--text-label); line-height: var(--lh-body); color: var(--color-text-secondary); margin: var(--space-2) 0; }

.about-sources { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-3); }
.about-source { display: flex; gap: var(--space-3); }
.about-source__icon { width: 22px; height: 22px; color: var(--color-text-secondary); flex-shrink: 0; margin-top: 1px; }
.about-source__name { font-size: var(--text-label); font-weight: 650; }
.about-source__access { font-weight: 500; color: var(--color-text-muted); font-size: var(--text-caption); }
.about-source__desc { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--color-text-secondary); margin-top: 1px; }

.about-hazards { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-3); }
.about-haz__head { display: flex; align-items: center; gap: var(--space-2); }
.about-haz__icon { width: 20px; height: 20px; color: var(--color-text-secondary); }
.about-haz__title { font-size: var(--text-label); font-weight: 650; }
.about-haz__basis { font-size: var(--text-caption); color: var(--color-text-muted); margin-top: 2px; }
.about-matrix { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.about-matrix__row { display: flex; align-items: flex-start; gap: var(--space-2); }
/* Fixed-width tier pills so every row (heat included) lines up. */
.about-matrix__tier { width: 116px; flex-shrink: 0; font-size: var(--text-caption); padding: 3px var(--space-2); }
.about-matrix__tier::before { display: none; }
.about-matrix__cond { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--color-text-secondary); }
.about-haz__note { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--color-text-muted); margin: var(--space-2) 0 0; }
/* Long, unspaced strings (e.g. the threshold version) must wrap inside the card. */
.about-wrap, .about-wrap .mono { overflow-wrap: anywhere; }

/* Lead cards: producer credit + donation. These come first so the human/support
   zone is read before the collapsed methodology below. */
.about-contact { display: inline-block; margin-top: var(--space-2); font-size: var(--text-label); font-weight: 600; color: var(--color-brand); }
.about-support { border-color: rgba(56, 189, 248, 0.30); }
.about-donate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-brand);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-size: var(--text-label);
  font-weight: 650;
  text-decoration: none;
}
.about-donate:hover { background: var(--color-brand-strong); }
.about-donate__icon { width: 18px; height: 18px; }
.about-support__note { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--color-text-muted); margin: var(--space-2) 0 0; }

/* "How this is calculated" section heading above the collapsed methodology. */
.about-section-head { font-size: var(--text-h2); line-height: var(--lh-h2); font-weight: 620; margin-top: var(--space-2); }

/* Collapsible methodology cards (native <details>): summary leads, body expands.
   Keeps the dense technical detail one tap away instead of dominating the page. */
.about-fold { padding: 0; }
.about-fold__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  cursor: pointer;
  list-style: none;
}
.about-fold__summary::-webkit-details-marker { display: none; }
.about-fold__summary:focus-visible { outline: 2px solid var(--color-brand-strong); outline-offset: -2px; border-radius: var(--radius-lg); }
.about-fold__head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.about-fold__teaser { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--color-text-muted); }
.about-fold__chev { width: 20px; height: 20px; color: var(--color-text-muted); flex-shrink: 0; transition: transform var(--dur) var(--ease); }
.about-fold[open] .about-fold__chev { transform: rotate(180deg); }
.about-fold__body { padding: 0 var(--space-4) var(--space-4); }
.about-fold__body > .about-p:first-child { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .about-fold__chev { transition: none; } }

/* ── 7.11 Briefing tab — Markdown SITREP render ───────────────────── */
.briefing-framed-note {
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}

.briefing-md {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  overflow-wrap: break-word;
}

.briefing-empty {
  color: var(--color-text-muted);
  font-size: var(--text-label);
  margin: 0;
}

.bmd-h1 {
  font-size: var(--text-h1);
  line-height: var(--lh-h1);
  font-weight: 650;
  color: var(--color-text);
  margin: 0 0 var(--space-3);
}

.bmd-h2 {
  font-size: var(--text-h2);
  line-height: var(--lh-h2);
  font-weight: 620;
  color: var(--color-text);
  margin: var(--space-5) 0 var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.bmd-h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.bmd-h3 {
  font-size: var(--text-label);
  line-height: var(--lh-label);
  font-weight: 650;
  color: var(--color-text);
  margin: var(--space-3) 0 var(--space-2);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.bmd-p {
  font-size: var(--text-label);
  line-height: var(--lh-body);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-2);
}

.bmd-list {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-5);
}

.bmd-list li {
  font-size: var(--text-label);
  line-height: var(--lh-body);
  color: var(--color-text-secondary);
  margin: var(--space-1) 0;
}

.bmd-table-wrap {
  overflow-x: auto;
  margin: 0 0 var(--space-2);
  border-radius: var(--radius-sm);
}

.bmd-table {
  border-collapse: collapse;
  font-size: var(--text-caption);
  line-height: var(--lh-caption);
}

.bmd-table th,
.bmd-table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.bmd-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  background: var(--color-surface-2);
}

.bmd-table td {
  color: var(--color-text-secondary);
}

.bmd-table tr:last-child td {
  border-bottom: none;
}

.bmd-table a,
.bmd-p a,
.bmd-list a {
  color: var(--color-brand);
  text-decoration: none;
}

.bmd-table a:hover,
.bmd-p a:hover,
.bmd-list a:hover {
  text-decoration: underline;
}
