/* Navster — Stripe-Dashboard visual pass with Tufte ink discipline.
   Inter sans, deep-navy ink on light blue-grey canvas, indigo accent,
   subtle elevation. Then strip every word/border/box that doesn't
   carry information. App-shell with slide-in drawers.

   The RNP-band palette in js/map.js is the data ink; left untouched. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;

  --fs-xs:    11px;
  --fs-sm:    12px;
  --fs-base:  14px;
  --fs-md:    16px;
  --fs-lg:    20px;
  --fs-xl:    28px;
  --fs-hero:  52px;

  --lh-tight: 1.2;
  --lh-base:  1.45;

  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  24px;
  --sp-6:  32px;
  --sp-7:  48px;

  --bg:        #d9e1ea;   /* canvas — darker so the white card edge reads on every side */
  --surface:   #ffffff;
  --surface-2: #f6f8fb;
  --ink:       #0a2540;
  --ink-2:     #425466;
  --ink-3:     #697386;
  --ink-mute:  #8898aa;
  --line:      #e6ebf1;
  --line-2:    #eef1f6;

  --accent:        #1c4cb3;   /* Navster deep aviation blue */
  --accent-hover:  #163e94;
  --accent-soft:   #e6edf9;
  --accent-ink:    #ffffff;
  --accent-green:  #3ec76b;   /* radar-sweep / success accent */
  --accent-green-soft: #e7f7ec;
  --accent-eng:    #d6336c;
  --accent-dis:    #37b04a;

  --success:    #1ea672;
  --success-bg: #e7f7ef;
  --warning:    #c47d00;
  --warning-bg: #fff6e5;
  --danger:     #cd3d64;
  --danger-bg:  #fdeef2;

  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-pill: 999px;
  --shadow-card: 0 0 0 1px rgba(10,37,64,0.06), 0 1px 3px rgba(10,37,64,0.04);
  --shadow-elev: 0 4px 12px rgba(10,37,64,0.08), 0 0 0 1px rgba(10,37,64,0.06);
  --shadow-pop:  0 10px 24px rgba(10,37,64,0.12), 0 0 0 1px rgba(10,37,64,0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  line-height: var(--lh-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

/* ─── APP BAR ───────────────────────────────────────────────────── */
.app-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  height: 52px;
  z-index: 10;
}
.app-bar h1 {
  margin: 0;
  font-weight: 700;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.app-bar h1.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-logo { display: block; flex: 0 0 auto; }
.brand-name { font-weight: 700; }
.app-bar-spacer { flex: 1; }
.drawer-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease;
}
.drawer-toggle:hover {
  background: var(--surface-2);
  border-color: var(--ink-mute);
  color: var(--ink);
}

/* ─── CANVAS ────────────────────────────────────────────────────── */
/* Left rail (340px) holds the input + RNP trays, stacked. The map +
   timeline get the remaining width. Timeline collapses to 0 pre-analyze. */
.canvas {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: 1fr 240px auto;
  padding: var(--sp-3);
  gap: var(--sp-3);
  min-height: 0;
  background: var(--bg);
}
.canvas .left-rail {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 0;
  overflow-y: auto;
}
.canvas #map         { grid-column: 2; grid-row: 1; }
.canvas #timeline-wrap { grid-column: 2; grid-row: 2; }
.canvas .app-footer  { grid-column: 1 / -1; grid-row: 3; }

.canvas:has(#timeline-wrap[hidden]) { grid-template-rows: 1fr 0 auto; }
.canvas:has(#timeline-wrap[hidden]) #timeline-wrap { display: none; }

/* Tray cards — collapsible, animated. Used for inputs (and as the base
   surface for the hero). The grid-template-rows trick animates between
   `1fr` (open) and `0fr` (collapsed) — height: auto isn't animatable
   directly, but grid implicit min-content is, which is why the inner
   wrapper has overflow:hidden + min-height:0. */
.tray {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  /* No overflow:hidden — would clip dropdown menus (Demo ▾) that extend
     past the bottom edge. The collapsible animation clips via
     .tray-body's max-height + overflow:hidden instead. */
}
.tray-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  user-select: none;
}
.tray-toggle .caret {
  font-size: 10px;
  color: var(--ink-3);
  width: 10px;
  display: inline-block;
  transition: transform 200ms cubic-bezier(.2,.7,.2,1);
}
.tray[data-collapsed="true"] .tray-toggle .caret {
  transform: rotate(-90deg);
}
.tray-body {
  overflow: hidden;
  max-height: 800px;
  transition: max-height 240ms cubic-bezier(.2,.7,.2,1);
}
.tray[data-collapsed="true"] .tray-body {
  max-height: 0;
}
.tray-body > .tray-body-inner {
  padding: 0 var(--sp-4) var(--sp-3) var(--sp-4);
}

/* Inputs tile internal form styling */
.tray-body-inner label {
  display: block;
  margin-top: var(--sp-3);
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.tray-body-inner label:first-child { margin-top: 0; }
.label-hint {
  font-weight: 400;
  color: var(--ink-3);
  font-size: var(--fs-xs);
}
.tray-body-inner textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.45;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}
.tray-body-inner textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tray-body-inner .row {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.tray-body-inner button {
  flex: 1;
  padding: 6px var(--sp-3);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background 100ms ease, border-color 100ms ease, transform 80ms ease;
}
.tray-body-inner button:hover {
  background: var(--surface-2);
  border-color: var(--ink-mute);
}
.tray-body-inner button:active { transform: translateY(1px); }
#analyze-btn {
  background: linear-gradient(180deg, #2a5dc8 0%, var(--accent) 100%);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(28,76,179,0.28), inset 0 1px 0 rgba(255,255,255,0.18);
}
#analyze-btn:hover {
  background: linear-gradient(180deg, #1f54bb 0%, var(--accent-hover) 100%);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(28,76,179,0.38), inset 0 1px 0 rgba(255,255,255,0.18);
}

#missing-fix-panel {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  background: var(--warning-bg);
  border: 1px solid #fae0a8;
  border-radius: var(--radius);
  color: var(--warning);
}
#missing-fix-panel:empty { display: none; }
.error-banner {
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  background: var(--danger-bg);
  border: 1px solid #f3c0cd;
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
}
.error-banner:empty, .error-banner[hidden] { display: none; }

/* Hero section — sits as a card on the canvas */
.hero-section {
  background: transparent;
}

/* Map — full canvas card. `isolation: isolate` keeps Leaflet's internal
   pane z-indices (200/400/600/800) contained — without it they bleed out
   and float above the drawers. */
#map {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  background: var(--surface);
  isolation: isolate;
}

/* Timeline */
#timeline-wrap {
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#timeline-header {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--surface);
}
#timeline-header button {
  border: none;
  background: transparent;
  padding: 0;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
#timeline-header button:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
#timeline-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: var(--sp-2) var(--sp-3);
}
#timeline-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
#brush-overlay {
  position: absolute;
  top: 4px; bottom: 4px;
  pointer-events: none;
  background: rgba(28,76,179,0.10);
  border-left: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  display: none;
}

/* Footer — debug only, collapsed into a <details> by default */
.app-footer {
  background: transparent;
  padding: 0;
}
.status-details {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.status-details > summary {
  list-style: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--ink-mute);
  padding: var(--sp-1) var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
  display: inline-block;
}
.status-details > summary::-webkit-details-marker { display: none; }
.status-details > summary::marker { content: ""; }
.status-details > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 4px;
  transition: transform 150ms ease;
}
.status-details[open] > summary::before { transform: rotate(90deg); }
.status-details[open] {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: var(--sp-2) var(--sp-3);
  display: block;
}
.app-footer .status {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  white-space: pre-wrap;
  margin: 0;
  display: block;
  padding-top: var(--sp-1);
}

/* ─── DRAWERS ───────────────────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--surface);
  z-index: 1100;
  box-shadow: var(--shadow-pop);
  transition: transform 220ms cubic-bezier(.2,.7,.2,1);
  display: flex;
  flex-direction: column;
}
.drawer.drawer-left { left: 0; transform: translateX(-100%); }
.drawer.drawer-right { right: 0; transform: translateX(100%); }
.drawer[data-open="true"] { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: 0 0 auto;
}
.drawer-head h2 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  display: block;
}
.drawer-head h2::before { content: none; }
.drawer-close {
  background: transparent;
  border: none;
  font-size: var(--fs-md);
  color: var(--ink-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.drawer-close:hover {
  color: var(--ink);
  background: var(--surface-2);
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
}

/* Right-drawer tabs */
.drawer-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
}
.drawer-tabs button {
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 100ms ease, border-color 100ms ease;
}
.drawer-tabs button:hover { color: var(--ink); }
.drawer-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

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

/* Scrim (overlays the canvas when a drawer is open) */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(10,37,64,0.35);
  z-index: 1090;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.drawer-scrim.active {
  opacity: 1;
  pointer-events: auto;
}

/* Drawer-body sections inherit aside.panel-like styles */
.drawer-body section {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line-2);
}
.drawer-body section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.drawer-body section h2 {
  margin: 0 0 var(--sp-2) 0;
  font-weight: 700;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.drawer-body section h2::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
}
.drawer-body section h3 {
  margin: var(--sp-3) 0 var(--sp-1) 0;
  font-weight: 500;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

/* ─── LIBRARY (in left drawer) ──────────────────────────────────── */
#library-list .trial-row {
  margin-bottom: 0;
  padding: var(--sp-2) var(--sp-1);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-2);
  border-radius: 0;
  font-size: var(--fs-sm);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-2);
  align-items: center;
}
#library-list .trial-row:hover { background: var(--surface-2); }
#library-list .trial-row .meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
#library-list .trial-row .actions { display: inline-flex; gap: var(--sp-2); }
#library-list .trial-row button {
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 2px 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
#library-list .trial-row button:hover { background: var(--surface-2); }
#library-list .trial-row.overlay-active {
  background: var(--accent-soft);
  border-bottom-color: var(--accent);
}

/* ─── ARTIFACT ROWS ─────────────────────────────────────────────── */
.artifact-list .artifact-row {
  margin-bottom: 0;
  padding: var(--sp-2) var(--sp-1);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-2);
  border-radius: 0;
  font-size: var(--fs-sm);
}
.artifact-list .artifact-row.disabled { opacity: 0.45; }
.artifact-list .artifact-row .head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-2);
}
.artifact-list .artifact-row .kind {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink);
}
.artifact-list .artifact-row .kind-departure { color: var(--warning); }
.artifact-list .artifact-row .kind-arrival { color: var(--warning); }
.artifact-list .artifact-row .kind-procedure-turn { color: #6b2bb8; }
.artifact-list .artifact-row .kind-off-route { color: var(--danger); }
.artifact-list .artifact-row .time {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-feature-settings: 'tnum';
}
.artifact-list .artifact-row .reason {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
}
.artifact-list .artifact-row .sliders {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: var(--sp-1);
  margin-top: var(--sp-2);
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.artifact-list .artifact-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* ─── CANDIDATE CARDS ───────────────────────────────────────────── */
.engagement-list .candidate-card {
  margin-bottom: 0;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) 10px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-2);
  border-left: 3px solid transparent;
  border-radius: 0;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background 100ms ease;
}
.engagement-list .candidate-card:hover { background: var(--surface-2); }
.engagement-list .candidate-card.selected {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.engagement-list .candidate-card.low-confidence {
  border-left-color: var(--warning);
}
.engagement-list .candidate-card.gap-row {
  background: repeating-linear-gradient(45deg,
    var(--surface-2) 0, var(--surface-2) 6px, var(--surface) 6px, var(--surface) 12px);
  border-left-style: dashed;
}
.engagement-list .candidate-card .rank {
  font-weight: 700;
  display: inline-block;
  width: 22px;
  color: var(--ink-mute);
  font-feature-settings: 'tnum';
}
.engagement-list .candidate-card .time {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  font-feature-settings: 'tnum';
}
.engagement-list .candidate-card .meta {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  margin-top: 2px;
  line-height: 1.4;
}
.engagement-list .candidate-card .flag {
  display: inline-block;
  background: var(--warning-bg);
  color: var(--warning);
  font-weight: 600;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: var(--sp-1);
}

/* ─── HEADLINE CARD (the hero on canvas) ────────────────────────── */
#headline-card {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  font-size: var(--fs-sm);
}
#headline-card .row {
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
  margin: var(--sp-1) 0;
}
#headline-card .label {
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
#headline-card .num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink);
  font-feature-settings: 'tnum';
}
#headline-card .small {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-feature-settings: 'tnum';
}
#headline-card .caveat {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border-left: 3px solid var(--ink-mute);
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  font-size: var(--fs-xs);
}
#headline-card .warn {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  color: var(--warning);
}
#headline-card .group-title {
  margin-top: var(--sp-4);
  font-weight: 700;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border-bottom: 1px solid var(--line-2);
  padding-bottom: var(--sp-1);
}

/* Hero number — left-aligned, compact, with the meta beside it */
#headline-card .rnp-hero {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin: 0 0 var(--sp-2) 0;
}
#headline-card .rnp-achieved-num {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-feature-settings: 'tnum', 'cv11';
  color: var(--ink);
}
#headline-card .rnp-hero-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  line-height: 1.35;
}
#headline-card .rnp-hero-meta .rnp-hero-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* "Time in band" subsection label */
#headline-card .hero-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: var(--sp-3) 0 var(--sp-1) 0;
}

/* The bar + labels + key live inside a constrained block so segment
   proportions remain visually comparable instead of stretching across
   the entire canvas width. */
.rnp-bar-block {
  max-width: 640px;
}

#headline-card .rnp-bar {
  display: flex;
  height: 16px;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 0 0 4px 0;
  background: var(--line-2);
  box-shadow: inset 0 0 0 1px rgba(10,37,64,0.04);
}
#headline-card .rnp-bar-band { height: 100%; min-width: 0; }

#headline-card .rnp-bar-labels {
  display: flex;
  margin: 0 0 var(--sp-2) 0;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  font-feature-settings: 'tnum';
}
#headline-card .rnp-bar-label {
  min-width: 0;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  padding: 0 2px;
}

/* MagNav duration line — just the duration; timestamps live in the drawer */
.eng-chain {
  margin: var(--sp-3) 0 0 0;
  padding: var(--sp-3) 0 0 0;
  border-top: 1px solid var(--line-2);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.eng-chain-text strong {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  color: var(--ink);
  font-weight: 600;
  margin-right: 4px;
}
.eng-chain-warn { color: var(--warning); font-weight: 500; }

/* Band table — properly labeled key with column headers */
#headline-card .rnp-band-table {
  width: 100%;
  max-width: 640px;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  border-collapse: collapse;
  font-feature-settings: 'tnum';
}
#headline-card .rnp-band-table th {
  text-align: left;
  padding: 2px var(--sp-1);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
#headline-card .rnp-band-table th.time,
#headline-card .rnp-band-table th.pct { text-align: right; }
#headline-card .rnp-band-table td {
  padding: 3px var(--sp-1);
  vertical-align: middle;
  border-bottom: 1px solid var(--line-2);
  color: var(--ink-2);
}
#headline-card .rnp-band-table tr:last-child td { border-bottom: none; }
#headline-card .rnp-band-table td.swatch { width: 14px; }
#headline-card .rnp-band-table td.swatch span {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: none;
  border-radius: 2px;
  vertical-align: middle;
}
#headline-card .rnp-band-table td.label { width: 5em; color: var(--ink-2); }
#headline-card .rnp-band-table td.label-m {
  width: 6em;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
#headline-card .rnp-band-table td.minutes {
  text-align: right;
  width: 5em;
  color: var(--ink);
  font-weight: 500;
  font-family: var(--font-mono);
}
#headline-card .rnp-band-table td.pct {
  text-align: right;
  width: 4em;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

/* ─── SPECTRAL ──────────────────────────────────────────────────── */
#spectral-table {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--ink);
  font-feature-settings: 'tnum';
}
#spectral-table table { width: 100%; border-collapse: collapse; }
#spectral-table th, #spectral-table td {
  padding: var(--sp-1) var(--sp-2);
  text-align: right;
  border-bottom: 1px solid var(--line-2);
}
#spectral-table th {
  background: transparent;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}
#spectral-table tr.aggregate td {
  font-weight: 700;
  background: var(--accent-soft);
  border-top: 1px solid var(--accent);
  color: var(--ink);
}
#spectral-psd {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  max-height: 200px;
  overflow-y: auto;
}
#spectral-psd .seg {
  border-bottom: 1px dashed var(--line);
  padding-bottom: var(--sp-1);
  margin-bottom: var(--sp-1);
}

/* ─── COMPARE ───────────────────────────────────────────────────── */
#coord-compare {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 500;
}
#coord-compare:empty { display: none; }
#coord-compare.good { background: var(--success-bg); color: var(--success); }
#coord-compare.bad  { background: var(--danger-bg); color: var(--danger); }

/* Stats list — used in Compare tab for the demoted envelope numbers */
.stats-list {
  display: flex;
  flex-direction: column;
}
.stats-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line-2);
  font-size: var(--fs-sm);
}
.stats-item:last-child { border-bottom: none; }
.stats-label { color: var(--ink-3); }
.stats-value {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
  color: var(--ink);
  font-weight: 500;
  text-align: right;
}
.glyph-eng { color: var(--accent-eng); margin-right: 4px; }
.glyph-dis { color: var(--accent-dis); margin-right: 4px; }

/* ─── MODE (radios) ─────────────────────────────────────────────── */
#mode-section label { margin-right: var(--sp-4); font-weight: normal; }
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-1);
}
.radio-row label {
  display: inline-flex !important;
  align-items: center;
  gap: var(--sp-1);
  margin: 0 !important;
  font-weight: normal !important;
  font-size: var(--fs-sm);
  color: var(--ink);
}
.radio-row label.disabled,
.radio-row label:has(input:disabled) {
  opacity: 0.4;
  cursor: not-allowed;
}
.radio-row input[type="radio"] { accent-color: var(--accent); }

/* Coord input row (inside Compare tab) */
.drawer-body .inline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.drawer-body .inline input[type="number"] {
  width: 100%;
  padding: 6px var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--ink);
}
.drawer-body .inline input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ─── MAP LEGEND ────────────────────────────────────────────────── */
.legend-svg {
  position: absolute;
  bottom: var(--sp-4);
  right: var(--sp-4);
  background: rgba(255,255,255,0.96);
  padding: var(--sp-2) var(--sp-3);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-elev);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink);
  z-index: 1000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Map markers — preserved data colors */
.engagement-marker,
.disengagement-marker {
  color: white !important;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.3;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  font-feature-settings: 'tnum';
}
.engagement-marker { background: var(--accent-eng) !important; }
.disengagement-marker { background: var(--accent-dis) !important; }

/* ─── DROPDOWNS (Library actions) ───────────────────────────────── */
.dropdown-row { position: relative; z-index: 5; display: flex; gap: var(--sp-2); }
.dropdown { position: relative; flex: 1; }
.dropdown > summary {
  list-style: none;
  cursor: pointer;
  padding: 6px var(--sp-3);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
  user-select: none;
  transition: background 100ms ease, border-color 100ms ease;
}
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::marker { content: ""; }
.dropdown > summary:hover {
  background: var(--surface-2);
  border-color: var(--ink-mute);
}
.dropdown[open] > summary {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: var(--sp-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-pop);
}
.dropdown-menu button {
  flex: none;
  text-align: left;
  padding: 6px var(--sp-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--ink);
  cursor: pointer;
}
.dropdown-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

#advanced-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: var(--sp-1) 0;
}

/* ─── RESPONSIVE (drawers become bottom-sheets on narrow viewports) ─ */
@media (max-width: 900px) {
  .drawer {
    width: 100vw;
    max-width: 100vw;
    top: auto;
    bottom: 0;
    height: 70vh;
    transform: translateY(100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .drawer.drawer-left { left: 0; transform: translateY(100%); }
  .drawer.drawer-right { right: 0; transform: translateY(100%); }
  .drawer[data-open="true"] { transform: translateY(0); }
  /* On narrow screens, stack rail + map vertically */
  .canvas {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr 240px auto;
  }
  .canvas .left-rail { grid-column: 1; grid-row: 1; }
  .canvas #map { grid-column: 1; grid-row: 2; }
  .canvas #timeline-wrap { grid-column: 1; grid-row: 3; }
  .canvas .app-footer { grid-column: 1; grid-row: 4; }
}

/* ─── PRINT — hide chrome, show the hero + map only ─────────────── */
@media print {
  .app-bar, .drawer, .drawer-scrim, .app-footer,
  .inputs-tile, .drawer-toggle, #timeline-wrap {
    display: none !important;
  }
  body, .canvas, .left-rail, #map, #headline-card {
    background: white !important;
    box-shadow: none !important;
  }
  .canvas {
    display: block;
    padding: 0;
    height: auto;
  }
  #headline-section { display: block !important; }
  #map { page-break-after: always; height: 90vh; }
}
