:root {
  --bg: #0b0d12;
  --panel: #141925;
  --panel-2: #111621;
  --text: #eef3f9;
  --muted: #9aa6b2;
  --accent: #38bdf8;
  --accent-2: #2dd4bf;
  --accent-3: #f59e0b;
  --outline: rgba(255, 255, 255, 0.08);
  --glow: rgba(56, 189, 248, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", system-ui, sans-serif;
  background: radial-gradient(circle at 20% 10%, #182032, #0b0d12 55%);
  color: var(--text);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: linear-gradient(120deg, #121927, #101622 55%, #101720);
  border-bottom: 1px solid var(--outline);
  gap: 16px;
}

.brand__title {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.brand__subtitle {
  font-size: 12px;
  color: var(--muted);
}

.controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.control {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 6px;
}

.control input,
.control select {
  background: var(--panel-2);
  border: 1px solid var(--outline);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  min-width: 170px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.control input:focus,
.control select:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.control--search .search-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.control--search input {
  flex: 1;
}

.search-field {
  position: relative;
  flex: 1;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(15, 18, 28, 0.98);
  border: 1px solid var(--outline);
  border-radius: 10px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.4);
  padding: 6px;
  z-index: 10;
}

.search-result {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.search-result:hover {
  background: rgba(56, 189, 248, 0.14);
}

.search-result--active {
  background: rgba(56, 189, 248, 0.22);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.search-result__main {
  font-weight: 600;
}

.search-result__meta {
  color: var(--muted);
  font-size: 11px;
}

.preset-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--outline);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.range-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--outline);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.preset-btn:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
}

.range-btn:hover {
  background: rgba(45, 212, 191, 0.16);
  border-color: rgba(45, 212, 191, 0.5);
}

.control--toggle input {
  min-width: unset;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.btn {
  background: linear-gradient(135deg, #38bdf8, #2dd4bf);
  color: #03121a;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(3, 20, 30, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn__icon {
  margin-right: 6px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(3, 20, 30, 0.45);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--outline);
  padding: 8px 12px;
}

.btn--ghost:hover {
  border-color: rgba(56, 189, 248, 0.6);
}

.main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  flex: 1;
}

.map {
  min-height: 600px;
  position: relative;
}

.panel {
  padding: 22px;
  background: linear-gradient(160deg, rgba(20, 25, 37, 0.96), rgba(12, 16, 26, 0.96));
  border-left: 1px solid var(--outline);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.panel h2 {
  margin-top: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  letter-spacing: 0.3px;
}

.panel ol {
  padding-left: 18px;
  color: var(--muted);
}

.note {
  margin-top: 16px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 12px;
  border-radius: 10px;
  color: #d6ebff;
}

.hint {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.legend {
  margin: 16px 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--outline);
}

.legend--overlay {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 200px;
  pointer-events: none;
  display: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
}

.legend__title {
  font-weight: 600;
  margin-bottom: 8px;
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.legend__section + .legend__section {
  margin-top: 10px;
}

.legend__label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.legend__items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}

.legend__swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.maplibregl-popup-content {
  background: #0f1620;
  color: #eef2f7;
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.maplibregl-popup-tip {
  border-top-color: rgba(56, 189, 248, 0.5);
}

.origin-marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #0b1110;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.status {
  margin-top: 18px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-row {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.status-row .status {
  flex: 1;
  margin-top: 0;
}

.status__spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  display: none;
  animation: spin 0.9s linear infinite;
}

.flight-details {
  margin: 16px 0 8px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--outline);
}

.flight-details__title {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.flight-details__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
}

.flight-details__item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
}

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


.status--loading .status__spinner {
  display: inline-block;
}

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

@media (max-width: 960px) {
  .main {
    grid-template-columns: 1fr;
  }

  .panel {
    border-left: none;
    border-top: 1px solid var(--outline);
  }
}

@media (max-width: 820px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
  }

  .control {
    width: 100%;
  }

  .control input,
  .control select {
    min-width: 0;
    width: 100%;
  }

  .preset-group {
    gap: 8px;
  }

  .btn {
    width: 100%;
  }

  .control--search .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  #locateBtn,
  #searchBtn {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .map {
    min-height: 420px;
  }

  .panel {
    padding: 16px;
  }

  .note {
    padding: 10px;
  }

  .status-row {
    flex-direction: column;
  }

  #legendPanel {
    display: none;
  }

  .legend--overlay {
    display: block;
  }
}
