:root {
  --bg: #05070a;
  --panel: rgba(14, 17, 22, 0.78);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #eef3f8;
  --muted: #9da9b8;
  --accent: #64b5ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
}

.panel {
  position: fixed;
  z-index: 2;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px) saturate(135%);
  -webkit-backdrop-filter: blur(16px) saturate(135%);
}

.hud-panel-head,
.legend-head,
.counter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.hud-panel-body {
  min-width: 0;
}

.hud-panel-body[hidden] {
  display: none !important;
}

.hud-head-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.hud-toggle {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.hud-toggle:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.hud-toggle:active {
  transform: translateY(1px);
}

.hud-toggle:focus-visible {
  outline: 2px solid rgba(100, 181, 255, 0.82);
  outline-offset: 2px;
}

.hud-chevron {
  width: 8px;
  height: 8px;
  margin-top: 3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-135deg);
  transition: transform 140ms ease, margin 140ms ease;
}

.hud-panel.is-collapsed .hud-chevron {
  margin-top: -3px;
  transform: rotate(45deg);
}

#header {
  top: 16px;
  left: 16px;
  min-width: 238px;
  padding: 10px 12px;
}

.header-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-copy {
  min-width: 0;
}

.signal {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #71d9a5;
  box-shadow: 0 0 18px rgba(113, 217, 165, 0.7);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 14px;
  font-weight: 680;
  line-height: 1.2;
}

#header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.weather-control {
  min-width: 0;
  margin-top: 8px;
  padding-top: 8px;
  display: grid;
  gap: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.weather-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.weather-switch {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 11px;
  font-weight: 720;
  line-height: 1.2;
  white-space: nowrap;
}

.weather-switch input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

#weather-status,
#wind-status {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-opacity {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(74px, 1fr) 34px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.2;
}

#weather-opacity,
#wind-opacity {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

#weather-opacity:disabled,
#wind-opacity:disabled {
  opacity: 0.52;
}

#weather-opacity-value,
#wind-opacity-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.replay-control {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.replay-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.replay-label {
  min-width: 48px;
  color: var(--text);
  font-size: 11px;
  font-weight: 720;
  line-height: 1.2;
}

.replay-button {
  width: 40px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(137, 164, 205, 0.26);
  border-radius: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  font-size: 10.5px;
  font-weight: 760;
  line-height: 1;
  cursor: pointer;
}

.replay-button:hover:not(:disabled) {
  border-color: rgba(125, 211, 252, 0.48);
  background: rgba(125, 211, 252, 0.12);
}

.replay-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.replay-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.replay-live {
  margin-left: auto;
}

.replay-range {
  min-width: 0;
  display: grid;
  grid-template-columns: 64px minmax(90px, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.2;
}

#replay-offset {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

#replay-time-label,
#replay-status {
  min-width: 0;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#replay-time-label {
  color: var(--text);
}

#replay-status {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.2;
}

.weather-sources {
  display: flex;
  align-items: center;
  gap: 9px;
}

.weather-source {
  width: max-content;
  color: #aac8ff;
  font-size: 10.5px;
  line-height: 1.2;
  text-decoration: none;
}

.weather-source:hover {
  text-decoration: underline;
}

#runway-status {
  top: 16px;
  left: 50%;
  width: min(620px, calc(100vw - 380px));
  min-width: 430px;
  padding: 8px;
  transform: translateX(-50%);
}

#runway-status .hud-panel-head {
  margin: 0 1px;
}

#runway-status:not(.is-collapsed) .hud-panel-head {
  margin-bottom: 8px;
}

#runway-status-rows {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.runway-status-row {
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px 8px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
}

.runway-status-runway {
  color: var(--text);
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
}

.runway-status-badge {
  justify-self: end;
  min-width: 58px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #d8fbe6;
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(74, 222, 128, 0.32);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.runway-status-detail,
.runway-status-time {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runway-status-time {
  justify-self: end;
  font-variant-numeric: tabular-nums;
}

.runway-status-row.near .runway-status-badge {
  color: #fef3c7;
  background: rgba(234, 179, 8, 0.17);
  border-color: rgba(250, 204, 21, 0.42);
}

.runway-status-row.occ .runway-status-badge {
  color: #ffedd5;
  background: rgba(249, 115, 22, 0.2);
  border-color: rgba(251, 146, 60, 0.48);
}

.runway-status-row.landing .runway-status-badge {
  color: #ffe4e6;
  background: rgba(225, 29, 72, 0.28);
  border-color: rgba(251, 113, 133, 0.66);
}

.runway-status-row.taxiing .runway-status-badge {
  color: #cffafe;
  background: rgba(8, 145, 178, 0.22);
  border-color: rgba(34, 211, 238, 0.46);
}

.runway-status-row.runway-roll .runway-status-badge {
  color: #ede9fe;
  background: rgba(124, 58, 237, 0.22);
  border-color: rgba(167, 139, 250, 0.52);
}

.runway-status-row.stale-acft .runway-status-badge {
  color: #fee2e2;
  background: rgba(220, 38, 38, 0.3);
  border-color: rgba(248, 113, 113, 0.72);
}

.runway-status-row.stale .runway-status-badge {
  color: #e5e7eb;
  background: rgba(107, 114, 128, 0.3);
  border-color: rgba(209, 213, 219, 0.28);
}

.runway-status-row.unknown .runway-status-badge {
  color: #cbd5e1;
  background: rgba(71, 85, 105, 0.28);
  border-color: rgba(148, 163, 184, 0.28);
}

#legend {
  top: 16px;
  right: 16px;
  width: min(290px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#legend .hud-panel-body {
  min-height: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
}

.legend-head {
  flex: 0 0 auto;
}

h2 {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

#legend-count {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

#legend-search {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

#legend-search:focus {
  border-color: rgba(100, 181, 255, 0.8);
}

#legend-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

#legend-list::-webkit-scrollbar {
  width: 6px;
}

#legend-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.legend-row {
  min-height: 28px;
  width: 100%;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 5px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  text-align: left;
  user-select: none;
}

.legend-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.legend-row[hidden] {
  display: none;
}

.legend-row.off {
  opacity: 0.4;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-number {
  color: var(--muted);
  font-size: 11px;
}

#bottom-left-stack {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 2;
  width: min(430px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#bottom-left-stack .panel {
  position: static;
}

#details {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 11px;
}

#details .hud-panel-body {
  margin-top: 7px;
}

#movement-counters {
  display: flex;
  flex-direction: column;
  padding: 12px;
  max-height: min(48vh, 520px);
  overflow: hidden;
}

.counter-head {
  flex: 0 0 auto;
  margin-bottom: 0;
}

#movement-counters:not(.is-collapsed) .counter-head {
  margin-bottom: 8px;
}

#movement-counters .hud-panel-body {
  min-height: 0;
  overflow-y: auto;
}

#counter-total {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

#movement-counters table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#movement-counters th,
#movement-counters td {
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  line-height: 1.25;
  text-align: left;
}

#movement-counters th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

#movement-counters th:nth-child(2),
#movement-counters td:nth-child(2) {
  width: 54px;
  text-align: right;
}

#movement-counters th:nth-child(3),
#movement-counters td:nth-child(3) {
  width: 92px;
  padding-left: 12px;
  color: var(--muted);
}

.counter-zone {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.counter-count {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

#tooltip {
  position: fixed;
  z-index: 3;
  min-width: 170px;
  max-width: 320px;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-999px, -999px, 0);
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(7, 10, 14, 0.92);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
  color: var(--text);
  transition: opacity 90ms ease;
}

#tooltip.visible {
  opacity: 1;
}

.crossing-bubble-marker {
  width: max-content;
  min-width: 42px;
  max-width: min(240px, calc(100vw - 32px));
  padding: 5px 10px 6px;
  border: 1px solid rgba(254, 202, 202, 0.96);
  border-radius: 7px;
  background: rgba(127, 29, 29, 0.94);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.38);
  color: #fff7ed;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none;
  white-space: normal;
}

.crossing-bubble-marker.stale {
  opacity: 0.6;
}

.aircraft-detail-popup .maplibregl-popup-content {
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.94);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
  color: var(--text);
}

.aircraft-detail-popup .maplibregl-popup-tip {
  border-top-color: rgba(8, 11, 16, 0.94);
  border-bottom-color: rgba(8, 11, 16, 0.94);
}

.aircraft-detail-popup .maplibregl-popup-close-button {
  width: 26px;
  height: 26px;
  color: var(--text);
  font-size: 18px;
  line-height: 24px;
}

.aircraft-detail-popup .maplibregl-popup-close-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.aircraft-popup-card {
  width: 300px;
  padding: 11px;
}

.aircraft-popup-title {
  padding-right: 24px;
  font-size: 14px;
  font-weight: 760;
  line-height: 1.2;
}

.aircraft-popup-subtitle,
.aircraft-popup-attribution {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.aircraft-popup-subtitle {
  margin-top: 2px;
}

.aircraft-popup-photo {
  width: 100%;
  aspect-ratio: 3 / 2;
  margin-top: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 11px;
}

.aircraft-popup-photo a,
.aircraft-popup-photo img {
  display: block;
  width: 100%;
  height: 100%;
}

.aircraft-popup-photo img {
  object-fit: cover;
}

.aircraft-popup-attribution {
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aircraft-popup-details {
  margin-top: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}

.aircraft-popup-row {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.aircraft-popup-row span {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.aircraft-popup-row strong {
  overflow: hidden;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aircraft-popup-route {
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.aircraft-popup-route-heading {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 760;
  line-height: 1;
  text-transform: uppercase;
}

.aircraft-popup-route-empty,
.aircraft-popup-route-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.aircraft-popup-route-code {
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
  line-height: 1.1;
}

.aircraft-popup-route-airports {
  margin-top: 5px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.aircraft-popup-route-airports span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aircraft-popup-route-meta {
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aircraft-popup-turn {
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.aircraft-popup-turn-heading {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 760;
  line-height: 1;
  text-transform: uppercase;
}

.aircraft-popup-turn-empty {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.aircraft-popup-turn-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  min-height: 20px;
  color: var(--text);
  font-size: 10.8px;
  line-height: 1.15;
}

.aircraft-popup-turn-row + .aircraft-popup-turn-row {
  margin-top: 4px;
}

.aircraft-popup-turn-swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #0f3b73;
  box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.2);
}

.aircraft-popup-turn-row[data-phase="inbound-airborne"] .aircraft-popup-turn-swatch {
  background: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(191, 219, 254, 0.24);
}

.aircraft-popup-turn-row[data-phase="landed"] .aircraft-popup-turn-swatch {
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(187, 247, 208, 0.24);
}

.aircraft-popup-turn-row[data-phase="turn-time"] .aircraft-popup-turn-swatch {
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(226, 232, 240, 0.22);
}

.aircraft-popup-turn-row[data-phase="taxi-out"] .aircraft-popup-turn-swatch {
  background: #eab308;
  box-shadow: 0 0 0 2px rgba(254, 240, 138, 0.26);
}

.aircraft-popup-turn-row[data-phase="takeoff-outbound"] .aircraft-popup-turn-swatch {
  background: #dc2626;
  box-shadow: 0 0 0 2px rgba(254, 202, 202, 0.26);
}

.aircraft-popup-turn-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aircraft-popup-turn-range {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.aircraft-popup-turn-duration {
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  white-space: nowrap;
}

.tooltip-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.tooltip-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.maplibregl-ctrl-top-left {
  top: 86px;
  left: 16px;
}

.maplibregl-ctrl-group {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.maplibregl-ctrl-group button {
  background-color: transparent;
}

.maplibregl-ctrl-attrib {
  background: rgba(5, 7, 10, 0.7) !important;
  color: #cfd8e3 !important;
}

.maplibregl-ctrl-attrib a {
  color: #aac8ff !important;
}

@media (max-width: 760px) {
  #header {
    max-width: calc(100vw - 32px);
  }

  #runway-status {
    top: 84px;
    right: 12px;
    left: 12px;
    width: auto;
    min-width: 0;
    transform: none;
  }

  #runway-status-rows {
    grid-template-columns: 1fr;
  }

  #legend {
    top: auto;
    right: 12px;
    bottom: 168px;
    left: 12px;
    width: auto;
    max-height: 38vh;
  }

  #bottom-left-stack {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
  }

  #movement-counters th:nth-child(3),
  #movement-counters td:nth-child(3) {
    width: 76px;
  }

  .maplibregl-ctrl-top-left {
    top: 86px;
    left: 12px;
  }
}
