:root {
  --c-bg:     #000000;
  --c-text:   #00ff41;
  --c-grid:   #003300;
  --c-hdr:    #00cc33;
  --c-status: #001100;
  --c-blip:   #00ff41;
  --font:     'Courier New', Courier, monospace;
}

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

html {
  height: 100%;
}

body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  height: 100%;
  overflow: hidden;
  user-select: none;
  display: flex;
  flex-direction: column;
}

/* ── Status bar ─────────────────────────────────────────────────── */
#status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 10px;
  background: var(--c-status);
  border-bottom: 1px solid var(--c-grid);
  font-size: 11px;
  height: 24px;
  white-space: nowrap;
}
#sb-status  { font-weight: bold; min-width: 32px; }
#sb-count   { flex: 1; }
#sb-filter  { font-weight: bold; }
.sb-sep     { opacity: 0.4; }
#sb-range, #sb-age { opacity: 0.7; }

/* ── Nav bar ─────────────────────────────────────────────────────── */
#nav-bar {
  display: flex;
  background: var(--c-status);
  border-bottom: 1px solid var(--c-grid);
  height: 28px;
}
#nav-bar button {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--c-grid);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.1s;
}
#nav-bar button:last-child { border-right: none; }
#nav-bar button.active     { opacity: 1; background: var(--c-grid); }
#nav-bar button:hover      { opacity: 0.8; }

#btn-popout {
  flex: 0 0 32px;
  font-size: 15px;
  border-left: 1px solid var(--c-grid) !important;
  opacity: 0.45;
}

/* ── Filter strip ───────────────────────────────────────────────── */
#filter-bar {
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-grid);
  overflow-x: auto;
  scrollbar-width: none;
}
#filter-bar::-webkit-scrollbar { display: none; }
.filter-btn {
  background: transparent;
  border: 1px solid var(--c-grid);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 10px;
  padding: 2px 7px;
  cursor: pointer;
  opacity: 0.45;
  border-radius: 2px;
  white-space: nowrap;
  transition: opacity 0.1s, background 0.1s;
}
.filter-btn.active, .filter-btn:hover {
  opacity: 1;
  background: var(--c-grid);
}

/* ── Main content ───────────────────────────────────────────────── */
#main {
  flex: 1 1 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  overflow: hidden;
  min-height: 0;
}

#radar-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
}

/* ── Info panel ─────────────────────────────────────────────────── */
#panel-info {
  width: 100%;
  max-width: 560px;
  padding: 4px 8px 16px;
  overflow-y: auto;
}
.no-data { opacity: 0.5; padding: 16px; text-align: center; }

.info-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

#btn-info-close {
  margin-left: auto;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--c-grid);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 14px;
  width: 26px;
  height: 26px;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
  opacity: 0.5;
  transition: opacity 0.1s;
}
#btn-info-close:hover { opacity: 1; }
.info-callsign {
  font-size: 26px;
  font-weight: bold;
  color: var(--c-text);
  letter-spacing: 2px;
}
.info-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge {
  font-size: 10px;
  font-weight: bold;
  padding: 1px 6px;
  border-radius: 2px;
}
.badge.mil     { background: #cc1100; color: #fff; }
.badge.emg     { background: #cc6600; color: #fff; }
.badge.airline { background: #004488; color: #88ccff; border: 1px solid #0066bb; }

.info-sub  { font-size: 11px; opacity: 0.7; margin-bottom: 2px; }
.info-desc { font-size: 11px; opacity: 0.6; margin-bottom: 10px; font-style: italic; }

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.tel-item {
  background: var(--c-status);
  border: 1px solid var(--c-grid);
  padding: 5px 8px;
  border-radius: 2px;
}
.tel-lbl { display: block; font-size: 9px; opacity: 0.5; margin-bottom: 2px; }
.tel-val { font-size: 14px; font-weight: bold; }

.route-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--c-status);
  border: 1px solid var(--c-grid);
  padding: 8px 10px;
  border-radius: 2px;
  margin-bottom: 10px;
}
.route-ap    { flex: 1; }
.ap-code     { display: block; font-size: 22px; font-weight: bold; letter-spacing: 2px; }
.ap-name     { display: block; font-size: 9px; opacity: 0.6; }
.route-arrow { font-size: 18px; opacity: 0.4; }

.enrich-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 10px;
}
.enrich-row span::after { content: '·'; margin-left: 8px; opacity: 0.4; }
.enrich-row span:last-child::after { content: ''; }

.photo-wrap { margin-top: 8px; }
.ac-photo   { width: 100%; max-height: 200px; object-fit: cover; border-radius: 3px; }
.photo-credit { font-size: 9px; opacity: 0.4; margin-top: 2px; }

/* ── Settings panel ─────────────────────────────────────────────── */
#panel-settings {
  width: 100%;
  max-width: 440px;
  padding: 4px 8px 16px;
}
.settings-title {
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 3px;
  opacity: 0.5;
  margin-bottom: 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--c-grid);
}
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--c-status);
  border: 1px solid var(--c-grid);
  border-radius: 2px;
}
.set-row.full { flex-direction: column; align-items: flex-start; gap: 6px; }
.set-lbl { font-size: 11px; opacity: 0.7; }

.tog-btn {
  background: var(--c-grid);
  border: 1px solid var(--c-text);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 11px;
  padding: 3px 12px;
  cursor: pointer;
  border-radius: 2px;
  opacity: 0.6;
  transition: opacity 0.1s, background 0.1s;
}
.tog-btn.on  { opacity: 1; background: #003300; }
.tog-btn.off { opacity: 0.4; }
.tog-btn:hover { opacity: 1; }

.loc-inputs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}
.loc-inputs input {
  background: #0a0a0a;
  border: 1px solid var(--c-grid);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 2px;
  width: 130px;
}
.loc-inputs input:focus {
  outline: 1px solid var(--c-text);
}

.range-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Scrollbar styling ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--c-bg); }
::-webkit-scrollbar-thumb { background: var(--c-grid); border-radius: 2px; }

/* ── Night theme overrides ───────────────────────────────────────── */
body[data-theme="night"] .tog-btn.on { background: #1a0800; }

/* ── Popup mode — radar only, no chrome ─────────────────────────── */
body.popup-mode #status-bar,
body.popup-mode #nav-bar,
body.popup-mode #filter-bar { display: none; }

body.popup-mode #main {
  height: 100vh;
  padding: 0;
}

body.popup-mode #radar-canvas {
  border-radius: 0;
}
