/* ===== Control panel ===== */
:root {
  --bg: #0e1116; --panel: #161b22; --input: #0d1117;
  --text: #e6edf3; --muted: #8b949e; --line: rgba(255, 255, 255, 0.1);
  --accent: #4ea1ff; --accent-ink: #06213f;
  --ok: #2ecc71; --err: #ff6b6b;
}
body { background: var(--bg); color: var(--text); }
.wrap { max-width: 1200px; margin: 0 auto; padding: clamp(0.8rem, 2vw, 1.6rem); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.title { font-size: 1.4rem; font-weight: 800; letter-spacing: 0.02em; }
.title .logo { color: var(--accent); margin-right: 0.3em; }
.title .sub { color: var(--muted); font-weight: 500; font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.18em; }
.badges { display: flex; gap: 0.6rem; align-items: center; }
.badge { font-size: 0.78rem; color: var(--muted); background: var(--panel); border: 1px solid var(--line); padding: 0.32rem 0.7rem; border-radius: 999px; text-decoration: none; }
.badge b { color: var(--text); }
.badge.link:hover { border-color: var(--accent); color: var(--text); }

.layout { display: grid; gap: 1.2rem; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

/* Panel + form */
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; flex-direction: column; gap: 0.4rem; }
label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.group { border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.group legend { padding: 0 0.5rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.hint { color: var(--muted); font-size: 0.75rem; margin: 0; }
.hint code, .group code { background: rgba(255,255,255,0.06); padding: 0.05em 0.35em; border-radius: 5px; }

input[type='text'], input[type='number'], input[type='password'], select {
  width: 100%; background: var(--input); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 0.55rem 0.65rem; font-size: 0.95rem;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(78,161,255,0.18); }
input[type='range'] { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: flex-end; }
.check label { display: flex; align-items: center; gap: 0.5rem; color: var(--text); font-weight: 500; }
.check input { width: auto; }

.toggles { display: flex; flex-direction: column; gap: 0.6rem; }
.toggles label { display: flex; align-items: center; gap: 0.6rem; color: var(--text); font-weight: 500; font-size: 0.92rem; }
.toggles input { width: auto; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); flex: 0 0 auto; }

.screens-ctl { display: flex; gap: 0.5rem; }
.screens-ctl select { flex: 1; }

/* Segmented mode toggle */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--input); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: block; text-align: center; padding: 0.5rem; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); }

/* Tracked flights */
.track-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.track-row .track-input { flex: 1; font-family: var(--mono); text-transform: uppercase; }
.track-row .remove { flex: 0 0 auto; }

/* ATC audio channels */
.audio-row { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.6rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 0.6rem; }
.au-url { font-family: var(--mono); font-size: 0.8rem; }
.au-controls { display: flex; align-items: center; gap: 0.5rem; }
.au-controls .au-pan { width: auto; flex: 0 0 auto; }
.au-vol { flex: 1; min-width: 40px; }
.au-proxy { display: flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.8rem; white-space: nowrap; font-weight: 500; }
.au-proxy input { width: auto; }
.au-remove { flex: 0 0 auto; }
.audio-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.audio-actions .ghost { flex: 1; white-space: nowrap; }
.hint a { color: var(--accent); }

/* Regulars (repeat tail numbers) */
.regulars { display: flex; flex-direction: column; gap: 0.35rem; max-height: 240px; overflow-y: auto; }
.reg-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0.55rem; background: var(--input); border: 1px solid var(--line); border-radius: 8px; }
.reg-tail { font-family: var(--mono); font-weight: 700; }
.reg-count { color: var(--accent); font-weight: 700; }
.reg-ago { margin-left: auto; color: var(--muted); font-size: 0.8rem; }

/* Filters */
.sub-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; background: var(--input); border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.6rem; font-family: var(--mono); font-size: 0.8rem; }
.chip button { background: none; border: none; color: var(--muted); padding: 0; font-size: 0.85rem; line-height: 1; cursor: pointer; }
.chip button:hover { color: var(--err); }

/* Advanced (collapsible) */
.advanced { border: 1px solid var(--line); border-radius: 9px; padding: 0.5rem 0.7rem; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.advanced .grid2 { margin-top: 0.6rem; }

/* Area editor */
.area-tools { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.area-map { height: 260px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0b1020; }
.leaflet-container { background: #0b1020; }
.area-hint { min-height: 1em; }
.area-hint:empty { display: none; }
.area-list { display: flex; flex-direction: column; gap: 0.4rem; }
.area-row { display: flex; align-items: center; gap: 0.5rem; }
.area-swatch { width: 0.9rem; height: 0.9rem; border-radius: 3px; flex: 0 0 auto; }
.area-label { flex: 1 1 auto; min-width: 0; }
.area-radius { flex: 1 1 auto; min-width: 60px; }
.area-meta { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.area-del { flex: 0 0 auto; }
.area-dot span { display: block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 4px rgba(0, 0, 0, 0.6); }
.leaflet-control-zoom a { background: var(--panel); color: var(--text); border-color: var(--line); }
.leaflet-control-attribution { background: rgba(0,0,0,0.5); color: #999; font-size: 9px; }

/* Buttons */
.ghost { background: var(--input); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 0.5rem 0.8rem; }
.ghost:hover { border-color: var(--accent); }
.ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.ghost.wide { width: 100%; }
.primary { background: var(--accent); color: var(--accent-ink); border: none; border-radius: 9px; padding: 0.7rem 1.3rem; font-weight: 700; font-size: 1rem; }
.primary:hover { filter: brightness(1.08); }

.actions { display: flex; align-items: center; gap: 1rem; }
.save-status { font-size: 0.85rem; }
.save-status.ok { color: var(--ok); }
.save-status.err { color: var(--err); }

/* Preview */
.preview-pane { min-width: 0; display: flex; flex-direction: column; gap: 0.7rem; position: sticky; top: 1rem; }
.preview-head { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; }
/* Render the display at a real 1280x720 and scale it down, so the preview
   faithfully mirrors a full-size display (same layout, not the mobile one). */
.preview-box { position: relative; min-width: 0; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.preview-box iframe { position: absolute; top: 0; left: 0; width: 1280px; height: 720px; border: 0; transform-origin: 0 0; }
.urlbar { display: flex; gap: 0.5rem; align-items: center; }
.urlbar code { flex: 1; min-width: 0; background: var(--input); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.65rem; font-size: 0.8rem; overflow-x: auto; white-space: nowrap; color: var(--accent); }

/* ---- Mobile ---- */
@media (max-width: 560px) {
  .wrap { padding: 0.8rem; }
  .topbar { gap: 0.6rem; }
  .title { font-size: 1.2rem; }
  .layout { gap: 1rem; }
  .grid2 { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
  /* Comfortable tap targets */
  input[type='text'], input[type='number'], input[type='password'], select { padding: 0.65rem; font-size: 16px; }
  .segmented span { padding: 0.65rem 0.4rem; }
  .primary { width: 100%; padding: 0.85rem; }
  .actions { flex-direction: column; align-items: stretch; }
}
