/* Dark is the default; index.html stamps data-theme on <html> before first
   paint so a light-theme reload never flashes dark. Map colours cannot live
   here — MapLibre takes literal colours — they are in js/theme.js. */
:root {
  --bg: #0a0e14;
  --panel: rgba(13, 18, 26, 0.82);
  --panel-solid: #0d121a;
  --line: rgba(120, 160, 200, 0.16);
  --line-bright: rgba(120, 200, 255, 0.35);
  --text: #c9d6e2;
  --text-dim: #6b7d92;
  --muted: #9aa7b5;
  --accent: #0affef;
  --accent-2: #ffd60a;
  --threat: #ff375f;
  --ok: #30d158;
  /* control surfaces: buttons, inputs, cards */
  --surface: #131a26;
  --surface-hover: #172030;
  --surface-sunken: #101722;
  --switch-off: #1a2230;
  --on-strong: #fff;
  --shadow: rgba(0, 0, 0, 0.45);
  /* Channel triplets for the tinted rgba() below: only the hue follows the
     theme, each rule keeps its own alpha. */
  --accent-rgb: 10, 239, 239;
  --accent2-rgb: 255, 214, 10;
  --threat-rgb: 255, 55, 95;
  --good-rgb: 46, 230, 166;
  --text-strong: #eaf2fb;
  --hover-rgb: 120, 160, 200;
  --ground-rgb: 8, 11, 16;
  --overlay-rgb: 255, 255, 255;
  --offline-bg: rgba(40, 10, 16, 0.95);
  --accent-panel: rgba(10, 30, 38, 0.92);
  --toast-glow: rgba(109, 255, 176, 0.2);
  --toast: #6dffb0;
  --toast-bg: rgba(10, 30, 22, 0.95);
  --warn: #ffb340;
  --warn-bg: rgba(255, 179, 64, 0.12);
  --danger: #ff6b81;
  --danger-bg: rgba(255, 55, 95, 0.12);
  --good: #2ee6a6;
  --badge: #f6d365;
  --badge-line: rgba(246, 211, 101, .55);
  --selected-line: #fff;
  --selected-glow: rgba(255, 255, 255, .25);
  --mono: "SFMono-Regular", "JetBrains Mono", "Consolas", ui-monospace, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}

/* Light is not the dark palette inverted: neon accents vanish on white, so the
   accent hues are re-picked darker to keep their contrast against --panel. */
:root[data-theme="light"] {
  --bg: #eef2f6;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --line: rgba(30, 60, 90, 0.18);
  --line-bright: rgba(10, 90, 140, 0.42);
  --text: #16202c;
  --text-dim: #5a6b7d;
  --muted: #6b7a8a;
  --accent: #0077a3;
  --accent-2: #9a7500;
  --threat: #e0102f;
  --ok: #1a9c46;
  --surface: #f3f6fa;
  --surface-hover: #e5ecf3;
  --surface-sunken: #e9eef4;
  --switch-off: #c7d0da;
  --on-strong: #fff;
  --shadow: rgba(20, 40, 70, 0.18);
  --accent-rgb: 0, 119, 163;
  --accent2-rgb: 154, 117, 0;
  --threat-rgb: 224, 16, 47;
  --good-rgb: 13, 143, 82;
  --text-strong: #0b1420;
  --hover-rgb: 60, 100, 140;
  --ground-rgb: 255, 255, 255;
  --overlay-rgb: 20, 40, 70;
  --offline-bg: rgba(255, 232, 235, 0.97);
  --accent-panel: rgba(232, 244, 250, 0.96);
  --toast-glow: rgba(13, 107, 63, 0.18);
  --toast: #0d6b3f;
  --toast-bg: rgba(222, 245, 232, 0.97);
  --warn: #9a5b00;
  --warn-bg: rgba(255, 179, 64, 0.20);
  --danger: #c0182f;
  --danger-bg: rgba(224, 16, 47, 0.12);
  --good: #0d8f52;
  --badge: #8a6300;
  --badge-line: rgba(154, 99, 0, .45);
  --selected-line: #0077a3;
  --selected-glow: rgba(0, 119, 163, .25);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body { font-family: var(--sans); color: var(--text); -webkit-font-smoothing: antialiased; }

#map { position: absolute; inset: 0; }

/* MapLibre dark tuning */
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { opacity: 0.35; font-size: 10px; }
.maplibregl-popup-content {
  background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-bright);
  border-radius: 4px; font-family: var(--mono); font-size: 11px; padding: 10px 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.maplibregl-popup-tip { border-top-color: var(--line-bright) !important; border-bottom-color: var(--line-bright) !important; }
.maplibregl-popup-content b { color: var(--accent); }

/* ---- Top HUD bar ---- */
.hud-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 44px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: linear-gradient(180deg, rgba(var(--ground-rgb), 0.95), rgba(var(--ground-rgb), 0.75));
  border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
}
.hud-brand { display: flex; align-items: center; gap: 10px; }
.hud-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }
.hud-brand .title { font-family: var(--mono); font-size: 13px; letter-spacing: 2px; font-weight: 600; }
.hud-brand .ver { font-family: var(--mono); font-size: 10px; color: var(--text-dim);
  border: 1px solid var(--line); padding: 1px 5px; border-radius: 3px; }

.hud-readout { display: flex; gap: 22px; font-family: var(--mono); }
.hud-readout .ro { display: flex; flex-direction: column; line-height: 1.15; }
.hud-readout label { font-size: 8.5px; letter-spacing: 1.5px; color: var(--text-dim); }
.hud-readout b { font-size: 12px; font-weight: 500; }
.hud-readout .threat b { color: var(--ok); }
.hud-readout .threat.hot b { color: var(--threat); text-shadow: 0 0 8px rgba(var(--threat-rgb), 0.6); }

.hud-right { display: flex; align-items: center; gap: 14px; }
.hud-clock { font-family: var(--mono); font-size: 11px; color: var(--text-dim); letter-spacing: 1px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono);
  font-size: 10px; letter-spacing: 1.2px; color: var(--ok);
  border: 1px solid rgba(var(--good-rgb), 0.35); border-radius: 3px; padding: 3px 7px; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.status.off { color: var(--threat); border-color: rgba(var(--threat-rgb), 0.4); }
.status.off i { background: var(--threat); }

.offline-note {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 26;
  background: var(--offline-bg); border: 1px solid var(--threat); border-radius: 5px;
  color: var(--text); font-size: 12px; line-height: 1.6; padding: 10px 16px; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.offline-note b { color: var(--threat); }
.offline-note code { font-family: var(--mono); font-size: 11px; background: rgba(var(--overlay-rgb), 0.07);
  padding: 1px 5px; border-radius: 3px; }

/* ---- Left panel: docked flush to the screen edge, not a floating card.
   Collapsed = a slim icon-only strip (~30px) permanently attached at left:0.
   Opens either by pinning (the « button) or by hovering over the strip. ---- */
.panel {
  position: absolute; top: 50%; left: 0; transform: translateY(-50%); z-index: 15;
  width: min(var(--panel-width, 264px), calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-left: none;
  border-radius: 0 6px 6px 0;
  backdrop-filter: blur(12px); box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  max-height: calc(100vh - 100px); display: flex; flex-direction: column;
  transition: width .18s ease;
}
.panel.collapsed { width: 30px; box-shadow: none; }
.panel.resizing { transition: none; user-select: none; }
/* Hovering a collapsed (unpinned) panel peeks it open, pure CSS — no JS state. */
.panel.collapsed:hover { width: min(var(--panel-width, 264px), calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }

.panel-resize-handle {
  position: absolute; top: 0; right: -5px; z-index: 2; width: 10px; height: 100%;
  cursor: ew-resize; touch-action: none;
}
.panel-resize-handle::after {
  content: ""; position: absolute; top: 12px; bottom: 12px; left: 4px; width: 2px;
  border-radius: 2px; background: transparent; transition: background .12s, box-shadow .12s;
}
.panel-resize-handle:hover::after,
.panel-resize-handle:focus-visible::after,
.panel.resizing .panel-resize-handle::after { background: var(--accent); box-shadow: 0 0 7px rgba(var(--accent-rgb), .65); }
.panel-resize-handle:focus-visible { outline: none; }
.panel.collapsed .panel-resize-handle { display: none; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--text-dim);
  padding: 12px 14px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.panel-head button { background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 15px; line-height: 1; flex: 0 0 auto; transition: transform .2s ease; }
.panel-head button:hover { color: var(--text); }
.panel.collapsed .panel-head button { transform: rotate(180deg); }
.panel.collapsed:not(:hover) .panel-head { justify-content: center; padding: 12px 0 8px; }
.panel.collapsed:not(:hover) .panel-title { display: none; }

/* Nav rows double as the section switcher — icon+label when open, icon-only
   (with a native tooltip via `title`) while collapsed. */
.panel-nav { display: flex; flex-direction: column; padding: 6px; gap: 2px;
  border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 5px;
  background: none; border: 1px solid transparent; color: var(--text-dim); cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; text-align: left; transition: all .12s; white-space: nowrap;
}
.nav-item:hover { background: rgba(var(--hover-rgb), 0.08); color: var(--text); }
.nav-item.active { background: rgba(var(--accent-rgb), 0.12); border-color: var(--accent); color: var(--accent); }
.nav-icon { flex: 0 0 auto; font-size: 15px; line-height: 1; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.panel.collapsed:not(:hover) .nav-item { justify-content: center; padding: 8px 0; }
.panel.collapsed:not(:hover) .nav-label { display: none; }

.panel-content { overflow: hidden; flex: 1 1 auto; display: flex; flex-direction: column; }
.panel.collapsed:not(:hover) .panel-content { display: none; }
.panel-section { overflow-y: auto; }
.panel-body { padding: 8px 12px 14px; }

.field-label { font-family: var(--mono); font-size: 8.5px; letter-spacing: 1.6px; color: var(--text-dim);
  text-transform: uppercase; margin: 2px 6px 6px; }
.panel-divider { border: none; border-top: 1px solid var(--line); margin: 12px 0; }

.action-btn { width: 100%; margin-top: 8px; font-family: var(--mono); font-size: 11px;
  padding: 9px 6px; border-radius: 4px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); cursor: pointer; transition: all .12s; }
.action-btn:hover { border-color: var(--line-bright); background: var(--surface-hover); }
.action-btn.active { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.algorithm-picker { display: grid; gap: 6px; margin-top: 12px; padding: 9px; border: 1px solid var(--line); border-radius: 5px; background: rgba(var(--ground-rgb), .55); }
.algorithm-picker .field-label { margin-bottom: 1px; }
.algorithm-option { display: grid; grid-template-columns: auto 1fr auto; gap: 7px; align-items: center; padding: 5px 6px; border-radius: 4px; cursor: pointer; }
.algorithm-option:hover { background: rgba(var(--accent-rgb), .08); }
.algorithm-option input { accent-color: var(--accent); }
.algorithm-option span { color: var(--text); font: 12px var(--mono); }
.algorithm-option small { color: var(--text-dim); font-size: 10px; }
.calc-route-btn { width: 100%; margin-top: 12px; font-family: var(--mono); font-size: 12px;
  font-weight: 600; letter-spacing: 1px; padding: 12px 6px; border-radius: 5px;
  background: rgba(var(--accent-rgb), 0.1); color: var(--accent); border: 1px solid var(--accent);
  cursor: pointer; transition: all .12s; }
.calc-route-btn:hover { background: rgba(var(--accent-rgb), 0.2); }
.calc-route-btn:active { transform: scale(0.98); }
.planner-settings-link { display: block; margin-top: 8px; padding: 7px 4px; color: var(--text-dim);
  font-family: var(--mono); font-size: 9px; letter-spacing: .3px; text-align: center;
  text-decoration: none; }
.planner-settings-link:hover { color: var(--accent); }

.layer-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 4px;
  cursor: pointer; transition: background .12s;
}
.layer-row:hover { background: rgba(var(--hover-rgb), 0.06); }
.layer-row .sw { width: 26px; height: 15px; border-radius: 8px; background: var(--switch-off);
  position: relative; flex: 0 0 auto; transition: background .15s; border: 1px solid var(--line); }
.layer-row .sw::after { content:""; position:absolute; top:1px; left:1px; width:11px; height:11px;
  border-radius:50%; background: var(--text-dim); transition: transform .15s, background .15s; }
.layer-row.on .sw { background: rgba(var(--accent-rgb), 0.25); border-color: var(--accent); }
.layer-row.on .sw::after { transform: translateX(11px); background: var(--accent); }
.layer-row .lbl { flex: 1; font-size: 12.5px; }
.layer-row .info { flex: 0 0 auto; width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--line-bright); color: var(--text-dim); font-size: 10px; font-style: italic;
  font-family: Georgia, serif; line-height: 13px; text-align: center; cursor: help; }
.layer-row .info:hover { color: var(--accent); border-color: var(--accent); }
.layer-row .grp { font-family: var(--mono); font-size: 8px; letter-spacing: 1px; color: var(--text-dim);
  text-transform: uppercase; }
.layer-row input[type=range] { width: 54px; accent-color: var(--accent); }

.grp-head { font-family: var(--mono); font-size: 8.5px; letter-spacing: 1.6px; color: var(--text-dim);
  text-transform: uppercase; margin: 10px 6px 3px; padding-top: 6px;
  border-top: 1px solid rgba(var(--hover-rgb), 0.09); }
.grp-head:first-child { margin-top: 2px; border-top: none; padding-top: 0; }
.layer-row.off-line { opacity: 0.45; cursor: not-allowed; }

/* Merged "add SAM + type" dropdown-button */
.sam-dd-wrap { position: relative; margin-bottom: 8px; }
.sam-dd { width: 100%; display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 4px;
  padding: 9px 10px; font-family: var(--mono); font-size: 11.5px; text-align: left; }
.sam-dd:hover { border-color: var(--line-bright); }
.sam-dd.active { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.sam-dd b { color: var(--accent); }
.sam-dd .caret { margin-left: auto; color: var(--text-dim); }

.sam-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--panel-solid); border: 1px solid var(--line-bright); border-radius: 5px;
  padding: 4px; max-height: 260px; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.6); }
.sam-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px;
  cursor: pointer; font-family: var(--mono); font-size: 11.5px; }
.sam-opt:hover { background: rgba(var(--hover-rgb), 0.12); }
.sam-opt .chip { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.sam-opt .nm { flex: 1; }
.sam-opt .rg { color: var(--text-dim); font-size: 10px; }

.toggle-row { display:flex; align-items:center; justify-content: space-between; font-size: 12.5px;
  padding: 4px 6px; cursor: pointer; }
.toggle-row input { accent-color: var(--accent); }
.hint { font-size: 10.5px; color: var(--text-dim); margin: 0 6px; padding-top: 12px; line-height: 1.4; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
/* One button per row, for the actions that stand alone. */
.tool { font-family: var(--mono); font-size: 11px; padding: 8px 6px; border-radius: 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); cursor: pointer;
  transition: all .12s; }
.tool:hover { border-color: var(--line-bright); background: var(--surface-hover); }
.tool.active { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tool.danger:hover { border-color: var(--threat); color: var(--threat); }

/* ---- Legend ---- */
/* The inspect button is the payoff of a long wait — it gets a glow so it is
   obviously the next thing to press. */
.action-btn.inspect-cta { border-color: rgba(var(--accent2-rgb), 0.55); color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(var(--accent2-rgb), 0.15) inset, 0 0 12px rgba(var(--accent2-rgb), 0.18); }
.action-btn.inspect-cta:hover { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(var(--accent2-rgb), 0.3) inset, 0 0 18px rgba(var(--accent2-rgb), 0.3); }

.sam-dd.danger { color: var(--danger); border-color: rgba(var(--threat-rgb), 0.3); }
.sam-opt.is-empty { opacity: 0.5; cursor: default; }
/* Screen-reader/label-only text inside the algorithm picker. */
.sr-hint { opacity: 0.55; }

.legend {
  position: absolute; bottom: 22px; right: 12px; z-index: 15; min-width: 150px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; backdrop-filter: blur(12px); font-family: var(--mono); font-size: 10px;
}
.legend h4 { margin: 0; font-size: 9px; letter-spacing: 1.5px; color: var(--text-dim); font-weight: 500; }
.legend-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.legend-body { margin-top: 8px; }
.legend-head button { background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px; transition: transform .2s ease; }
.legend-head button:hover { color: var(--accent); }
.legend.collapsed { min-width: 0; }
.legend.collapsed .legend-body { display: none; }
.legend.collapsed .legend-head button { transform: rotate(180deg); }
/* Suppress the hover-peek until the pointer has left once — see panel.js. */
.panel.collapsed.no-peek:hover { width: 30px; box-shadow: none; }
.panel.collapsed.no-peek:hover .panel-head { justify-content: center; padding: 12px 0 8px; }
.panel.collapsed.no-peek:hover .panel-title,
.panel.collapsed.no-peek:hover .nav-label,
.panel.collapsed.no-peek:hover .panel-content { display: none; }
.panel.collapsed.no-peek:hover .nav-item { justify-content: center; padding: 8px 0; }
.legend .item { display: flex; align-items: center; gap: 8px; padding: 2px 0; color: var(--text); }
.legend .chip { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.legend-section-title { margin: 8px 0 3px; color: var(--text-dim); font-size: 8px; letter-spacing: 1.2px; }
.legend-section-title:first-child { margin-top: 0; }
.legend .route-chip { width: 18px; height: 4px; border-radius: 2px; flex: 0 0 auto; background: var(--route-color); }
.legend .route-chip.dashed { background: repeating-linear-gradient(90deg, var(--route-color) 0 5px, transparent 5px 8px); }

/* Fullscreen catalog overlay for browsing and editing SAM types. */
body.sam-catalog-fullscreen-open .hud-bar,
body.sam-catalog-fullscreen-open .panel,
body.sam-catalog-fullscreen-open .legend,
body.sam-catalog-fullscreen-open .offline-note,
body.sam-catalog-fullscreen-open .draw-banner { display: none; }

.sam-catalog-fullscreen-modal {
  position: fixed; inset: 0; z-index: 100;
  display: block; background: rgba(var(--ground-rgb), 0.94); padding: 18px;
}
.sam-catalog-fullscreen-modal[hidden] { display: none; }
.sam-catalog-fullscreen-window {
  height: 100%; border: 1px solid var(--line-bright);
  border-radius: 9px; box-shadow: 0 20px 70px rgba(0,0,0,.72);
  background: var(--panel-solid); display: flex; flex-direction: column;
}
.sam-catalog-fullscreen-head {
  flex: 0 0 48px; z-index: 110;
  display: flex; align-items: center; gap: 14px;
  padding: 0 12px 0 16px; border-bottom: 1px solid var(--line-bright);
  background: rgba(var(--ground-rgb), 0.96); color: var(--accent);
  font: 10px var(--mono); letter-spacing: 1.5px;
}
/* The title must be allowed to shrink; without this a long one pushed the
   tools past the right edge instead of ellipsing. */
#sam-catalog-fullscreen-title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sam-catalog-fullscreen-tools { display: flex; align-items: center; gap: 14px; margin-left: auto; min-width: 0; }
.sam-catalog-fullscreen-count { color: var(--text-dim); font: 9px var(--mono); letter-spacing: 1px; white-space: nowrap; }
.sam-catalog-create-btn { padding: 6px 10px; border: 1px solid var(--accent); border-radius: 4px;
  background: rgba(var(--accent-rgb), .08); color: var(--accent); cursor: pointer;
  font: 9px var(--mono); letter-spacing: .4px; line-height: 1.2; white-space: nowrap; flex: 0 0 auto; }
.sam-catalog-create-btn:hover { background: rgba(var(--accent-rgb), .2); }
/* Scoped to the CLOSE button by id. As `.sam-catalog-fullscreen-head button`
   it also hit the create button — which sits in the same head — and forced
   "＋ Створити новий тип" into a 26x26 icon box, so its label spilled over the
   count beside it. Specificity is why: (0,1,1) beat .sam-catalog-create-btn's
   (0,1,0), whatever the source order. */
#sam-catalog-fullscreen-close {
  width: 26px; height: 26px; flex: 0 0 auto; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 4px;
  background: transparent; color: var(--text-dim); cursor: pointer; font-size: 18px; line-height: 1;
}
#sam-catalog-fullscreen-close:hover { color: var(--text); border-color: var(--accent); }
/* min-height:0 is what actually lets a flex child scroll instead of growing
   the window past the viewport. */
.sam-catalog-fullscreen-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 18px; }
body.sam-catalog-fullscreen-open .sam-details-modal { z-index: 150; }
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 0;
}
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card {
  display: flex; flex-direction: column; gap: 12px; min-height: 310px; padding: 12px;
}
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-photo {
  width: 100%; height: 132px;
}
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-body { flex: 1; }
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-body .nm { font-size: 14px; }
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-body .mini { font-size: 10px; }
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-details {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; margin-top: 12px;
}
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-details div {
  min-width: 0; padding-top: 6px; border-top: 1px solid var(--line);
}
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-details span {
  display: block; color: var(--text-dim); font: 8px var(--mono); letter-spacing: .5px; text-transform: uppercase;
}
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-details b {
  display: block; overflow: hidden; color: var(--text); font: 10px var(--mono); text-overflow: ellipsis; white-space: nowrap;
}
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-actions {
  flex-direction: row; justify-content: stretch;
}
body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-card-actions button { flex: 1; padding: 7px 8px; }
@media (max-width: 1100px) {
  body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
  body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body { padding: 10px; }
  body.sam-catalog-fullscreen-open .sam-catalog-fullscreen-body .catalog-grid { grid-template-columns: 1fr; }
}

/* ---- Drawing-mode banner ---- */
.draw-banner {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 25;
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.2px;
  padding: 7px 16px; border-radius: 4px; color: var(--accent);
  background: var(--accent-panel); border: 1px solid var(--accent);
  box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.25); pointer-events: none;
  animation: banner-in .18s ease;
}
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -6px); } }

/* ---- Toast (top-right confirmation) ---- */
.toast {
  position: absolute; top: 64px; right: 16px; z-index: 60;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.6px;
  padding: 9px 16px; border-radius: 4px; color: var(--toast);
  background: var(--toast-bg); border: 1px solid var(--toast);
  box-shadow: 0 0 20px var(--toast-glow);
  animation: toast-in .18s ease;
}
.toast.hide { animation: toast-out .18s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(8px); } }

.maplibregl-popup-content .k { color: var(--text-dim); }
.maplibregl-popup-content .pick-head { color: var(--text-dim); margin-bottom: 6px; }
.maplibregl-popup-content .pick { display: flex; align-items: center; gap: 8px; padding: 5px 4px;
  cursor: pointer; border-radius: 4px; }
.maplibregl-popup-content .pick:hover { background: rgba(var(--hover-rgb), 0.12); color: var(--accent); }
.maplibregl-popup-content .pick .chip { width: 10px; height: 10px; border-radius: 2px; }

/* Popup actions (SAM delete / move hint) */
.maplibregl-popup-content .pop-actions { margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px; }

.maplibregl-popup-content .more-info, .maplibregl-popup-content .del,
.maplibregl-popup-content .ready {
  border: none; border-radius: 4px; padding: 5px 8px; cursor: pointer;
  font-family: var(--mono); font-size: 11px; transition: all 0.12s;
}

.maplibregl-popup-content .more-info { background: rgba(var(--accent-rgb), 0.12); color: var(--accent);
  border: 1px solid var(--accent); }
.maplibregl-popup-content .more-info:hover { background: rgba(var(--accent-rgb), 0.25); }

.maplibregl-popup-content .ready { background: var(--warn-bg); color: var(--warn);
  border: 1px solid rgba(255,179,64,0.4); }
.maplibregl-popup-content .ready:hover { background: rgba(255,179,64,0.25); color: var(--on-strong); }

.maplibregl-popup-content .del { background: var(--danger-bg); color: var(--danger);
  border: 1px solid rgba(var(--threat-rgb), 0.4); }
.maplibregl-popup-content .del:hover { background: rgba(var(--threat-rgb), 0.25); color: var(--on-strong); }

.maplibregl-popup-content .mv { color: var(--text-dim); font-size: 10px; }
.maplibregl-popup-content .ok { color: var(--good); font-weight: 600; }
.maplibregl-popup-content .bad { color: var(--threat); font-weight: 600; }
.maplibregl-popup-content .risk-low { color: var(--good); }
.maplibregl-popup-content .risk-medium { color: var(--warn); }
.maplibregl-popup-content .risk-high { color: var(--threat); }

/* Wind particle overlay — above the map, but never eats clicks */
.wind-canvas { position: absolute; inset: 0; z-index: 5; pointer-events: none; display: none; }

/* scrollbar */
.panel-section::-webkit-scrollbar { width: 8px; }
.panel-section::-webkit-scrollbar-thumb { background: rgba(var(--hover-rgb), 0.2); border-radius: 4px; }

/* ---- SAM Details Modal ---- */
.sam-details-modal {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(2px);
}

.sam-card {
  background: var(--panel-solid); border: 1px solid var(--line-bright); border-radius: 8px;
  max-height: 85vh; max-width: 600px; width: 90%; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8); animation: slide-up 0.3s ease;
}

@keyframes slide-up { from { opacity: 0; transform: translateY(20px); } }

.sam-card-header {
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.1), rgba(var(--accent2-rgb), 0.05));
  border-bottom: 1px solid var(--line-bright); padding: 20px 24px;
}

.sam-card-header h2 { margin: 0; font-size: 20px; color: var(--accent); font-weight: 600; }
.sam-card-header .en-name { margin: 4px 0 0; font-size: 12px; color: var(--text-dim); }

.sam-card-photo {
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  height: 220px; background: linear-gradient(180deg, rgba(var(--hover-rgb), 0.04), transparent);
  display: flex; align-items: center; justify-content: center;
}

.photo-placeholder {
  width: 100%; height: 100%; background: rgba(var(--hover-rgb), 0.08); border: 1px dashed var(--line-bright);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text-dim); font-style: italic;
}

.sam-card-photo img { max-width: 100%; max-height: 100%; border-radius: 4px; }

.sam-card-content { padding: 20px 24px; }

.section { margin-bottom: 20px; }
.section:last-child { margin-bottom: 0; }

.section h3 {
  font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-dim);
  margin: 0 0 10px; font-weight: 600;
}

.specs-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 11px; }
.specs-table tr { border-bottom: 1px solid rgba(var(--hover-rgb), 0.08); }
.specs-table td { padding: 8px 0; }
.specs-table td:first-child { color: var(--text-dim); width: 45%; }
.specs-table td:last-child { color: var(--accent); font-weight: 500; }

.close-btn {
  display: block; margin: 20px auto 0; padding: 10px 20px; background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid var(--accent); border-radius: 4px; color: var(--accent); cursor: pointer;
  font-family: var(--mono); font-size: 11px; font-weight: 500; transition: all 0.15s;
}

.close-btn:hover { background: rgba(var(--accent-rgb), 0.25); }

.rrt-settings-modal {
  position: fixed; inset: 0; z-index: 51; display: none; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0,0,0,0.78); backdrop-filter: blur(3px);
}
.rrt-settings-card {
  width: min(900px, 96vw); max-height: 90vh; overflow-y: auto; padding: 20px;
  background: var(--panel-solid); border: 1px solid var(--line-bright); border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.rrt-settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.rrt-settings-head h2 { margin: 0; color: var(--accent); font-size: 18px; }
.rrt-settings-card .settings-grid { display: grid; gap: 12px; }
.rrt-settings-card .settings-group { overflow: hidden; border: 1px solid var(--line); border-radius: 6px; }
.rrt-settings-card .group-title { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.rrt-settings-card .group-key { margin-left: 8px; color: var(--text-dim); font: 10px var(--mono); }
.rrt-settings-card .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.rrt-settings-card .field { min-height: 76px; padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rrt-settings-card .field-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; font-size: 11px; }
.rrt-settings-card .field-name { color: var(--text); }
.rrt-settings-card .symbol { color: var(--accent); font: 10px var(--mono); }
.rrt-settings-card .control { display: flex; }
.rrt-settings-card input[type="number"] { width: 100%; min-width: 0; padding: 6px 8px; color: var(--text); background: var(--bg); border: 1px solid var(--line-bright); border-radius: 4px; font: 11px var(--mono); }
.rrt-settings-card .unit { margin-left: 5px; color: var(--text-dim); font: 10px var(--mono); }
.rrt-settings-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }

/* Info button in SAM menu */
.sam-opt .info-btn {
  flex: 0 0 auto; background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 12px; padding: 0 4px; transition: color 0.12s;
}

.sam-opt .info-btn:hover { color: var(--accent); }

/* scrollbar in modal */
.sam-card::-webkit-scrollbar { width: 6px; }
.sam-card::-webkit-scrollbar-track { background: transparent; }
.sam-card::-webkit-scrollbar-thumb { background: rgba(var(--hover-rgb), 0.2); border-radius: 3px; }

/* ---- Catalog: SAM type cards + edit form ---- */
.catalog-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.catalog-card {
  display: flex; gap: 10px; padding: 8px; border-radius: 5px;
  background: var(--surface); border: 1px solid var(--line); transition: border-color .12s;
}
.catalog-card:hover { border-color: var(--line-bright); }
.catalog-card-photo {
  width: 44px; height: 44px; border-radius: 4px; flex: 0 0 auto; overflow: hidden;
  background: rgba(var(--hover-rgb), 0.08); display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.catalog-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.catalog-card-photo, .catalog-card-body { cursor: pointer; }
.catalog-card-body { flex: 1; min-width: 0; }
.catalog-card-body .nm { font-size: 12.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-decoration: underline; text-decoration-color: var(--line-bright); text-underline-offset: 2px; }
.catalog-card-body:hover .nm { color: var(--accent); text-decoration-color: var(--accent); }
.catalog-card-body .mini { font-size: 9.5px; color: var(--text-dim); font-family: var(--mono);
  margin-top: 3px; line-height: 1.5; }
.catalog-card-installed { display: flex; align-items: baseline; gap: 6px; margin-top: 9px; color: var(--accent); }
.catalog-card-installed b { font: 700 18px var(--mono); }
.catalog-card-installed span { color: var(--text-dim); font: 9px var(--mono); text-transform: uppercase; letter-spacing: .5px; }
.catalog-card-details { display: none; }
/* The card title is a button now (it opens the spec sheet) — strip the button
   chrome so it still reads as a heading. */
.catalog-card-body .nm-link { background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; }
.catalog-card-body .nm-link:hover { color: var(--accent); text-decoration: underline; }
.catalog-card-actions { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; justify-content: center; }
.catalog-card-actions button {
  font-family: var(--mono); font-size: 9.5px; padding: 4px 8px; border-radius: 3px;
  border: 1px solid var(--line); background: none; color: var(--text-dim); cursor: pointer;
  transition: all .12s; white-space: nowrap;
}
.catalog-card-actions button:hover { color: var(--text); border-color: var(--line-bright); }
.catalog-card-actions button.danger:hover { color: var(--threat); border-color: var(--threat); }

/* Edit/create form (rendered inside the same #sam-details-modal overlay) */
.cat-form .f-row { margin-bottom: 10px; }
.cat-form .f-row.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-form label { display: block; font-size: 10px; letter-spacing: .5px; color: var(--text-dim);
  margin-bottom: 4px; font-family: var(--mono); }
.cat-form input, .cat-form textarea {
  width: 100%; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 4px;
  color: var(--text); font-family: var(--mono); font-size: 12px; padding: 7px 9px;
}
.cat-form input:focus, .cat-form textarea:focus { outline: none; border-color: var(--accent); }
.cat-form input:disabled { color: var(--text-dim); background: rgba(var(--hover-rgb), 0.04); }
.cat-form .custom-field-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.cat-form .custom-field-row input { flex: 1; }
.cat-form .custom-field-row button {
  flex: 0 0 auto; background: none; border: 1px solid var(--line); color: var(--threat);
  border-radius: 4px; width: 28px; height: 28px; cursor: pointer;
}
.cat-form .add-field-btn {
  font-family: var(--mono); font-size: 10.5px; padding: 6px 10px; border-radius: 4px;
  background: none; border: 1px dashed var(--line-bright); color: var(--text-dim); cursor: pointer;
}
.cat-form .add-field-btn:hover { color: var(--accent); border-color: var(--accent); }
.cat-form .form-actions { display: flex; gap: 8px; margin-top: 18px; }
.cat-form .form-actions button { flex: 1; padding: 10px; border-radius: 4px; cursor: pointer;
  font-family: var(--mono); font-size: 11.5px; font-weight: 500; }
.cat-form .save-btn { background: rgba(var(--accent-rgb), 0.12); border: 1px solid var(--accent); color: var(--accent); }
.cat-form .save-btn:hover { background: rgba(var(--accent-rgb), 0.25); }
.cat-form .cancel-btn { background: none; border: 1px solid var(--line); color: var(--text-dim); }
.cat-form .cancel-btn:hover { border-color: var(--line-bright); color: var(--text); }
.cat-form .form-error { color: var(--threat); font-size: 11px; margin-top: 10px; white-space: pre-wrap; }

.route-history-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.route-history-actions .action-btn { width: auto; flex: 1; text-align: center; }
.route-list { display: grid; gap: 8px; }
.route-card { border: 1px solid rgba(var(--overlay-rgb), .12); border-radius: 6px; padding: 8px; background: rgba(var(--ground-rgb), .72); }
.route-card.selected { border-color: var(--selected-line); box-shadow: 0 0 0 1px var(--selected-glow); }
.route-card small, .route-metrics { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; }
.route-card-actions { display: flex; gap: 5px; margin-top: 7px; }
.route-card-actions button { flex: 1; font-size: 10px; }
.route-comparison { margin-top: 10px; padding: 8px; border-top: 1px solid rgba(var(--overlay-rgb), .12); font-size: 11px; line-height: 1.5; }

.route-history-select { width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--text); font-family: var(--mono); font-size: 11.5px; }
.route-history-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.route-history-heading { margin-top: 10px; color: var(--text-dim); font: 10px var(--mono); letter-spacing: .7px; }
.route-history-list { display: grid; gap: 6px; margin-top: 6px; }
.route-target-card { overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.route-target-card.active { border-color: var(--accent); background: rgba(var(--accent-rgb), .045); }
.route-target-toggle { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 10px; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.route-target-toggle:hover { background: rgba(var(--accent-rgb), .06); }
.route-target-chevron { margin-left: auto; color: var(--accent); font: 12px var(--mono); }
.route-target-actions { display: flex; gap: 6px; padding: 0 9px 9px; }
.route-target-actions button { flex: 1; padding: 7px 6px; border: 1px solid var(--line-bright); border-radius: 4px; background: var(--surface-sunken); color: var(--text-dim); font: 10px var(--mono); cursor: pointer; }
.route-target-actions button:hover { border-color: var(--accent); color: var(--accent); }
.route-target-runs { display: grid; gap: 7px; padding: 0 8px 8px; }
.route-run-card { padding: 8px; border: 1px solid rgba(var(--overlay-rgb), .11); border-radius: 5px; background: rgba(var(--ground-rgb), .72); }
.route-history-item { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.route-history-item:hover, .route-history-item.active { border-color: var(--accent); background: rgba(var(--accent-rgb), .08); }
.route-history-item-name { overflow: hidden; color: var(--text); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.route-history-item-title { display: flex; gap: 6px; align-items: center; min-width: 0; }
.route-history-badge { flex: none; padding: 2px 5px; border: 1px solid var(--badge-line); border-radius: 999px; color: var(--badge); font: 9px var(--mono); letter-spacing: .35px; text-transform: uppercase; }
.route-history-item-meta { color: var(--text-dim); font: 10px var(--mono); }
.route-history-meta { padding: 8px 6px 0; color: var(--text-dim); font-family: var(--mono); font-size: 10px; }
.route-card-actions button:disabled { opacity: .45; cursor: not-allowed; }
.route-group-routes { display: grid; gap: 5px; margin-top: 8px; }
.route-group-route { display: grid; grid-template-columns: auto 1fr; gap: 6px; align-items: center; padding: 7px 6px; border: 1px solid rgba(var(--overlay-rgb), .1); border-radius: 4px; font-size: 11px; }
.route-group-route small { grid-column: 2 / 3; color: var(--muted); font-size: 10px; }
.route-group-route input { accent-color: var(--accent); }

/* ---- Flight-altitude slider. Drives radar-rings, engagement-rings and
   blind-corridors, plus the cursor's threat readout: a radar's reach and a
   battery's kill radius are both horizon-limited, so the same site draws a
   different ring at 30 m than at 300 m. ---- */
.altitude-row {
  padding: 6px 6px 9px; margin: -2px 0 4px;
  border-bottom: 1px solid var(--line);
}
.altitude-row label {
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); margin-bottom: 6px;
}
.altitude-row b { color: var(--accent); font-weight: 600; min-width: 30px; text-align: right; }
.altitude-row input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }

/* ============================ Інспекція маршруту (3D-топо + бічна панель) */
#inspect-view {
  position: fixed; inset: 0; z-index: 2000; background: var(--bg);
  display: grid; grid-template-columns: 1fr 372px; grid-template-rows: 46px 1fr;
  font-family: var(--sans);
}
/* `#id` beats the UA `[hidden]{display:none}`, so hidden must be re-asserted
   at higher specificity or the view never closes. */
#inspect-view[hidden] { display: none; }
#inspect-topbar {
  grid-column: 1 / 3; grid-row: 1; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; background: var(--panel-solid); border-bottom: 1px solid var(--line-bright);
}
#inspect-topbar .ins-title { font-size: 12px; letter-spacing: 2px; color: var(--accent); font-weight: 600; }
#inspect-topbar .ins-summary { font-size: 11px; color: var(--text-dim); flex: 1 1 auto;
  font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#inspect-close {
  background: var(--surface); color: var(--text); border: 1px solid var(--line-bright);
  border-radius: 4px; padding: 5px 12px; cursor: pointer; font-size: 12px; }
#inspect-close:hover { border-color: var(--accent); color: var(--accent); }
.ins-cam { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.ins-cambtn { background: var(--surface); color: var(--text-dim); border: none; padding: 5px 12px;
  cursor: pointer; font-size: 11px; font-family: var(--mono); }
.ins-cambtn.active { background: rgba(var(--accent-rgb), 0.14); color: var(--accent); }
#inspect-map { grid-column: 1; grid-row: 2; position: relative; }

#inspect-sidebar {
  grid-column: 2; grid-row: 2; background: var(--panel-solid); border-left: 1px solid var(--line-bright);
  display: flex; flex-direction: column; overflow: hidden; }
.ins-sec-title { font-size: 10px; letter-spacing: 1.6px; color: var(--text-dim);
  padding: 12px 14px 6px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }

/* The brief and the radar list share one scroll box, capped at half the
   sidebar, so however long they get the analyst's input stays reachable.
   `flex: 0 1 auto` (not `1 1`) keeps the box at its content height when the
   content is short, instead of stealing space from the chat below. */
.ins-scroll { flex: 0 1 auto; overflow-y: auto; max-height: 50%; }
.ins-fold > summary { cursor: pointer; user-select: none; list-style: none;
  display: flex; align-items: center; gap: 6px; }
.ins-fold > summary::-webkit-details-marker { display: none; }
/* Own marker rather than the browser's: the native triangle sits outside the
   padding and breaks the header row's alignment with the rest of the panel. */
.ins-fold > summary::before { content: "▸"; font-size: 9px; transition: transform 0.12s;
  color: var(--text-dim); }
.ins-fold[open] > summary::before { transform: rotate(90deg); }
.ins-fold > summary:hover { color: var(--text); }

.ins-brief { padding: 10px 14px; font-size: 12px; color: var(--text);
  border-bottom: 1px solid var(--line); }
.ins-brief .row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0;
  border-bottom: 1px dotted var(--line); }
.ins-brief .row label { color: var(--text-dim); }
.ins-brief .row b { font-family: var(--mono); }
.ins-brief .psurv-hi { color: var(--ok); } .ins-brief .psurv-mid { color: var(--accent-2); }
.ins-brief .psurv-lo { color: var(--threat); }
.ins-brief .threat-line { color: var(--threat); font-family: var(--mono); font-size: 11px; }
.ins-brief .safe-line { color: var(--ok); font-family: var(--mono); font-size: 11px; }

.ins-chat-log { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px; display: flex;
  flex-direction: column; gap: 10px; }
.ins-msg { font-size: 12px; line-height: 1.5; padding: 8px 11px; border-radius: 8px; max-width: 92%; }
.ins-msg.bot { background: rgba(var(--accent-rgb), 0.08); border: 1px solid var(--line);
  color: var(--text); align-self: flex-start; border-top-left-radius: 2px; }
.ins-msg.user { background: var(--surface-hover); border: 1px solid var(--line-bright);
  color: var(--text); align-self: flex-end; border-top-right-radius: 2px; }
/* Which backend tools produced the answer — the grounding is visible, not implied. */
/* Light markdown from the analyst: paragraphs, headings, lists, inline code. */
.ins-msg .md-p { margin: 4px 0; }
.ins-msg .md-h { margin: 8px 0 3px; font-weight: 600; color: var(--accent); font-size: 11.5px;
  letter-spacing: .3px; }
.ins-msg ul, .ins-msg ol { margin: 4px 0 4px 0; padding-left: 18px; }
.ins-msg li { margin: 2px 0; }
.ins-msg b { color: var(--text-strong); font-weight: 600; }
.ins-msg code { font-family: var(--mono); font-size: 10.5px; background: rgba(var(--overlay-rgb), 0.07);
  padding: 1px 4px; border-radius: 3px; }
.ins-msg-meta { margin-top: 5px; font-size: 9px; letter-spacing: .5px; color: var(--text-dim);
  opacity: .8; font-family: var(--mono, monospace); }
.ins-msg .who { display: block; font-size: 9px; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 3px; }
.ins-chat-form { flex: 0 0 auto; display: flex; gap: 6px; padding: 10px 12px;
  border-top: 1px solid var(--line); }
.ins-chat-form input { flex: 1 1 auto; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; font-size: 12px; outline: none; }
.ins-chat-form input:focus { border-color: var(--accent); }
.ins-chat-form button { background: rgba(var(--accent-rgb), 0.12); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 4px; padding: 0 14px; cursor: pointer; font-size: 12px; }

/* Marks the altitude as coming from the planned route, not the slider. */
.alt-src { color: var(--accent); font-size: 9px; letter-spacing: .3px; }

/* Colour key for the along-route overlay (seen / extrapolated / under fire). */
.ins-seg-legend { padding: 6px 12px 10px; display: flex; flex-direction: column; gap: 3px; }
.ins-seg-legend .seg-row { display: flex; align-items: center; gap: 7px; font-size: 10.5px;
  color: var(--text-dim); }
.ins-seg-legend .seg-row i { width: 14px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.ins-seg-legend .seg-row i.dot { width: 8px; height: 8px; border-radius: 50%; margin: 0 3px;
  border: 1.5px solid var(--panel-solid); }

/* Per-radar track list: click a row to show that radar's own track on the map. */
.ins-radar-list { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.ins-radar-list .rt-row { display: flex; justify-content: space-between; gap: 8px; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; cursor: pointer;
  color: var(--text); font-family: var(--mono); font-size: 10px; padding: 5px 7px; text-align: left; }
.ins-radar-list .rt-row:hover { border-color: var(--line-bright); }
.ins-radar-list .rt-row.on { border-color: var(--good); color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.ins-radar-list .rt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-radar-list .rt-time { flex: 0 0 auto; color: var(--text-dim); }
.ins-radar-list .rt-empty { font-size: 10.5px; color: var(--text-dim); }

/* Live calculation status: what each planner is doing, and for how long.
   Sits directly above the button that starts it, replacing the pre-flight
   hint for the duration — the operator is looking at that spot already. */
.calc-progress { margin: 6px 0 8px; padding: 8px 10px; border-radius: 5px;
  background: rgba(var(--accent-rgb), 0.06); border: 1px solid rgba(var(--accent-rgb), 0.25);
  font-size: 11px; color: var(--text); }
/* Label and stopwatch on ONE row. They were stacking because 264 px of panel
   minus padding could not fit the sentence plus the clock at 1px tracking, and
   a wrapped timer reads as a layout accident. */
.calc-progress .cp-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.2px;
  white-space: nowrap; color: var(--accent); margin-bottom: 5px; }
.calc-progress .cp-head .cp-what { overflow: hidden; text-overflow: ellipsis; }
.calc-progress .cp-head .cp-clock { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.calc-progress .cp-row { display: flex; justify-content: space-between; gap: 8px;
  padding: 1px 0; color: var(--text-dim); }
.calc-progress .cp-row b { color: var(--text); font-weight: 500; flex: 0 0 auto; }
.calc-progress .cp-row span { text-align: right; }
.calc-progress.cp-done { background: rgba(var(--good-rgb), 0.07); border-color: rgba(var(--good-rgb), 0.3); }
.calc-progress.cp-done .cp-head { color: var(--good); }
.calc-progress.cp-error { background: rgba(var(--threat-rgb), 0.07); border-color: rgba(var(--threat-rgb), 0.35); }
.calc-progress.cp-error .cp-head { color: var(--threat); }
.calc-progress .cp-row-error span { color: var(--danger); }

/* The inspect entry point only appears once there is something to inspect,
   so it gets a glow rather than competing with the permanent buttons. */
.inspect-cta { border-color: rgba(var(--accent2-rgb), 0.55) !important; color: var(--accent-2) !important;
  box-shadow: 0 0 0 1px rgba(var(--accent2-rgb), 0.18) inset, 0 0 12px rgba(var(--accent2-rgb), 0.18); }
.inspect-cta:hover { border-color: var(--accent-2) !important;
  box-shadow: 0 0 0 1px rgba(var(--accent2-rgb), 0.35) inset, 0 0 18px rgba(var(--accent2-rgb), 0.3); }
