:root {
  --bg: #0b1020;
  --panel: #121a30;
  --panel2: #0e1528;
  --line: #243150;
  --text: #e8eefc;
  --muted: #8ea0c4;
  --accent: #7fd1ff;
  --warn: #ffb347;
  --red: #ff3b3b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow: hidden;
}
/* dvh: 100vh on mobile includes the space behind the collapsing URL bar,
   which pushes the panel's action buttons off-screen. */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* top bar */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: var(--panel2); border-bottom: 1px solid var(--line);
  z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 12px; }
.swisscross {
  width: 30px; height: 30px; border-radius: 6px; background: var(--red); position: relative; flex: none;
}
.swisscross::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  background:
    linear-gradient(#fff,#fff) center/40% 70% no-repeat,
    linear-gradient(#fff,#fff) center/70% 40% no-repeat;
}
.brandtext strong { letter-spacing: 3px; font-size: 16px; }
.brandtext small { display: block; color: var(--muted); font-size: 11px; }

.clock { text-align: right; }
.utc { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 18px; color: var(--accent); }
.warpline { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 2px; }
.warpline button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px;
}
.warpline button:hover { border-color: var(--accent); }
.warplabel { font-family: ui-monospace, monospace; font-size: 12px; color: var(--warn); min-width: 56px; }
#warp { width: 120px; accent-color: var(--accent); }

/* WISeSat next-pass highlight banner */
.wisesat-banner {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: linear-gradient(90deg, rgba(255,59,59,.18), rgba(18,26,48,.6));
  border: 0; border-bottom: 1px solid var(--line); color: var(--text);
  padding: 7px 14px; cursor: pointer; font-size: 13px;
}
.wisesat-banner:hover { background: linear-gradient(90deg, rgba(255,59,59,.28), rgba(18,26,48,.7)); }
.wb-flag { font-size: 16px; }
.wb-text { color: var(--muted); }
#wbBody { color: var(--text); font-family: ui-monospace, monospace; }
#wbBody .wb-eta { color: #ff7a7a; font-weight: 600; }
#wbBody .wb-sat { color: var(--accent); }

/* main split */
#main { flex: 1; display: flex; min-height: 0; position: relative; }
#map { flex: 1; background: #06080f; }

/* floating actions over the map */
#fabs {
  position: absolute; top: 10px; right: 352px; z-index: 1150;
  display: flex; gap: 8px;
}
.fab {
  background: rgba(18,26,48,.92); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 14px; font-size: 13px; cursor: pointer;
  backdrop-filter: blur(4px);
}
.fab:hover { border-color: var(--accent); }
.fab.armed { border-color: var(--warn); color: var(--warn); }

/* context sheet: side panel on desktop, bottom sheet on mobile */
#sheet {
  width: 340px; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-handle {
  display: none; width: 100%; background: var(--panel); border: 0;
  padding: 10px 0 7px; cursor: pointer;
}
.panel-handle span {
  display: block; width: 46px; height: 5px; border-radius: 3px;
  background: var(--muted); opacity: .6; margin: 0 auto;
}

.sheet-section { display: none; padding: 14px; overflow-y: auto; }
/* flex+min-height cap the sheet's height so long result lists scroll inside it
   instead of pushing the footer out. */
.sheet-section.active { display: block; flex: 1 1 0; min-height: 0; }
.sheet-title { margin: 0 0 12px; font-size: 15px; }
.subhead { margin: 16px 0 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.lede { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 0 0 14px; }

.fld { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.fld select, .fld input[type=text], .fld input[list], .fld input[type=date] {
  display: block; width: 100%; margin-top: 4px; background: var(--panel2);
  color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; font-size: 13px;
}
.fld input[type=range] { width: 100%; accent-color: var(--accent); margin-top: 6px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; cursor: pointer; }
.chk input { accent-color: var(--accent); }
.count { font-size: 12px; color: var(--accent); margin: -6px 0 12px; }

.leg { font-size: 13px; vertical-align: middle; }
.leg-opt { color: #7fffd4; } .leg-sar { color: #ffb347; } .leg-rec { color: #ff7a7a; }

button.ghost {
  width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; font-size: 12.5px; cursor: pointer; margin-bottom: 8px;
}
button.ghost:hover { border-color: var(--accent); }
button.ghost.armed { border-color: var(--warn); color: var(--warn); }

.summary {
  margin-top: 12px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.6;
}
.summary.exposed { border-color: var(--red); background: rgba(255,59,59,.10); }
.summary.clear { border-color: #2ec26a; background: rgba(46,194,106,.10); }
.summary .big { font-size: 14px; font-weight: 600; }
.row .kind { font-size: 11px; padding: 0 5px; border-radius: 4px; margin-right: 6px; }
.kind-opt { background: rgba(127,255,212,.18); color: #7fffd4; }
.kind-sar { background: rgba(255,179,71,.18); color: #ffb347; }
.kind-rec { background: rgba(255,122,122,.18); color: #ff7a7a; }

button.primary {
  width: 100%; background: linear-gradient(180deg, #1d62ff, #134fd6); color: #fff;
  border: 0; border-radius: 8px; padding: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }

.list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.row {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.row:hover { border-color: var(--accent); }
.rname { font-size: 12.5px; }
.rmeta { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; }
.muted { color: var(--muted); font-size: 12px; }
.err { color: var(--red); font-size: 12px; }

#panelfoot { margin-top: auto; padding: 8px 14px; border-top: 1px solid var(--line); }
#status { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; }

.hidden { display: none; }

/* leaflet dark tweaks */
.leaflet-container { background: #06080f; }
.leaflet-control-layers, .leaflet-bar a { background: var(--panel); color: var(--text); border-color: var(--line); }
.leaflet-control-attribution { background: rgba(11,16,32,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--accent) !important; }

@media (max-width: 760px) {
  #main { flex-direction: column; }
  /* flex-basis, not height: %-heights against a flex-sized parent resolve to
     auto in Safari, letting the sheet swallow the map. */
  #sheet { width: 100%; flex: 0 0 55%; height: auto; border-left: 0; border-top: 1px solid var(--line); }
  #fabs { right: 10px; }

  /* touch sizing */
  .row { padding: 12px 10px; }
  .rname { font-size: 13.5px; }
  .rmeta { font-size: 12px; }
  /* 16px inputs stop iOS from auto-zooming the page on focus */
  .fld select, .fld input[type=text], .fld input[list], .fld input[type=date] { font-size: 16px; padding: 10px; }
  button.primary { padding: 13px; font-size: 14.5px; }
  button.ghost { padding: 11px; }
  .brandtext small { display: none; }

  /* collapsible sheet: the grab handle shrinks it to a slim strip */
  .panel-handle { display: block; }
  body.sheet-collapsed #sheet { flex-basis: auto; }
  body.sheet-collapsed .sheet-section.active { display: none; }
  body.sheet-collapsed #panelfoot { display: none; }
}
