/* ═══════════════════════════════════════════════════════════
   SatTrack — style.css
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #21262d;
  --border:   #30363d;
  --text:     #e6edf3;
  --muted:    #8b949e;
  --accent:   #58a6ff;
  --green:    #3fb950;
  --orange:   #f0883e;
  --red:      #f85149;
  --yellow:   #d29922;
  --left-w:   280px;
  --right-w:  260px;
  --top-h:    48px;
  --mob-tab-h: 0px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Light Theme ─────────────────────────────────────────── */
body.light {
  --bg:       #f6f8fa;
  --surface:  #ffffff;
  --surface2: #f0f2f4;
  --border:   #d0d7de;
  --text:     #1f2328;
  --muted:    #57606a;
  --accent:   #0969da;
  --green:    #1a7f37;
  --orange:   #bc4c00;
  --red:      #cf222e;
  --yellow:   #9a6700;
}
body.light .leaflet-container { background: #c8dff0; }
body.light #polar-wrap        { background: #e8edf5; }

/* ── Top Bar ─────────────────────────────────────────────── */
#topbar {
  height: var(--top-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 200;
  position: relative;
}
.tb-left  { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.tb-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.logo {
  font-size: 15px; font-weight: 700;
  color: var(--accent); white-space: nowrap;
  letter-spacing: -.3px; flex-shrink: 0;
}
.sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }
.clock {
  font-family: 'Courier New', monospace;
  font-size: 13px; color: var(--green); white-space: nowrap; flex-shrink: 0;
}
.obs-info {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 6px; border: none;
  cursor: pointer; font-size: 12px; font-weight: 500;
  white-space: nowrap; transition: opacity .15s, background .15s;
}
.btn:hover   { opacity: .82; }
.btn.primary { background: var(--accent); color: #000; }
.btn.ghost   { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
.btn.danger  { background: var(--red); color: #fff; }
.btn.sm      { padding: 4px 9px; font-size: 11px; }
.btn.icon    { padding: 6px 8px; }

.icon-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 4px;
}
.icon-btn:hover { color: var(--text); background: var(--surface2); }

/* ── Main Layout ─────────────────────────────────────────── */
#main {
  display: flex;
  height: calc(100vh - var(--top-h) - var(--mob-tab-h));
  overflow: hidden;
}

/* ── Resizer ─────────────────────────────────────────────── */
.resizer {
  width: 5px; flex-shrink: 0;
  background: var(--border);
  cursor: col-resize;
  transition: background .15s;
  position: relative; z-index: 10;
}
.resizer:hover, .resizer.dragging { background: var(--accent); }

/* ── Panel Header ────────────────────────────────────────── */
.panel-hdr {
  height: 36px; display: flex; align-items: center;
  justify-content: space-between; padding: 0 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}

/* ── Left Panel ──────────────────────────────────────────── */
#left {
  width: var(--left-w); min-width: 160px; max-width: 420px;
  background: var(--surface);
  display: flex; flex-direction: column; overflow: hidden;
}

#sat-list { flex: 1; overflow-y: auto; overflow-x: hidden; }

#left-foot {
  padding: 8px 12px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.stat-label { font-size: 11px; color: var(--muted); }

.badge {
  display: inline-block; font-size: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 6px; color: var(--muted); font-weight: 600;
}

/* Satellite list items */
.sat-item {
  padding: 7px 10px 7px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s;
  border-left: 3px solid transparent;
}
.sat-item:hover    { background: var(--surface2); }
.sat-item.selected { background: rgba(88,166,255,.07); border-left-color: var(--accent); }
.sat-item.overhead { border-left-color: var(--green); }

.si-top {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 4px;
}
.si-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 4px currentColor;
}
.si-name {
  font-weight: 600; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.si-status {
  font-size: 10px; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; text-transform: uppercase; flex-shrink: 0;
}
.si-status.up   { background: rgba(63,185,80,.18);   color: var(--green); }
.si-status.down { background: rgba(139,148,158,.12); color: var(--muted); }
.si-status.soon { background: rgba(240,136,62,.18);  color: var(--orange); }

/* Elevation bar */
.si-bar-wrap {
  height: 3px; background: var(--border); border-radius: 2px;
  margin-bottom: 4px; overflow: hidden;
}
.si-bar {
  height: 100%; border-radius: 2px;
  transition: width .5s ease, background .3s ease;
  width: 0%; background: var(--muted);
}

.si-data {
  font-size: 11px; color: var(--muted); font-family: 'Courier New', monospace;
}
.si-data .up { color: var(--green); }
.si-data .cd { color: var(--orange); }

/* Countdown */
.countdown-list { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.cd-item { font-size: 11px; color: var(--accent); line-height: 1.5; }
.cd-item.active  { color: var(--green); font-weight: 600; }
.cd-item.warning { color: var(--orange); }

/* ── Center ──────────────────────────────────────────────── */
#center {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

/* Tab bar */
#tab-bar {
  display: flex; background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 6px; flex-shrink: 0; overflow-x: auto;
}
.tab {
  padding: 10px 14px; background: none; border: none;
  border-bottom: 2px solid transparent; color: var(--muted);
  cursor: pointer; font-size: 13px; white-space: nowrap; transition: color .15s;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Panes */
#panes { flex: 1; position: relative; overflow: hidden; }
.pane {
  position: absolute; inset: 0;
  display: none; flex-direction: column; overflow: hidden;
}
.pane.active { display: flex; }

/* Map */
#map { width: 100%; height: 100%; }

/* Sky view */
#polar-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #080d16; overflow: hidden; padding: 12px;
}
#polar { max-width: 100%; max-height: 100%; }

/* Passes */
#pass-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; flex-wrap: wrap; gap: 6px; background: var(--surface);
}
.pass-title { font-size: 14px; font-weight: 600; }
.pass-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.mini {
  width: 50px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 4px 6px; border-radius: 5px;
  font-size: 12px; display: inline; margin-left: 3px;
}
.mini-sel {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 4px 7px; border-radius: 5px;
  font-size: 12px; max-width: 140px;
}

/* Filter panel */
.filter-panel {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 12px; background: var(--surface2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.filter-panel.hidden { display: none; }
.filter-panel .form-in.sm { padding: 4px 7px; font-size: 12px; }

#pass-wrap { flex: 1; overflow-y: auto; overflow-x: auto; }

/* Pass table */
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  text-align: left; padding: 8px 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:hover { color: var(--text); }
tbody td {
  padding: 7px 10px; border-bottom: 1px solid rgba(48,54,61,.4);
  font-size: 12px; white-space: nowrap;
}
tbody tr:hover td { background: var(--surface2); }

.el-hi { color: var(--green); font-weight: 700; }
.el-md { color: var(--orange); }
.el-lo { color: var(--muted); }
.sun-yes { color: #ffd700; }
.sun-no  { color: var(--muted); }

/* Active pass row */
tbody tr.pass-active td {
  background: rgba(63,185,80,.08) !important;
}
tbody tr.pass-active td:first-child {
  border-left: 2px solid var(--green);
}

/* Overlap rows */
tbody tr.overlap td { background: rgba(240,136,62,.06); }
tbody tr.overlap td:first-child { border-left: 2px solid var(--orange); }

/* Overlap section */
#overlap-section {
  padding: 12px; border-top: 2px solid var(--border);
}
#overlap-section h4 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--orange); margin-bottom: 8px;
}

/* Settings */
.settings-body { padding: 16px; max-width: 560px; overflow-y: auto; flex: 1; }
.sgroup {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin-bottom: 10px;
}
.sgroup h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin-bottom: 8px;
}
.srow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; font-size: 12px; gap: 8px;
}
.srow select, .srow input[type=number] {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 5px 8px; border-radius: 5px; font-size: 12px;
}

/* ── Right Panel ─────────────────────────────────────────── */
#right {
  width: var(--right-w); min-width: 180px; max-width: 380px;
  background: var(--surface);
  display: flex; flex-direction: column; overflow-y: auto;
}

.dsec { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.dsec h4 {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin-bottom: 6px;
}
.drow {
  display: flex; justify-content: space-between;
  align-items: center; padding: 2px 0; font-size: 12px;
}
.drow > span:first-child { color: var(--muted); }
.dval { font-weight: 600; font-size: 12px; }
.mono { font-family: 'Courier New', monospace; }
.blue   { color: var(--accent); }
.green  { color: var(--green); }
.orange { color: var(--orange); }
.red    { color: var(--red); }

/* Doppler */
.dop-row { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.dl { font-size: 11px; color: var(--muted); width: 28px; flex-shrink: 0; }
.freq-in {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 4px 6px; border-radius: 5px;
  font-size: 12px; font-family: 'Courier New', monospace; min-width: 0;
}
.dop-val {
  font-family: 'Courier New', monospace; font-size: 12px;
  min-width: 68px; text-align: right; color: var(--muted);
}
.hint { font-size: 10px; color: var(--muted); margin-top: 3px; }

.action-row { display: flex; flex-direction: column; gap: 5px; }
.action-row .btn { width: 100%; justify-content: center; }

/* ── Empty State ─────────────────────────────────────────── */
.empty {
  text-align: center; color: var(--muted);
  padding: 32px 16px; font-size: 12px; line-height: 1.7;
}

/* ── Modals ──────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  z-index: 1000; display: flex; align-items: center;
  justify-content: center; padding: 20px;
}
.modal-bg.hidden { display: none; }

.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px; width: 100%;
  max-width: 500px; max-height: 88vh; overflow-y: auto;
}
.modal-hdr {
  font-size: 15px; font-weight: 600; margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.close-btn {
  background: none; border: none; color: var(--muted);
  font-size: 17px; cursor: pointer; line-height: 1; padding: 2px 4px; border-radius: 4px;
}
.close-btn:hover { color: var(--text); background: var(--surface2); }

/* Add-sat inner tabs */
.tab-sw {
  display: flex; border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; margin-bottom: 12px;
}
.stab {
  flex: 1; padding: 7px; background: var(--surface2); border: none;
  color: var(--muted); font-size: 12px; cursor: pointer; transition: background .15s;
}
.stab + .stab { border-left: 1px solid var(--border); }
.stab.active   { background: var(--accent); color: #000; font-weight: 600; }

/* Search results */
.search-res {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; max-height: 200px; overflow-y: auto; margin-top: 6px;
}
.sr-item {
  padding: 7px 11px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--border); }

/* Groups grid */
.group-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grp-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 6px; cursor: pointer; text-align: left;
  font-size: 12px; transition: background .15s;
}
.grp-btn:hover { background: var(--border); }
.grp-btn .gname { font-weight: 600; display: block; margin-bottom: 1px; }
.grp-btn .gdesc { color: var(--muted); font-size: 11px; }

/* Observer list */
.obs-list { margin-bottom: 14px; }
.obs-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 7px; margin-bottom: 5px;
  background: var(--surface2); border: 1px solid var(--border);
  transition: border-color .15s;
}
.obs-item.active { border-color: var(--green); }
.obs-item-info { flex: 1; min-width: 0; }
.obs-item-name {
  font-weight: 600; font-size: 13px; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.obs-item-coords { font-size: 11px; color: var(--muted); font-family: monospace; }
.obs-item-actions { display: flex; gap: 5px; flex-shrink: 0; margin-left: 8px; }
.obs-add-wrap {
  border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px;
}
.obs-add-title {
  font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 10px;
}

/* Form elements */
.form-in {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 7px 9px; border-radius: 6px; font-size: 13px;
}
.form-in:focus { outline: none; border-color: var(--accent); }
textarea.form-in { font-family: 'Courier New', monospace; font-size: 12px; resize: vertical; }
.form-lbl { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.form-grp { margin-bottom: 9px; }
.coord-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-bottom: 9px; }

/* ── Loading ─────────────────────────────────────────────── */
#loading {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
#loading.hidden { display: none; }
.loading-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 22px 32px; text-align: center; min-width: 200px;
}
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .75s linear infinite; margin: 0 auto 10px;
}
#loading-msg  { font-size: 13px; color: var(--text); margin-bottom: 2px; }
.loading-prog { font-size: 11px; color: var(--muted); margin-top: 6px; }
.loading-prog.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Transponder list ────────────────────────────────────── */
.trsp-item {
  padding: 6px 8px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--border); margin-bottom: 4px;
  background: var(--surface2); transition: border-color .15s;
}
.trsp-item:hover, .trsp-item.active { border-color: var(--accent); }
.trsp-name  { display: block; font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.trsp-freqs { font-size: 10px; font-family: 'Courier New', monospace; color: var(--muted); }
.trsp-freqs .green { color: var(--green); }
.trsp-freqs .muted { color: var(--muted); }

/* ── Favorites ───────────────────────────────────────────── */
.fav-list { display: flex; flex-direction: column; gap: 6px; }
.fav-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 7px;
  background: var(--surface2); border: 1px solid var(--border);
}
.fav-name  { font-weight: 600; font-size: 12px; }

/* ── Calendar view ───────────────────────────────────────── */
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; flex-shrink: 0;
  background: var(--surface); position: sticky; top: 0; z-index: 1;
}
.cal-grid {
  display: flex; overflow-x: auto; overflow-y: auto;
  flex: 1; font-size: 11px;
}
.cal-timecol { flex-shrink: 0; width: 42px; }
.cal-hour-lbl {
  height: 28px; line-height: 28px; text-align: right;
  padding-right: 6px; color: var(--muted); font-size: 10px;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.cal-day-col { flex: 1; min-width: 80px; border-left: 1px solid var(--border); }
.cal-hdr-cell {
  height: 28px; line-height: 28px; text-align: center; font-weight: 600;
  border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 1; font-size: 11px;
}
.cal-day-body {
  position: relative; height: 672px; /* 24 * 28px */
  background-image: repeating-linear-gradient(
    to bottom, transparent, transparent 27px, var(--border) 27px, var(--border) 28px
  );
}
.cal-pass-block {
  position: absolute; left: 2px; right: 2px;
  border-radius: 3px; padding: 1px 3px;
  font-size: 9px; color: #000; overflow: hidden;
  cursor: pointer; opacity: .88; line-height: 1.3;
  transition: opacity .15s;
}
.cal-pass-block:hover { opacity: 1; }
.cal-pass-block span { font-weight: 700; }

/* ── Keyboard shortcuts modal ────────────────────────────── */
.keys-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.keys-table tr { border-bottom: 1px solid var(--border); }
.keys-table tr:last-child { border: none; }
.keys-table td { padding: 7px 8px; }
.keys-table td:first-child { width: 130px; white-space: nowrap; }

kbd {
  display: inline-block; padding: 1px 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; font-family: monospace; font-size: 11px;
}

/* ── Pass elevation sparkline ────────────────────────────── */
.pass-chart td { padding: 2px 6px; vertical-align: middle; }

/* ── WebSerial / Settings extras ────────────────────────── */
.srow .hint { font-size: 10px; color: var(--muted); }
.sgroup h3 .hint { font-size: 10px; font-weight: 400; color: var(--muted); }

/* ── Leaflet ─────────────────────────────────────────────── */
.leaflet-container { background: #080d16; }

/* ── Mobile bottom tabs ──────────────────────────────────── */
#mob-tabs { display: none; }

/* ── Mobile sat drawer overlay ───────────────────────────── */
#mob-sat-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 400; opacity: 0; transition: opacity .25s;
}
#mob-sat-overlay.open { opacity: 1; }

/* ── Mobile details bottom sheet ─────────────────────────── */
#mob-details-sheet {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  z-index: 450;
  max-height: 75vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,0,.67,0);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#mob-details-sheet.open { transform: translateY(0); }
#mob-details-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 8px; cursor: pointer;
}

@media (max-width: 720px) {
  :root {
    --top-h: 44px;
    --mob-tab-h: 56px;
  }

  /* ── Bottom nav bar ── */
  #mob-tabs {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--mob-tab-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 300;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #mob-tabs button {
    flex: 1; background: none; border: none;
    color: var(--muted); font-size: 11px; font-weight: 500;
    cursor: pointer; transition: color .15s;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; padding: 6px 2px;
    min-height: 44px;
  }
  #mob-tabs button .mob-icon { font-size: 18px; line-height: 1; }
  #mob-tabs button.mob-active { color: var(--accent); }
  #mob-tabs button:hover { color: var(--accent); }

  /* ── Hide desktop panels ── */
  #left   { display: none !important; }
  #right  { display: none !important; }
  .resizer { display: none; }
  #tab-bar { display: none; }

  /* ── Center fills full screen ── */
  #center { width: 100% !important; flex: 1; }
  #main   { padding-bottom: var(--mob-tab-h); }

  /* ── Topbar compact ── */
  .tb-right .obs-info { display: none; }
  .logo { font-size: 13px; }
  .clock { font-size: 11px; }
  #topbar { padding: 0 10px; gap: 6px; }
  .tb-right { gap: 4px; }
  .btn { font-size: 11px; padding: 5px 9px; }
  .btn.icon { padding: 5px 7px; }

  /* ── Pass toolbar wraps ── */
  #pass-toolbar { flex-direction: column; gap: 6px; padding: 8px; }
  .pass-controls { flex-wrap: wrap; gap: 4px; }
  .pass-title { font-size: 13px; }

  /* ── Modals full-screen ── */
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal {
    width: 100% !important; max-width: 100% !important;
    border-radius: 16px 16px 0 0;
    max-height: 90vh; overflow-y: auto;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }

  /* ── Satellite drawer from left ── */
  #mob-sat-overlay { display: block; pointer-events: none; }
  #mob-sat-overlay.open { pointer-events: all; }
  #mob-sat-drawer {
    position: fixed; top: 0; left: 0; bottom: 0; width: 80vw; max-width: 320px;
    background: var(--surface); z-index: 401; overflow-y: auto;
    transform: translateX(-100%); transition: transform .3s cubic-bezier(.32,0,.67,0);
    display: flex; flex-direction: column;
  }
  #mob-sat-overlay.open #mob-sat-drawer { transform: translateX(0); }

  /* ── Details sheet ── */
  #mob-details-sheet { display: block; }

  /* ── Settings / Tools panes scrollable ── */
  .settings-body { padding: 8px; }
  .sgroup { margin-bottom: 12px; }
  .srow { min-height: 40px; }

  /* ── Tab content padding ── */
  .pane.active { padding-bottom: 8px; }

  /* ── Polar canvas ── */
  #polar-wrap { padding: 8px; }

  /* ── Forms ── */
  .form-in, .mini-sel { font-size: 16px; } /* prevent iOS zoom */

  /* ── Filter panel ── */
  .filter-panel { flex-wrap: wrap; }
  .filter-panel input { width: 100% !important; }
}

/* ── Toast notifications ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  z-index: 9999;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-error   { background: var(--red); }
.toast-warn    { background: var(--orange); }
.toast-success { background: var(--green); }


/* -- Tools pane -------------------------------------------- */
#pane-tools { overflow-y: auto; }
#tools-body { padding: 8px 12px; }
#gantt-body svg { display:block; }
#gantt-body { background: var(--surface); border-radius:6px; padding:8px; }
#vismap-canvas { max-width:100%; }
#obs-log-list .drow { padding:4px 0; }

/* -- Command Palette --------------------------------------- */
#modal-cmd { align-items: flex-start; padding-top: 80px; }
#modal-cmd .modal { border-radius: 10px; box-shadow: 0 24px 60px rgba(0,0,0,.7); }
#cmd-input { background: transparent; border: none; outline: none; color: var(--text); }
.cmd-item {
  display: flex;
  align-items: center;
  padding: 9px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  border-radius: 0;
  transition: background 0.1s;
}
.cmd-item:hover, .cmd-active {
  background: var(--surface2);
  color: var(--accent);
}

/* -- Heatmap canvas --------------------------------------- */
#heatmap-canvas { max-width: 100%; }

/* -- Onboarding ------------------------------------------- */
#onboarding { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
#onboarding.hidden { display: none; }
#onb-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.75); backdrop-filter: blur(4px); }
#onb-card {
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px 24px;
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.onb-step { display: none; }
.onb-step.active { display: block; }
.onb-step-num { font-size: 11px; color: var(--muted); margin-bottom: 8px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.onb-logo { font-size: 22px; font-weight: 800; color: var(--accent); margin-bottom: 12px; }
#onb-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
#onb-card p { color: var(--muted); font-size: 13px; line-height: 1.6; margin-bottom: 12px; }
.onb-bullets { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.onb-bullet { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.onb-bullet::before { content: ''; display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: rgba(63,185,80,.15); border: 1px solid var(--green); flex-shrink: 0; }
.onb-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.onb-preset-btn {
  padding: 10px 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s; color: var(--text);
}
.onb-preset-btn:hover, .onb-preset-btn.selected { border-color: var(--accent); background: rgba(88,166,255,.08); }
.onb-preset-btn .onb-pname { font-size: 12px; font-weight: 600; }
.onb-preset-btn .onb-pdesc { font-size: 10px; color: var(--muted); margin-top: 2px; }
.onb-dots { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.onb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background .2s; }
.onb-dot.active { background: var(--accent); }
@media (max-width: 480px) {
  #onb-card { padding: 24px 16px 16px; border-radius: 16px 16px 0 0; }
  #onboarding { align-items: flex-end; }
}

/* -- Reentry / Launches bodies ----------------------------- */
#reentry-body, #launches-body, #eclipse-body { padding: 4px 0; }

/* -- Antenna canvas --------------------------------------- */
#antenna-canvas { cursor: default; }

/* -- Doppler graph ---------------------------------------- */
#sec-doppler-graph canvas { display: block; }

/* -- Pass quality stars ----------------------------------- */
.pass-tbl td [data-scored] { pointer-events: none; }

/* -- Multi-observer table --------------------------------- */
#multiobs-body table th { font-weight: 600; font-size: 11px; }

/* -- Drag handle on sat items ----------------------------- */
.sat-item[draggable="true"] { cursor: grab; }
.sat-item[draggable="true"]:active { cursor: grabbing; }

/* -- Satellite edit button -------------------------------- */
.si-edit-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 0 3px;
  margin-left: auto; opacity: 0; transition: opacity .15s;
  flex-shrink: 0; line-height: 1;
}
.sat-item:hover .si-edit-btn { opacity: 1; }
.si-edit-btn:hover { color: var(--accent); }

/* -- Color swatches in sat edit modal --------------------- */
#se-swatches span:hover { transform: scale(1.25); }

/* -- Overlap / share bodies ------------------------------- */
#overlap-body { padding: 4px 0; }
#share-status { transition: opacity .3s; }

/* -- Satellite profile card ------------------------------- */
.sat-profile-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; margin: 10px 0 6px;
  font-size: 12px;
}
.spc-type-badge {
  display: inline-block; border-radius: 6px;
  padding: 2px 8px; font-size: 11px; font-weight: 600;
  letter-spacing: .04em; margin-bottom: 8px;
}
.spc-rows { display: flex; flex-direction: column; gap: 4px; }
.spc-row { display: flex; gap: 8px; }
.spc-label { color: var(--muted); min-width: 62px; flex-shrink: 0; }
.spc-val { color: var(--text); }
.spc-wiki-link {
  display: inline-block; margin-top: 8px;
  color: var(--accent); font-size: 11px; text-decoration: none;
}
.spc-wiki-link:hover { text-decoration: underline; }

/* -- Data freshness badge --------------------------------- */
.freshness-badge {
  font-size: 10px; font-weight: 600; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 20px;
  border: 1px solid transparent; white-space: nowrap;
}
.freshness-fresh { background: #14532d30; color: #4ade80; border-color: #4ade8040; }
.freshness-stale { background: #78350f30; color: #fbbf24; border-color: #fbbf2440; }
.freshness-old   { background: #7f1d1d30; color: #f87171; border-color: #f8717140; }

/* -- Empty states ----------------------------------------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px 20px; text-align: center;
  gap: 8px; color: var(--muted);
}
.es-icon {
  font-size: 28px; opacity: .35; margin-bottom: 4px; line-height: 1;
}
.es-title { font-size: 14px; font-weight: 600; color: var(--text); opacity: .7; }
.es-sub   { font-size: 12px; line-height: 1.5; max-width: 220px; }

/* -- Pass Log --------------------------------------------- */
.passlog-stats {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px;
}
.pls-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; text-align: center; flex: 1; min-width: 60px;
}
.pls-val  { font-size: 18px; font-weight: 700; color: var(--accent); }
.pls-lbl  { font-size: 10px; color: var(--muted); margin-top: 2px; }
.passlog-header {
  display: grid; grid-template-columns: 1fr 110px 48px 56px;
  gap: 4px; padding: 4px 0; border-bottom: 1px solid var(--border);
  font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase;
}
.passlog-list { max-height: 220px; overflow-y: auto; }
.passlog-row {
  display: grid; grid-template-columns: 1fr 110px 48px 56px;
  gap: 4px; padding: 5px 0; border-bottom: 1px solid var(--border)30;
  font-size: 11px; align-items: center;
}
.plr-name { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plr-date { color: var(--muted); }
.plr-el   { color: var(--accent); text-align: right; }
.plr-dur  { color: var(--muted); text-align: right; }

/* -- Weather widget --------------------------------------- */
.wx-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.wx-rating { font-size: 16px; font-weight: 700; }
.wx-sub    { font-size: 11px; color: var(--muted); }
.wx-grid   { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.wx-item   {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; text-align: center;
}
.wx-val  { font-size: 15px; font-weight: 600; color: var(--text); }
.wx-lbl  { font-size: 10px; color: var(--muted); margin-top: 2px; }
.wx-bar  { height: 3px; background: var(--border); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.wx-fill { height: 100%; border-radius: 2px; transition: width .4s; }
.wx-footer { font-size: 10px; color: var(--muted); margin-top: 8px; text-align: right; }

/* -- Orbital elements ------------------------------------- */
.orb-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px;
}
.orb-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; text-align: center;
}
.orb-val { font-size: 13px; font-weight: 600; color: var(--text); }
.orb-lbl { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* -- TLE age badge ---------------------------------------- */
.tle-age-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px; margin-left: 6px;
  vertical-align: middle; border: 1px solid transparent;
}
.age-fresh { background: #14532d20; color: #4ade80; border-color: #4ade8030; }
.age-ok    { background: #1e3a5f20; color: #60a5fa; border-color: #60a5fa30; }
.age-stale { background: #78350f20; color: #fbbf24; border-color: #fbbf2430; }
.age-old   { background: #7f1d1d20; color: #f87171; border-color: #f8717130; }

/* -- ISS crew -------------------------------------------- */
.crew-count { font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.crew-row   { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border)30; }
.crew-name  { font-size: 12px; color: var(--text); }
.crew-craft { font-size: 10px; color: var(--muted); background: var(--surface2); padding: 1px 6px; border-radius: 8px; }

/* -- PWA install banner ----------------------------------- */
#pwa-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: 13px; color: var(--text);
  transform: translateY(100%); transition: transform .3s;
}
#pwa-banner.visible { transform: translateY(0); }

/* -- Keyboard shortcut rows ------------------------------ */
.key-row { display: flex; align-items: center; gap: 12px; padding: 5px 4px; border-bottom: 1px solid var(--border)30; }
.kbd {
  display: inline-block; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 7px; font-size: 11px; font-family: monospace;
  color: var(--text); white-space: nowrap; flex-shrink: 0; min-width: 80px; text-align: center;
}
.key-desc { font-size: 12px; color: var(--muted); }

/* -- Print styles ----------------------------------------- */
/* -- Satellite groups / filter bar ----------------------- */
.sg-filter-btn {
  font-size: 11px; padding: 2px 8px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.sg-filter-btn:hover { border-color: var(--accent); color: var(--text); }
.sg-filter-btn.sg-active { background: var(--accent)20; border-color: var(--accent); color: var(--accent); }
.sg-filter-btn.sg-fav { color: #f59e0b; border-color: #f59e0b40; }
.sg-filter-btn.sg-fav.sg-active { background: #f59e0b20; }
.sg-cnt { font-size: 10px; opacity: .6; margin-left: 2px; }

/* Fav star button */
.fav-star {
  background: none; border: none; cursor: pointer; font-size: 13px;
  color: var(--border); padding: 0 2px; line-height: 1; transition: color .15s;
}
.fav-star:hover, .fav-star.active { color: #f59e0b; }

/* -- Wide split view (>1400px) ---------------------------- */
@media (min-width: 1400px) {
  #main { grid-template-columns: 260px 1fr 340px; }
  #right { display: flex; flex-direction: column; }
  /* Show details panel always on wide screens */
  #no-sel { display: none !important; }
  #details { display: block !important; }
}

@media print {
  #topbar, #left, #mob-tabs, #mob-sat-overlay, #mob-details-sheet,
  #pwa-banner, #offline-banner, .tab-bar, #pass-toolbar,
  .pass-controls, #filter-panel, #cmd-palette,
  #onboarding, button, .btn { display: none !important; }

  body, #main, #center, #pane-passes { display: block !important; background: white !important; color: black !important; }
  .pane { display: block !important; height: auto !important; overflow: visible !important; }
  .pane:not(#pane-passes) { display: none !important; }

  #pass-wrap { display: block !important; height: auto !important; overflow: visible !important; }

  .pass-row { break-inside: avoid; border-bottom: 1px solid #ccc; }
  .pass-row td, .pass-row th { color: black !important; }

  @page { margin: 15mm; }
}
