:root {
  --bg: #020308;
  --panel: rgba(12, 14, 22, 0.62);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e9ecf2;
  --dim: rgba(233, 236, 242, 0.55);
  --faint: rgba(233, 236, 242, 0.32);
  --accent: #7cc4ff;
  --radius: 12px;
  --sans: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;   /* one typeface site-wide; numbers use tabular figures */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#scene:active { cursor: grabbing; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
body { font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }

/* ---------- Panels ---------- */
.panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
}

.panel-head {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 14px 16px 8px;
}

/* ---------- Header ---------- */
:root { --top-h: 60px; }
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  height: var(--top-h);
  display: grid; grid-template-columns: 1fr minmax(0, 420px) auto; align-items: center; gap: 12px;
  padding: 0 20px;
  background: rgba(10, 11, 14, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand { display: flex; align-items: center; color: inherit; text-decoration: none; justify-self: start; }
.brand-logo { display: block; height: 32px; width: auto; max-width: 220px; object-fit: contain; }
.brand-text { display: none; line-height: 1.2; }           /* shown only if the logo file is missing */
.brand.no-logo .brand-text { display: block; }
.brand-title { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { display: block; font-size: 11px; color: var(--dim); }
.brand-accent { color: var(--accent); }
/* with the logo: the Starwonder mark, then the Atlas logo after a thin divider
   (the word "Atlas" stands in until assets/atlas.png exists) */
.brand-product-logo {
  display: block; height: 26px; width: auto; max-width: 160px; object-fit: contain;
  padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.18); box-sizing: content-box;
}
.brand-product {
  display: none; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--accent);
}
.brand.no-atlas-logo .brand-product { display: block; }
.brand.no-logo .brand-product, .brand.no-logo .brand-product-logo { display: none; }
.brand:not(.no-logo) { gap: 12px; }
.loader-logo { height: 40px; width: auto; margin-bottom: 4px; }
#loader:has(.loader-logo) .loader-word { display: none; }   /* the logo already says Starwonder */
.top-search { position: relative; }
.search-icon {
  position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  fill: none; stroke: var(--dim); stroke-width: 1.8; stroke-linecap: round; pointer-events: none;
}
.search-key {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 5px;
  border: 1px solid rgba(255,255,255,0.16); border-radius: 5px;
  font: 500 11px var(--sans); color: var(--faint); pointer-events: none;
}
.top-search:focus-within .search-key { display: none; }
.top-actions { justify-self: end; display: flex; gap: 8px; }

/* ---------- Body list ---------- */
#bodies {
  top: calc(var(--top-h) + 16px);
  left: 16px;
  width: 236px;
  max-height: calc(100% - var(--top-h) - 40px);
  overflow-y: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

#body-nav { padding: 6px 6px 0; }
.nav-section + .nav-section { border-top: 1px solid var(--panel-border); margin-top: 4px; padding-top: 2px; }
.nav-head {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 8px; background: none; border: 0; cursor: pointer;
  color: var(--faint); font: 600 10.5px var(--sans); letter-spacing: 0.12em; text-transform: uppercase;
}
.nav-head:hover { color: var(--text); }
.nav-title { flex: 1; text-align: left; }
.nav-count { letter-spacing: 0; font-weight: 400; font-size: 11px; color: var(--faint); }
.nav-head svg, .nav-toggle svg {
  width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; transition: transform 0.18s ease;
}
.nav-section.open > .nav-head svg { transform: rotate(90deg); }
.nav-items, .nav-sub { list-style: none; margin: 0; padding: 0; }
.nav-section:not(.open) > .nav-items { display: none; }
.nav-sub { display: none; padding-bottom: 2px; }
.nav-item.expanded > .nav-sub { display: block; }
.nav-item.expanded > .nav-row .nav-toggle svg { transform: rotate(90deg); }
.nav-row { display: flex; align-items: center; border-radius: 7px; }
.nav-row:hover { background: rgba(255, 255, 255, 0.06); }
.nav-row.active { background: rgba(255, 255, 255, 0.1); }
.nav-name {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 6px 10px; color: var(--text); font: 13px var(--sans);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-row.level-1 .nav-name { padding: 5px 10px 5px 24px; font-size: 12.5px; color: var(--dim); }
.nav-row.level-2 .nav-name { padding: 4px 10px 4px 38px; font-size: 12.5px; color: var(--dim); }
.nav-row.level-2:hover .nav-name, .nav-row.level-2.active .nav-name { color: var(--text); }
.nav-row.level-2.active { background: rgba(255, 255, 255, 0.06); border-radius: 6px; }
.nav-name:has(.nav-meta) { display: flex; align-items: center; gap: 8px; }
.nav-meta { margin-left: auto; flex: none; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-row.level-1:hover .nav-name, .nav-row.level-1.active .nav-name { color: var(--text); }
.nav-row.active .nav-name { color: var(--text); }
.nav-toggle {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center; padding: 0;
  background: none; border: 0; border-radius: 6px; color: var(--faint); cursor: pointer;
}
.nav-toggle:hover { color: var(--text); }


.sheet-head, #search-cancel, .icon-btn-m, .info-expand { display: none; }
html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }

/* ---------- Info ---------- */
#info {
  top: calc(var(--top-h) + 16px);
  right: 16px;
  width: 272px;
  padding: 0;
  overflow: hidden;
}
/* Header: a small grey label like the left panel's section titles, then the name */
.info-kind {
  padding: 13px 16px 0;
  font: 600 10.5px var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  line-height: 1.5;
}
.info-name {
  margin: 0;
  padding: 3px 16px 13px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  border-bottom: 1px solid var(--panel-border);
}
/* Details: plain rows with the same rhythm as the left panel's list */
.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 16px;
  margin: 0;
  padding: 7px 16px 9px;
}
.info-grid dt, .info-grid dd { padding: 5px 0; font-size: 13px; line-height: 1.4; }
.info-grid dt { color: var(--dim); white-space: nowrap; }
.info-grid dd {
  margin: 0; text-align: right; color: var(--text);
  font-family: var(--sans); font-variant-numeric: tabular-nums;
}
/* Lists of names run full width, under a small section label */
.info-grid dt.wide {
  grid-column: 1 / -1; padding: 9px 0 1px;
  font: 600 10.5px var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint);
}
.info-grid dd.wide { grid-column: 1 / -1; padding: 2px 0 7px; text-align: left; line-height: 1.5; }
.info-grid dt.wide:first-child { padding-top: 5px; }
.info-grid dt.stack { grid-column: 1 / -1; padding-bottom: 1px; }
.info-grid dd.stack { grid-column: 1 / -1; padding-top: 0; text-align: left; line-height: 1.45; }
.info-note {
  margin: 0;
  padding: 11px 16px 14px;
  border-top: 1px solid var(--panel-border);
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.5;
}
.info-note:empty { display: none; }
#info.sat .info-kind { color: var(--faint); opacity: 1; }
.close-btn {
  position: absolute; top: 9px; right: 10px;
  width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; color: var(--dim); cursor: pointer; padding: 0;
}
.close-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.close-btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }
.close-btn[hidden] { display: none; }
#info .close-btn { z-index: 2; }
#info:has(#info-close:not([hidden])) .info-kind { padding-right: 30px; }   /* keep long labels clear of the close button */

/* ---------- Earth-orbit panel ---------- */
#layers {
  right: 16px;
  bottom: 18px;
  width: 264px;
  padding-bottom: 10px;
  max-height: calc(100% - 390px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
#layers .tabs { display: flex; gap: 4px; padding: 10px 12px 8px; }
#layers .tab {
  flex: 1; height: 30px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--dim); font: 500 11.5px var(--sans); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
#layers .tab .mono { font-size: 10.5px; color: var(--faint); }
#layers .tab:hover { color: var(--text); }
#layers .tab.active { background: rgba(255,255,255,0.08); border-color: var(--panel-border); color: var(--text); }
#sb-list { list-style: none; margin: 0; padding: 2px 6px; }
#sb-list li { display: flex; align-items: center; gap: 9px; padding: 4px 10px; border-radius: 7px; cursor: pointer; user-select: none; font-size: 12px; }
#sb-list li:hover { background: rgba(255,255,255,0.06); }
#sb-list li.off { opacity: 0.32; }
#sb-list .swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c); box-shadow: 0 0 6px var(--c); }
.res-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-type { font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.label.small .name { font-size: 11px; color: rgba(255,255,255,0.85); }
#sat-search {
  width: 100%; height: 38px; padding: 0 38px 0 36px;
  border-radius: 9px; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05); color: var(--text);
  font: 13.5px var(--sans); outline: none;
}
#sat-search::-webkit-search-cancel-button { -webkit-appearance: none; }
#sat-search:focus { border-color: rgba(124, 196, 255, 0.45); }
#sat-search::placeholder { color: var(--faint); }
#sat-results {
  list-style: none; margin: 0; padding: 4px;
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: rgba(14, 15, 19, 0.98); border: 1px solid rgba(255,255,255,0.12); border-radius: 10px;
  max-height: 380px; overflow-y: auto; z-index: 6;
}
#sat-results:empty { display: none; }
#sat-results li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; }
#sat-results li:hover { background: rgba(255,255,255,0.07); }
#cat-list { list-style: none; margin: 0; padding: 2px 6px; }
#cat-list li {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px; border-radius: 7px; cursor: pointer; user-select: none; font-size: 12px;
}
#cat-list li:hover { background: rgba(255,255,255,0.06); }
#cat-list li.off { opacity: 0.32; }
.cat-name { flex: 1; }
.cat-count { color: var(--dim); font-size: 11px; }
#cat-list .swatch, #sat-results .swatch {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--c); box-shadow: 0 0 6px var(--c);
}
.layers-note { margin: 8px 16px 0; font-size: 10px; line-height: 1.45; color: var(--faint); }



.label.station .name { color: #fff; font-size: 11px; }

/* Crewed missions in flight */
.label.crewed-body { display: none !important; }
.label.crew .name {
  color: #ffd27a; font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
}
.label.crew.selected .name { color: #fff; background: rgba(255, 210, 122, 0.22); padding: 1px 6px; border-radius: 4px; }

/* Spacecraft: small diamonds */
.label.craft .dot { border-radius: 1px; transform: rotate(45deg); width: 6px; height: 6px; margin-left: -3px; }
.label.craft .name { color: rgba(186, 230, 253, 0.85); font-size: 11px; }
.label.craft.focus .name { color: var(--accent); }

/* Landing sites: pins on the surface */
.label.site { gap: 5px; }
.label.site .pin {
  width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%;
  border: 1.5px solid #fff; background: rgba(124, 196, 255, 0.9); box-shadow: 0 0 6px rgba(0,0,0,0.8);
}
.label.site .name { font-size: 10.5px; color: rgba(255, 255, 255, 0.85); }
.label.site.focus .name { color: var(--accent); }
.label.site.focus .pin { background: var(--accent); transform: scale(1.3); }

/* ---------- Small buttons (mobile menus) ---------- */
.chip {
  height: 32px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(22, 23, 26, 0.88);
  color: var(--text);
  font: 500 12px var(--sans);
  cursor: pointer;
}
.chip:hover { background: rgba(255, 255, 255, 0.1); }

/* ---------- Time bar ---------- */
:root { --tb-h: 150px; }
#timebar {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 600px));
  padding: 10px 16px 6px;
  border-radius: 12px;
  background: rgba(22, 23, 26, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
}
.tb-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.tb-time { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: nowrap; }
.tb-time > * { flex: none; }
.tb-time:has(.tb-rate:not(:empty)) #time-clock { display: none; }   /* while time is sped up, show the speed instead of the seconds */
#time-date { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
#time-clock { font-size: 12px; color: var(--dim); white-space: nowrap; }
.tb-rate { font-size: 12px; color: var(--faint); white-space: nowrap; }
.tb-now {
  height: 24px; padding: 0 10px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18); background: transparent; color: var(--text);
  font: 500 11.5px var(--sans); cursor: pointer; align-self: center;
}
.tb-now:hover { background: rgba(255,255,255,0.08); }
.tb-now[hidden] { display: none; }
.tb-controls { display: flex; align-items: center; gap: 8px; margin: 0 12px; }
.tb-icon, .tb-play {
  display: grid; place-items: center; padding: 0; cursor: pointer; color: var(--text);
  background: transparent; border: 1px solid transparent;
}
.tb-icon { width: 28px; height: 28px; border-radius: 6px; }
.tb-icon:hover { background: rgba(255,255,255,0.07); }
.tb-icon svg { width: 16px; height: 16px; fill: currentColor; }
.tb-play {
  width: 38px; height: 28px; border-radius: 7px;
  border-color: var(--accent); background: rgba(124, 196, 255, 0.16); color: var(--accent);
}
.tb-play:hover { background: rgba(124, 196, 255, 0.26); }
.tb-play svg { width: 16px; height: 16px; fill: currentColor; }
.tb-play svg[hidden], .tb-icon svg[hidden] { display: none; }
.tb-scale {
  justify-self: end; display: flex;
  border: 1px solid rgba(255,255,255,0.16); border-radius: 7px; overflow: hidden;
}
.tb-scale button {
  height: 28px; min-width: 0; padding: 0 12px;
  background: transparent; border: 0; border-left: 1px solid rgba(255,255,255,0.12);
  color: var(--dim); font: 500 12px var(--sans); cursor: pointer;
}
.tb-scale button:first-child { border-left: 0; }
.tb-scale button:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tb-scale button.active {
  color: var(--text); background: rgba(124, 196, 255, 0.16);
  box-shadow: inset 0 0 0 1px var(--accent); border-radius: 6px;
}
#ruler {
  display: block; width: 100%; height: 46px; margin-top: 4px;
  cursor: grab; touch-action: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
#ruler:active { cursor: grabbing; }
#overview {
  position: relative; height: 36px; margin: 0 16px; cursor: pointer; touch-action: none;
}
.ov-track { position: absolute; left: 0; right: 0; top: 14px; height: 1px; background: rgba(255,255,255,0.35); }
.ov-tick { position: absolute; top: 9px; width: 1px; height: 11px; background: rgba(255,255,255,0.45); }
.ov-tick span {
  position: absolute; top: 15px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--dim); white-space: nowrap;
}
.ov-thumb {
  position: absolute; top: 5px; width: 9px; height: 19px; margin-left: -4.5px; border-radius: 3px;
  background: rgba(124, 196, 255, 0.5); border: 1px solid var(--accent); pointer-events: none;
}

/* ---------- Labels ---------- */
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.label {
  position: absolute;
  top: 0; left: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
  will-change: transform;
  transform: translate3d(-9999px, -9999px, 0);
}
.label .dot {
  width: 7px; height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
  flex: none;
}
.label .name {
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  letter-spacing: 0.01em;
}
.label.moon .dot { width: 5px; height: 5px; margin-left: -2.5px; box-shadow: none; }
.label.moon .name { font-size: 10.5px; color: rgba(255, 255, 255, 0.6); }
.label.resolved .dot { visibility: hidden; }
.label.focus .name { color: var(--accent); }
.label:hover .name { color: #fff; }
.label.hidden { display: none; }

/* ---------- Hint ---------- */
#hint {
  position: absolute;
  bottom: calc(var(--tb-h) + 30px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11.5px;
  color: var(--faint);
  pointer-events: none;
  transition: opacity 1s;
}
#hint.gone { opacity: 0; }

/* ---------- Credits ---------- */
#credits {
  margin: 10px 16px 6px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
  font-size: 10px;
  line-height: 1.5;
  color: var(--faint);
}
#credits a { color: var(--dim); text-decoration: none; }
#credits a:hover { color: var(--text); }

/* ---------- Loader ---------- */
#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #000;
  z-index: 10;
  transition: opacity 1.1s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
.loader-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.loader-bar { width: 180px; height: 2px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
#loader-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
.loader-sub { font-size: 11.5px; color: var(--faint); }

/* ---------- Small screens ---------- */
@media (max-height: 820px) and (min-width: 761px) and (min-height: 501px) {
  #layers .layers-note { display: none; }
  .info-note { display: none; }
}
@media (max-width: 1100px) and (min-width: 761px) and (min-height: 501px) {
}
@media (max-width: 1100px) and (min-width: 761px) and (min-height: 501px) {
  #timebar { left: 268px; right: 296px; width: auto; transform: none; }
}
/* Info card pager: step through the objects of one launch */
.info-pager {
  display: flex; align-items: center; gap: 6px; margin: 0; padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
}
.info-pager[hidden] { display: none; }
.info-pager button {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px;
  border: 1px solid rgba(124, 196, 255, 0.35); background: rgba(124, 196, 255, 0.08); color: var(--accent); cursor: pointer;
}
.info-pager button:hover { background: rgba(124, 196, 255, 0.2); }
.info-pager svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pager-label { flex: 1; min-width: 0; text-align: center; line-height: 1.3; }
.pager-label b { display: block; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pager-label span { display: block; font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#info.paged .close-btn { top: 58px; }

/* ===================================================================================
   Header view tabs
   =================================================================================== */
#topbar { grid-template-columns: auto 1fr minmax(0, 420px) auto; }
.view-tabs { display: flex; gap: 4px; justify-self: start; margin-left: 20px; }
.view-tab {
  height: 34px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent;
  color: var(--dim); font: 500 13px var(--sans); cursor: pointer;
}
.view-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.view-tab.active { color: var(--text); background: rgba(124, 196, 255, 0.14); box-shadow: inset 0 0 0 1px rgba(124, 196, 255, 0.35); }
body.history-open #topbar .top-search { visibility: hidden; }

/* ===================================================================================
   Human Timeline
   =================================================================================== */
#history {
  position: absolute; left: 0; right: 0; bottom: 0; top: var(--top-h); z-index: 4;
  background: rgba(11, 12, 16, 0.985);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#history[hidden] { display: none; }
body.history-open #bodies, body.history-open #info, body.history-open #layers,
body.history-open #timebar, body.history-open #hint, body.history-open #hl-chip, body.history-open #labels { visibility: hidden; }
.hist-inner { height: 100%; overflow-y: auto; padding: 28px max(24px, calc(50% - 520px)) 60px; overscroll-behavior: contain; }
.hist-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.hist-head h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.hist-head p { margin: 6px 0 0; color: var(--dim); font-size: 14px; max-width: 640px; line-height: 1.5; }
.hist-back {
  flex: none; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04); color: var(--text); font: 500 13px var(--sans); cursor: pointer;
}
.hist-back:hover { border-color: rgba(124, 196, 255, 0.5); }

.hist-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 22px; }
.hist-field { display: flex; flex-direction: column; gap: 5px; }
.hist-field span { font-size: 11px; color: var(--dim); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.hist-field input {
  height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04); color: var(--text); font: 400 14px var(--sans); color-scheme: dark;
}
.hist-field input:focus { outline: none; border-color: rgba(124, 196, 255, 0.6); }
.hist-find { flex: 1; min-width: 200px; max-width: 360px; }
.hist-toggle {
  height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.04); color: var(--text);
  font: 500 13px var(--sans); cursor: pointer;
}
.hist-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.hist-toggle.on { background: rgba(124, 196, 255, 0.16); border-color: rgba(124, 196, 255, 0.5); color: var(--accent); }
.hist-toggle.on svg { fill: currentColor; }

.hist-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.hist-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1); background: transparent; color: var(--faint);
  font: 500 12px var(--sans); cursor: pointer;
}
.hist-chip i { width: 8px; height: 8px; border-radius: 50%; opacity: 0.35; }
.hist-chip.on { color: var(--text); border-color: rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.04); }
.hist-chip.on i { opacity: 1; }

.hist-chart-wrap { position: relative; margin-top: 14px; }
#hist-chart { display: block; width: 100%; height: 170px; cursor: pointer; touch-action: pan-y; }
.hist-tip {
  position: absolute; top: -6px; transform: translateY(-100%); pointer-events: none; z-index: 2;
  min-width: 190px; padding: 10px 12px; border-radius: 10px; background: rgba(18, 20, 27, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12); font-size: 12px; line-height: 1.6; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.hist-tip div { display: flex; align-items: center; gap: 7px; color: var(--dim); }
.hist-tip div i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.hist-tip div span { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.hist-tip .tip-stars { display: block; margin-top: 4px; color: var(--accent); max-width: 260px; }

.hist-list-head {
  position: sticky; top: -28px; z-index: 1; margin: 22px -4px 0; padding: 14px 4px 10px;
  background: rgb(11, 12, 16); border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.hist-list-head h2 { margin: 0; font-size: 22px; font-weight: 600; }
.hist-list-head h2 span { font-size: 14px; font-weight: 400; color: var(--dim); margin-left: 8px; }
.hist-months { display: flex; gap: 4px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.hist-months:empty { display: none; }
.hist-months button {
  flex: 1; min-width: 46px; height: 40px; border: 0; border-radius: 7px; background: rgba(255, 255, 255, 0.04);
  color: var(--dim); font: 500 11.5px var(--sans); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.25;
}
.hist-months button b { color: var(--text); font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.hist-months button:hover:not(:disabled) { background: rgba(124, 196, 255, 0.12); }
.hist-months button:disabled { opacity: 0.35; cursor: default; }

.hist-list {
  --rail: 48px;                           /* width of the column the line runs down */
  --axis: calc(var(--rail) / -2);         /* the line's centre, measured from the content edge */
  --page: #0b0c10;                        /* page colour, used to cut a gap in the line around markers */
  position: relative; margin-top: 10px; padding-left: var(--rail);
}
.hist-list::before {                      /* the line: 1px, centred in the rail, fading at both ends */
  content: ''; position: absolute; top: 0; bottom: 0; left: calc(var(--rail) / 2); width: 1px; transform: translateX(-50%);
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.16) 24px, rgba(255, 255, 255, 0.16) calc(100% - 40px), transparent);
}
.list-note { color: var(--dim); font-size: 13px; margin: 16px 0; }

/* Every marker is centred on the axis with the same rule */
.day::before, .day-note::before, .l-dot {
  content: ''; position: absolute; left: var(--axis); transform: translate(-50%, -50%);
}

/* Days: a short tick across the line */
.day {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 26px; margin: 34px 0 16px;
  font-size: 11px; font-weight: 600; color: var(--dim); letter-spacing: 0.08em; text-transform: uppercase;
}
.hist-list > .day:first-child, .hist-list > .list-note + .day { margin-top: 14px; }
.day::before { top: 50%; width: 11px; height: 1px; background: rgba(255, 255, 255, 0.45); }
.day.picked { color: var(--accent); }
.day.picked::before { width: 17px; height: 2px; background: var(--accent); box-shadow: 0 0 8px rgba(124, 196, 255, 0.7); }
.goto-year, .see-day {
  height: 26px; padding: 0 10px; border-radius: 6px; border: 1px solid rgba(124, 196, 255, 0.35);
  background: rgba(124, 196, 255, 0.1); color: var(--accent); font: 500 11.5px var(--sans); cursor: pointer;
  text-transform: none; letter-spacing: 0;
}
.goto-year { border-color: rgba(255, 255, 255, 0.12); background: transparent; color: var(--dim); }
.day-note {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 30px 0 16px; padding: 12px 14px; border-radius: 10px; border: 1px dashed rgba(124, 196, 255, 0.4); background: rgba(124, 196, 255, 0.05);
}
.day-note::before { top: 50%; width: 17px; height: 2px; background: var(--accent); box-shadow: 0 0 8px rgba(124, 196, 255, 0.7); }
.day-note b { display: block; color: var(--accent); font-size: 13px; }
.day-note span { color: var(--dim); font-size: 12.5px; }

/* Launches: the marker sits on the axis, level with the time row */
.launch { position: relative; margin: 0 0 26px; }
.l-dot {
  top: 10px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 0 4px var(--page);
  transition: transform 0.15s ease;
}
.launch:hover .l-dot { transform: translate(-50%, -50%) scale(1.25); }
.launch.milestone .l-dot {
  width: 15px; height: 15px;
  box-shadow: 0 0 0 3px var(--page), 0 0 0 4.5px var(--accent), 0 0 18px 2px rgba(124, 196, 255, 0.45);
}
.launch.fail .l-dot { background: var(--page); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 75%, transparent), 0 0 0 4px var(--page); }
.l-body { min-width: 0; }
.l-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 20px; line-height: 20px; font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.l-top > span:first-child { font-weight: 600; color: rgba(233, 236, 242, 0.7); letter-spacing: 0.02em; }
.l-group { color: var(--c); }
.badge { height: 19px; display: inline-flex; align-items: center; padding: 0 7px; border-radius: 5px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.badge.star { background: rgba(124, 196, 255, 0.16); color: var(--accent); }
.badge.fail { background: rgba(240, 82, 82, 0.15); color: #ff8b8b; }
.launch h3 { margin: 4px 0 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.launch.milestone h3 { font-size: 21px; }
.launch.fail h3 { color: rgba(233, 236, 242, 0.7); }
.l-text { margin: 6px 0 0; font-size: 15px; line-height: 1.55; color: var(--text); max-width: 640px; }
.l-sub { margin: 5px 0 0; font-size: 13px; color: var(--dim); line-height: 1.45; max-width: 720px; }
.l-meta { margin: 5px 0 0; font-size: 12px; color: var(--faint); line-height: 1.55; }
.l-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; }
.l-see {
  height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid rgba(124, 196, 255, 0.4);
  background: rgba(124, 196, 255, 0.08); color: var(--accent); font: 600 12.5px var(--sans); cursor: pointer; white-space: nowrap;
}
.l-see span { display: inline-block; transition: transform 0.15s; }
.l-see:hover { background: rgba(124, 196, 255, 0.18); }
.l-see:hover span { transform: translateX(2px); }
.l-where { font-size: 12px; color: var(--dim); }
.hist-credit { margin-top: 30px; font-size: 11.5px; color: var(--faint); }
.hist-credit a { color: var(--dim); }

/* Highlight chip in the 3D view after "See in 3D" */
.hl-chip {
  position: absolute; z-index: 3; left: 50%; transform: translateX(-50%); top: calc(var(--top-h) + 16px);
  display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100% - 32px));
  padding: 8px 8px 8px 16px; border-radius: 22px; background: rgba(14, 16, 22, 0.9);
  border: 1px solid rgba(124, 196, 255, 0.4); color: var(--text); font-size: 13px; line-height: 1.4;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.hl-chip[hidden] { display: none; }
.hl-chip b { color: var(--accent); font-weight: 600; }
.hl-chip button { flex: none; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.06); color: var(--dim); cursor: pointer; display: grid; place-items: center; }
.hl-chip button svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }

/* ===================================================================================
   Phones (portrait, and landscape up to 960 px wide)
   =================================================================================== */
@media (max-width: 760px), (max-width: 960px) and (max-height: 500px) {
  :root { --top-h: calc(52px + env(safe-area-inset-top)); --pad-x: max(10px, env(safe-area-inset-left)); }

  /* Header: logo + three icon buttons; search expands to fill the bar */
  #topbar {
    grid-template-columns: 1fr auto; gap: 8px;
    padding: env(safe-area-inset-top) var(--pad-x) 0;
  }
  .brand-logo { height: 26px; max-width: 140px; }
  .brand-product-logo { height: 22px; max-width: 110px; padding-left: 10px; }
  .brand-title { font-size: 15px; }
  .brand-sub { display: none; }
  .top-search { display: none; }
  .top-actions { gap: 4px; }
  .icon-btn-m {
    display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
    background: transparent; border: 0; border-radius: 10px; color: var(--text); cursor: pointer;
  }
  .icon-btn-m svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .icon-btn-m.on { background: rgba(124, 196, 255, 0.16); color: var(--accent); }
  #topbar.searching { grid-template-columns: 1fr; }
  #topbar.searching .brand, #topbar.searching .top-actions { display: none; }
  #topbar.searching .top-search { display: flex; align-items: center; gap: 8px; }
  #topbar.searching .search-icon { left: 12px; }
  #sat-search { height: 40px; padding: 0 12px 0 36px; font-size: 16px; flex: 1; }   /* 16px stops iOS zooming in */
  .search-key { display: none; }
  #search-cancel {
    display: block; background: none; border: 0; color: var(--accent); font: 500 15px var(--sans); padding: 8px 2px; cursor: pointer;
  }
  #sat-results { position: fixed; left: var(--pad-x); right: var(--pad-x); top: calc(var(--top-h) + 6px); max-height: 60vh; }
  #sat-results li { padding: 11px 10px; font-size: 14px; }

  /* Explore and Layers open as full-width sheets under the header, one at a time */
  #bodies, #layers {
    display: none; top: calc(var(--top-h) + 8px); bottom: auto; left: var(--pad-x); right: var(--pad-x);
    width: auto; max-height: calc(100% - var(--top-h) - var(--tb-h) - 36px); overflow-y: auto;
    background: rgba(16, 17, 21, 0.97); z-index: 4;
  }
  #bodies.open, #layers.open { display: block; }
  .sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1; padding: 10px 8px 8px 16px;
    background: rgba(16, 17, 21, 0.97); border-bottom: 1px solid var(--panel-border);
    font-size: 15px; font-weight: 600;
  }
  .sheet-close { width: 36px; height: 36px; display: grid; place-items: center; background: none; border: 0; color: var(--dim); cursor: pointer; }
  .sheet-close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }
  .nav-name { padding: 11px 12px; font-size: 15px; }
  .nav-row.level-1 .nav-name { padding: 9px 12px 9px 28px; font-size: 14px; }
  .nav-row.level-2 .nav-name { padding: 9px 12px 9px 44px; font-size: 14px; }
  .nav-toggle { width: 44px; height: 44px; }
  .nav-head { padding: 14px 12px 10px; font-size: 11px; }
  #cat-list li, #sb-list li { padding: 9px 12px; font-size: 14px; }
  #layers .tabs { position: sticky; top: 55px; background: rgba(16, 17, 21, 0.97); z-index: 1; }

  /* Info: a compact bar above the time bar; tap to expand the details */
  #info {
    top: auto; right: var(--pad-x); left: var(--pad-x); width: auto;
    bottom: calc(var(--tb-h) + 16px + env(safe-area-inset-bottom));
    padding: 0; cursor: pointer;
    max-height: 46vh; overflow-y: auto;
  }
  .info-kind { padding: 10px 52px 0 14px; font-size: 10px; }
  .info-name { font-size: 18px; padding: 2px 52px 10px 14px; border-bottom: 0; }
  #info.expanded .info-name { border-bottom: 1px solid var(--panel-border); }
  #info:has(#info-close:not([hidden])) .info-kind, #info:has(#info-close:not([hidden])) .info-name { padding-right: 84px; }
  #info .info-grid, #info .info-note { display: none; }
  #info.expanded .info-grid { display: grid; padding: 6px 14px 8px; }
  #info.expanded .info-note { display: block; padding: 10px 14px 12px; }
  .info-expand {
    display: grid; place-items: center; position: absolute; top: 8px; right: 8px; width: 36px; height: 36px;
    background: none; border: 0; color: var(--dim); cursor: pointer;
  }
  .info-expand svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; transition: transform 0.18s; }
  #info.expanded .info-expand svg { transform: rotate(180deg); }
  #info .close-btn { right: 44px; top: 12px; }
  .info-pager { padding: 8px 10px; }
  #info.paged .close-btn, #info.paged .info-expand { top: 58px; }

  /* Time bar: two compact rows plus the ruler; the century track is hidden */
  #timebar {
    left: var(--pad-x); right: var(--pad-x); bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto; transform: none; padding: 8px 12px 4px;
  }
  .tb-top { grid-template-columns: 1fr auto; row-gap: 8px; padding-bottom: 6px; }
  .tb-time { gap: 8px; flex-wrap: nowrap; }
  #time-date { font-size: 15px; }
  #time-clock { font-size: 11.5px; }
  .tb-rate { display: none; }
  #btn-now { height: 26px; padding: 0 9px; font-size: 11.5px; }
  .tb-time:has(#btn-now:not([hidden])) #time-clock { display: none; }
  .tb-controls { margin: 0; gap: 2px; }
  .tb-icon { width: 38px; height: 34px; }
  .tb-play { width: 44px; height: 34px; }
  .tb-scale { grid-column: 1 / -1; justify-self: stretch; }
  .tb-scale button { flex: 1; min-width: 0; height: 30px; font-size: 12.5px; }
  #ruler { height: 42px; border-bottom: 0; }
  #overview { display: none; }

  .view-tabs { display: none; }
  #topbar { grid-template-columns: 1fr auto; }
  #history-toggle.on { background: rgba(124, 196, 255, 0.16); color: var(--accent); }
  .hist-inner { padding: 18px var(--pad-x) calc(40px + env(safe-area-inset-bottom)); }
  .hist-head h1 { font-size: 22px; }
  .hist-head p { font-size: 13px; }
  .hist-back { display: none; }
  .hist-tools { margin-top: 16px; gap: 10px; }
  .hist-field { flex: 1 1 140px; }
  .hist-find { max-width: none; }
  .hist-field input { font-size: 16px; }              /* stops iOS zooming in */
  .hist-toggle { flex: 1 1 100%; justify-content: center; }
  .hist-legend { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: calc(-1 * var(--pad-x)); }
  .hist-chip { flex: none; }
  #hist-chart { height: 130px; }
  .hist-tip { display: none; }
  .hist-list-head { top: -18px; }
  .hist-list-head h2 { font-size: 19px; }
  .hist-months button { min-width: 42px; flex: none; }
  .hist-list { --rail: 34px; }
  .launch h3 { font-size: 17px; }
  .launch.milestone h3 { font-size: 19px; }
  .l-text { font-size: 14px; }
  .day-note { flex-direction: column; align-items: flex-start; }
  .hl-chip { top: calc(var(--top-h) + 8px); left: var(--pad-x); right: var(--pad-x); transform: none; max-width: none; font-size: 12.5px; border-radius: 14px; }

  #hint { display: none; }
  .label .name { font-size: 10.5px; }
  .label.moon .name { font-size: 10px; }
}

/* Phones held sideways: keep the scene visible */
@media (max-width: 960px) and (max-height: 500px) {
  :root { --top-h: calc(46px + env(safe-area-inset-top)); }
  #info { max-height: 52vh; right: auto; width: 300px; }
  .tb-scale { display: none; }
  #timebar { padding-top: 6px; }
}
