/* NaviX v1.0.1 - Global UAV Localization */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap");

:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --success: #10b981;
  --success-dark: #059669;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --orange: #f59e0b;
  --orange-dark: #d97706;
  --purple: #8b5cf6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --radius: 10px;
  --radius-sm: 6px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "JetBrains Mono", monospace;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.header {
  background: var(--primary);
  color: var(--white);
  padding: 8px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 6px;
}

.header-title h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-title .subtitle {
  font-size: 11px;
  opacity: 0.8;
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.version {
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 4px;
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--white);
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--gray-200);
}

.card-header svg {
  flex-shrink: 0;
}

.header-icon {
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

/* Colored card headers */
.card-blue .card-header {
  background: var(--primary);
  color: var(--white);
  border-bottom: none;
}

.card-green .card-header {
  background: var(--success);
  color: var(--white);
  border-bottom: none;
}

.card-orange .card-header {
  background: var(--orange);
  color: var(--white);
  border-bottom: none;
}

.card-gray .card-header {
  background: var(--gray-100);
  color: var(--gray-700);
}

.card-purple .card-header {
  background: var(--purple);
  color: var(--white);
  border-bottom: none;
}

.dev-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--gray-500);
  line-height: 1.4;
}

.card-content {
  padding: 12px;
}

.card-content.compact {
  padding: 10px;
}

.card-footer {
  padding: 0 12px 12px;
}

/* State Items */
.state-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--gray-100);
}

.state-item:last-child {
  border-bottom: none;
}

.state-label {
  color: var(--gray-500);
  font-weight: 500;
}

.state-value {
  font-weight: 600;
  color: var(--gray-900);
}

.state-value.idle {
  color: var(--gray-500);
}
.state-value.ready {
  color: var(--success);
}
.state-value.processing {
  color: var(--primary);
}
.state-value.error {
  color: var(--danger);
}
.state-value.connected {
  color: var(--success);
}
.state-value.disconnected {
  color: var(--danger);
}

/* Error value color coding based on accuracy */
.state-value.error-good {
  color: var(--success);
}
.state-value.error-ok {
  color: #22c55e;
}
.state-value.error-warning {
  color: var(--orange);
}
.state-value.error-bad {
  color: var(--danger);
}

/* Inputs */
.input-group {
  margin-bottom: 10px;
  position: relative;
}

.input-group:last-child {
  margin-bottom: 0;
}

.input-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  color: var(--gray-500);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.input-group input::placeholder {
  color: var(--gray-400);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-group.half {
  flex: 1;
  min-width: 0;
}

.input-with-suffix {
  position: relative;
}

.input-with-suffix input {
  padding-right: 36px;
}

.input-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.checkbox-row label {
  margin: 0;
  font-weight: 500;
  color: var(--gray-600);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label,
.input-group .toggle-row .toggle-label {
  display: inline;
  margin: 0 !important;
  margin-bottom: 0 !important;
  font-weight: 500;
  color: var(--gray-600);
  font-size: 12px;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer;
  user-select: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input,
.input-group .toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gray-300);
  border-radius: 20px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #eab308;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

.sub-input {
  margin-top: 8px;
}

/* Search Input */
.search-input-container {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.search-input-container input {
  padding-left: 36px;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 11px;
}

.btn-success {
  background: var(--success);
  color: var(--white);
}

.btn-success:hover {
  background: var(--success-dark);
}

.btn-orange {
  background: var(--orange);
  color: var(--white);
}

.btn-orange:hover {
  background: var(--orange-dark);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-outline {
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover {
  background: var(--gray-50);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mono {
  font-family: "JetBrains Mono", monospace;
}

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
  background: var(--gray-200);
  min-width: 0;
}

#map {
  width: 100%;
  height: 100%;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 11px;
  z-index: 10;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.red {
  background: var(--danger);
}
.legend-dot.green {
  background: var(--success);
}
.legend-dot.blue {
  background: var(--primary);
}
.legend-dot.yellow {
  background: #eab308;
}

.legend-line {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-line.red {
  background: var(--danger);
}

.legend-line.green {
  background: var(--success);
}

.legend-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: rgba(30, 64, 175, 0.15);
  flex-shrink: 0;
}

.legend-circle.yellow {
  border-color: #f59e0b;
  background: rgba(253, 224, 71, 0.5);
}

/* ── Restart overlay (full-page, shown while ua-pilot reboots) ───────── */
.restart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);     /* slate-900 @ 92% */
  color: #f1f5f9;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: "JetBrains Mono", monospace;
}
.restart-overlay.visible { display: flex; }
.restart-overlay-inner {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.restart-overlay-title {
  font-size: 16px; font-weight: 600; letter-spacing: 0.5px;
}
.restart-overlay-sub {
  font-size: 12px; color: #94a3b8; letter-spacing: 0.3px;
}
/* StabX cardmap-style ring spinner (border-ring, light translucent
   track + bright top arc), sized for a full-screen overlay and in
   brand blue instead of cardmap's accent lime. */
.sb-spinner {
  width: 64px; height: 64px;
  border: 4px solid rgba(59, 130, 246, 0.18);   /* blue-500 @ 18% — track */
  border-top-color: #3b82f6;                    /* blue-500 — spinning arc */
  border-radius: 50%;
  animation: sb-spin 0.7s linear infinite;
  background: transparent;
}
@keyframes sb-spin { to { transform: rotate(360deg); } }

/* Progress Overlay */
.progress-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.progress-overlay.visible {
  display: flex;
}

.progress-content {
  text-align: center;
  width: 340px;
  max-width: 90vw;
  padding: 24px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.progress-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.status-text {
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
  width: 0%;
  transition: width 0.8s ease-out;
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.hidden {
  display: none !important;
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

/* Search Results Dropdown */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 4px;
}

.search-result-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  font-size: 12px;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--gray-50);
}

.search-result-item strong {
  display: block;
  color: var(--gray-900);
  font-weight: 600;
}

.search-result-item span {
  color: var(--gray-500);
  font-size: 11px;
}

.search-result-item.no-results {
  color: var(--gray-500);
  cursor: default;
}

.search-result-item.no-results:hover {
  background: transparent;
}

/* Leaflet Custom Markers */
.uav-marker {
  background: transparent;
}

.uav-marker-inner {
  width: 20px;
  height: 20px;
  background: var(--danger);
  border: 3px solid var(--white);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.6);
  }
}

.mission-marker {
  background: transparent;
}

.mission-marker-inner {
  width: 24px;
  height: 24px;
  background: var(--primary);
  border: 3px solid var(--white);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Leaflet overrides */
.leaflet-control-layers {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

.leaflet-control-zoom a {
  font-family: "JetBrains Mono", monospace;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }

  .map-container {
    min-height: 50vh;
  }

  .header {
    padding: 8px 14px;
  }

  .header-title h1 {
    font-size: 18px;
  }

  .logo {
    width: 36px;
    height: 36px;
  }
}

/* ── Uncertainty Banner ─────────────────────────────────────────────────── */

.uncertainty-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: linear-gradient(90deg, #d97706 0%, #f59e0b 50%, #d97706 100%);
  background-size: 200% 100%;
  animation: banner-shimmer 3s ease-in-out infinite;
  color: #1c1917;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 0.82rem;
  text-align: center;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.45);
}

.uncertainty-banner.hidden {
  display: none;
}

.uncertainty-banner.aligning {
  background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 50%, #1d4ed8 100%);
  background-size: 200% 100%;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.45);
}

.uncertainty-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

@keyframes banner-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

/* Push map down when banner is showing — supported in modern browsers */
.map-container:has(.uncertainty-banner:not(.hidden)) #map {
  height: calc(100% - 38px);
  margin-top: 38px;
}

/* Map-pick crosshair buttons next to lat/lng coordinate pairs.
   Square button, same height as the .input-group input (35px box-sizing:
   border-box → 8+8 padding + 1+1 border + 17 line-box). Match margin-bottom
   of input-group siblings so flex-end aligns visible boxes flush. */
.coord-row {
  align-items: flex-end;
}
.btn-map-pick {
  flex-shrink: 0;
  width: 35px;
  height: 35px;
  margin-bottom: 10px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn-map-pick:hover {
  background: var(--gray-50);
  color: var(--gray-900);
  border-color: var(--gray-400);
}
.btn-map-pick.is-armed {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.20);
}
.map-pick-armed #map {
  cursor: crosshair !important;
}

/* ── Debug Panel ─────────────────────────────────────────────────────────
   Right-side dev panel mirroring the left .sidebar: white cards on light
   background, JetBrains Mono, existing button + input patterns. Shown only
   on /debug (server injects data-mode="debug"; debug.js sets body.debug-on). */

.debug-panel {
  display: none;
  width: 320px;
  min-width: 320px;
  background: var(--white);
  border-left: 1px solid var(--gray-200);
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  flex-direction: column;
  gap: 12px;
  font-size: 12px;
}

body.debug-on .debug-panel {
  display: flex;
}

.debug-panel::-webkit-scrollbar { width: 6px; }
.debug-panel::-webkit-scrollbar-track { background: transparent; }
.debug-panel::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* Header card — purple banner + pause button + source pill */
.debug-panel .card-purple .card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.debug-source-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: auto;
}
.debug-source-pill.real {
  background: var(--success);
  color: var(--white);
}

.debug-panel .btn-pause {
  background: var(--orange);
  color: var(--white);
}
.debug-panel .btn-pause:hover { background: var(--orange-dark); }

.debug-panel .btn-pause.is-paused {
  background: var(--success);
}
.debug-panel .btn-pause.is-paused:hover { background: var(--success-dark); }

/* Frame wrap */
.debug-frame-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--gray-200);
}

.debug-frame-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.debug-frame-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--gray-500);
}

.debug-frame-meta .live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 6px;
  vertical-align: middle;
}

/* Slider rows in the Search card */
.debug-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.debug-slider-row:last-child { margin-bottom: 0; }

.debug-slider-row label {
  width: 56px;
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
  flex-shrink: 0;
}

.debug-slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--purple);
  margin: 0;
  height: 18px;
  cursor: pointer;
  padding: 0;
  border: none;
}

.debug-val {
  width: 60px;
  text-align: right;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--gray-900);
  font-weight: 600;
  flex-shrink: 0;
}

/* Band — segmented button group, solid colors */
.debug-band-group {
  display: inline-flex;
  flex: 1;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.debug-band-btn {
  flex: 1;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 7px 8px;
  border: none;
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  border-right: 1px solid var(--gray-200);
  transition: background 0.12s, color 0.12s;
}
.debug-band-btn:last-child { border-right: none; }
.debug-band-btn:hover { background: var(--gray-50); }
.debug-band-btn.is-active {
  background: var(--purple);
  color: var(--white);
}

/* Hidden legacy <select> for backwards-compat with debug.js */
#debug-band[hidden] { display: none; }

/* Top-K card grows to fill remaining space */
.debug-card-grow {
  flex: 1;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.debug-card-grow .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.debug-card-grow .card-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}
.debug-card-grow .card-content::-webkit-scrollbar { width: 6px; }
.debug-card-grow .card-content::-webkit-scrollbar-thumb {
  background: var(--gray-300); border-radius: 3px;
}

.debug-section-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--white);
  background: rgba(255, 255, 255, 0.22);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: none;
}

/* Top-K rows: ref-image thumbnail + body + score */
.debug-topk-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.debug-topk-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.debug-topk-card:hover {
  border-color: var(--purple);
  background: var(--gray-50);
}
.debug-topk-card.is-active {
  border-color: var(--purple);
  background: var(--gray-50);
  box-shadow: inset 3px 0 0 var(--purple);
}

.debug-topk-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--gray-200);
  flex-shrink: 0;
}

.debug-topk-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.debug-topk-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--white);
  font-weight: 700;
  text-align: center;
  padding: 4px;
  word-break: break-all;
  line-height: 1.1;
}

.debug-topk-rank {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--purple);
  color: var(--white);
  font-weight: 700;
  font-size: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px var(--white);
}

.debug-topk-card[data-rank="1"] .debug-topk-rank {
  background: var(--orange);
}

.debug-topk-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.debug-topk-coord {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--gray-900);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debug-topk-meta {
  font-size: 10px;
  color: var(--gray-500);
  font-family: "JetBrains Mono", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debug-topk-score {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--success);
  font-weight: 700;
  flex-shrink: 0;
  padding-right: 4px;
}
.debug-topk-card[data-rank="1"] .debug-topk-score { color: var(--orange-dark); }

/* Score progress bar (subtle, no gradient — single solid fill) */
.debug-topk-card {
  position: relative;
  overflow: hidden;
}
.debug-topk-card .debug-topk-score-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--purple);
  width: 0;
  transition: width 0.4s ease;
}
.debug-topk-card[data-rank="1"] .debug-topk-score-bar { background: var(--orange); }

.debug-topk-empty {
  text-align: center;
  padding: 24px 10px;
  color: var(--gray-500);
  font-style: italic;
  font-size: 11px;
}

/* PAUSED banner — solid orange chip top-center of the map */
body.debug-paused .map-container::after {
  content: "PAUSED";
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 6px 14px;
  background: var(--orange);
  color: var(--white);
  border-radius: var(--radius-sm);
  z-index: 600;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.legend-dot.purple { background: var(--purple); }

@media (max-width: 1100px) {
  .debug-panel { width: 280px; min-width: 280px; }
}

@media (max-width: 768px) {
  body.debug-on .debug-panel { display: none; }
}
