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

:root {
  color-scheme: dark;
  --panel-bg: rgba(16, 20, 34, 0.78);
  --panel-border: rgba(140, 160, 220, 0.18);
  --text: #dfe6f5;
  --text-dim: #93a0bd;
  --accent: #7aa2ff;
  --accent-dim: rgba(122, 162, 255, 0.25);
}

html, body {
  height: 100%;
  background: #000;
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#sky { position: fixed; inset: 0; display: block; cursor: crosshair; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  color: var(--text-dim); font-size: 16px; letter-spacing: .04em;
  background: #000; z-index: 50; transition: opacity .4s;
}
#loading.done { opacity: 0; pointer-events: none; }

#tooltip {
  position: fixed; z-index: 40; pointer-events: none;
  background: rgba(30, 37, 54, 0.94); border: 1px solid rgba(120, 138, 176, 0.35);
  border-radius: 8px; padding: 5px 9px; font-size: 12.5px;
  color: var(--text); white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
}
#tooltip b { color: var(--accent); }

#fps {
  position: fixed; right: 12px; bottom: 8px; z-index: 20;
  font-size: 20px; color: rgba(147, 160, 189, 0.52);
  font-variant-numeric: tabular-nums;
  pointer-events: none; user-select: none;
}

/* ---------- zoom controls, top left ---------- */
#viewCtl {
  position: fixed; top: 14px; left: 14px; z-index: 30;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  background: var(--panel-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
#viewCtl button {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,.05); color: var(--text);
  font-size: 17px; line-height: 1; cursor: pointer; transition: background .15s;
}
#viewCtl button:hover { background: rgba(255,255,255,.12); }
#zoomVal {
  font-size: 10.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- limiting magnitude bar, along the top, left ---------- */
#magBar {
  position: fixed; top: 14px; left: 82px; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 8px 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
  font-size: 11px; color: var(--text-dim);
}
#magBar input { width: 140px; }
#magBar b {
  color: var(--text); font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums; min-width: 24px;
}
/* 🏙️ the Bortle stop button: a live badge (B∅ off · B1..B9) on the mag bar */
#magBar button {
  min-width: 30px; height: 24px; border-radius: 8px;
  border: 1px solid transparent; background: transparent;
  color: #aab8d8; font: 700 12px Georgia, serif; line-height: 1;
  cursor: pointer; opacity: 0.6;
  transition: opacity .15s, background .15s;
}
#magBar button:hover { opacity: 0.95; background: rgba(255,255,255,.07); }
#magBar button.on {
  opacity: 1; color: #cfdaf4;
  background: rgba(122, 162, 255, 0.10);
  border-color: rgba(122, 162, 255, 0.22);
}

/* ---------- display toggles icon rail, bottom left ---------- */
#iconBar {
  position: fixed; left: 14px; bottom: 14px; z-index: 30;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 7px 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
  max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: none;
}
#iconBar.closed [data-key], #iconBar.closed #sceneryBtn { display: none; }
#iconBar button {
  width: 32px; height: 30px; border-radius: 8px;
  border: 1px solid transparent; background: transparent;
  font-size: 15px; line-height: 1; cursor: pointer;
  /* monochrome slate-navy rendering for all icons */
  filter: grayscale(1) sepia(0.75) hue-rotate(175deg) saturate(1.5) brightness(0.5);
  opacity: 0.55;
  transition: opacity .15s, background .15s, filter .15s;
}
#iconBar button:hover {
  opacity: 0.9; background: rgba(255,255,255,.07);
  filter: grayscale(1) sepia(0.75) hue-rotate(175deg) saturate(1.5) brightness(0.9);
}
#iconBar button.on {
  opacity: 1;
  filter: grayscale(1) sepia(0.75) hue-rotate(175deg) saturate(1.3) brightness(1.15);
  background: rgba(122, 162, 255, 0.10);
  border-color: rgba(122, 162, 255, 0.22);
}
#iconBar .glyph, #iconBar #iconsToggle {
  color: #aab8d8; font-weight: 700; font-size: 14px;
  font-family: Georgia, serif;
}
#iconsToggle { opacity: 0.8 !important; }

/* custom dark-slate tooltip for the icon rail */
#iconTip {
  position: fixed; z-index: 40; pointer-events: none;
  transform: translateY(-50%);
  background: rgba(30, 37, 54, 0.96);
  border: 1px solid rgba(120, 138, 176, 0.35);
  border-radius: 7px; padding: 4px 10px;
  font-size: 12px; color: #c6d0e6; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
}

/* ---------- control panel ---------- */
#panel {
  position: fixed; top: 14px; right: 14px; z-index: 30;
  width: 288px; max-height: calc(100vh - 28px);
  display: flex; flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
  overflow: hidden;
}
#panel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px;
}
#panel h1 { font-size: 15px; font-weight: 650; letter-spacing: .02em; }
#collapseBtn {
  background: none; border: none; color: var(--text-dim);
  font-size: 15px; cursor: pointer; padding: 2px 6px; border-radius: 6px;
  transition: transform .25s;
}
#collapseBtn:hover { color: var(--text); background: rgba(255,255,255,.06); }
#panel.collapsed #panelBody { display: none; }
#panel.collapsed #collapseBtn { transform: rotate(180deg); }
#panel:not(.collapsed) #mini { display: none; }

#panelBody {
  overflow-y: auto; padding: 0 14px 12px; scrollbar-width: thin;
  flex: 1 1 auto; min-height: 0;   /* allow the flex child to shrink & scroll */
}

/* ---------- collapsed mini bar ---------- */
#mini { padding: 0 12px 12px; }
#miniTime {
  font-size: 12px; color: var(--text-dim); text-align: center;
  margin-bottom: 8px; font-variant-numeric: tabular-nums;
}
#mini .btnRow { margin-top: 6px; }
#chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.chip {
  font-size: 10.5px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--panel-border); color: var(--text-dim);
  cursor: pointer; background: rgba(255,255,255,.04);
  user-select: none; transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: rgba(255,255,255,.1); }
.chip.on {
  background: var(--accent-dim); border-color: rgba(122,162,255,.5);
  color: var(--text);
}

.grp { padding: 10px 0; border-top: 1px solid rgba(255,255,255,.06); }
.grpTitle {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-dim); margin-bottom: 8px;
}

input[type="datetime-local"] {
  width: 100%; padding: 7px 9px; border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,.05); color: var(--text);
  font: inherit; color-scheme: dark;
}

/* ---- 📅 the in-app calendar. The native Chromium datetime picker is a
   wide two-pane popover anchored to the field's LEFT edge — from a panel
   at the screen's right its time column runs off the display. Inside a
   .dtRow the native indicator is hidden (the segments stay editable) and
   the 📅 button opens our own popover, placed to always fit. ---- */
.dtRow { display: flex; gap: 6px; }
.dtRow input { flex: 1; min-width: 0; }
.dtRow input::-webkit-calendar-picker-indicator { display: none; }
.calBtn {
  flex: none; width: 36px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,.05); color: var(--text);
  font: inherit; transition: background .15s;
}
.calBtn:hover { background: rgba(255,255,255,.11); }
.dpk {
  position: fixed; z-index: 90; width: 252px; padding: 10px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 12px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
.dpkHead { display: flex; align-items: center; gap: 2px; margin-bottom: 7px; }
.dpkHead b {
  flex: 1; text-align: center; font-size: 12.5px; font-weight: 600;
  color: var(--text);
}
.dpkHead button {
  width: 26px; height: 24px; padding: 0; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--text-dim);
  font: inherit; font-size: 13px; line-height: 1;
}
.dpkHead button:hover { background: rgba(255,255,255,.11); color: var(--text); }
.dpkGrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.dpkDow {
  text-align: center; font-size: 10px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em; padding: 3px 0 4px;
}
.dpkDay {
  height: 26px; padding: 0; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--text);
  font: inherit; font-size: 12px; font-variant-numeric: tabular-nums;
}
.dpkDay:hover { background: rgba(255,255,255,.11); }
.dpkDay.out { color: var(--text-dim); opacity: .45; }
.dpkDay.today { border-color: rgba(122,162,255,.45); }
.dpkDay.sel { background: var(--accent-dim); color: var(--text); font-weight: 700; }
.dpkTime {
  display: flex; align-items: center; gap: 8px; margin-top: 9px;
  padding-top: 8px; border-top: 1px solid var(--panel-border);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-dim);
}
.dpkTime input {
  flex: 1; padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,.05); color: var(--text);
  font: inherit; font-size: 12.5px; letter-spacing: normal;
  font-weight: 500; text-transform: none; color-scheme: dark;
}

/* ---- 🌍 the location-picker globe: a small button riding a group title,
   opening a floating draggable panel with the orthographic Earth ---- */
.grpTitle .ttlBtn {
  float: right; width: 24px; height: 22px; padding: 0; margin-top: -4px;
  border-radius: 7px; cursor: pointer; line-height: 1; font-size: 13px;
  border: 1px solid transparent; background: none;
  filter: grayscale(0.4) brightness(0.9);
  transition: background .15s, filter .15s;
}
.grpTitle .ttlBtn:hover { background: rgba(255,255,255,.11); filter: none; }
.gpk {
  position: fixed; z-index: 90; padding: 0 10px 8px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
  user-select: none; -webkit-user-select: none;
  display: flex; flex-direction: column;
  resize: both; overflow: hidden;
  min-width: 280px; min-height: 330px; max-width: 92vw; max-height: 92vh;
}
.gpkHead, .gpkFoot { flex: none; }
.gpk canvas { flex: 1 1 auto; min-height: 0; width: 100%; }
.gpkHead {
  display: flex; align-items: center; gap: 8px; cursor: grab;
  padding: 9px 2px 7px; font-size: 12px; font-weight: 600; color: var(--text);
}
.gpkHead:active { cursor: grabbing; }
.gpkHead .gpkLL {
  margin-left: auto; font-weight: 600; color: #ffb98a;
  font-variant-numeric: tabular-nums; font-size: 11.5px;
}
.gpkX {
  width: 22px; height: 22px; padding: 0; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--text-dim);
  font: inherit; font-size: 12px; line-height: 1;
}
.gpkX:hover { background: rgba(255,255,255,.11); color: var(--text); }
.gpk canvas { display: block; border-radius: 10px; cursor: crosshair; touch-action: none; }
.gpkFoot {
  padding: 6px 2px 2px; font-size: 10.5px; color: var(--text-dim);
  text-align: center;
}
.gpkFoot b { color: var(--text); font-weight: 600; }

#tzInfo {
  font-size: 11px; color: var(--text-dim); margin-top: 5px;
  line-height: 1.35;
}
#tzInfo b { color: var(--text); font-weight: 600; }
#tzInfo .warn { color: #d8b06a; }

.btnRow { display: flex; gap: 6px; margin-top: 8px; }
.btnRow[hidden] { display: none; }   /* flex beats the UA hidden rule otherwise */
.btnRow button, #geoBtn, select {
  flex: 1; padding: 6px 4px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,.05); color: var(--text);
  font: inherit; font-size: 12.5px; transition: background .15s;
}
.btnRow button:hover, #geoBtn:hover { background: rgba(255,255,255,.11); }
button.accent { background: var(--accent-dim); border-color: rgba(122,162,255,.45); }
button.accent:hover { background: rgba(122,162,255,.4); }
#geoBtn { width: 100%; margin-top: 8px; flex: none; }
select { color-scheme: dark; background-color: #131829; }
option { background-color: #131829; color: var(--text); }

.slider { display: block; margin-top: 9px; font-size: 12.5px; color: var(--text-dim); }
.slider span { display: flex; justify-content: space-between; margin-bottom: 3px; }
.slider b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
input[type="range"] {
  width: 100%; height: 4px; appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,.14); border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0d1224; cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0d1224; cursor: pointer;
}

.selectRow { display: block; margin-top: 10px; font-size: 12.5px; color: var(--text-dim); }
.selectRow span { display: block; margin-bottom: 4px; }
.selectRow select { width: 100%; }

.switches { display: grid; gap: 2px; margin-top: 6px; }
.switch {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: 13px; padding: 4px 2px; border-radius: 7px;
}
.switch:hover { background: rgba(255,255,255,.05); }
.switch input { display: none; }
.switch i {
  flex: none; width: 30px; height: 17px; border-radius: 9px;
  background: rgba(255,255,255,.15); position: relative; transition: background .18s;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #cbd5ec; transition: left .18s;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 15px; background: #fff; }

#panel footer { padding: 10px 0 2px; border-top: 1px solid rgba(255,255,255,.06); }
#readout {
  font-size: 11.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; margin-bottom: 7px; white-space: pre-line;
}
.credits { font-size: 10.5px; color: rgba(147,160,189,.65); margin-top: 3px; }
.credits a { color: rgba(122,162,255,.8); text-decoration: none; }
.credits a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  #panel { width: calc(100vw - 20px); top: 10px; right: 10px; }
}

/* ---- 📸 saved views: floating buttons + gallery overlay. Shared by the
   planisphere and the celestial sphere (which adds more buttons of the
   same species in celestial.css) ---- */
#snapBtn, #snapQuick, #recBtn, #tourLib, #orreryBtn, #learnBtn, #homeBtn {
  position: fixed; top: 14px; z-index: 30;
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 16px; line-height: 1; cursor: pointer;
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
  filter: grayscale(1) sepia(0.75) hue-rotate(175deg) saturate(1.5) brightness(0.62);
  opacity: 0.85;
  transition: opacity .15s, filter .15s;
}
#snapBtn { right: 312px; }
#homeBtn { right: 312px; display: grid; place-items: center; text-decoration: none; }
#snapQuick { right: 356px; }
#recBtn { right: 400px; }
#tourLib { right: 444px; }
#orreryBtn { right: 488px; }
#learnBtn { right: 532px; }
#snapBtn:hover, #snapQuick:hover, #recBtn:hover, #tourLib:hover, #orreryBtn:hover, #learnBtn:hover, #homeBtn:hover {
  opacity: 1;
  filter: grayscale(1) sepia(0.75) hue-rotate(175deg) saturate(1.3) brightness(1.1);
}
#recBtn.on {
  opacity: 1;
  filter: grayscale(1) sepia(0.75) hue-rotate(175deg) saturate(1.3) brightness(1.15);
  background: rgba(122, 162, 255, 0.10);
  border-color: rgba(122, 162, 255, 0.35);
}
#snapQuick.saved, #recBtn.saved {
  opacity: 1; color: var(--accent);
  filter: grayscale(1) sepia(0.75) hue-rotate(175deg) saturate(1.3) brightness(1.25);
  background: var(--accent-dim); border-color: rgba(122, 162, 255, 0.5);
}
#recBtn.live {
  opacity: 1; filter: none; color: #ff8a8a;
  border-color: rgba(255, 120, 120, 0.5); background: rgba(255, 120, 120, 0.08);
}
@media (max-width: 780px) { #snapBtn, #snapQuick, #recBtn, #homeBtn { display: none; } }

.hint {
  font-size: 11px; color: rgba(147, 160, 189, 0.7);
  margin-top: 7px; line-height: 1.35; font-style: italic;
}

#snapOv {
  position: fixed; inset: 0; z-index: 44;
  background: rgba(4, 7, 16, 0.55);
  display: flex; align-items: center; justify-content: center;
}
#snapOv[hidden] { display: none; }
#snapBox {
  width: min(1130px, calc(100vw - 40px));
  max-height: min(88vh, 1000px);
  display: flex; flex-direction: column;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 12px 14px 10px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
#snapHead {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim); padding: 2px 2px 10px;
}
#snapHead b { color: var(--text); font-size: 14px; font-weight: 650; }
#snapHead .sp { flex: 1; }
#snapTitle {
  width: min(300px, 34vw);
  background: rgba(255,255,255,.05); border: 1px solid var(--panel-border);
  border-radius: 8px; color: var(--text); padding: 5px 9px; font-size: 12px;
}
#snapTitle::placeholder { color: rgba(147, 160, 189, 0.55); font-style: italic; }
#snapHead button {
  background: none; border: 1px solid var(--panel-border); color: var(--text-dim);
  border-radius: 7px; height: 26px; padding: 0 9px; cursor: pointer; font-size: 12px;
}
#snapHead button:hover { color: var(--text); background: rgba(255,255,255,.06); }
#snapSave { color: var(--accent) !important; border-color: rgba(122,162,255,.35) !important; }

#snapGrid {
  overflow-y: auto; scrollbar-width: thin;
  display: grid; grid-template-columns: repeat(auto-fill, 200px);
  gap: 12px 14px; justify-content: center; padding: 2px;
}
#snapEmpty { grid-column: 1 / -1; text-align: center; color: var(--text-dim); font-size: 12.5px; padding: 34px 0 38px; }
.snapCard { width: 200px; cursor: pointer; }
.sc-shot {
  position: relative; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--panel-border); background: #0a0e1a;
  transition: border-color .15s, transform .15s;
}
.snapCard:hover .sc-shot { border-color: rgba(122, 162, 255, 0.55); transform: translateY(-1px); }
.sc-shot img { display: block; width: 100%; height: auto; }
.sc-act { position: absolute; top: 5px; right: 5px; display: none; gap: 4px; }
.snapCard:hover .sc-act { display: flex; }
.sc-act button {
  min-width: 24px; height: 22px; border-radius: 6px;
  border: 1px solid var(--panel-border); background: rgba(10, 14, 26, 0.85);
  color: var(--text-dim); cursor: pointer; font-size: 12px; line-height: 1;
}
.sc-act button:hover { color: var(--text); background: rgba(122, 162, 255, 0.28); }
.sc-act button.armed { color: #ff9a9a; border-color: rgba(255, 120, 120, 0.55); }
.sc-title { margin-top: 6px; font-size: 12px; color: var(--text); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-title input {
  width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--panel-border);
  border-radius: 6px; color: var(--text); padding: 2px 6px; font-size: 12px;
}
.sc-meta { font-size: 10.5px; color: var(--text-dim); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#snapBox .hint { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.06); }

/* ---- tour player: caption bar + library ---- */
/* while a tour runs (body.touring) only the presenter bar stays on
   screen; everything else returns untouched when the tour ends */
body.touring #panel, body.touring #viewCtl, body.touring #magBar,
body.touring #iconBar, body.touring #objBar, body.touring #tourLib,
body.touring #snapQuick, body.touring #snapBtn, body.touring #recBtn, body.touring #meteorsBtn,
body.touring #cometBtn, body.touring #cometMenu, body.touring #viewBtn,
body.touring #orreryBtn, body.touring #orrery, body.touring #homeBtn { display: none; }
/* the presenter bar parks where the (tour-hidden) control panel sits, so
   the chart / sphere underneath stays uncovered at its standard size */
#tourBar {
  position: fixed; top: 14px; right: 14px; z-index: 40;
  width: 490px; max-height: calc(100vh - 28px);
  overflow-y: auto; scrollbar-width: thin;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 12px 14px 10px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
#tourBar[hidden] { display: none; }
/* a try-it step: the hint pulses until the viewer's action satisfies it */
#tourTry {
  margin: 8px 0 4px; padding: 6px 10px; border-radius: 9px;
  border: 1px dashed rgba(122,162,255,.5); background: rgba(122,162,255,.08);
  color: var(--accent); font-size: 11.5px; line-height: 1.35;
  animation: tryPulse 1.6s ease-in-out infinite;
}
#tourTry[hidden] { display: none; }
#tourTry.done { border-style: solid; color: #86e2d0; border-color: rgba(78,200,180,.5); background: rgba(78,200,180,.1); animation: none; }
@keyframes tryPulse { 50% { background: rgba(122,162,255,.18); } }
/* 🎓 the last step's hand-over: the story's hands-on partner */
#tourLearn {
  display: block; width: 100%; margin: 2px 0 10px; padding: 7px 10px;
  border-radius: 9px; border: 1px solid rgba(122,162,255,.42);
  background: rgba(122,162,255,.09); color: var(--accent);
  font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
#tourLearn:hover { background: rgba(122,162,255,.17); color: var(--text); }
#tourLearn[hidden] { display: none; }
#tourTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#tourStep {
  font-size: 11.5px; color: var(--text-dim);
  margin: 7px 2px 0; min-height: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#tourCtl { display: flex; gap: 6px; margin-top: 7px; }
#tourCtl button { flex: 1; }
#tourHead, #tourLibHead { display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim); }
#tourHead b, #tourLibHead b { color: var(--text); font-weight: 600; margin-right: 4px; }
#tourHead .sp, #tourLibHead .sp { flex: 1; }
#tourHead button, #tourLibHead button, #tourCtl button, .tg-head button, .tc-act button {
  background: none; border: 1px solid var(--panel-border); color: var(--text-dim);
  border-radius: 7px; min-width: 26px; height: 24px; cursor: pointer; font-size: 13px;
}
#tourHead button:hover, #tourLibHead button:hover, #tourCtl button:hover, .tg-head button:hover, .tc-act button:hover {
  color: var(--text); background: rgba(255,255,255,.06); }
#tourSay {
  font-size: 13px; line-height: 1.55;
  color: var(--text); margin: 9px 2px 9px; min-height: 22px;
}
#tourDots { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
#tourDots i { width: 7px; height: 7px; border-radius: 50%;
  background: rgba(147, 160, 189, 0.35); cursor: pointer; }
#tourDots i.on { background: var(--accent); }

/* fixed-size popup — 3 tour cards per row, groups stacked, vertical scroll only */
#tourLibBox {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(76vw, 1150px); height: min(76vh, 860px);
  display: flex; flex-direction: column;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 12px 14px;
  backdrop-filter: blur(8px); z-index: 41;
}
#tourLibBox[hidden] { display: none; }
#tourLibList { flex: 1; overflow-y: auto; overflow-x: hidden;
  margin-top: 8px; padding-right: 4px; }
.tourGroup { margin: 0 0 16px; }
.tg-head { display: flex; align-items: center; gap: 8px; padding: 3px 2px 6px;
  border-bottom: 1px solid rgba(140, 160, 220, 0.14); margin-bottom: 10px;
  font-size: 12px; color: var(--text-dim); }
.tg-head .sp { flex: 1; }
.tg-name { color: var(--text); font-size: 13px; font-weight: 600; cursor: text;
  border-radius: 5px; padding: 0 3px; }
.tg-name:hover { background: rgba(255, 255, 255, 0.06); }
.tg-name input { background: none; border: 1px solid var(--panel-border);
  border-radius: 5px; color: var(--text); font: inherit; padding: 0 4px; width: 180px; }
.tg-count { font-size: 11px; color: var(--text-dim); }
.tg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px; border-radius: 10px; }
.tg-grid.insEnd { outline: 1px dashed var(--accent); outline-offset: 3px; }
.tg-empty { grid-column: 1 / -1; color: var(--text-dim); font-size: 11.5px;
  text-align: center; padding: 16px;
  border: 1px dashed rgba(140, 160, 220, 0.25); border-radius: 10px; }
.tourCard { display: flex; gap: 10px; padding: 10px 11px; min-width: 0;
  border: 1px solid rgba(140, 160, 220, 0.13); border-radius: 11px;
  background: rgba(148, 168, 214, 0.05); cursor: grab; }
.tourCard.dragging { opacity: 0.35; }
.tourCard.insL { box-shadow: -3px 0 0 0 var(--accent); }
.tourCard.insR { box-shadow: 3px 0 0 0 var(--accent); }
.tc-icon { font-size: 26px; line-height: 1.2; }
.tc-body { flex: 1; min-width: 0; }
.tc-head { display: flex; align-items: baseline; gap: 8px; }
.tc-head b { color: var(--text); font-size: 13px; }
.tc-dur { color: var(--text-dim); font-size: 11px; }
.tc-desc { color: var(--text-dim); font-size: 11.5px; line-height: 1.4; margin: 3px 0 6px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.tc-act { display: flex; gap: 6px; }
.tc-act button { font-size: 11px; padding: 0 8px; }
/* …and the same partner on the shelf, with the stars already lit in it */
.tourCard .tc-learn { display: block; max-width: 100%; margin-top: 7px; padding: 0;
  border: 0; background: none; color: var(--text-dim); font: inherit; font-size: 11px;
  text-align: left; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tourCard .tc-learn[hidden] { display: none; }
.tourCard .tc-learn i { font-style: normal; letter-spacing: .08em; color: #b9c8f2; }
.tourCard .tc-learn:hover { color: var(--text); }

/* ---- 🎥 the clip recorder: box picker, live frame, control chip ---- */
#recSel {
  position: fixed; inset: 0; z-index: 60; display: none;
  cursor: crosshair; background: rgba(4, 7, 16, 0.18); touch-action: none;
}
#recHint {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 10px; font-size: 12.5px; color: var(--text);
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  pointer-events: none; white-space: nowrap;
}
#recRect {
  position: fixed; z-index: 59; display: none; pointer-events: none;
  border: 1.5px dashed rgba(122, 162, 255, 0.8); border-radius: 4px;
  box-shadow: 0 0 0 100vmax rgba(4, 7, 16, 0.25);
}
#recRect.live { border: 1.5px solid rgba(255, 120, 120, 0.75); box-shadow: none; }
#recChip {
  position: fixed; z-index: 61; display: none; gap: 6px; align-items: center;
  padding: 4px 6px; border-radius: 10px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
#recChip button {
  border: 1px solid var(--panel-border); background: none; color: var(--text);
  border-radius: 7px; height: 24px; padding: 0 10px;
  cursor: pointer; font-size: 12px; line-height: 1; white-space: nowrap;
}
#recChip button:hover { background: rgba(122, 162, 255, 0.18); }
#recChip #recGo, #recChip .stop { color: #ff9a9a; border-color: rgba(255, 120, 120, 0.45); }
#recChip #recOrr, #recChip #recEye { padding: 0 7px; }
#recChip #recOrr.on, #recChip #recEye.on { background: var(--accent-dim); border-color: rgba(122, 162, 255, 0.5); }
#recChip .stop { font-variant-numeric: tabular-nums; animation: recPulse 1.6s ease-in-out infinite; }
@keyframes recPulse { 50% { border-color: rgba(255, 120, 120, 0.9); } }

/* ▶ clip cards & the player lightbox */
.sc-dur {
  position: absolute; left: 6px; bottom: 5px; padding: 2px 7px;
  border-radius: 7px; font-size: 10.5px; color: var(--text);
  background: rgba(10, 14, 26, 0.8); border: 1px solid var(--panel-border);
  pointer-events: none; font-variant-numeric: tabular-nums;
}
#vidOv {
  position: fixed; inset: 0; z-index: 46;
  background: rgba(4, 7, 16, 0.7);
  display: flex; align-items: center; justify-content: center;
}
#vidOv[hidden] { display: none; }
#vidBox {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 10px 12px 12px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
#vidHead {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 2px 8px; font-size: 12px; color: var(--text-dim);
}
#vidHead b { color: var(--text); font-size: 13px; font-weight: 650;
  max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#vidHead .sp { flex: 1; }
#vidHead button {
  background: none; border: 1px solid var(--panel-border); color: var(--text-dim);
  border-radius: 7px; height: 24px; padding: 0 8px; cursor: pointer; font-size: 12px;
}
#vidHead button:hover { color: var(--text); background: rgba(255,255,255,.06); }
#vidBox video {
  display: block; background: #000; border-radius: 10px;
  max-width: min(1400px, calc(100vw - 90px)); max-height: calc(90vh - 70px);
}

/* ---- pocket orrery: floating solar-system quick look ---- */
#orrery {
  position: fixed; z-index: 32;   /* floats over the panel and icon rails */
  width: 280px; height: 280px;
  min-width: 190px; min-height: 190px;
  max-width: 70vw; max-height: 80vh;
  resize: both; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
#orrery[hidden] { display: none; }
#orreryHead {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px 3px;
  font-size: 12px; color: var(--text-dim); cursor: grab;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#orreryHead b { color: var(--text); font-weight: 600; }
#orreryHead .sp { flex: 1; }
#orreryHead button {
  background: none; border: 1px solid var(--panel-border); color: var(--text-dim);
  border-radius: 7px; min-width: 26px; height: 24px; cursor: pointer; font-size: 13px;
}
#orreryHead button:hover { color: var(--text); background: rgba(255,255,255,.06); }
#orreryBar {
  display: flex; align-items: center; gap: 6px; padding: 0 10px 6px;
}
#orreryBar[hidden] { display: none; }
#orreryBar button {
  background: none; border: 1px solid var(--panel-border); color: var(--text-dim);
  border-radius: 7px; min-width: 26px; height: 24px; cursor: pointer; font-size: 13px;
}
#orreryBar button:hover { color: var(--text); background: rgba(255,255,255,.06); }
#orreryBar button.on { color: #e8c87a; border-color: rgba(232, 200, 122, 0.45); }
#orreryCfgLbl {
  font-size: 11px; color: #e8c87a; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#orreryCv { flex: 1; min-height: 0; width: 100%; display: block; }

/* ---- 🔭 the leave-for-the-hub dialog ---- */
#homeOv {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(4, 7, 16, 0.55);
  display: flex; align-items: center; justify-content: center;
}
#homeOv[hidden] { display: none; }
#homeBox {
  width: min(440px, calc(100vw - 40px));
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 16px 18px 14px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
}
#homeBox b { color: var(--text); font-size: 14.5px; font-weight: 650; }
#homeBox p { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; margin: 8px 0 12px; }
#homeBox .hb-act { display: flex; gap: 8px; flex-wrap: wrap; }
#homeBox .hb-act button {
  background: none; border: 1px solid var(--panel-border); color: var(--text-dim);
  border-radius: 8px; height: 28px; padding: 0 12px; cursor: pointer; font-size: 12.5px;
}
#homeBox .hb-act button:hover { color: var(--text); background: rgba(255,255,255,.06); }
#homeBox #hbSave { color: var(--accent); border-color: rgba(122,162,255,.35); }
#homeBox #hbSave:disabled { opacity: .8; cursor: default; }
#homeBox #hbStay { margin-left: auto; }
