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

html, body {
  height: 100%;
  background: #0a0a12;
  color: #c8d0e0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

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

/* ── Controls panel ── */
#controls {
  width: 300px;
  min-width: 300px;
  background: #0d1117;
  border-right: 1px solid #1e2a3a;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}


.control-section {
  padding: 8px 0;
  border-bottom: 1px solid #141c28;
}

.section-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5a7499;
  margin-bottom: 5px;
}

/* Location search box */
.location-search {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
}

.location-search input {
  flex: 1;
  padding: 5px 8px;
  background: #0a1020;
  border: 1px solid #243048;
  border-radius: 4px;
  color: #c8d0e0;
  font-size: 12px;
}

.location-search input:focus {
  outline: none;
  border-color: #3a6fa8;
}

.location-search-status {
  font-size: 11px;
  min-height: 14px;
  margin-bottom: 4px;
  color: #5a7499;
}

.location-search-status.error { color: #c0504a; }

/* Map */
#map-container {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #1e2a3a;
  margin-bottom: 6px;
}

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

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

.coord-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #7a8eaa;
}

.coord-row input {
  width: 100%;
  padding: 4px 6px;
  background: #0a1020;
  border: 1px solid #243048;
  border-radius: 4px;
  color: #c8d0e0;
  font-size: 12px;
}

/* Inputs */
input[type="datetime-local"],
select {
  width: 100%;
  padding: 5px 8px;
  background: #0a1020;
  border: 1px solid #243048;
  border-radius: 4px;
  color: #c8d0e0;
  font-size: 12px;
  margin-top: 2px;
}

input[type="datetime-local"]:focus,
select:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #3a6fa8;
}

.time-display {
  font-size: 11px;
  color: #5a7499;
  margin-top: 4px;
  line-height: 1.5;
}

/* Radio groups */
.radio-group {
  display: flex;
  gap: 16px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

/* Declination (magnetic heading mode) */
.declination-status {
  font-size: 11px;
  color: #5a7499;
  margin-top: 4px;
  min-height: 14px;
}

.declination-status.error { color: #c0504a; }

.declination-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #c8d0e0;
  margin-top: 6px;
}

.declination-label input[type="number"] {
  width: 58px;
  padding: 3px 6px;
  background: #0a1020;
  border: 1px solid #243048;
  border-radius: 4px;
  color: #c8d0e0;
  font-size: 12px;
  text-align: right;
}

.declination-label input[type="number"]:focus {
  outline: none;
  border-color: #3a6fa8;
}

/* Heading */
#heading-slider,
#elevation-slider,
#mag-filter-slider {
  width: 100%;
  accent-color: #3a6fa8;
  display: block;
}

.section-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}
.section-label-row .section-label {
  margin-bottom: 0;
}


.heading-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  margin-top: 1px;
  font-size: 10px;
  color: #4a6a8a;
  letter-spacing: 0.04em;
}

/* Buttons */
.btn-row {
  display: flex;
  gap: 6px;
}

.btn {
  padding: 6px 12px;
  border: 1px solid #243048;
  border-radius: 4px;
  background: #111927;
  color: #c8d0e0;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #1a2940;
  border-color: #3a6fa8;
}

.btn-primary {
  background: #1a4a7a;
  border-color: #2a6aaa;
  color: #e8f0ff;
  font-weight: 600;
}

.btn-primary:hover {
  background: #2060a0;
}

.btn-small {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-icon {
  padding: 6px 0;
  width: 40px;
  font-size: 16px;
  text-align: center;
  flex: 1;
}

/* Spacer used to align Visible-jump buttons under ⏪ and ⏩ */
.btn-icon-spacer {
  flex: 1;
}

/* Visible-jump buttons — same flex share as the icon buttons above them */
.btn-visible-jump {
  flex: 1;
  text-align: center;
  padding: 4px 2px;
}

/* TLE status */
.tle-status {
  font-size: 11px;
  color: #5a7499;
}

#tle-info {
  margin-bottom: 4px;
  line-height: 1.4;
}

#tle-info.tle-stale {
  color: #b8860b;
}

.note {
  font-size: 10px;
  color: #3d5070;
  line-height: 1.4;
  padding-top: 4px;
}

/* ── Sky container ── */
#sky-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

#sky-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Overlays */
#sat-count-wrapper {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 10;
}

#sat-count-overlay {
  font-size: 13px;
  font-family: 'Courier New', monospace;
  color: #c8dff0;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.50);
  border-radius: 10px;
  padding: 5px 14px 4px;
  user-select: none;
}

#sat-count-overlay:hover {
  background: rgba(0, 0, 0, 0.70);
}

#sat-list-dropdown {
  margin-top: 4px;
  background: rgba(0, 8, 18, 0.88);
  border: 1px solid rgba(200, 223, 240, 0.20);
  border-radius: 8px;
  padding: 6px 0;
  max-height: 50vh;
  overflow-y: auto;
  min-width: max-content;
}

.sat-list-row {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #c8dff0;
  padding: 3px 14px;
  white-space: pre;
}

.sat-list-row:hover {
  background: rgba(200, 223, 240, 0.08);
}

.sat-list-empty {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #7a9ab8;
  padding: 4px 14px;
  font-style: italic;
}

#sim-time-overlay {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  color: #c8dff0;
  pointer-events: none;
  background: rgba(0, 8, 18, 0.60);
  border-radius: 10px;
  padding: 5px 14px 4px;
  text-align: right;
  white-space: pre;
  z-index: 1;
}

.overlay-warning {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 50, 65, 0.7);
  color: rgba(180, 190, 210, 0.85);
  padding: 5px 14px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 400;
  pointer-events: auto;
  white-space: nowrap;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

#show-anyway-label {
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
}

/* Legend */
#legend {
  position: absolute;
  bottom: 10px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: #6a88aa;
  pointer-events: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.bright { background: #ffffff; }
.dot.mid    { background: #ffe0a0; }
.dot.faint  { background: #7090b0; }

/* Tooltip */
#tooltip {
  position: absolute;
  background: rgba(5, 15, 30, 0.92);
  border: 1px solid #2a4a6a;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #b0c8e8;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
  line-height: 1.6;
}

#tooltip strong {
  color: #7eb8f7;
  display: block;
  margin-bottom: 2px;
}

/* Satellite name labels */
.sat-label {
  position: absolute;
  color: #a0c8f0;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  pointer-events: none;
}

/* Planet / Moon labels — warmer color to distinguish from satellites */
.planet-label {
  color: #ffd580;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 0 0 8px #000, 0 0 4px #000;
}

/* Satellite name labels */
.sat-label {
  position: absolute;
  color: #a0c8f0;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  pointer-events: none;
  text-shadow: 0 0 6px #000, 0 0 3px #000;
  user-select: none;
  white-space: nowrap;
}

/* Heading (azimuth) ruler just below the horizon */
.heading-tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: rgba(180, 210, 235, 0.9);
  font-size: 10px;
  font-family: 'Courier New', monospace;
  text-shadow: 0 1px 2px #000, 0 -1px 2px #000, 1px 0 2px #000, -1px 0 2px #000;
  user-select: none;
  white-space: nowrap;
  z-index: 1;
  transform: translateX(-50%) translateY(-16px);
}

.heading-tick::before {
  content: '';
  display: block;
  width: 1px;
  background: rgba(106, 155, 195, 0.55);
  flex-shrink: 0;
}

.heading-tick--major::before { height: 10px; }
.heading-tick--minor::before { height: 5px; }

/* Elevation ruler ticks on the left edge of the sky view */
.ruler-tick {
  display: flex;
  align-items: center;
  gap: 3px;
  color: rgba(180, 210, 235, 0.9);
  font-size: 10px;
  font-family: 'Courier New', monospace;
  text-shadow: 0 1px 2px #000, 0 -1px 2px #000, 1px 0 2px #000, -1px 0 2px #000;
  user-select: none;
  line-height: 1;
  z-index: 1;
}

.ruler-tick::before {
  content: '';
  display: block;
  height: 1px;
  background: rgba(106, 155, 195, 0.55);
  flex-shrink: 0;
}

.ruler-tick--major::before { width: 10px; }
.ruler-tick--minor::before { width: 5px; }

/* Right-side ruler: flip row so tick mark faces inward (left) */
.ruler-tick--right {
  flex-direction: row-reverse;
}

/* Compass labels */
.compass-label {
  color: rgba(180, 210, 235, 0.9);
  font-size: 12px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  pointer-events: none;
  transform: translateX(-50%) translateY(-16px);
  text-shadow: 0 1px 2px #000, 0 -1px 2px #000, 1px 0 2px #000, -1px 0 2px #000;
  user-select: none;
  z-index: 1;
}

/* Direction overlay — heading at top centre */
#direction-overlay {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  color: #c8dff0;
  pointer-events: none;
  background: rgba(0, 8, 18, 0.60);
  border-radius: 10px;
  padding: 5px 14px 4px;
  text-shadow: none;
  z-index: 1;
}

#direction-overlay .dir-drag-hint {
  font-size: 10px;
  color: #7aaabf;
  font-style: italic;
  font-family: system-ui, sans-serif;
}

/* Compass overlay */
#compass-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  color: #4a6a8a;
  pointer-events: none;
  text-align: center;
}

/* ── Mode toggle (Ground / Aircraft) ── */
.mode-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-label {
  font-size: 12px;
  color: #7a8eaa;
}

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

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #1e2a3a;
  border: 1px solid #2a4060;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: #5a7499;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #1a4a7a;
  border-color: #2a6aaa;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #7eb8f7;
}

#view-direction-value {
  margin-left: auto;
  font-size: 11px;
  color: #7a8eaa;
  font-weight: normal;
}

/* ── View direction (Aircraft mode) ── */
.view-dir-adjust-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #7a8eaa;
  cursor: pointer;
  margin-bottom: 6px;
}
.view-direction-slider-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.view-direction-slider-row input[type="range"] {
  width: 100%;
}
.view-direction-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #7a8eaa;
}
.view-direction-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Aircraft panel ── */
.field-row {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
}

.field-row .field-label {
  flex: 1;
  min-width: 0;
}

.credentials-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.credentials-edit-btn {
  background: none;
  border: none;
  color: #3a8fd8;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  flex-shrink: 0;
}
.credentials-edit-btn:hover { color: #5aaff8; }

.field-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #7a8eaa;
  margin-bottom: 5px;
}

.field-label input {
  width: 100%;
  padding: 4px 6px;
  background: #0a1020;
  border: 1px solid #243048;
  border-radius: 4px;
  color: #c8d0e0;
  font-size: 12px;
}

.field-label input:focus {
  outline: none;
  border-color: #3a6fa8;
}

.credentials-link {
  float: right;
  font-size: 10px;
  color: #3a8fd8;
  text-decoration: none;
}
.credentials-link:hover { text-decoration: underline; }

.credentials-btn-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.btn-danger {
  background: #3a1010;
  border-color: #6a2020;
  color: #c07070;
}
.btn-danger:hover { background: #4a1818; }

.credentials-status {
  font-size: 11px;
  min-height: 14px;
  color: #5a7499;
}
.credentials-status.ok    { color: #50a060; }
.credentials-status.error { color: #c0504a; }

.flight-status {
  margin-top: 6px;
  font-size: 11px;
  color: #5a7499;
  min-height: 14px;
  line-height: 1.5;
}

.flight-status.error  { color: #c0504a; }
.flight-status.ok     { color: #50a060; }

.opensky-req-count {
  font-size: 11px;
  color: #7090b0;
}

/* ── Map tile dark/light toggle ── */
.map-tile-toggle {
  width: 26px;
  height: 26px;
  font-size: 15px;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  border: none;
  padding: 0;
  display: block;
}
.map-tile-toggle:hover {
  background: #f4f4f4;
}

/* ── Aircraft map icon ── */
.aircraft-icon {
  font-size: 16px;
  line-height: 1;
  color: #ff9f00;
  text-shadow: 0 0 4px #000;
  user-select: none;
}

/* Scrollbar */
#controls::-webkit-scrollbar { width: 6px; }
#controls::-webkit-scrollbar-track { background: transparent; }
#controls::-webkit-scrollbar-thumb { background: #1e2a3a; border-radius: 3px; }

/* ── Satellite Statistics Modal ──────────────────────────────────────────── */

/* ── Generic dialog ──────────────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.dialog-panel {
  background: #0f1826;
  border: 1px solid #243048;
  border-radius: 6px;
  min-width: 280px;
  max-width: 360px;
  width: 90%;
  color: #c8d0e0;
  font-size: 13px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.dialog-header {
  padding: 12px 16px;
  border-bottom: 1px solid #1e2e42;
  font-weight: 600;
  font-size: 14px;
}

.dialog-body {
  padding: 14px 16px;
  line-height: 1.55;
}

.dialog-body p {
  margin: 0 0 8px;
}

.dialog-body p:last-child {
  margin-bottom: 0;
}

.dialog-footer {
  padding: 8px 16px 14px;
  text-align: right;
}

.stats-modal-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 20px 0 0 310px;
  z-index: 1000;
  pointer-events: none;
}

.stats-modal-panel {
  pointer-events: auto;
  background: #0f1826;
  border: 1px solid #243048;
  border-radius: 6px;
  min-width: 320px;
  max-width: 420px;
  width: 90%;
  color: #c8d0e0;
  font-size: 13px;
}

.stats-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #1e2e42;
  font-weight: 600;
  font-size: 13px;
  cursor: move;
  user-select: none;
}

a.star-link {
  color: #5ab4e8;
  text-decoration: none;
}
a.star-link:hover {
  color: #00d8ff;
  text-decoration: underline;
}

#stats-modal-body {
  padding: 14px;
}

.stats-note {
  font-size: 11px;
  color: #8aaccc;
  line-height: 1.5;
  margin-bottom: 10px;
}

.stats-updated {
  font-size: 11px;
  color: #5a7499;
  margin-bottom: 12px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.stats-table th {
  text-align: left;
  padding: 4px 8px;
  color: #7a9ac0;
  border-bottom: 1px solid #1e2e42;
  font-weight: 600;
}

.stats-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #141c28;
}

.stats-table td:nth-child(2),
.stats-table td:nth-child(3) { text-align: right; }

.stats-table th:nth-child(2),
.stats-table th:nth-child(3) { text-align: right; }

.stats-table tfoot td {
  border-top: 1px solid #243048;
  border-bottom: none;
  font-weight: 600;
  color: #8aaccc;
  padding-top: 7px;
}

