:root {
  --bg: #0f1419;
  --surface: #1a222c;
  --border: #2d3a4a;
  --text: #e8eef4;
  --muted: #8b9cb3;
  --accent: #3d9cf5;
  --accent-dim: #2a6fa8;
  --point: #5cb3ff;
  --ellipse: #c9a227;
  --zone: #4cd97b;
  --danger: #e85d5d;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-nav {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: var(--text);
  background: rgba(61, 156, 245, 0.2);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.live-badge {
  font-size: 0.75rem;
  color: var(--muted);
}

.live-badge #live-updated-at {
  color: #7dd87a;
  font-variant-numeric: tabular-nums;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.brand-logo {
  display: block;
  height: 2.25rem;
  width: auto;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1rem 1rem 0.25rem;
  display: flex;
  justify-content: center;
}

.sidebar-logo {
  display: block;
  width: min(100%, 11rem);
  height: auto;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  margin-left: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.env-badge {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 320px;
  min-width: 280px;
  max-width: 40vw;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.map-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

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

.panel {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.panel h2 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hint {
  font-size: 0.85rem;
  line-height: 1.45;
  margin: 0 0 0.75rem;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.field input[type="range"] {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.45rem 0.85rem;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
}

.btn.primary {
  background: var(--accent);
  color: #061018;
  font-weight: 600;
}

.btn.primary:hover {
  background: #5aadff;
}

.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  border-color: var(--muted);
}

.btn.icon {
  background: transparent;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.swatch-point {
  background: var(--point);
  border: 2px solid #fff;
}

.swatch-hyperbola {
  background: transparent;
  border: 2px solid var(--ellipse);
  border-radius: 0;
  transform: rotate(-35deg);
}

.swatch-zone {
  background: rgba(76, 217, 123, 0.35);
  border: 2px solid var(--zone);
}

.event-log {
  list-style: none;
  margin: 0;
  padding: 0;
}

.event-log li {
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 0.35rem;
}

.event-log li:hover {
  background: rgba(255, 255, 255, 0.04);
}

.event-log li.active {
  border-color: var(--accent);
  background: rgba(61, 156, 245, 0.22);
  box-shadow: inset 0 0 0 1px rgba(61, 156, 245, 0.35);
}

.event-log .time {
  font-size: 0.75rem;
  color: var(--muted);
}

.event-log .kind {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-top: 0.2rem;
}

.event-log .freq {
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.event-log-load-more {
  text-align: center;
  padding: 0.75rem 0.5rem !important;
  font-size: 0.8rem;
  cursor: default;
}

.event-log-load-more:hover {
  background: transparent !important;
}

.event-log-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.event-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 1.5rem;
}

.event-tags-add {
  margin-top: 0.65rem;
}

.tag-picker {
  position: relative;
}

.tag-picker-toggle {
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.tag-picker-toggle:hover {
  border-color: var(--accent-dim);
}

.tag-picker-menu {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 12rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.tag-picker-menu.hidden {
  display: none;
}

.tag-picker-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
}

.tag-picker-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.tag-picker-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  flex-shrink: 0;
}

.tag-picker-desc {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.2;
  background: color-mix(in srgb, var(--tag-color) 20%, transparent);
  border: 1px solid color-mix(in srgb, var(--tag-color) 50%, transparent);
  color: var(--tag-color);
}

.event-tag-badge.compact {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
}

.event-tag-icon {
  width: 0.85rem;
  height: 0.85rem;
  object-fit: contain;
}

.event-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 -0.15rem 0 0.05rem;
  padding: 0;
  width: 1rem;
  height: 1rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}

.event-tag-remove:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--tag-color) 25%, transparent);
}

/*
 * Detail UI lives inside `.map-wrap` (not viewport-fixed) so it only covers the map column.
 * Backdrop is pointer-events: none so wheel/drag reach Leaflet. Expanded GeoJSON uses
 * interactive: false so hyperbolas / zone polygons do not capture the map drag handler.
 */
.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  pointer-events: none;
}

.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.detail-panel.hidden,
.detail-backdrop.hidden {
  display: none;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.detail-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  word-break: break-all;
  padding-right: 0.5rem;
}

.detail-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  font-size: 0.9rem;
}

.detail-section {
  margin-bottom: 1.25rem;
}

.detail-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.detail-meta {
  display: grid;
  gap: 0.35rem;
}

.detail-meta div {
  display: flex;
  gap: 0.5rem;
}

.detail-meta dt {
  color: var(--muted);
  min-width: 7rem;
}

.adsb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.adsb-table th,
.adsb-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.45rem;
  text-align: left;
}

.adsb-table th {
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font-weight: 600;
}

.adsb-table tbody tr.adsb-row-match td {
  background: rgba(232, 192, 64, 0.16);
}

.adsb-table tbody tr.adsb-row-clickable {
  cursor: pointer;
}

.adsb-table tbody tr.adsb-row-clickable:hover td {
  background: rgba(92, 179, 255, 0.1);
}

.adsb-table tbody tr.adsb-row-selected td {
  background: rgba(92, 179, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(92, 179, 255, 0.55);
}

.adsb-match-hint {
  margin: 0 0 0.5rem;
}

.gp-adsb-icon-wrap.gp-adsb-selected .gp-adsb-goose-img {
  filter: drop-shadow(0 0 4px #5cb3ff) drop-shadow(0 0 10px rgba(92, 179, 255, 0.85));
}

.audio-note {
  font-size: 0.85rem;
  color: var(--muted);
}

.capture-audio-block {
  margin-bottom: 0.85rem;
}

.capture-audio-block:last-child {
  margin-bottom: 0;
}

.capture-audio-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.capture-audio-block audio {
  width: 100%;
}

.diag-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.12);
}

.diag-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.leaflet-container {
  background: #1a2430;
  font-family: var(--font);
}

/* ADS-B snapshot markers (Leaflet DivIcon — transparent PNG, white on dark map) */
.leaflet-div-icon.gp-adsb-div-icon {
  background: transparent !important;
  border: none !important;
  overflow: visible;
}

.gp-adsb-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  background: transparent;
  overflow: visible;
  pointer-events: none;
}

.gp-adsb-goose-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.85));
}

.gp-leaflet-popup .leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.gp-leaflet-popup .leaflet-popup-tip {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: none;
}

.gp-leaflet-popup .leaflet-popup-content {
  margin: 0.65rem 0.85rem;
  min-width: 12rem;
}

.gp-leaflet-popup a.leaflet-popup-close-button {
  color: var(--muted);
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1.4rem;
}

.gp-leaflet-popup a.leaflet-popup-close-button:hover {
  color: var(--text);
}

.gp-adsb-popup-title {
  font-weight: 600;
  font-size: 0.88rem;
  margin: 0 0 0.4rem;
  color: var(--text);
}

.gp-adsb-popup-dl {
  margin: 0;
}

.search-summary {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1100;
}

.search-modal {
  position: fixed;
  z-index: 1101;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 94vw);
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.search-modal-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
}

.search-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.search-modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.search-modal-body {
  padding: 0.75rem 1rem 1rem;
  overflow-y: auto;
  flex: 1;
}

.search-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.modal-section {
  margin-bottom: 1.1rem;
}

.modal-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.modal-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .modal-two-col {
    grid-template-columns: 1fr;
  }
}

.modal-geo-map {
  height: 220px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.modal-backdrop.hidden,
.search-modal.hidden {
  display: none;
}

/* —— Account / API keys —— */
.account-main {
  max-width: 40rem;
  margin: 1.25rem auto;
  padding: 0 1rem 2rem;
  width: 100%;
}

.account-panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.account-who {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-login-row {
  margin-top: 1rem;
}

.account-create-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 1rem 0;
}

.account-create-form .field {
  flex: 1 1 12rem;
  margin: 0;
}

.plaintext-banner {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  background: rgba(61, 156, 245, 0.12);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.plaintext-banner p {
  margin: 0;
  flex: 1 1 100%;
}

.plaintext-value {
  flex: 1 1 auto;
  word-break: break-all;
  font-size: 0.85rem;
  color: var(--text);
}

.keys-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.keys-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.15);
}

.keys-list-item.revoked {
  opacity: 0.55;
}

.keys-meta strong {
  margin-right: 0.35rem;
}

.account-error {
  color: var(--danger);
  margin: 0.5rem 0 0.75rem;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

/* —— About —— */
.about-main {
  max-width: 52rem;
  margin: 1.25rem auto;
  padding: 0 1rem 2.5rem;
  width: 100%;
  display: grid;
  gap: 1rem;
}

@media (min-width: 900px) {
  .about-main {
    grid-template-columns: 14rem 1fr;
    align-items: start;
  }

  .about-toc {
    position: sticky;
    top: 1rem;
  }
}

.about-toc h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.about-toc ol {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.about-toc a {
  color: var(--accent);
  text-decoration: none;
}

.about-toc a:hover {
  text-decoration: underline;
}

.about-article {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.about-section h1,
.about-section h2 {
  margin: 0 0 0.65rem;
  font-size: 1.25rem;
  line-height: 1.25;
}

.about-section h3 {
  margin: 1.1rem 0 0.4rem;
  font-size: 1rem;
}

.about-section p,
.about-section li {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
}

.about-section p {
  margin: 0 0 0.75rem;
}

.about-section ul,
.about-section ol {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.about-section li {
  margin-bottom: 0.4rem;
}

.about-section a {
  color: var(--accent);
}
