:root,
.r2-theme {
  color-scheme: dark;

  --r2-bg: #0a0e1a;
  --r2-bg-secondary: #111827;
  --r2-surface: rgba(17, 24, 39, 0.78);
  --r2-surface-hover: rgba(24, 34, 56, 0.88);
  --r2-sidebar: rgba(10, 14, 26, 0.95);
  --r2-glass: rgba(255, 255, 255, 0.03);
  --r2-input: rgba(255, 255, 255, 0.05);

  --r2-border: rgba(255, 255, 255, 0.06);
  --r2-border-medium: rgba(255, 255, 255, 0.1);
  --r2-border-strong: rgba(255, 255, 255, 0.14);
  --r2-border-accent: rgba(45, 212, 191, 0.3);

  --r2-text: #f1f5f9;
  --r2-text-secondary: #94a3b8;
  --r2-text-muted: #64748b;
  --r2-text-accent: #2dd4bf;

  --r2-accent: #2dd4bf;
  --r2-accent-hover: #5eead4;
  --r2-accent-dim: rgba(45, 212, 191, 0.15);
  --r2-cyan: #22d3ee;
  --r2-blue: #3b82f6;
  --r2-violet: #8b5cf6;
  --r2-brand-bar: linear-gradient(90deg, #2dd4bf, #3b82f6, #8b5cf6);

  --r2-online: #10b981;
  --r2-offline: #ef4444;
  --r2-degraded: #f59e0b;
  --r2-unknown: #6b7280;

  --r2-radius-sm: 6px;
  --r2-radius-md: 10px;
  --r2-radius-lg: 14px;

  --r2-font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --r2-font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r2-shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --r2-shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.4);
  --r2-shadow-glow: 0 0 30px rgba(45, 212, 191, 0.12);

  --r2-fast: 150ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  min-height: 100%;
  margin: 0;
}

body.r2-theme {
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(45, 212, 191, 0.05) 0%, transparent 58%),
    radial-gradient(ellipse at 86% 12%, rgba(139, 92, 246, 0.035) 0%, transparent 52%),
    radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.04) 0%, transparent 60%),
    var(--r2-bg);
  color: var(--r2-text);
  font-family: var(--r2-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.r2-theme::before {
  content: "";
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 10000;
  width: 100%;
  height: 3px;
  background: var(--r2-brand-bar);
  pointer-events: none;
}

a {
  color: var(--r2-accent);
}

:focus-visible {
  outline: 2px solid var(--r2-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--r2-accent-dim);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  height: 100vh;
  isolation: isolate;
  transition: grid-template-columns 180ms ease;
}

body[data-sidebar-collapsed="true"] .app-shell {
  grid-template-columns: 56px minmax(0, 1fr);
}

.panel {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
  padding: 18px 12px 16px;
  border-right: 1px solid var(--r2-border);
  background: var(--r2-sidebar);
  backdrop-filter: blur(20px);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.24);
  transition: padding var(--r2-fast), gap var(--r2-fast);
}

.panel-toggle {
  display: inline-grid;
  width: 26px;
  min-width: 26px;
  min-height: 26px;
  place-items: center;
  padding: 0;
  border-color: var(--r2-border-medium);
  border-radius: var(--r2-radius-sm);
  background: rgba(148, 163, 184, 0.08);
  color: var(--r2-text-secondary);
  box-shadow: none;
}

.panel-toggle::before {
  content: "−";
  font-family: var(--r2-font-mono);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

[data-collapsed="true"] .panel-toggle::before {
  content: "+";
}

.panel-toggle:hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.panel-toggle-sidebar {
  position: absolute;
  top: 18px;
  right: 12px;
  z-index: 3;
}

/* Collapsed state: a slim icon rail that summarises the full sidebar. */
body[data-sidebar-collapsed="true"] .panel {
  gap: 12px;
  padding: 56px 0 14px;
  align-items: center;
}

body[data-sidebar-collapsed="true"] .panel-toggle-sidebar {
  right: 15px;
}

/* Hide the list- and text-heavy sections in the rail. */
body[data-sidebar-collapsed="true"] .group-controls,
body[data-sidebar-collapsed="true"] .layer-section,
body[data-sidebar-collapsed="true"] .summary {
  display: none;
}

/* Brand becomes a centred stack of the logo mark + dashboard launcher. */
body[data-sidebar-collapsed="true"] .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0;
  border-bottom: 0;
}

body[data-sidebar-collapsed="true"] .eyebrow,
body[data-sidebar-collapsed="true"] .brand h1,
body[data-sidebar-collapsed="true"] .brand-sub {
  display: none;
}

/* Keep the 2D/3D switch reachable in the collapsed rail as a compact vertical
   toggle — it used to be hidden, leaving no way to change map mode. */
body[data-sidebar-collapsed="true"] .mode-switch {
  display: grid;
  grid-template-columns: 1fr;
  width: 38px;
  gap: 4px;
}

body[data-sidebar-collapsed="true"] .mode-switch a {
  min-height: 26px;
  font-size: 11px;
}

body[data-sidebar-collapsed="true"] .brand::before {
  grid-row: auto;
}

body[data-sidebar-collapsed="true"] .dashboard-icon {
  grid-column: auto;
  grid-row: auto;
  align-self: auto;
  margin: 0;
}

/* Alerts collapses to a single round indicator button in the rail. */
body[data-sidebar-collapsed="true"] .brand-controls {
  flex-direction: column;
  gap: 12px;
  align-self: auto;
}

body[data-sidebar-collapsed="true"] .alerts-link {
  width: 36px;
  min-width: 36px;
  padding: 0;
  justify-content: center;
  font-size: 0; /* hide the "Alerts" label, keep the status dot */
}

/* Filter row collapses to stacked show/hide icons; search box is hidden. */
body[data-sidebar-collapsed="true"] .toolbar {
  padding: 0;
}

body[data-sidebar-collapsed="true"] #layerSearch {
  display: none;
}

body[data-sidebar-collapsed="true"] .filter-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Utility links pin to the bottom of the rail as a vertical icon stack. */
body[data-sidebar-collapsed="true"] .utility-nav {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 0;
}

.brand {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 6px 10px 12px;
  border-bottom: 1px solid var(--r2-border);
}

/* Logo is now the .brand-logo SVG element (replaces the old pseudo dot). */
.brand-logo {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--r2-border-accent);
  border-radius: var(--r2-radius-md);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.16), rgba(59, 130, 246, 0.16));
  box-shadow: var(--r2-shadow-glow);
}

.brand-logo svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--r2-accent);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.brand-logo .r-ring {
  opacity: 0.4;
}

.brand-logo .r-tick {
  opacity: 0.7;
}

.brand-logo .r-sweep {
  opacity: 0.95;
}

.brand-logo .r-blip {
  fill: var(--r2-accent);
  stroke: none;
}

.eyebrow {
  display: inline-flex;
  grid-column: 2;
  align-items: center;
  gap: 7px;
  margin: 0 0 5px;
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--r2-accent);
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.65);
  animation: r2-pulse 2.4s ease-in-out infinite;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  grid-column: 2;
  background: linear-gradient(135deg, var(--r2-text), var(--r2-accent));
  background-clip: text;
  color: var(--r2-text);
  font-size: 22px;
  font-weight: 780;
  letter-spacing: 0.04em;
  line-height: 1.08;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* The title doubles as a disclosure for the full name. */
.brand h1[role="button"] {
  cursor: pointer;
}

.brand h1[role="button"]::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 0 3px 7px;
  border-right: 1.5px solid var(--r2-text-muted);
  border-bottom: 1.5px solid var(--r2-text-muted);
  transform: rotate(45deg);
  transition: transform var(--r2-fast);
  vertical-align: middle;
}

.brand[data-sub-open="true"] h1[role="button"]::after {
  transform: rotate(-135deg);
}

/* Subtitle hidden by default; revealed by clicking the title. */
.brand-sub {
  display: none;
  grid-column: 2;
  margin: 3px 0 0;
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.brand[data-sub-open="true"] .brand-sub {
  display: block;
}

.dashboard-icon {
  display: grid;
  grid-column: 3;
  grid-row: 1 / span 2;
  grid-template-columns: repeat(2, 7px);
  gap: 4px;
  align-self: start;
  margin: -8px 36px 0 0;
  width: 34px;
  min-height: 34px;
  padding: 0;
  place-content: center;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(148, 163, 184, 0.06);
  box-shadow: none;
}

.dashboard-icon span {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--r2-text-secondary);
}

.dashboard-icon:hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
}

.dashboard-icon:hover span {
  background: var(--r2-accent);
  box-shadow: 0 0 10px rgba(45, 212, 191, 0.45);
}

.brand-controls {
  display: flex;
  grid-column: 2 / span 2;
  align-items: center;
  gap: 8px;
  align-self: end;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(40px, 1fr));
  gap: 4px;
  width: 104px;
  padding: 3px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(148, 163, 184, 0.08);
}

.mode-switch a {
  display: grid;
  min-height: 28px;
  place-items: center;
  border-radius: var(--r2-radius-sm);
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.mode-switch a[aria-current="page"] {
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

h2 {
  color: var(--r2-text);
  font-size: 15px;
  font-weight: 720;
}

.toolbar {
  display: grid;
  gap: 12px;
  padding: 0 6px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
button,
.icon-link,
.api-menu a,
.layer-json {
  min-height: 36px;
  border-radius: var(--r2-radius-md);
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--r2-border);
  background: var(--r2-input);
  color: var(--r2-text);
  padding: 0 12px;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  transition: border-color var(--r2-fast), box-shadow var(--r2-fast), background var(--r2-fast);
}

input::placeholder {
  color: var(--r2-text-muted);
}

input:hover {
  border-color: var(--r2-border-medium);
}

input:focus {
  outline: none;
  border-color: var(--r2-accent);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px var(--r2-accent-dim);
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  display: inline-grid;
  width: 36px;
  min-width: 36px;
  padding: 0;
  place-items: center;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.group-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 0 6px;
  padding: 3px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(148, 163, 184, 0.08);
}

.layer-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1 1 calc(33.333% - 2px); /* 3 per row → wraps to 2 rows for 6 tabs */
  min-width: 0;
  min-height: 30px;
  padding: 0 3px;
  border: 0;
  border-radius: var(--r2-radius-sm);
  background: transparent;
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 10.5px;
  font-weight: 700;
}

.layer-tab:hover {
  background: var(--r2-surface-hover);
  color: var(--r2-text);
}

.layer-tab[data-selected="true"] {
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.layer-tab-count {
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.layer-tab[data-selected="true"] .layer-tab-count {
  color: var(--r2-accent);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(45, 212, 191, 0.45);
  background: var(--r2-accent);
  color: #04221d;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: 0 0 22px rgba(45, 212, 191, 0.18);
  transition: transform var(--r2-fast), border-color var(--r2-fast), background var(--r2-fast), color var(--r2-fast), box-shadow var(--r2-fast);
}

/* Accent hover is for primary buttons only. Ghost/icon/chip buttons opt out so
   they can never flash solid accent-green (their own :hover styles take over). */
button:hover:not(.secondary):not(.icon-btn):not(.icon-link):not(.layer-icon):not(.layer-tab):not(.layer-filters-toggle):not(.ais-chip):not(.panel-toggle):not(.summary-head):not(.dashboard-icon):not(.feature-close):not(:disabled) {
  border-color: var(--r2-accent-hover);
  background: var(--r2-accent-hover);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  border-color: var(--r2-border-medium);
  background: rgba(148, 163, 184, 0.08);
  color: var(--r2-text);
  box-shadow: none;
}

button.secondary:hover {
  border-color: var(--r2-border-strong);
  background: rgba(148, 163, 184, 0.13);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0 6px;
}

.stats div {
  display: grid;
  min-height: 62px;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
  box-shadow: var(--r2-shadow-card);
}

.stats dt {
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.summary {
  display: grid;
  gap: 8px;
  padding: 12px 6px 0;
  border-top: 1px solid var(--r2-border);
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-family: var(--r2-font-mono);
  font-size: 11px;
  font-weight: 700;
}

.summary-head:hover {
  border-color: var(--r2-border-medium);
  background: var(--r2-surface-hover);
  color: var(--r2-text);
}

.summary-head::after {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--r2-fast);
}

.summary:not([data-collapsed="true"]) .summary-head::after {
  transform: rotate(-135deg);
}

.summary-line {
  overflow: hidden;
  color: var(--r2-text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.summary[data-collapsed="true"] .stats {
  display: none;
}

.layer-section {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 0 6px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#layerCount {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border: 1px solid var(--r2-border);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.06);
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.layer-list {
  display: grid;
  gap: 5px;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-color: rgba(45, 212, 191, 0.35) rgba(255, 255, 255, 0.04);
}

.layer-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
  box-shadow: var(--r2-shadow-card);
  transition: border-color var(--r2-fast), background var(--r2-fast), box-shadow var(--r2-fast);
}

/* The class above sets display:grid, which beats the UA [hidden] rule; without
   this, applyFilter()'s row.hidden never visually filters the list. */
.layer-row[hidden] {
  display: none;
}

.layer-row:hover {
  border-color: var(--r2-border-medium);
  background: var(--r2-surface-hover);
  box-shadow: var(--r2-shadow-card-hover);
}

.layer-row[data-active="true"] {
  border-color: var(--r2-border-accent);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.14), rgba(59, 130, 246, 0.07));
}

.layer-row.is-pulsing {
  animation: r2-row-pulse 900ms ease;
}

.layer-row[data-disabled="true"] {
  background: rgba(17, 24, 39, 0.44);
  opacity: 0.72;
}

.layer-row input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--r2-accent);
}

.layer-main {
  min-width: 0;
}

.layer-name {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--r2-text);
  font-size: 12.5px;
  font-weight: 800;
}

.layer-key {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-dot {
  width: 8px;
  height: 8px;
  margin-left: auto;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--r2-text-muted);
}

.layer-dot[data-status="ready"] {
  background: var(--r2-accent);
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.7);
}

.layer-dot[data-status="awaiting"] {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
}

.layer-dot[data-status="error"] {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
}

.swatch {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--layer-color);
  color: #06111f;
  box-shadow: 0 0 10px var(--layer-color);
}

.swatch span,
.legend-swatch span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  font-family: var(--r2-font-mono);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}

.layer-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  min-width: 0;
}

.layer-meta-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--r2-text-secondary);
  font-size: 11px;
}

.layer-tag {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 16px;
  padding: 0 6px;
  border: 1px solid var(--r2-border);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.06);
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.layer-tag[data-kind="live"],
.layer-tag[data-kind="hybrid"] {
  border-color: rgba(34, 211, 238, 0.34);
  color: var(--r2-cyan);
}

.layer-tag[data-kind="temporal"] {
  border-color: rgba(45, 212, 191, 0.34);
  color: var(--r2-accent);
}

.layer-json {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  min-height: 30px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  color: var(--r2-text-secondary);
  text-decoration: none;
  background: rgba(148, 163, 184, 0.06);
  font-family: var(--r2-font-mono);
  font-size: 13px;
  font-weight: 800;
  transition: color var(--r2-fast), border-color var(--r2-fast), background var(--r2-fast);
}

.layer-json:hover {
  color: var(--r2-accent);
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
}

.layer-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.layer-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  color: var(--r2-text-secondary);
  background: rgba(148, 163, 184, 0.06);
  box-shadow: none;
  transition: color var(--r2-fast), border-color var(--r2-fast), background var(--r2-fast);
}

.layer-icon:hover:not(:disabled) {
  color: var(--r2-accent);
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
}

.layer-icon:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.layer-vis svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-vis .eye-off {
  display: none;
}

/* Hidden state: dim the open eye and reveal the slash. */
.layer-vis[aria-pressed="false"]:not(:disabled) {
  color: var(--r2-text-muted);
}

.layer-vis[aria-pressed="false"] .eye-open {
  opacity: 0.45;
}

.layer-vis[aria-pressed="false"] .eye-off {
  display: inline;
}

.layer-format-menu {
  position: fixed;
  z-index: 1300;
  width: 188px;
  padding: 5px;
  border: 1px solid var(--r2-border-medium);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.97);
  box-shadow: var(--r2-shadow-card);
  backdrop-filter: blur(18px);
}

.layer-format-head {
  margin: 2px 6px 5px;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-format-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border-radius: var(--r2-radius-sm);
  color: var(--r2-text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.layer-format-menu a:hover {
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.layer-format-menu a em {
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
}

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

.utility-nav {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 0 6px;
}

/* Release version, pinned at the very bottom of the controls rail. */
.app-version {
  padding: 8px 6px 4px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--r2-text-muted);
  text-align: center;
  user-select: none;
}

body[data-sidebar-collapsed="true"] .app-version {
  font-size: 9px;
  padding: 6px 0 2px;
}

.api-menu-wrap {
  position: relative;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  border: 1px solid var(--r2-border);
  color: var(--r2-text-secondary);
  text-decoration: none;
  background: rgba(148, 163, 184, 0.06);
  box-shadow: none;
  transition: color var(--r2-fast), border-color var(--r2-fast), background var(--r2-fast), box-shadow var(--r2-fast);
}

.icon-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-link:hover,
.icon-link[aria-expanded="true"] {
  color: var(--r2-text);
  border-color: var(--r2-border-medium);
  background: var(--r2-glass);
}

.icon-link[aria-expanded="true"] {
  border-color: var(--r2-border-accent);
  color: var(--r2-accent);
  box-shadow: 0 0 22px rgba(45, 212, 191, 0.12);
}

.api-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 1000;
  display: grid;
  width: min(312px, calc(100vw - 28px));
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.94);
  box-shadow: var(--r2-shadow-card-hover);
  backdrop-filter: blur(18px);
}

.api-menu[hidden] {
  display: none;
}

.api-menu a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--r2-border);
  background: rgba(148, 163, 184, 0.06);
  color: var(--r2-text-secondary);
  font-size: 12px;
  font-weight: 740;
  text-decoration: none;
  transition: color var(--r2-fast), border-color var(--r2-fast), background var(--r2-fast);
}

.api-menu a:hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.map-wrap,
#map {
  min-width: 0;
  height: 100vh;
}

.map-wrap {
  position: relative;
  background: #050914;
}

#map,
#globe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#map {
  z-index: 1;
}

#globe {
  z-index: 2;
  display: none;
  background: #000;
}

#globe canvas {
  display: block;
}

body[data-map-presentation="3d"] #map {
  visibility: hidden;
  pointer-events: none;
}

body[data-map-presentation="3d"] #globe {
  display: block;
}

body[data-map-presentation="2d"] #globe {
  display: none;
}

.map-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 430;
  background:
    radial-gradient(circle at 50% 45%, transparent 0%, transparent 45%, rgba(5, 9, 20, 0.42) 100%),
    linear-gradient(90deg, rgba(10, 14, 26, 0.48), transparent 18%, transparent 78%, rgba(10, 14, 26, 0.32));
  pointer-events: none;
}

.map-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 450;
  background:
    linear-gradient(rgba(45, 212, 191, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 212, 191, 0.018) 1px, transparent 1px);
  background-size: 52px 52px;
  pointer-events: none;
  mix-blend-mode: screen;
}

.map-tools,
.time-tools,
.map-hud,
.map-legend,
.timeline-replay {
  position: absolute;
  z-index: 900;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.82);
  box-shadow: var(--r2-shadow-card);
  backdrop-filter: blur(18px);
}

/* "Panels" manager: a draggable pull-down tab pinned top-center by default.
   Collapsed it's just the handle (no overlap with the toolbars); the chip tray
   drops downward over the map on hover or tap. */
.panel-manager {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 901;
  width: max-content;
}

/* Once dragged it's pinned by left/top, so drop the centering transform. */
.panel-manager.is-moved {
  transform: none;
}

.panel-manager.is-dragging {
  user-select: none;
}

.panel-manager-handle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.82);
  box-shadow: var(--r2-shadow-card);
  backdrop-filter: blur(18px);
  color: var(--r2-text-muted);
  cursor: grab;
  /* The handle drives the drag; suppress native touch panning. */
  touch-action: none;
}

.panel-manager.is-dragging .panel-manager-handle {
  cursor: grabbing;
}

.panel-manager-grip {
  width: 8px;
  height: 12px;
  background-image: radial-gradient(currentColor 1px, transparent 1px);
  background-size: 4px 4px;
  opacity: 0.5;
}

.panel-manager-label {
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-manager-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform 150ms ease;
}

.panel-manager[data-open="true"] .panel-manager-caret {
  transform: rotate(180deg);
}

.panel-manager:hover .panel-manager-handle,
.panel-manager[data-open="true"] .panel-manager-handle {
  border-color: var(--r2-border-accent);
  color: var(--r2-text);
}

/* Pull-down tray: hidden until the tab is hovered or pinned open. */
.panel-manager-tray {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.92);
  box-shadow: var(--r2-shadow-card);
  backdrop-filter: blur(18px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.panel-manager:hover .panel-manager-tray,
.panel-manager[data-open="true"] .panel-manager-tray {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.panel-manager-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.panel-manager-reset {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--r2-border-medium);
  border-radius: var(--r2-radius-sm);
  background: transparent;
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.panel-manager-reset:hover {
  border-color: var(--r2-border-accent);
  color: var(--r2-text);
}

.panel-chip {
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--r2-border-medium);
  border-radius: 999px;
  background: transparent;
  color: var(--r2-text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.panel-chip:hover {
  border-color: var(--r2-border-accent);
  color: var(--r2-text);
}

/* Filled = panel visible; outline = panel hidden. */
.panel-chip[aria-pressed="true"] {
  border-color: var(--r2-accent);
  background: var(--r2-accent);
  color: #03211c;
}

.time-tools {
  top: 14px;
  right: 16px;
  display: grid;
  /* Right-anchored: content fills leftward, the collapse toggle stays pinned to
     the right edge (matches .map-hud and the replay bar). */
  grid-template-columns: repeat(6, 44px) 26px;
  gap: 4px;
  padding: 4px;
}

.time-tools .panel-toggle {
  order: 1;
}

.marker-label {
  min-height: 0;
  padding: 4px 7px;
  border: 1px solid rgba(45, 212, 191, 0.42);
  border-radius: var(--r2-radius-sm);
  background: rgba(10, 14, 26, 0.82);
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.18);
}

.marker-label:hover {
  border-color: var(--r2-accent);
  background: rgba(13, 26, 38, 0.94);
  color: var(--r2-accent);
}

.time-tools button:not(.panel-toggle) {
  min-width: 0;
  min-height: 34px;
  padding: 0;
  border-color: transparent;
  border-radius: var(--r2-radius-sm);
  background: rgba(148, 163, 184, 0.08);
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-family: var(--r2-font-mono);
  font-size: 13px;
  font-weight: 800;
}

.time-tools button:not(.panel-toggle):hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.time-tools button:not(.panel-toggle)[aria-pressed="true"] {
  border-color: rgba(45, 212, 191, 0.72);
  background: var(--r2-accent);
  color: #03211c;
  box-shadow: 0 0 22px rgba(45, 212, 191, 0.22);
}

.timeline-replay {
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 940;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  /* Match the bottom-right feature panel's color / look & feel. */
  background: rgba(10, 14, 26, 0.94);
  border-radius: var(--r2-radius-lg);
  box-shadow: var(--r2-shadow-card-hover);
  backdrop-filter: blur(20px);
  transition: right 220ms ease;
}

/* Don't sit under the bottom-right feature panel while it is open. */
.map-wrap:has(.feature-panel.is-open) .timeline-replay {
  right: calc(420px + 32px);
}

.timeline-replay > .panel-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
}

.timeline-replay-head {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px 10px;
  align-items: center;
  padding-right: 34px;
}

.timeline-replay-meta {
  margin-right: auto;
}

/* Keep the head on a single row: the scenario and base-map selectors shrink
   (truncating their option label) rather than wrapping onto a second line. */
.timeline-replay-scenario,
.timeline-replay-basemap {
  min-width: 0;
  flex: 0 1 auto;
}

.timeline-replay-scenario select,
.timeline-replay-basemap select {
  max-width: 100%;
  width: 100%;
}

.timeline-replay-scenario select,
.timeline-replay-basemap select,
.replay-select select {
  min-width: 0;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--r2-border-accent, rgba(45, 212, 191, 0.42));
  border-radius: var(--r2-radius-sm);
  background: rgba(10, 14, 26, 0.82);
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.timeline-replay-head p,
.timeline-replay-labels,
.timeline-replay-card span {
  margin: 0;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-replay-head strong {
  display: block;
  margin-top: 4px;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.replay-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  padding: 1px 7px 1px 6px;
  border: 1px solid var(--r2-border-medium);
  border-radius: 999px;
  font-size: 9px;
  vertical-align: middle;
}

.replay-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.replay-status[data-state="live"] {
  border-color: rgba(45, 212, 191, 0.5);
  color: var(--r2-accent);
}

.replay-status[data-state="live"]::before {
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.85);
  animation: r2-pulse 2s ease-in-out infinite;
}

.replay-status[data-state="playing"] {
  border-color: rgba(251, 191, 36, 0.55);
  color: #fbbf24;
}

.replay-status[data-state="paused"] {
  border-color: var(--r2-border-medium);
  color: var(--r2-text-muted);
}

.timeline-replay-transport,
.timeline-replay-mode {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

/* Live/Replay segmented toggle */
.timeline-replay-mode {
  gap: 0;
  padding: 2px;
  border: 1px solid var(--r2-border-medium);
  border-radius: 999px;
  background: rgba(10, 14, 26, 0.6);
}

.timeline-replay-mode button {
  border-radius: 999px !important;
  border-color: transparent !important;
  background: transparent !important;
}

.timeline-replay-mode button[aria-pressed="true"] {
  background: var(--r2-accent) !important;
  color: #03211c !important;
}

/* Live mode: collapse replay-only transport + scrubber for a clean default. */
body[data-replay-mode="live"] .timeline-replay-transport,
body[data-replay-mode="live"] .timeline-replay-body {
  display: none;
}

.replay-select select {
  font-variant-numeric: tabular-nums;
}

.replay-status[data-state="ready"] {
  border-color: rgba(45, 212, 191, 0.5);
  color: var(--r2-accent);
}

.timeline-replay button:not(.panel-toggle) {
  min-width: 34px;
  min-height: 30px;
  padding: 0 9px;
  border-color: var(--r2-border-medium);
  border-radius: var(--r2-radius-sm);
  background: rgba(148, 163, 184, 0.08);
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-family: var(--r2-font-mono);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.timeline-replay button:not(.panel-toggle):hover,
.timeline-replay button:not(.panel-toggle)[aria-pressed="true"] {
  border-color: rgba(45, 212, 191, 0.7);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.timeline-replay button[data-replay-action="play"][aria-pressed="true"] {
  background: var(--r2-accent);
  color: #03211c;
}

.timeline-replay-body {
  display: grid;
  gap: 4px;
}

.timeline-replay-body svg {
  width: 100%;
  height: 42px;
  overflow: visible;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  background:
    linear-gradient(rgba(45, 212, 191, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 212, 191, 0.06) 1px, transparent 1px);
  background-size: 100% 50%, 12.5% 100%;
}

.timeline-density-entity,
.timeline-density-stress {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.timeline-density-entity {
  stroke: var(--r2-accent);
}

.timeline-density-stress {
  stroke: #fbbf24;
}

.timeline-event-track {
  position: relative;
  height: 18px;
}

.timeline-event-dot {
  position: absolute;
  top: 50%;
  width: 11px;
  min-width: 11px;
  min-height: 11px;
  height: 11px;
  padding: 0;
  border: 2px solid rgba(248, 250, 252, 0.82);
  border-radius: 999px;
  background: var(--r2-accent);
  transform: translate(-50%, -50%);
}

.timeline-event-dot.severity-low {
  background: #5eead4;
}

.timeline-event-dot.severity-medium {
  background: #fbbf24;
}

.timeline-event-dot.severity-high {
  background: #fb7185;
}

.timeline-event-dot[data-muted="true"] {
  opacity: 0.35;
}

.timeline-event-dot[aria-pressed="true"] {
  width: 15px;
  min-width: 15px;
  min-height: 15px;
  height: 15px;
  box-shadow: 0 0 0 5px rgba(45, 212, 191, 0.16);
}

.timeline-replay-range {
  width: 100%;
  accent-color: var(--r2-accent);
}

.timeline-replay-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.timeline-replay-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  background: rgba(148, 163, 184, 0.06);
}

.timeline-replay-card strong {
  display: block;
  margin: 3px 0;
  color: var(--r2-text);
  font-size: 13px;
}

.timeline-replay-card p {
  margin: 0;
  color: var(--r2-text-secondary);
  font-size: 12px;
  line-height: 1.35;
}

.timeline-replay-card em {
  padding: 5px 8px;
  border: 1px solid rgba(45, 212, 191, 0.42);
  border-radius: var(--r2-radius-sm);
  color: var(--source-color, var(--r2-accent));
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-style: normal;
  font-weight: 850;
  text-transform: uppercase;
  white-space: nowrap;
}

.map-tools {
  top: 14px;
  left: 58px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
}

/* Find-on-map feature search (floats below the top toolbar). */
.map-search {
  position: absolute;
  top: 58px;
  left: 58px;
  z-index: 950;
  width: min(300px, 42vw);
}

.map-search > input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.86);
  color: var(--r2-text);
  font-size: 13px;
  box-shadow: var(--r2-shadow-card);
  backdrop-filter: blur(18px);
}

.map-search > input:focus {
  outline: none;
  border-color: var(--r2-accent);
  box-shadow: 0 0 0 3px var(--r2-accent-dim), var(--r2-shadow-card);
}

.map-search-icon {
  position: absolute;
  top: 11px;
  left: 11px;
  z-index: 1;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--r2-text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.map-search-results {
  margin-top: 6px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.94);
  box-shadow: var(--r2-shadow-card);
  backdrop-filter: blur(18px);
}

.map-search-result {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 0;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--r2-border);
  border-radius: 0;
  background: transparent;
  color: var(--r2-text);
  text-align: left;
  box-shadow: none;
}

.map-search-result:last-child {
  border-bottom: 0;
}

.map-search-result:hover,
.map-search-result.is-active {
  background: var(--r2-accent-dim);
}

.map-search-result strong {
  font-size: 13px;
  font-weight: 700;
}

.map-search-result span {
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 11px;
}

.map-search-empty {
  padding: 10px 12px;
  color: var(--r2-text-muted);
  font-size: 12px;
}

.map-tools button {
  min-height: 30px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 12px;
}

.map-tools button:hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.map-tools button[aria-pressed="true"] {
  border-color: rgba(45, 212, 191, 0.72);
  background: var(--r2-accent);
  color: #03211c;
}

.tool-separator {
  width: 1px;
  min-height: 24px;
  align-self: center;
  background: var(--r2-border-medium);
}

/* --- Weather / wind overlay ------------------------------------------------ */
.weather-legend {
  top: 56px;
  left: 58px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--r2-text-secondary);
}

.weather-legend strong {
  font-size: 11px;
  color: var(--r2-text-primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.weather-legend-scale {
  width: 150px;
  height: 8px;
  border-radius: 4px;
  /* Matches windColor() in farsight.js: calm -> gale. */
  background: linear-gradient(
    90deg,
    #3b82f6 0%,
    #22d3ee 28%,
    #22c55e 48%,
    #eab308 68%,
    #f97316 84%,
    #ef4444 100%
  );
}

.weather-legend-ticks {
  display: flex;
  justify-content: space-between;
  width: 150px;
  font-variant-numeric: tabular-nums;
}

.weather-legend-time {
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

/* Canvas painted by the WeatherLayer custom Leaflet layer. */
.weather-pane canvas {
  pointer-events: none;
}

.map-hud {
  right: 16px;
  bottom: 296px;
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, auto));
  gap: 1px;
  overflow: hidden;
}

.map-hud .panel-toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}

.map-hud div {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.02);
}

.map-hud .hud-cell {
  position: relative;
}

/* Quick-copy button, revealed on cell hover. */
.hud-copy {
  position: absolute;
  top: 3px;
  right: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--r2-border-medium);
  border-radius: 5px;
  background: rgba(10, 14, 26, 0.85);
  color: var(--r2-text-secondary);
  opacity: 0;
  cursor: pointer;
  transition: opacity 100ms ease;
}

.hud-cell:hover .hud-copy {
  opacity: 1;
}

.hud-copy svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hud-copy:hover {
  color: var(--r2-accent);
  border-color: var(--r2-border-accent);
}

.hud-copy.is-copied {
  background: var(--r2-accent);
  border-color: var(--r2-accent);
  color: #03211c;
  opacity: 1;
}

.map-hud span,
.map-legend-head span {
  color: var(--r2-text-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.map-hud strong,
.map-legend-head strong {
  overflow-wrap: anywhere;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.map-hud .hud-actions {
  display: flex;
  gap: 5px;
  margin-top: 2px;
  /* Reserve the top-right corner for the collapse toggle so the icon buttons
     don't sit under it. */
  justify-content: flex-end;
  padding-right: 36px;
}

.hud-link-btn {
  flex: 1;
  cursor: pointer;
  padding: 3px 7px;
  border: 1px solid var(--r2-border, rgba(45, 212, 191, 0.35));
  border-radius: 6px;
  background: rgba(45, 212, 191, 0.08);
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}

.hud-link-btn:hover {
  background: rgba(45, 212, 191, 0.18);
}

.hud-link-btn[aria-pressed="true"] {
  background: rgba(45, 212, 191, 0.28);
  border-color: #2dd4bf;
}

.hud-link-btn.is-copied {
  background: var(--r2-accent, #2dd4bf);
  border-color: #2dd4bf;
  color: #03211c;
}

/* Compact icon variant (Copy link / Grid) — sit on one line, not stretched. */
.hud-icon-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  padding: 0;
}

.hud-icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-hud[data-collapsed="true"] .hud-actions {
  display: none;
}

/* Right-click coordinate menu */
.coord-menu {
  position: fixed;
  z-index: 1200;
  min-width: 230px;
  padding: 5px;
  border: 1px solid var(--r2-border-accent, rgba(45, 212, 191, 0.42));
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.96);
  box-shadow: var(--r2-shadow-card);
  backdrop-filter: blur(18px);
}

.coord-menu-head {
  padding: 4px 8px 6px;
  color: var(--r2-text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.coord-menu-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 0;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--r2-radius-sm);
  background: transparent;
  color: var(--r2-text);
  text-align: left;
  box-shadow: none;
  cursor: pointer;
}

.coord-menu-item:hover {
  background: var(--r2-accent-dim);
}

.coord-menu-label {
  color: var(--r2-text-secondary);
  font-size: 11px;
  white-space: nowrap;
}

.coord-menu-value {
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  text-align: right;
}

.coord-menu-share {
  margin-top: 3px;
  border-top: 1px solid var(--r2-border);
  border-radius: 0 0 var(--r2-radius-sm) var(--r2-radius-sm);
}

.coord-menu-share .coord-menu-label {
  color: var(--r2-accent);
}

.map-legend {
  left: 16px;
  bottom: 296px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr); /* fixed head + scrollable list */
  width: min(320px, calc(100% - 32px));
  max-height: 52vh;
  overflow: hidden;
}

.map-legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--r2-border);
}

.map-legend-head .panel-toggle {
  margin-left: auto;
}

.map-legend-head .legend-features {
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.map-legend-items {
  display: grid;
  gap: 4px;
  min-height: 0; /* allow the grid track to shrink so overflow-y scrolls */
  /* Explicit cap (not just the parent's max-height) so the list always
     scrolls — an absolutely-positioned grid's 1fr track can otherwise size to
     content and never engage the inner overflow. ~56px reserves the header. */
  max-height: calc(52vh - 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  scrollbar-color: rgba(45, 212, 191, 0.35) rgba(255, 255, 255, 0.04);
}

.map-legend-items p {
  margin: 0;
  padding: 4px;
  color: var(--r2-text-muted);
  font-size: 12px;
}

/* A collapsed floating panel hides entirely — the top "Panels" manager is the
   single control that brings it back, so no stray "+" stubs litter the map. */
.panel-float[data-collapsed="true"] {
  display: none !important;
}

/* Draggable map panels: grab affordance + smooth pickup. */
.panel-float,
.feature-panel.is-open {
  cursor: grab;
}

.panel-float button,
.panel-float input,
.panel-float select,
.panel-float a,
.panel-float .timeline-replay-range,
.feature-panel button,
.feature-panel input,
.feature-panel select,
.feature-panel a {
  cursor: auto;
}

.panel-float.is-dragging,
.feature-panel.is-dragging {
  cursor: grabbing;
  user-select: none;
  transition: none;
}

.time-tools[data-collapsed="true"] {
  grid-template-columns: 26px;
}

.panel-float:not(.map-legend)[data-collapsed="true"] > :not(.panel-toggle),
.map-legend[data-collapsed="true"] .map-legend-items,
.map-legend[data-collapsed="true"] .map-legend-head > :not(.panel-toggle),
.map-hud[data-collapsed="true"] div {
  display: none;
}

.map-legend[data-collapsed="true"] .map-legend-head {
  min-height: 36px;
  padding: 4px;
  border-bottom: 0;
}

.map-hud[data-collapsed="true"] {
  display: block;
  width: 36px;
  height: 36px;
}

.map-hud[data-collapsed="true"] .panel-toggle {
  position: static;
  margin: 4px;
}

.legend-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  min-height: 42px;
  border-radius: 8px;
}

.legend-item:hover {
  background: var(--r2-accent-dim);
}

.legend-item.is-dragging {
  opacity: 0.5;
}

.legend-item.is-drop-target {
  box-shadow: inset 0 2px 0 0 var(--r2-accent);
}

.legend-drag {
  display: flex;
  align-items: center;
  padding: 0 2px 0 4px;
  color: var(--r2-text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: grab;
  user-select: none;
}

.legend-drag:active {
  cursor: grabbing;
}

.legend-item:hover .legend-drag {
  color: var(--r2-text-secondary);
}

.legend-item.is-hidden .legend-focus {
  opacity: 0.42;
}

.legend-focus {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  justify-content: start;
  align-items: start;
  min-width: 0;
  padding: 8px;
  border-color: transparent;
  background: transparent;
  color: var(--r2-text);
  box-shadow: none;
  text-align: left;
}

.legend-visibility {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--r2-text-secondary);
  box-shadow: none;
  cursor: pointer;
}

.legend-visibility:hover {
  color: var(--r2-text);
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
}

.legend-item.is-hidden .legend-visibility {
  color: var(--r2-text-secondary);
  opacity: 0.7;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--layer-color);
  color: #06111f;
  box-shadow: 0 0 10px var(--layer-color);
}

.legend-item strong,
.legend-item em {
  display: block;
  min-width: 0;
}

.legend-item strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-item em {
  margin-top: 3px;
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-style: normal;
}

.power-key {
  display: grid;
  gap: 10px;
  margin-bottom: 6px;
  padding: 10px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(15, 23, 42, 0.62);
}

.power-key-title,
.power-key-section h4 {
  margin: 0;
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.power-key-section {
  display: grid;
  gap: 6px;
}

.power-key-rows {
  display: grid;
  gap: 5px;
}

.power-key-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 18px;
  color: var(--r2-text-secondary);
  font-size: 11px;
}

.power-key-row span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.power-key-row em {
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.power-key-line {
  display: block;
  width: 28px;
  height: 0;
  border-top: 3px solid var(--key-color);
  border-radius: 999px;
  box-shadow: 0 0 8px color-mix(in srgb, var(--key-color), transparent 35%);
}

.power-key-line.is-dashed {
  border-top-style: dashed;
}

/* Editable altitude-band swatch in the color key (Active Layers panel). */
.alt-key-color {
  width: 28px;
  height: 14px;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 4px;
  background: none;
  cursor: pointer;
  flex: 0 0 auto;
}
.alt-key-color::-webkit-color-swatch-wrapper {
  padding: 0;
}
.alt-key-color::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}
.power-key-hint {
  opacity: 0.6;
  font-size: 0.85em;
  cursor: help;
}

.power-key-dot {
  justify-self: center;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: 0 0 8px currentColor;
}

.leaflet-container {
  background: #050914;
  color: var(--r2-text);
  font-family: var(--r2-font-sans);
}

.leaflet-container {
  overflow: hidden;
  outline-offset: 1px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  border: 0;
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-zoom-animated {
  transform-origin: 0 0;
}

.leaflet-interactive {
  cursor: pointer;
}

.leaflet-grab {
  cursor: grab;
}

.leaflet-dragging .leaflet-grab {
  cursor: move;
  cursor: grabbing;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  float: left;
  clear: both;
}

.leaflet-right .leaflet-control {
  float: right;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-right .leaflet-control {
  margin-right: 10px;
}

.leaflet-control-zoom a {
  display: block;
  width: 34px;
  height: 34px;
  line-height: 34px;
  text-align: center;
  text-decoration: none;
}

.leaflet-control-container .leaflet-control {
  border: 1px solid var(--r2-border) !important;
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.78);
  backdrop-filter: blur(14px);
  box-shadow: var(--r2-shadow-card);
}

.leaflet-bar a,
.leaflet-bar a:hover {
  border-bottom-color: var(--r2-border) !important;
  background: transparent;
  color: var(--r2-text);
}

.leaflet-bar a:hover {
  color: var(--r2-accent);
}

.leaflet-control-attribution {
  color: var(--r2-text-muted);
  font-size: 10px;
}

.leaflet-control-attribution a {
  color: var(--r2-text-accent);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  border: 1px solid var(--r2-border);
  background: rgba(10, 14, 26, 0.94);
  color: var(--r2-text);
  box-shadow: var(--r2-shadow-card-hover);
}

.leaflet-popup-content {
  max-width: 300px;
  overflow-wrap: anywhere;
}

.leaflet-popup-content strong {
  color: var(--r2-text-accent);
}

.leaflet-overlay-pane {
  z-index: 600 !important;
}

.leaflet-feed-area-pane-pane {
  z-index: 610 !important;
}

.leaflet-feed-line-pane-pane {
  z-index: 640 !important;
}

.leaflet-feed-point-pane-pane {
  z-index: 700 !important;
}

.leaflet-shadow-pane {
  z-index: 690 !important;
}

.leaflet-marker-pane {
  z-index: 700 !important;
}

.leaflet-tooltip-pane {
  z-index: 710 !important;
}

.leaflet-popup-pane {
  z-index: 720 !important;
}

.leaflet-overlay-pane svg {
  overflow: visible;
}

.leaflet-overlay-pane path {
  filter: drop-shadow(0 1px 2px rgba(45, 212, 191, 0.1)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.38));
}

.leaflet-feed-area-pane-pane path,
.leaflet-feed-area-pane-pane canvas {
  opacity: 0.78;
  filter: drop-shadow(0 1px 1px rgba(45, 212, 191, 0.04));
}

.leaflet-feed-line-pane-pane path,
.leaflet-feed-line-pane-pane canvas {
  opacity: 0.82;
  filter: drop-shadow(0 1px 2px rgba(45, 212, 191, 0.1)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}

.leaflet-tile-pane {
  filter: saturate(0.82) contrast(1.04) brightness(0.86);
}

.feed-marker {
  width: 22px !important;
  height: 22px !important;
  margin-left: -11px !important;
  margin-top: -11px !important;
  border: 0;
  background: transparent;
  color: #06111f;
  transition: box-shadow var(--r2-fast), transform var(--r2-fast);
}

.marker-fill {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border: 2px solid #07111f;
  border-radius: inherit;
  background: var(--layer-color);
  box-shadow:
    0 0 0 2px rgba(248, 250, 252, 0.92),
    0 0 12px color-mix(in srgb, var(--layer-color) 65%, transparent),
    0 5px 10px rgba(0, 0, 0, 0.34);
}

.marker-symbol {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: #06111f;
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
}

body[data-marker-mode="dots"] .feed-marker {
  width: 16px !important;
  height: 16px !important;
  margin-left: -8px !important;
  margin-top: -8px !important;
}

body[data-marker-mode="dots"] .marker-fill,
body[data-marker-mode="dots"] .swatch,
body[data-marker-mode="dots"] .legend-swatch {
  border-radius: 999px;
  clip-path: none;
}

body[data-marker-mode="dots"] .marker-symbol,
body[data-marker-mode="dots"] .swatch span,
body[data-marker-mode="dots"] .legend-swatch span {
  display: none;
}

.marker-shape-circle,
.marker-shape-circle .marker-fill {
  border-radius: 999px;
}

.marker-shape-square,
.marker-shape-square .marker-fill {
  border-radius: 6px;
}

.marker-shape-diamond,
.marker-shape-diamond .marker-fill {
  border-radius: 5px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.marker-shape-triangle,
.marker-shape-triangle .marker-fill {
  border-radius: 3px;
  clip-path: polygon(50% 0, 100% 88%, 0 88%);
}

.marker-shape-hex,
.marker-shape-hex .marker-fill {
  border-radius: 4px;
  clip-path: polygon(25% 4%, 75% 4%, 100% 50%, 75% 96%, 25% 96%, 0 50%);
}

.marker-shape-star,
.marker-shape-star .marker-fill {
  border-radius: 4px;
  clip-path: polygon(50% 0, 62% 33%, 98% 35%, 69% 56%, 79% 91%, 50% 70%, 21% 91%, 31% 56%, 2% 35%, 38% 33%);
}

/* Symbols-mode plan-view glyphs (vessels / aircraft), oriented by heading. */
.glyph-marker.feed-marker {
  width: 26px !important;
  height: 26px !important;
  margin-left: -13px !important;
  margin-top: -13px !important;
}
.marker-glyph {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
}
.marker-glyph svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
body[data-marker-mode="dots"] .marker-glyph {
  display: none;
}

.marker-shape-line {
  height: 4px;
  border-radius: 999px;
}

.marker-shape-area {
  border-radius: 4px;
  opacity: 0.72;
}

.feed-marker.is-hovered,
.feed-marker.is-selected {
  transform: scale(1.28);
  box-shadow:
    0 0 0 3px rgba(248, 250, 252, 0.95),
    0 0 18px rgba(45, 212, 191, 0.82),
    0 8px 18px rgba(0, 0, 0, 0.42);
}

.feed-marker.is-selected {
  outline: 2px solid var(--r2-accent);
  outline-offset: 4px;
}

.feed-cluster {
  /* Cluster icons keep Leaflet's count-scaled iconSize/iconAnchor (they do NOT
     carry the fixed-size .feed-marker class). Transparent so the round bubble
     never sits on the div-icon's default square. */
  background: transparent;
  border: 0;
  border-radius: 999px;
}

.cluster-fill {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 999px;
  color: #f8fafc;
  /* Translucent layer-coloured core so the basemap reads through the bubble —
     keeps clusters subtle against the dark map rather than solid blobs. */
  background: radial-gradient(
    circle at 50% 38%,
    color-mix(in srgb, var(--layer-color) 66%, transparent),
    color-mix(in srgb, var(--layer-color) 46%, transparent)
  );
  /* Thin tinted hairline + a soft glow = a clean, restrained cluster read. */
  border: 1px solid color-mix(in srgb, var(--layer-color) 55%, transparent);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--layer-color) 9%, transparent),
    0 0 10px color-mix(in srgb, var(--layer-color) 22%, transparent),
    0 2px 6px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(1px);
}

.cluster-fill span {
  font-family: var(--r2-font-mono);
  font-size: inherit; /* per-bubble size set on the icon, scales with count */
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.cluster-feature-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cluster-feature-list li {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  background: rgba(148, 163, 184, 0.06);
}

.cluster-feature-list strong {
  overflow: hidden;
  color: var(--r2-text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster-feature-list span {
  color: var(--r2-text-secondary);
  font-size: 11px;
}

.r2-feature-tooltip {
  border: 1px solid var(--r2-border-accent);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.94);
  color: var(--r2-text);
  box-shadow: var(--r2-shadow-card-hover);
  backdrop-filter: blur(16px);
}

.r2-feature-tooltip::before {
  border-top-color: var(--r2-border-accent);
}

.feature-tooltip {
  display: grid;
  gap: 4px;
  min-width: 160px;
}

.feature-tooltip strong {
  color: var(--r2-text);
  font-size: 12px;
  line-height: 1.2;
}

.feature-flag {
  margin-right: 6px;
  font-size: 14px;
  line-height: 1;
  vertical-align: -1px;
}

.feature-tooltip span {
  color: var(--r2-text-accent);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Freshness cue dot next to the target name. */
.tt-fresh {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--fresh, #94a3b8);
  box-shadow: 0 0 6px var(--fresh, #94a3b8);
  vertical-align: 1px;
}

/* Compact COG / SPD / DEST / SIDC readout grid in the hover tooltip. */
.feature-tooltip .tt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 10px;
  margin-top: 2px;
}

.feature-tooltip .tt-grid span {
  display: flex;
  gap: 6px;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  overflow-wrap: anywhere;
}

.feature-tooltip .tt-grid em {
  color: var(--r2-text-muted);
  font-style: normal;
  font-weight: 700;
}

.feature-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
  display: flex;
  width: min(420px, calc(100% - 32px));
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-lg);
  background: rgba(10, 14, 26, 0.94);
  box-shadow: var(--r2-shadow-card-hover);
  backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 24px));
  transition: opacity var(--r2-fast), transform 220ms ease;
}

.feature-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.feature-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: start;
  padding: 18px;
  border-bottom: 1px solid var(--r2-border);
  background: rgba(255, 255, 255, 0.02);
}

.feature-panel-head h2 {
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.18;
}

.feature-kicker {
  margin: 0;
  color: var(--r2-text-accent);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.feature-close {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: var(--r2-border);
  background: rgba(148, 163, 184, 0.06);
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 22px;
  line-height: 1;
}

.feature-close:hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.feature-panel-body {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  scrollbar-color: rgba(45, 212, 191, 0.35) rgba(255, 255, 255, 0.04);
}

/* Grid items default to min-width:auto, which lets wide content force a
   horizontal scrollbar — pin to 0 so everything fits the panel width. */
.feature-panel-body > * {
  min-width: 0;
}

.feature-panel[data-collapsed="true"] {
  bottom: auto;
  max-height: 92px;
}

.feature-panel[data-collapsed="true"] .feature-panel-head {
  border-bottom: 0;
}

.feature-panel[data-collapsed="true"] .feature-panel-body {
  display: none;
}

.feature-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(148, 163, 184, 0.06);
}

.feature-tab-icon {
  font-size: 12px;
  opacity: 0.85;
}

.feature-tabs button {
  min-width: 0;
  min-height: 32px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 12px;
}

.feature-tabs button:hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.feature-tabs button[aria-selected="true"] {
  border-color: rgba(45, 212, 191, 0.6);
  background: var(--r2-accent);
  color: #04221d;
}

.feature-pane {
  display: grid;
  gap: 12px;
}

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

.feature-empty {
  margin: 0;
  color: var(--r2-text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.feature-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.feature-summary div {
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
}

.feature-summary span,
.feature-section h3,
.feature-desc dt {
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.feature-summary strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

/* Ship class & capabilities tab */
.class-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.class-head strong {
  color: var(--r2-text);
  font-size: 15px;
  font-weight: 800;
}
.class-badge {
  padding: 2px 7px;
  border: 1px solid var(--r2-border-medium);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
  color: var(--r2-text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.class-badge--data {
  border-color: rgba(45, 212, 191, 0.6);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}
.class-role {
  margin: 6px 0 10px;
  color: var(--r2-text-secondary);
  font-size: 13px;
  line-height: 1.45;
}
.class-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.class-chip {
  padding: 4px 9px;
  border: 1px solid var(--r2-border);
  border-radius: 999px;
  background: var(--r2-surface);
  color: var(--r2-text);
  font-size: 11px;
  font-weight: 600;
}
.class-note {
  margin: 8px 0 0;
  color: var(--r2-text-muted);
  font-size: 11px;
  line-height: 1.45;
}
.class-note--caveat {
  padding-top: 8px;
  border-top: 1px dashed var(--r2-border);
  font-style: italic;
}

.feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.feature-actions button,
.feature-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--r2-border-medium);
  border-radius: var(--r2-radius-sm);
  background: rgba(148, 163, 184, 0.08);
  color: var(--r2-text);
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.feature-actions button:hover,
.feature-actions a:hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.feature-actions span {
  margin-left: auto;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
}

.feature-visual-list,
.feature-card-grid {
  display: grid;
  gap: 8px;
}

.feature-visual-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-visual-list article,
.feature-data-card {
  min-width: 0;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
}

.feature-visual-list article {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.feature-visual-list span,
.feature-data-card em {
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.feature-visual-list strong {
  overflow-wrap: anywhere;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 12px;
}

.feature-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-data-card {
  display: grid;
  gap: 8px;
  padding: 11px;
}

.feature-data-card h4 {
  margin: 0;
  overflow: hidden;
  color: var(--r2-text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feature-data-card div {
  display: grid;
  gap: 6px;
}

.feature-data-card span {
  display: grid;
  gap: 2px;
}

.feature-data-card strong {
  overflow-wrap: anywhere;
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  line-height: 1.3;
}

.feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feature-chips span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--r2-border);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--r2-text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.feature-section {
  display: grid;
  gap: 10px;
}

.feature-section h3 {
  margin: 0;
}

/* Visual representation of the clicked object (Data tab header). */
.feature-visual {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
}

.feature-visual-meta {
  min-width: 0;
}

.feature-visual-glyph {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
}

/* Inline 3D model preview (satellites). */
.feature-model {
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
  border-radius: var(--r2-radius-md);
  background:
    radial-gradient(circle at 50% 40%, rgba(148, 163, 184, 0.12), rgba(10, 14, 26, 0.6) 70%);
  touch-action: none;
}

.feature-model canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* OpenBridge navigation instruments (compass + speed) in the target panel. */
.obc-instrument-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.feature-compass {
  display: block;
  width: 180px;
  height: 180px;
}

.feature-speed {
  display: block;
  width: 116px;
  height: 180px;
}

/* Avoid a flash of empty box before the custom elements register. */
obc-compass:not(:defined),
obc-heading-indicator:not(:defined),
obc-speed-indicator:not(:defined),
obc-speed-gauge:not(:defined),
obc-rate-of-turn:not(:defined),
obc-gauge-radial:not(:defined) {
  visibility: hidden;
}

/* --- Conning display: bridge-style panel of large live gauges -------------- */
.conning-panel {
  position: absolute;
  left: 360px;
  bottom: 110px;
  z-index: 945;
  width: min(720px, calc(100% - 380px));
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  display: grid;
  gap: 12px;
  padding: 12px 14px 14px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-lg);
  background: rgba(10, 14, 26, 0.94);
  box-shadow: var(--r2-shadow-card-hover);
  backdrop-filter: blur(20px);
}

.conning-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.conning-id {
  margin-right: auto;
  min-width: 0;
}

.conning-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.conning-id h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 0;
  color: var(--r2-text);
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

/* APP-6 SIDC badge to the left of the tracked target's id. */
.conning-sidc {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-top: 1px;
}
.conning-sidc:empty {
  display: none;
}

/* Country flag next to the name. */
.conning-flag {
  font-size: 18px;
  line-height: 1;
}
.conning-flag:empty {
  display: none;
}

.conning-stop {
  width: 26px;
  min-height: 26px;
  padding: 0;
  border: 1px solid var(--r2-border-medium);
  border-radius: var(--r2-radius-sm);
  background: transparent;
  color: var(--r2-text-muted);
  font-size: 12px;
  cursor: pointer;
}

.conning-stop:hover {
  border-color: var(--r2-border-accent);
  color: var(--r2-text);
}

.conning-instruments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px 14px;
  justify-items: center;
}

.conning-gauge {
  margin: 0;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

/* Uniform, square, label-safe gauges that scale to the grid cell. */
.conning-gauge obc-compass,
.conning-gauge obc-heading-indicator,
.conning-gauge obc-speed-gauge,
.conning-gauge obc-rate-of-turn,
.conning-gauge obc-gauge-radial {
  display: block;
  width: 100%;
  max-width: 150px;
  aspect-ratio: 1 / 1;
  height: auto;
}

.conning-gauge figcaption {
  text-align: center;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.conning-readouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.conning-readouts div {
  padding: 7px 9px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  background: var(--r2-surface);
}

.conning-readouts span {
  display: block;
  color: var(--r2-text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.conning-readouts strong {
  display: block;
  margin-top: 2px;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.conning-readouts[hidden] {
  display: none;
}

/* --- Multi-tab conning views ---------------------------------------------- */
.conning-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: -2px 0 2px;
  border-bottom: 1px solid var(--r2-border);
}

.conning-tab {
  appearance: none;
  padding: 7px 12px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    color 0.12s ease,
    border-color 0.12s ease;
}

.conning-tab:hover {
  color: var(--r2-text);
}

.conning-tab.is-active {
  color: var(--r2-text);
  border-bottom-color: var(--r2-border-accent);
}

/* A single full-width child (Voyage/Flight readouts) takes the whole row. */
.conning-instruments:has(.conning-readouts--full) {
  display: block;
}

.conning-readouts--full {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Enlarged single-instrument tabs (Compass / Wind). */
.conning-gauge--xl {
  grid-column: 1 / -1;
}

.conning-gauge--xl obc-compass {
  max-width: 300px;
}

/* Speed tab: SOG vector arrows + live trend sparkline. */
.conning-arrows obc-speed-arrows {
  display: block;
  width: 100%;
  max-width: 120px;
  height: auto;
}

.conning-trend {
  grid-column: 1 / -1;
}

.conning-spark-wrap {
  width: 100%;
  padding: 6px 4px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  background: var(--r2-surface);
}

.conning-spark {
  display: block;
  width: 100%;
  height: 56px;
  color: var(--r2-accent, #67e8f9);
}

.conning-spark polyline {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.conning-spark line {
  stroke: var(--r2-border-medium);
  stroke-width: 1;
}

/* Greyed "no feed data" placeholder (Wind tab). */
.conning-nodata {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 6px 0;
  opacity: 0.55;
  filter: grayscale(1);
}

.conning-nodata obc-wind {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
}

.conning-nodata-note {
  margin: 0;
  max-width: 320px;
  text-align: center;
  color: var(--r2-text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.conning-nodata-note strong {
  display: block;
  margin-bottom: 2px;
  color: var(--r2-text);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* CPA/TCPA proximity readout (FEEDS-qsh.6). */
.conning-cpa {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.conning-cpa .cpa-head {
  color: var(--r2-text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.conning-cpa .cpa-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: baseline;
  padding: 5px 9px;
  border: 1px solid var(--r2-border);
  border-left: 3px solid #f59e0b;
  border-radius: var(--r2-radius-sm);
  background: var(--r2-surface);
  font-size: 11px;
}

.conning-cpa .cpa-row.cpa-danger {
  border-left-color: #ef4444;
}

/* Click-to-focus on a CPA contact (pans + opens its panel, retargeting CPA). */
.conning-cpa .cpa-row[role="button"] {
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.conning-cpa .cpa-row[role="button"]:hover,
.conning-cpa .cpa-row[role="button"]:focus-visible {
  background: var(--r2-surface-2, var(--r2-surface));
  border-color: var(--r2-accent, currentColor);
  outline: none;
}

.conning-cpa .cpa-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--r2-text);
}

.conning-cpa .cpa-row strong {
  font-family: var(--r2-font-mono);
  color: var(--r2-text);
}

.conning-cpa .cpa-row em {
  font-style: normal;
  font-family: var(--r2-font-mono);
  color: var(--r2-text-muted);
}

/* OpenBridge icon library (obi-* elements). */
.ob-icon {
  display: inline-flex;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -2px;
  margin-right: 6px;
  color: var(--r2-text-muted);
}

.ob-icon-lg {
  display: inline-flex;
  width: 44px;
  height: 44px;
  color: var(--r2-accent);
}

.ob-icon:not(:defined),
.ob-icon-lg:not(:defined) {
  visibility: hidden;
}

.feature-visual-swatch.swatch {
  width: 44px;
  height: 44px;
}

.feature-visual-swatch.swatch span {
  font-size: 18px;
}

.feature-visual-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.feature-visual-meta strong {
  overflow-wrap: anywhere;
  color: var(--r2-text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.feature-visual-meta span {
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 11px;
}

.feature-count {
  display: inline-flex;
  align-items: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--r2-text-secondary);
  font-size: 10px;
  font-weight: 800;
}

/* Full attribute table (Data tab). */
.feature-data-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  overflow: hidden;
  font-size: 12px;
}

.feature-data-table tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.05);
}

.feature-data-table th,
.feature-data-table td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--r2-border);
}

.feature-data-table tr:last-child th,
.feature-data-table tr:last-child td {
  border-bottom: 0;
}

.feature-data-table th[scope="row"] {
  width: 40%;
  color: var(--r2-text-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
}

.feature-data-table td {
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.feature-desc {
  display: grid;
  grid-template-columns: minmax(92px, max-content) minmax(0, 1fr);
  gap: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
}

.feature-desc dt,
.feature-desc dd {
  min-width: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--r2-border);
}

.feature-desc dt:nth-of-type(1),
.feature-desc dd:nth-of-type(1) {
  border-top: 0;
}

.feature-desc dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.feature-raw {
  margin-top: 4px;
}

.feature-raw > summary {
  cursor: pointer;
  padding: 6px 0;
  color: var(--r2-text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  list-style: none;
}

.feature-raw > summary::-webkit-details-marker {
  display: none;
}

.feature-raw > summary::before {
  content: "▸ ";
  display: inline-block;
  color: var(--r2-text-secondary);
}

.feature-raw[open] > summary::before {
  content: "▾ ";
}

.feature-raw > summary:hover {
  color: var(--r2-text);
}

.feature-code {
  max-height: 320px;
  margin: 6px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(0, 0, 0, 0.35);
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre;
}

.dashboard-page {
  position: fixed;
  inset: 14px;
  z-index: 5000;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-lg);
  background:
    radial-gradient(ellipse at 18% 0%, rgba(45, 212, 191, 0.08), transparent 45%),
    radial-gradient(ellipse at 88% 10%, rgba(139, 92, 246, 0.07), transparent 45%),
    rgba(10, 14, 26, 0.97);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(24px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.985);
  transition: opacity var(--r2-fast), transform 220ms ease;
  visibility: hidden;
}

.dashboard-page.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--r2-border);
  background: rgba(255, 255, 255, 0.02);
}

.dashboard-header h2,
.admin-card h3 {
  margin: 0;
  color: var(--r2-text);
  font-size: 22px;
  line-height: 1.15;
}

.dashboard-kicker {
  margin: 0 0 5px;
  color: var(--r2-text-accent);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-close {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: var(--r2-border);
  background: rgba(148, 163, 184, 0.06);
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 24px;
}

.dashboard-close:hover {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.dashboard-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  padding: 16px;
}

.dashboard-page[data-operator-view="true"] .dashboard-content {
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}

.dashboard-page[data-operator-view="false"] .dashboard-rail {
  display: none;
}

.dashboard-rail,
.dashboard-main,
.admin-card {
  min-height: 0;
}

.dashboard-rail {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 8px;
}

.dashboard-metrics div {
  position: relative;
  min-width: 0;
  padding: 12px 12px 12px 42px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
  box-shadow: var(--r2-shadow-card);
}

.dashboard-metrics div::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  border: 1px solid var(--r2-border-accent);
  border-radius: 6px;
  background: var(--r2-accent-dim);
}

.dashboard-metrics span,
.admin-field span,
.dashboard-search span,
.dashboard-filter span {
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-metrics strong {
  display: block;
  margin-top: 5px;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 18px;
}

.admin-card {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(17, 24, 39, 0.72);
  box-shadow: var(--r2-shadow-card);
}

.admin-card h3 {
  font-size: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-field,
.dashboard-search,
.dashboard-filter {
  display: grid;
  gap: 6px;
}

.admin-field input,
.admin-field select,
.admin-field textarea,
.dashboard-search input,
.dashboard-filter select {
  width: 100%;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-input);
  color: var(--r2-text);
  font: inherit;
  font-size: 13px;
}

.admin-field input,
.admin-field select,
.dashboard-search input,
.dashboard-filter select {
  min-height: 36px;
  padding: 0 11px;
}

.admin-field textarea {
  min-height: 96px;
  padding: 10px 11px;
  resize: vertical;
}

.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus,
.dashboard-search input:focus,
.dashboard-filter select:focus {
  outline: none;
  border-color: var(--r2-accent);
  box-shadow: 0 0 0 3px var(--r2-accent-dim);
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-actions button {
  min-width: 0;
}

.admin-note {
  margin: 0;
  color: var(--r2-text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.dashboard-main {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 10px;
}

.dashboard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(148, 163, 184, 0.06);
}

.dashboard-tabs button,
.dashboard-edit {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 12px;
}

.dashboard-tabs button:hover,
.dashboard-edit:hover {
  border-color: var(--r2-border-accent);
  /* Slightly stronger tint + bright text so the label stays legible on hover
     instead of melting into the accent-dim background. */
  background: rgba(45, 212, 191, 0.22);
  color: var(--r2-text);
}

/* Global hover contrast pass: the accent-on-accent-dim combo used across menus,
   chips and floating panels washes out the label. Force bright text and a
   slightly stronger tint so every hovered control reads cleanly. */
.layer-format-menu a:hover,
.api-menu a:hover,
.time-tools button:not(.panel-toggle):hover,
.panel-toggle:hover {
  background: rgba(45, 212, 191, 0.22) !important;
  color: var(--r2-text) !important;
}

.dashboard-tabs button:hover.is-active,
.dashboard-tabs button.is-active:hover {
  /* Keep the active tab's high-contrast dark-on-accent regardless of hover. */
  background: var(--r2-accent);
  color: #04221d;
}

.dashboard-tabs button.is-active {
  border-color: rgba(45, 212, 191, 0.6);
  background: var(--r2-accent);
  color: #04221d;
}

.dashboard-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px) auto auto auto;
  align-items: end;
  gap: 10px;
}

.dashboard-view-tools {
  display: inline-flex;
  gap: 4px;
  align-self: end;
  padding: 3px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(148, 163, 184, 0.06);
}

.dashboard-view-tools button,
.dashboard-new-draft {
  min-height: 32px;
  padding: 0 12px;
  border-color: transparent;
  background: transparent;
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
}

.dashboard-new-draft {
  align-self: end;
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.dashboard-view-tools button:hover,
.dashboard-new-draft:hover {
  border-color: var(--r2-border-accent);
  color: var(--r2-accent);
}

.dashboard-view-tools button.is-active {
  background: var(--r2-accent);
  color: #04221d;
}

.dashboard-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 9px;
  color: var(--r2-text-secondary);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.dashboard-toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--r2-accent);
  cursor: pointer;
}

.dashboard-table-wrap {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.55);
}

.dashboard-table-wrap[hidden],
.dashboard-grid[hidden] {
  display: none;
}

.dashboard-table {
  width: 100%;
  min-width: 920px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.dashboard-table th,
.dashboard-table td {
  padding: 11px 12px;
  border-top: 1px solid var(--r2-border);
  vertical-align: top;
  text-align: left;
}

.dashboard-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-top: 0;
  background: rgba(10, 14, 26, 0.94);
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-table tbody tr:hover td {
  background: rgba(45, 212, 191, 0.045);
}

.dashboard-table td strong,
.dashboard-table td span,
.dashboard-table td em,
.dashboard-table td p {
  display: block;
}

.dashboard-feed-title,
.dashboard-card-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.dashboard-feed-copy {
  min-width: 0;
}

.dashboard-feed-icon {
  display: inline-grid !important;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0 !important;
  border: 1px solid rgba(45, 212, 191, 0.22);
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.08);
  color: var(--r2-accent);
}

.dashboard-feed-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dashboard-category-chip {
  display: inline-flex !important;
  width: max-content;
  margin-top: 8px !important;
  min-height: 20px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(248, 113, 113, 0.6);
  border-radius: 999px;
  color: #fb7185 !important;
  background: rgba(248, 113, 113, 0.08);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-table td strong {
  color: var(--r2-text);
  font-size: 13px;
}

.dashboard-table td span,
.dashboard-table td em {
  margin-top: 4px;
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  font-style: normal;
}

.dashboard-table td p {
  margin: 0;
  max-width: 680px;
  color: var(--r2-text);
  line-height: 1.45;
}

.dashboard-mode {
  display: inline-flex !important;
  width: max-content;
  min-height: 22px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--r2-border-accent);
  border-radius: 999px;
  background: var(--r2-accent-dim);
  color: var(--r2-accent) !important;
}

.dashboard-admin-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

/* Action icon buttons */
.dashboard-action-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--r2-border);
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--r2-text-secondary);
  cursor: pointer;
  transition: border-color var(--r2-fast), background var(--r2-fast), color var(--r2-fast);
}

.dashboard-action-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dashboard-action-icon:hover:not(:disabled) {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.dashboard-action-icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Category chip sits in its own table column — drop the stacked top margin. */
.dashboard-table td .dashboard-category-chip {
  margin-top: 0 !important;
}

/* Inline validation */
.field-error {
  display: block;
  margin-top: 4px;
  color: #f87171;
  font-size: 11px;
  line-height: 1.3;
}

.is-invalid {
  border-color: #f87171 !important;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.22) !important;
}

.slide-drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.slide-drawer-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-drawer-scrim {
  position: absolute;
  inset: 0;
  z-index: 32;
  background: rgba(2, 6, 16, 0.48);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.admin-drawer-scrim[hidden],
.admin-drawer[hidden] {
  display: none;
}

.admin-drawer-scrim.is-open {
  opacity: 1;
}

.admin-drawer {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 33;
  display: flex;
  flex-direction: column;
  width: min(430px, 94vw);
  height: 100%;
  border-left: 1px solid var(--r2-border-accent);
  background:
    radial-gradient(ellipse at 90% 0%, rgba(45, 212, 191, 0.08), transparent 45%),
    rgba(10, 14, 26, 0.98);
  box-shadow: -18px 0 48px rgba(2, 6, 16, 0.6);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.admin-drawer.is-open {
  transform: translateX(0);
}

.admin-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--r2-border);
}

.admin-drawer-head h3 {
  margin: 2px 0 0;
  color: var(--r2-text);
  font-size: 16px;
}

.admin-drawer-close {
  border: 0;
  background: transparent;
  color: var(--r2-text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.admin-drawer-close:hover {
  color: var(--r2-accent);
}

.admin-drawer-body {
  flex: 1;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.admin-drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--r2-border);
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--r2-text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.admin-tab:hover {
  color: var(--r2-text);
}

.admin-tab.is-active {
  color: var(--r2-accent);
  border-bottom-color: var(--r2-accent);
}

.admin-tab-count:empty {
  display: none;
}

.admin-tab-count {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
  font-size: 10px;
  font-weight: 800;
}

.admin-empty-note {
  margin: 0;
  padding: 16px;
  color: var(--r2-text-muted);
  font-size: 12px;
  line-height: 1.5;
  border: 1px dashed var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(148, 163, 184, 0.05);
}

#adminConfigPane:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
}

/* The hidden attribute must win over the panes' display rules. */
.admin-drawer [hidden] {
  display: none !important;
}

.dashboard-total {
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-weight: 800;
}

.dashboard-empty {
  color: var(--r2-text-secondary);
  text-align: center !important;
}

.dashboard-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.dashboard-sortable:hover {
  color: var(--r2-accent);
}

.dashboard-sortable.is-sorted {
  color: var(--r2-accent);
}

.dashboard-row {
  cursor: pointer;
}

.dashboard-grid {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-content: start;
  gap: 12px;
}

.dashboard-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 210px;
  padding: 16px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(17, 24, 39, 0.72);
  box-shadow: var(--r2-shadow-card);
  cursor: pointer;
}

/* Description grows so the meta row + actions align across all cards. */
.dashboard-card > p {
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dashboard-card:hover {
  border-color: var(--r2-border-accent);
  background: rgba(17, 24, 39, 0.86);
}

.dashboard-card-head strong,
.dashboard-card-head span {
  display: block;
}

.dashboard-card-head strong {
  color: var(--r2-text);
  font-size: 15px;
}

.dashboard-card-head span {
  margin-top: 3px;
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 11px;
}

.dashboard-card p {
  margin: 0;
  color: var(--r2-text-secondary);
  line-height: 1.45;
}

.dashboard-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.dashboard-card-meta .dashboard-category-chip {
  margin-top: 0 !important;
}

.dashboard-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--r2-border);
}

.dashboard-grid-empty {
  padding: 24px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.55);
}

.dashboard-table tbody tr.is-selected td {
  background: rgba(45, 212, 191, 0.1);
}

/* A single unbroken accent stripe on the row's leading edge — applied only to
   the first cell so it doesn't segment at column boundaries. */
.dashboard-table tbody tr.is-selected td:first-child {
  box-shadow: inset 2px 0 0 var(--r2-accent);
}

.dashboard-sample {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 31;
  display: flex;
  flex-direction: column;
  max-height: min(48vh, 520px);
  border: 1px solid var(--r2-border-accent);
  border-radius: var(--r2-radius-md);
  background:
    radial-gradient(ellipse at 18% 0%, rgba(45, 212, 191, 0.08), transparent 45%),
    rgba(10, 14, 26, 0.96);
  box-shadow: 0 -18px 52px rgba(2, 6, 16, 0.62);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(100% + 24px));
  transition: transform 0.24s ease, opacity 0.18s ease;
}

.dashboard-sample.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dashboard-sample-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--r2-border);
  background: rgba(45, 212, 191, 0.06);
}

.dashboard-sample-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.dashboard-sample-title strong {
  color: var(--r2-text);
  font-size: 13px;
}

.dashboard-sample-count {
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 11px;
}

.dashboard-sample-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-sample-formats {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: rgba(148, 163, 184, 0.06);
}

.dashboard-sample-format {
  min-height: 26px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.dashboard-sample-format:hover {
  color: var(--r2-accent);
}

.dashboard-sample-format.is-active {
  background: var(--r2-accent);
  color: #04221d;
}

/* Slide-in-right operator drawers (AOI / sub-feed) */
.slide-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 6000;
  display: flex;
  flex-direction: column;
  width: min(440px, 94vw);
  height: 100vh;
  border-left: 1px solid var(--r2-border-accent);
  background:
    radial-gradient(ellipse at 90% 0%, rgba(45, 212, 191, 0.08), transparent 45%),
    rgba(10, 14, 26, 0.98);
  box-shadow: -18px 0 48px rgba(2, 6, 16, 0.6);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.slide-drawer.is-open {
  transform: translateX(0);
}

.slide-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--r2-border);
}

.slide-drawer-head h3 {
  margin: 2px 0 0;
  font-size: 16px;
  color: var(--r2-text);
}

.slide-drawer-close {
  border: 0;
  background: transparent;
  color: var(--r2-text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.slide-drawer-close:hover {
  color: var(--r2-accent);
}

.slide-drawer-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slide-drawer-foot {
  border-top: 1px solid var(--r2-border);
  padding: 12px 18px 16px;
}

/* Live sources & API keys drawer cards */
.source-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--r2-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}
.source-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.source-card-head strong {
  display: block;
  font-size: 0.92rem;
}
.source-card-sub {
  display: block;
  font-size: 0.72rem;
  opacity: 0.6;
  margin-top: 2px;
}
.source-pill {
  flex: none;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.source-pill[data-state="live"] {
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.5);
  background: rgba(45, 212, 191, 0.12);
}
.source-pill[data-state="ready"] {
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.5);
  background: rgba(147, 197, 253, 0.1);
}
.source-pill[data-state="missing"] {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.1);
}
.source-card-actions {
  display: flex;
  justify-content: flex-end;
}

/* Dashboard "Sources & Keys" view: providers grouped by capability */
.dashboard-sources {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 4px 2px 24px;
  overflow: auto;
}
.source-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--r2-border);
  padding-bottom: 8px;
  margin-bottom: 4px;
}
.source-group-head h3 {
  margin: 0;
  font-size: 1rem;
}
.source-group-head .dashboard-feed-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  margin: 0 !important;
}
.source-group-head .dashboard-feed-icon svg {
  width: 16px;
  height: 16px;
}
.source-group-count {
  margin-left: auto;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2dd4bf;
}
.source-group-note {
  margin: 0 0 12px;
  font-size: 0.78rem;
  opacity: 0.6;
}
.source-group-note code {
  font-size: 0.74rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}
.source-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.source-field-help {
  display: block;
  margin-top: 3px;
  font-size: 0.7rem;
  opacity: 0.55;
}

/* Section label inside a source card (e.g. "Pull quota") + info tooltip icon */
.config-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  color: var(--r2-accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.info-icon {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  color: var(--r2-text-secondary);
  cursor: help;
}
.info-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.info-icon:hover,
.info-icon:focus-visible {
  color: var(--r2-accent);
  outline: none;
}

.aoi-draw-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.aoi-draw-hint {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6100;
  padding: 8px 16px;
  border: 1px solid var(--r2-border-accent);
  border-radius: 999px;
  background: rgba(10, 14, 26, 0.92);
  color: var(--r2-accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: var(--r2-shadow-card);
}

body.aoi-drawing #map {
  cursor: crosshair;
}

#subfeedAois {
  min-height: 84px;
  padding: 6px;
}

.dashboard-sample-copy {
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--r2-border-accent);
  border-radius: var(--r2-radius-md);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
  box-shadow: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.dashboard-sample-copy:hover:not(:disabled) {
  background: var(--r2-accent);
  color: #04221d;
}

.dashboard-sample-copy:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dashboard-sample-copy.is-copied {
  background: var(--r2-accent);
  color: #04221d;
}

/* Download dropdown — matches the Copy button style and pops a menu below. */
.dashboard-sample-download-wrap {
  position: relative;
}

.dashboard-sample-download {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--r2-border-accent);
  border-radius: var(--r2-radius-md);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
  box-shadow: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.dashboard-sample-download:hover {
  background: var(--r2-accent);
  color: #04221d;
}

.dashboard-sample-download .caret {
  margin-left: 4px;
  opacity: 0.8;
}

.dashboard-sample-download-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 220px;
  padding: 4px;
  border: 1px solid var(--r2-border-accent);
  border-radius: var(--r2-radius-md);
  background: rgba(10, 14, 26, 0.98);
  box-shadow: 0 12px 36px rgba(2, 6, 16, 0.5);
}

.dashboard-sample-download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--r2-text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  gap: 16px;
}

.dashboard-sample-download-item:hover:not(:disabled) {
  background: rgba(45, 212, 191, 0.12);
}

.dashboard-sample-download-item .format-label {
  font-weight: 700;
}

.dashboard-sample-download-item .format-hint {
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

.dashboard-sample-download-item.is-disabled,
.dashboard-sample-download-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dashboard-sample-close {
  min-height: 28px;
  min-width: 28px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--r2-text-secondary);
  box-shadow: none;
  font-size: 18px;
  line-height: 1;
}

.dashboard-sample-close:hover {
  color: var(--r2-accent);
}

.dashboard-sample-body {
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.dashboard-sample-status {
  margin: 0;
  color: var(--r2-text-secondary);
  font-size: 12px;
}

.dashboard-sample-status.is-error {
  color: #f87171;
}

.dashboard-sample-code {
  margin: 0;
  color: var(--r2-text);
  font-family: var(--r2-font-mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre;
}

.dashboard-sample-table-wrap {
  overflow: auto;
}

.dashboard-sample-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  font-family: var(--r2-font-mono);
}

.dashboard-sample-table th,
.dashboard-sample-table td {
  padding: 6px 10px;
  border-top: 1px solid var(--r2-border);
  text-align: left;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-sample-table thead th {
  position: sticky;
  top: 0;
  border-top: 0;
  background: rgba(10, 14, 26, 0.94);
  color: var(--r2-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dashboard-sample-table tbody tr:hover td {
  background: rgba(45, 212, 191, 0.045);
}

@keyframes r2-pulse {
  0%,
  100% {
    opacity: 0.65;
    transform: scale(0.9);
  }

  50% {
    opacity: 1;
    transform: scale(1.18);
  }
}

@keyframes r2-row-pulse {
  0%,
  100% {
    box-shadow: var(--r2-shadow-card);
  }

  45% {
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.32), var(--r2-shadow-card-hover);
  }
}

@media (max-width: 820px) {
  body.r2-theme {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 68vh;
    height: auto;
    min-height: 100vh;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--r2-border);
  }

  .dashboard-content,
  .dashboard-page[data-operator-view="true"] .dashboard-content {
    grid-template-columns: 1fr;
  }

  .dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .dashboard-view-tools,
  .dashboard-new-draft {
    width: 100%;
  }

  .dashboard-view-tools button {
    flex: 1;
  }

  .layer-list {
    max-height: 320px;
  }

  .map-wrap,
  #map,
  #globe {
    height: 68vh;
  }

  .map-tools {
    top: 10px;
    right: 10px;
    left: auto;
  }

  .timeline-replay {
    right: 10px;
    bottom: 10px;
    left: 10px;
    min-width: 0;
    padding: 9px;
  }

  .timeline-replay-head {
    grid-template-columns: 1fr;
    padding-right: 34px;
  }

  .timeline-replay-actions,
  .timeline-replay-speeds,
  .timeline-replay-lookback {
    flex-wrap: wrap;
  }

  .timeline-replay-card {
    grid-template-columns: 1fr;
  }

  .map-hud,
  .map-legend {
    display: none;
  }

  .feature-panel {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: min(560px, calc(100vh - 40px));
    transform: translateY(calc(100% + 24px));
  }

  .feature-panel.is-open {
    transform: translateY(0);
  }

  .feature-summary,
  .feature-desc {
    grid-template-columns: 1fr;
  }

  .feature-desc dd {
    border-top: 0;
    padding-top: 0;
  }

  .dashboard-page {
    inset: 8px;
    border-radius: var(--r2-radius-md);
  }

  .dashboard-header {
    padding: 14px;
  }

  .dashboard-content {
    grid-template-columns: 1fr;
    overflow-y: auto;
    padding: 10px;
  }

  .dashboard-rail {
    grid-template-rows: auto auto;
  }

  .dashboard-toolbar,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-table {
    min-width: 760px;
  }

  .dashboard-sample {
    right: 10px;
    bottom: 10px;
    left: 10px;
    max-height: min(58vh, 560px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (prefers-contrast: more) {
  .r2-theme {
    --r2-surface: #0f172a;
    --r2-surface-hover: #111c31;
    --r2-border: rgba(255, 255, 255, 0.22);
    --r2-text-secondary: #cbd5e1;
    --r2-text-muted: #94a3b8;
  }
}

/* AIS per-type display control (chip strip under the `ais` layer row). */
.ais-type-control {
  margin: -2px 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-bg-secondary, var(--r2-surface));
}

/* --- Elegant expandable filter rows (satellite control; eye toggles) ----- */
.filter-sec {
  border-top: 1px solid var(--r2-border);
}
.filter-sec:first-child {
  border-top: 0;
}
.filter-sec-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-sec-toggle {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 2px;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--r2-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.filter-sec-chev {
  transition: transform 0.15s ease;
  font-size: 10px;
}
.filter-sec[data-collapsed="true"] .filter-sec-chev {
  transform: rotate(-90deg);
}
.filter-sec[data-collapsed="true"] .filter-sec-rows {
  display: none;
}
.filter-sec-title {
  flex: 1 1 auto;
  text-align: left;
}
.filter-sec-meta {
  font-family: var(--r2-font-mono);
  font-size: 10px;
  color: var(--r2-text-muted);
}
.filter-sec-rows {
  display: flex;
  flex-direction: column;
  padding-bottom: 6px;
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: 0;
  border-radius: var(--r2-radius-sm);
  cursor: pointer;
  color: var(--r2-text);
  font-size: 12px;
  text-align: left;
}
.filter-row:hover {
  background: var(--r2-surface-hover, rgba(148, 163, 184, 0.1));
}
.filter-row[data-on="false"] {
  opacity: 0.4;
}
.filter-row-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.filter-row-label {
  flex: 1 1 auto;
}
.filter-row-ct {
  font-family: var(--r2-font-mono);
  font-size: 11px;
  color: var(--r2-text-muted);
}
.filter-eye,
.filter-sec-eye {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 2px;
}
.filter-eye svg,
.filter-sec-eye svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--r2-text-muted);
}
.filter-eye[data-on="true"] .eye-off,
.filter-sec-eye .filter-eye[data-on="true"] .eye-off {
  display: none;
}
.filter-eye[data-on="false"] .eye-open {
  display: none;
}
.filter-row[data-on="true"] .filter-eye {
  color: var(--r2-accent, #2dd4bf);
}

/* --- Satellite lookup + detail ------------------------------------------- */
.sat-search-box {
  position: relative;
  margin: -2px 0 8px;
}
.sat-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-bg-secondary, var(--r2-surface));
  color: var(--r2-text);
  font-size: 12px;
}
.sat-search-input:focus {
  outline: none;
  border-color: var(--r2-accent, #8b5cf6);
}
.sat-search-results {
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
}
.sat-search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-bottom: 1px solid var(--r2-border);
  background: transparent;
  color: var(--r2-text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.sat-search-result:hover {
  background: var(--r2-bg-secondary, rgba(139, 92, 246, 0.12));
}
.sat-search-name {
  font-weight: 600;
}
.sat-search-meta {
  margin-left: auto;
  color: var(--r2-text-muted);
  font-size: 11px;
}
.sat-search-empty {
  padding: 8px 10px;
  color: var(--r2-text-muted);
  font-size: 12px;
}
.sat-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.sat-actions button,
.sat-actions a {
  border: 1px solid var(--r2-border);
  background: transparent;
  color: var(--r2-text-secondary);
  border-radius: var(--r2-radius-sm);
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
}
.sat-actions button:hover,
.sat-actions a:hover {
  color: var(--r2-text);
  border-color: var(--r2-accent, #8b5cf6);
}
.sat-vectors {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0 4px;
  font-family: var(--r2-font-mono);
  font-size: 11px;
  color: var(--r2-text-secondary);
}
.sat-source {
  margin: 4px 0 0;
  color: var(--r2-text-muted);
  font-size: 11px;
}
/* GFW maritime-intelligence risk indicators in the vessel panel. */
.gfw-subhead {
  margin: 12px 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--r2-text-muted);
}
.gfw-risk {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.gfw-risk--ok {
  color: #34d399;
  background: rgba(52, 211, 153, 0.14);
}
.gfw-risk--warn {
  color: #fb923c;
  background: rgba(251, 146, 60, 0.16);
}
.gfw-risk--alert {
  color: #f87171;
  background: rgba(248, 113, 113, 0.18);
}

/* --- Bad-actor watchlist / Risk History tab --- */
[data-watchlist-tab].is-flagged {
  color: #f87171;
}
[data-watchlist-tab].is-flagged .feature-tab-icon {
  filter: drop-shadow(0 0 4px rgba(248, 113, 113, 0.8));
}
.feature-panel.is-watchlisted .feature-title {
  color: #fca5a5;
}
.watch-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r2-radius-md);
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.12);
  margin-bottom: 12px;
}
.watch-banner.gfw-risk--warn {
  border-color: rgba(251, 146, 60, 0.4);
  background: rgba(251, 146, 60, 0.12);
}
.watch-banner .watch-score {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: #f87171;
  flex: 0 0 auto;
}
.watch-banner.gfw-risk--warn .watch-score {
  color: #fb923c;
}
.watch-banner strong {
  display: block;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.watch-banner span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--r2-text-muted);
}
.watch-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.watch-cat {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--r2-text);
}
.watch-events {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.watch-event {
  padding: 8px 10px;
  border-left: 2px solid rgba(248, 113, 113, 0.5);
  background: var(--r2-surface);
  border-radius: 0 var(--r2-radius-sm) var(--r2-radius-sm) 0;
}
.watch-event-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.watch-event-head strong {
  font-size: 12px;
}
.watch-ev-when {
  margin-left: auto;
  font-size: 11px;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
}
.watch-ev-notes {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--r2-text);
  line-height: 1.4;
}
.watch-ev-src {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--r2-text-muted);
}
.sat-pass-table {
  width: 100%;
  margin-top: 6px;
  border-collapse: collapse;
  font-size: 11px;
}
.sat-pass-table th,
.sat-pass-table td {
  text-align: left;
  padding: 3px 6px;
  border-bottom: 1px solid var(--r2-border);
  font-family: var(--r2-font-mono);
}
.sat-pass-table th {
  color: var(--r2-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ais-type-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--r2-text-muted);
  margin-bottom: 8px;
}
.ais-type-head span {
  margin-right: auto;
}
.ais-all {
  border: 1px solid var(--r2-border);
  background: transparent;
  color: var(--r2-text-secondary);
  border-radius: var(--r2-radius-sm);
  padding: 1px 7px;
  font-size: 10px;
  cursor: pointer;
}
.ais-all:hover {
  border-color: var(--r2-border-medium);
}
/* --- Per-layer facet filter sub-menu (in-card) ---------------------------- */
.layer-filters {
  margin: -6px 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--r2-border);
  border-top: 0;
  border-radius: 0 0 var(--r2-radius-md) var(--r2-radius-md);
  background: var(--r2-bg-secondary, var(--r2-surface));
  display: grid;
  gap: 8px;
}

.layer-filters-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 3px 8px;
  border: 0;
  background: transparent;
  color: var(--r2-text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

/* Stay subtle on hover — without this the global button:hover fills the bar
   solid accent-green, which clashes with the rest of the row. */
.layer-filters-toggle:hover,
.layer-filters-toggle:focus-visible {
  background: transparent;
  color: var(--r2-accent);
}

/* Collapsed: caret points right (▶). Expanded: rotates down (▼). Matches the
   .legend-filter-caret convention so every collapsible filter agrees. */
.layer-filters-caret {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform 150ms ease;
}

.layer-filters-toggle[aria-expanded="true"] .layer-filters-caret {
  transform: rotate(90deg);
}

.facet-active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--r2-accent);
}

.layer-filters-summary {
  margin-left: auto;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.facet-group {
  display: grid;
  gap: 5px;
}

.facet-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--r2-text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.facet-acts {
  display: inline-flex;
  gap: 4px;
}

.facet-acts button {
  padding: 1px 6px;
  border: 1px solid var(--r2-border);
  border-radius: 999px;
  background: transparent;
  color: var(--r2-text-muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}

.facet-acts button:hover {
  border-color: var(--r2-border-accent);
  color: var(--r2-text);
}

/* Facet values render as full-width rows (not a wrapped pill cloud): dot +
   label on the left, count right-aligned — same shape as .legend-cat-row. */
.ais-chips {
  display: grid;
  gap: 2px;
}
.ais-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 4px 6px;
  font-size: 11px;
  text-align: left;
  color: var(--r2-text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--r2-radius-sm);
  cursor: pointer;
  opacity: 0.42;
  transition: opacity var(--r2-fast), background var(--r2-fast);
}
.ais-chip:hover {
  background: rgba(148, 163, 184, 0.08);
}
.ais-chip[data-on="true"] {
  opacity: 1;
}

/* Facet chip in an actively-filtered field: selected reads accent, the rest
   stay dimmed — so it's obvious which values are constraining the layer. */
.ais-chip[data-filtered="true"][data-on="true"] {
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
  color: var(--r2-accent);
}

.ais-chip[data-filtered="true"][data-on="false"] {
  opacity: 0.38;
}
.ais-chip:hover {
  border-color: var(--r2-accent, var(--r2-border-strong));
}
.ais-dot {
  display: inline-block;
  vertical-align: middle;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  flex: none;
}
.facet-dot {
  margin-right: 0;
}
.ais-ct {
  margin-left: auto;
  font-family: var(--r2-font-mono);
  font-size: 10px;
  color: var(--r2-text-muted);
}

/* Attribute-derived vessel silhouette in the AIS feature panel (under SIDC). */
/* Target identity hero: silhouette stand-in (vessel/aircraft) with a small
   APP-6 symbol badge, until per-asset make/model imagery is available. */
.feature-visual-silhouette {
  position: relative;
  /* Shrinkable + width-capped so the long figcaption (class · reg · spd · hdg)
     wraps instead of pushing the meta column out of the panel. */
  flex: 0 1 auto;
  min-width: 0;
  max-width: 58%;
  display: grid;
  place-items: center;
  padding: 6px 8px;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface-2, rgba(148, 163, 184, 0.06));
}
.feature-visual-silhouette .vessel-figure {
  margin: 0;
}
.feature-visual-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  opacity: 0.9;
}

/* Raw SIDC / APP-6 code line under the target identity meta. */
.vessel-sidc {
  display: block;
  margin-top: 2px;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.vessel-figure {
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}
.vessel-svg {
  width: 96px;
  height: 42px;
  display: block;
}
.vessel-figure figcaption {
  font-size: 10px;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* --- Alerts feed (/farsight/alerts) --------------------------------------- */
.alerts-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--r2-border-medium);
  border-radius: var(--r2-radius-md);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--r2-text-secondary);
  text-decoration: none;
  transition: var(--r2-fast);
}
.alerts-link:hover {
  color: var(--r2-text);
  border-color: var(--r2-border-accent);
  background: var(--r2-accent-dim);
}
.alerts-link-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--r2-online);
  box-shadow: 0 0 8px var(--r2-online);
}

.alerts-page {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px clamp(16px, 4vw, 48px);
  background: var(--r2-bg);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--r2-fast), transform var(--r2-fast), visibility var(--r2-fast);
}
.alerts-page.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.alerts-sub {
  margin: 4px 0 0;
  color: var(--r2-text-muted);
  font-size: 13px;
}
.alerts-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.alerts-search {
  flex: 1 1 240px;
  min-width: 200px;
}
.alerts-window {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--r2-text-secondary);
}
.alerts-window select {
  background: var(--r2-input);
  color: var(--r2-text);
  border: 1px solid var(--r2-border-medium);
  border-radius: var(--r2-radius-sm);
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
}
.alerts-bbox-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--r2-text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
/* Override the global full-width `input` rule for the checkbox. */
.alerts-bbox-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  margin: 0;
  flex: none;
  accent-color: var(--r2-accent);
  cursor: pointer;
}
.alerts-reset {
  background: var(--r2-glass);
  color: var(--r2-text-secondary);
  border: 1px solid var(--r2-border-medium);
  border-radius: var(--r2-radius-sm);
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.alerts-reset:hover {
  color: var(--r2-text);
  border-color: var(--r2-border-strong);
}
.alerts-chiprow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.alerts-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--r2-border-medium);
  background: var(--r2-glass);
  color: var(--r2-text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--r2-fast);
}
.alerts-chip:hover {
  color: var(--r2-text);
  border-color: var(--r2-border-strong);
}
.alerts-chip[aria-pressed="true"] {
  color: var(--r2-bg);
  background: var(--r2-accent);
  border-color: var(--r2-accent);
  font-weight: 600;
}
.alerts-chip-count {
  font-family: var(--r2-font-mono);
  font-size: 10px;
  opacity: 0.75;
}
.alerts-status {
  margin: 0;
  color: var(--r2-text-muted);
  font-size: 12px;
  font-family: var(--r2-font-mono);
}
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 32px;
}
.alerts-item {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 16px;
  align-items: start;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 1px solid var(--r2-border);
  border-left: 3px solid var(--r2-border-medium);
  border-radius: var(--r2-radius-md);
  background: var(--r2-surface);
  color: var(--r2-text);
  cursor: pointer;
  transition: var(--r2-fast);
}
.alerts-item:hover {
  background: var(--r2-surface-hover);
  border-color: var(--r2-border-strong);
}
.alerts-item[data-severity="high"] { border-left-color: #fb7185; }
.alerts-item[data-severity="medium"] { border-left-color: #fbbf24; }
.alerts-item[data-severity="low"] { border-left-color: #5eead4; }
.alerts-item-time {
  font-family: var(--r2-font-mono);
  font-size: 11px;
  color: var(--r2-text-muted);
}
.alerts-item-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.alerts-item-summary {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--r2-text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.alerts-item-tags {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 11px;
}
.alerts-item-type {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--r2-text-accent);
  font-weight: 600;
}
.alerts-item-source {
  color: var(--r2-text-muted);
}
.alerts-empty {
  padding: 32px;
  text-align: center;
  color: var(--r2-text-muted);
  border: 1px dashed var(--r2-border-medium);
  border-radius: var(--r2-radius-md);
}
@media (max-width: 720px) {
  .alerts-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .alerts-item-tags {
    flex-direction: row;
    align-items: center;
  }
}

/* --- Locale switch (header) + Factbook nation panel ----------------------- */
.locale-switch {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
}
.locale-switch select {
  appearance: none;
  background: var(--r2-accent-dim, rgba(45, 212, 191, 0.12));
  color: var(--r2-text-secondary, #cbd5e1);
  border: 1px solid var(--r2-border-medium, rgba(255, 255, 255, 0.16));
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.factbook-info {
  margin: 0 0 10px;
}
.factbook-info-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--r2-border-accent, rgba(45, 212, 191, 0.4));
  border-radius: 6px;
  background: var(--r2-accent-dim, rgba(45, 212, 191, 0.12));
  color: var(--r2-accent, #2dd4bf);
  font-size: 12px;
  cursor: pointer;
}
.factbook-info-btn:hover {
  background: var(--r2-accent, #2dd4bf);
  color: #03211c;
}
.factbook-info-icon {
  font-size: 13px;
}
.factbook-info-btn[aria-expanded="true"] {
  border-color: var(--r2-accent, #2dd4bf);
}
.factbook-info-body {
  margin-top: 8px;
}
.factbook-info-body .feature-visual-list {
  margin-top: 0;
}
.factbook-info-body .fb-status {
  font-size: 12px;
  color: var(--r2-text-muted, #94a3b8);
  font-style: italic;
}
.factbook-info-body .fb-background {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--r2-text-secondary, #cbd5e1);
/* Acronyms with a glossary tooltip: subtle dotted underline + help cursor. */
.has-glossary {
  cursor: help;
  text-decoration: underline dotted rgba(148, 163, 184, 0.55);
  text-underline-offset: 2px;
}

/* Speed-based range-ring distance labels (collision-avoidance rings). */
.range-ring-label {
  color: #7dd3fc;
  font-family: var(--r2-font-mono);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(2, 6, 23, 0.9);
  transform: translate(6px, -50%);
  pointer-events: none;
}

/* Selected-vessel "virtual image" glyph (fixed-size oriented plan-view hull). */
.vessel-ghost-icon {
  background: none;
  border: none;
}
.vessel-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(2, 6, 23, 0.7));
}
.vessel-ghost-rot {
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
}

/* Vessel-type filter relocated into the Active Layers panel: collapsible rows. */
.legend-filter {
  margin: 2px 0 6px 24px;
  display: grid;
  gap: 4px;
}
.legend-filter-head {
  display: flex;
  align-items: center;
  gap: 4px;
}
.legend-filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  padding: 3px 6px;
  border: 0;
  background: transparent;
  color: var(--r2-text-secondary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--r2-radius-sm);
}
.legend-filter-toggle:hover {
  background: rgba(148, 163, 184, 0.08);
  color: var(--r2-text);
}
/* Caret points inward (right) when collapsed; rotates down when expanded. */
.legend-filter-caret {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform 150ms ease;
}
.legend-filter-toggle[aria-expanded="true"] .legend-filter-caret {
  transform: rotate(90deg);
}
.legend-filter-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  background: transparent;
  color: var(--r2-text-muted);
  cursor: pointer;
}
.legend-filter-icon:hover {
  border-color: var(--r2-border-accent);
  color: var(--r2-text);
}
.legend-filter-icon svg {
  width: 13px;
  height: 13px;
}
.legend-filter-count {
  font-family: var(--r2-font-mono);
  font-size: 10px;
  color: var(--r2-text-muted);
}
.legend-filter-acts {
  display: flex;
  gap: 4px;
  padding-left: 6px;
}
.legend-filter-acts button {
  padding: 1px 7px;
  border: 1px solid var(--r2-border);
  border-radius: 999px;
  background: transparent;
  color: var(--r2-text-muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}
.legend-filter-acts button:hover {
  border-color: var(--r2-border-accent);
  color: var(--r2-text);
}
.legend-filter-rows {
  display: grid;
  gap: 2px;
}
.legend-cat-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: var(--r2-text-secondary);
  font-size: 11px;
  cursor: pointer;
  border-radius: var(--r2-radius-sm);
}
.legend-cat-row:hover {
  background: rgba(148, 163, 184, 0.08);
}
.legend-cat-row[data-on="false"] {
  opacity: 0.42;
}

/* Webcam media (feature panel + hover tooltip). */
.webcam-media {
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.webcam-media img,
.webcam-media video {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #000;
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  display: block;
}
.webcam-media--sm img {
  max-height: 150px;
  width: 240px;
}
.webcam-media figcaption {
  font-size: 10px;
  color: var(--r2-text-muted);
  font-family: var(--r2-font-mono);
}
.webcam-media.webcam-err img,
.webcam-media.webcam-err video {
  display: none;
}
.webcam-media.webcam-err::after {
  content: "image unavailable";
  font-size: 10px;
  color: var(--r2-text-muted);
  padding: 14px;
  text-align: center;
  border: 1px dashed var(--r2-border);
  border-radius: var(--r2-radius-sm);
}
.webcam-stream-link {
  display: inline-block;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--r2-accent, #2dd4bf);
  border: 1px solid var(--r2-border);
  border-radius: var(--r2-radius-sm);
  text-decoration: none;
}
.webcam-tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
}

/* Range-ring config sliders (per-layer adjustment from defaults). */
.ring-config-body {
  padding: 4px 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ring-config-group {
  margin-top: 6px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--r2-text-muted);
}
.ring-slider {
  display: grid;
  grid-template-columns: 1fr 96px auto;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--r2-text-secondary);
}
.ring-slider-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ring-range {
  width: 96px;
  accent-color: var(--r2-accent, #2dd4bf);
}
.ring-slider-val {
  font-family: var(--r2-font-mono);
  font-size: 10px;
  color: var(--r2-text-muted);
  text-align: right;
  min-width: 42px;
}
.ring-reset {
  margin-top: 8px;
  align-self: flex-start;
  border: 1px solid var(--r2-border);
  background: transparent;
  color: var(--r2-text-secondary);
  border-radius: var(--r2-radius-sm);
  padding: 3px 9px;
  font-size: 10px;
  cursor: pointer;
}
.ring-reset:hover {
  border-color: var(--r2-border-medium);
  color: var(--r2-text);
}
.legend-cat-label {
  flex: 1 1 auto;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-cat-ct {
  font-family: var(--r2-font-mono);
  font-size: 10px;
  color: var(--r2-text-muted);
}
.legend-cat-eye {
  display: inline-flex;
  width: 14px;
  height: 14px;
  color: var(--r2-text-muted);
}
.legend-cat-eye svg {
  width: 14px;
  height: 14px;
}

/* Persistent identity hero above the feature-panel tabs (card + instruments). */
.feature-hero {
  display: grid;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--r2-border);
}
.feature-hero .feature-section h3 {
  margin-top: 0;
}

/* --- Rich interactive instrument cluster ---------------------------------- */
.feature-instruments .instr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.feature-instruments .instr-head h3 {
  margin: 0;
}
.instr-controls {
  display: flex;
  gap: 4px;
}
.instr-chip {
  min-height: 22px;
  padding: 0 9px;
  border: 1px solid var(--r2-border-medium);
  border-radius: 999px;
  background: transparent;
  color: var(--r2-text-secondary);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}
.instr-chip:hover {
  border-color: var(--r2-border-accent);
  color: var(--r2-text);
}
.instr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 8px 10px;
  margin-top: 8px;
}
.instr-gauge {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px 2px;
  border-radius: var(--r2-radius-md);
  transition: background 120ms ease, box-shadow 120ms ease;
}
.instr-gauge:hover {
  background: rgba(148, 163, 184, 0.08);
}
.instr-gauge.instr-alarm {
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.65);
}
.instr-dial {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
}
.instr-gauge obc-compass,
.instr-gauge obc-speed-gauge,
.instr-gauge obc-gauge-radial,
.instr-gauge obc-rate-of-turn {
  display: block;
  width: 100%;
  max-width: 116px;
  aspect-ratio: 1 / 1;
}
.instr-courseup .instr-compass {
  transform: rotate(var(--up, 0deg));
  transition: transform 220ms ease;
}
.instr-hub {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--r2-font-mono);
  font-size: 10px;
  font-weight: 800;
  color: var(--r2-text);
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(2, 6, 23, 0.9);
}
.instr-gauge figcaption {
  font-family: var(--r2-font-mono);
  font-size: 9px;
  color: var(--r2-text-muted);
  text-align: center;
}
.instr-gauge figcaption strong {
  color: var(--r2-text);
  font-size: 11px;
}
