* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --android-nav-height: env(safe-area-inset-bottom, 0px);
}
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  background: #1a1a2e;
  color: #e0e0e0;
  overflow: hidden;
}

#container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Desktop layout */
body.desktop-mode #container {
  flex-direction: row;
}
body.desktop-mode #sidebar {
  width: 410px;
  min-width: 410px;
  overflow-y: auto;
  background: #16213e;
  border-right: 1px solid #0f3460;
  display: flex;
  flex-direction: column;
  z-index: 1;
}
body.desktop-mode #sidebar-resizer {
  width: 4px;
  cursor: col-resize;
  flex-shrink: 0;
  background: transparent;
  position: relative;
  z-index: 2;
}
body.desktop-mode #sidebar-resizer:hover,
body.desktop-mode #sidebar-resizer:active {
  background: #e94560;
}
body.mobile-mode #sidebar-resizer {
  display: none;
}
body.desktop-mode #overlay,
body.desktop-mode #divider-handle {
  display: none;
}

/* Mobile layout */
body.mobile-mode #container {
  flex-direction: column;
}
body.mobile-mode #sidebar {
  display: none;
}
body.mobile-mode #divider-handle {
  display: flex;
  height: 10px;
  background: #0f3460;
  cursor: row-resize;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
body.mobile-mode #drag-grip {
  width: 40px;
  height: 3px;
  border-radius: 2px;
  background: #2a4a6a;
}
body.mobile-mode #divider-handle:hover #drag-grip {
  background: #e94560;
}
body.mobile-mode #overlay {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: #16213e;
  overflow: hidden;
  height: 40dvh;
  padding-bottom: max(var(--android-nav-height), 60px); 
  box-sizing: border-box;
}
body.mobile-mode #overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #080a14;
  border-bottom: 2px dotted #0f3460;
  position: sticky;
  top: 0;
  z-index: 3;
  font-weight: 700;
  color: #e8edf5;
  font-size: 13px;
  letter-spacing: 1px;
  gap: 8px;
  touch-action: none;
}
body.mobile-mode #overlay-header::before,
body.mobile-mode #overlay-header::after {
  content: '⇅';
  font-size: 28px;
  color: #5a9aba;
  line-height: 1;
  user-select: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
body.mobile-mode #overlay-header::before {
  left: 6px;
}
body.mobile-mode #overlay-header::after {
  right: 6px;
}
body.mobile-mode #overlay-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}
body.mobile-mode #overlay-slider {
  width: 100px;
  height: 3px;
  accent-color: #e94560;
  cursor: pointer;
}
body.mobile-mode #overlay-icon {
  font-size: 14px;
  color: #b4c7dc;
  line-height: 1;
}
body.mobile-mode #brightness-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}
body.mobile-mode #brightness-slider {
  width: 100px;
  height: 3px;
  accent-color: #e94560;
  cursor: pointer;
}
body.mobile-mode #overlay-date-row {
  display: flex;
  gap: 6px;
  padding: 6px 16px;
  background: #1a1a2e;
  border-bottom: 1px solid #0f3460;
  align-items: center;
}
body.mobile-mode #overlay-date-row input[type="date"] {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: #16213e;
  color: #f0f4fa;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  min-height: 36px;
}
body.mobile-mode #overlay-date-row input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}
/* Map panel — shared */
#map-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
#map {
  flex: 1;
  min-height: 0;
  background: #0d1117;
}

/* Section headers — shared */
.section-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #e8edf5;
  background: #080a14;
  border-bottom: 2px dotted  #0f3460;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 2;
}

.last-updated {
  font-size: 11px;
  color: #e8edf5;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  margin-left: auto;
  white-space: nowrap;
}

#date-section {
  border-bottom: 1px solid #0f3460;
}
#date-controls {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  align-items: center;
}
#date-picker {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: #1a1a2e;
  color: #f0f4fa;
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
}
#date-picker:focus {
  outline: 1px solid #e94560;
}
#date-picker::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

#flying-section {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}
#flying-section.hidden {
  display: none;
}
#completed-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#flying-list {
  overflow-y: auto;
  max-height: 40dvh;
}
#completed-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.flight-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #8899bb;
  cursor: default;
  border-bottom: 1px solid #1a3a5a;
  padding: 4px 12px;
  background: #0d1a30;
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
.flight-header .color-dot {
  visibility: hidden;
}

.flight-wrapper {
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #0f3460;
  padding: 4px 12px;
}
.flight-wrapper:hover {
  background: #1a2745;
}
.flight-wrapper.selected {
  background: #0f3460;
  box-shadow: inset 0 0 0 1px #e94560;
}

.flight-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.flight-subrow {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 66px;
  font-size: 11px;
  color: #b0c0d8;
  margin-top: 2px;
  min-height: 18px;
}
.flight-subrow .pilot-name {
  color: #f0f4fa;
  font-weight: 500;
}
.flight-subrow .pilot-sep {
  color: #556;
  margin: 0 4px;
}

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

.seq {
  width: 22px;
  font-weight: 700;
  color: #8899bb;
  text-align: center;
  flex-shrink: 0;
  font-size: 11px;
}

.rego {
  width: 28px;
  font-weight: 800;
  color: #ffffff;
  flex-shrink: 0;
}

.timer {
  width: 40px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: #7dd8fc;
  flex-shrink: 0;
}

.last-updated.pulse {
  animation: updated-pulse 0.4s ease-out;
}
@keyframes updated-pulse {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

.pilot-inline {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f0f4fa;
  font-weight: 500;
  font-size: 12px;
  padding-left: 4px;
}

.altitude-msl {
  width: 54px;
  text-align: right;
  font-size: 11px;
  color: #a5d6a7;
  font-weight: 600;
  flex-shrink: 0;
}

.altitude-agl {
  width: 54px;
  text-align: right;
  font-size: 11px;
  color: #c5e1a5;
  font-weight: 600;
  flex-shrink: 0;
}

.distance {
  width: 52px;
  text-align: right;
  font-size: 12px;
  color: #e0e0e0;
  font-weight: 500;
  flex-shrink: 0;
}

.age {
  width: 36px;
  text-align: right;
  font-size: 11px;
  color: #ffcc80;
  font-weight: 600;
  flex-shrink: 0;
}

#sidebar-show-all {
  display: none;
}
.btn-filter {
  float: right;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: #e94560;
  border: none;
  padding: 3px 10px;
  border-radius: 4px;
  line-height: normal;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-filter:hover {
  background: #d63851;
}
.btn-filter.active {
  background: #555;
  color: #e94560;
}
.btn-filter.active-md {
  background: #777;
  color: #e066ff;
  border: 1px solid #e066ff;
}
.btn-filter.spin {
  animation: refresh-spin 0.6s ease-out;
}
@keyframes refresh-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#dev-panel {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 999;
  background: rgba(15, 20, 40, 0.92);
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  min-width: 160px;
}
#dev-header {
  font-weight: 700;
  color: #e94560;
  font-size: 9px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.dev-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.dev-row label {
  width: 80px;
  color: #b4c7dc;
  flex-shrink: 0;
}
.dev-row label span {
  color: #7dd8fc;
  font-family: monospace;
}
.dev-row input[type="range"] {
  flex: 1;
  accent-color: #e94560;
  height: 4px;
  cursor: pointer;
}

/* Desktop typography */
@media (min-width: 769px) {
  .section-header {
    font-size: 13px;
    padding: 10px 14px;
  }
  .last-updated {
    font-size: 12px;
  }
  #date-picker {
    font-size: 13px;
  }
  .flight-header {
    font-size: 12px;
    padding: 6px 14px;
  }
  .flight-wrapper {
    padding: 6px 14px;
  }
  .flight-row {
    font-size: 15px;
  }
  .flight-subrow {
    font-size: 13px;
    padding-left: 68px;
  }
  .pilot-inline {
    font-size: 14px;
  }
  .timer {
    width: 45px;
    font-size: 13px;
  }
  .altitude-msl, .altitude-agl {
    font-size: 13px;
    width: 64px;
  }
  .age {
    font-size: 13px;
    width: 42px;
  }
  .btn-filter {
    font-size: 12px;
    padding: 4px 12px;
  }
}

.wp-marker {
  background: none !important;
  border: none !important;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.wp-dot {
  border-radius: 50%;
  flex-shrink: 0;
}
.wp-label {
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 6px #000;
  line-height: 1;
}
