:root {
  --bg: #04060c;
  --ink: #e8eef7;
  --ink-dim: #93a2b8;
  --ink-faint: #5f6e85;
  --amber: #ffb058;
  --amber-soft: #ffd6a3;
  --blue: #6aa8ff;
  --line: rgba(150, 175, 210, 0.16);
  --glass: rgba(10, 16, 28, 0.72);
  --glass-hi: rgba(22, 32, 50, 0.82);
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

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

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

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

body.ui-hidden .masthead,
body.ui-hidden .panel,
body.ui-hidden .panel__open,
body.ui-hidden .bodies,
body.ui-hidden .info,
body.ui-hidden .help,
body.ui-hidden .label-layer { opacity: 0; pointer-events: none; }

.masthead, .panel, .bodies, .info, .help, .panel__open, .label-layer {
  transition: opacity 0.25s ease;
}

/* ------------------------------------------------------------- masthead -- */

.masthead {
  position: absolute;
  top: 18px;
  left: 20px;
  pointer-events: none;
  z-index: 5;
}
.masthead h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 24px rgba(0, 0, 0, 0.9);
}
.masthead__sub {
  margin: 3px 0 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.clock {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--mono);
}
.clock__date { font-size: 15px; color: var(--amber-soft); letter-spacing: 0.04em; }
.clock__speed { font-size: 11px; color: var(--ink-faint); }

/* --------------------------------------------------------- body picker -- */

.bodies {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 5;
}
.body-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.05em;
  padding: 4px 10px 4px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.body-btn:hover { background: rgba(120, 160, 220, 0.10); color: var(--ink); }
.body-btn--active { background: rgba(255, 176, 88, 0.13); color: var(--amber-soft); }
.body-btn--moon { padding-left: 22px; font-size: 11px; opacity: 0.78; }
.body-btn__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 8px currentColor;
}

/* --------------------------------------------------------------- panel -- */

.panel {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: 296px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 22px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 6;
  scrollbar-width: thin;
  scrollbar-color: rgba(150,175,210,0.3) transparent;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: rgba(150,175,210,0.25); border-radius: 4px; }
.panel[hidden] { display: none; }

.panel__toggle, .panel__open {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--glass-hi);
  color: var(--ink-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.panel__toggle {
  position: absolute;
  top: 12px; right: 12px;
  width: 24px; height: 24px;
  padding: 0;
}
.panel__toggle:hover, .panel__open:hover { color: var(--ink); border-color: rgba(150,175,210,0.4); }
.panel__open {
  position: absolute;
  top: 16px; right: 16px;
  width: 34px; height: 34px;
  z-index: 6;
  display: none;
}
.panel__open.is-visible { display: block; }

.group { margin-bottom: 22px; }
.group:last-child { margin-bottom: 0; }
.group h2 {
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.note {
  margin: -2px 0 10px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink-faint);
}

.field { display: block; margin-bottom: 11px; }
.field__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: var(--ink-dim);
  margin-bottom: 5px;
}
.field__label em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber-soft);
}

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(150, 175, 210, 0.22);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid #0a1020;
  box-shadow: 0 0 10px rgba(255, 176, 88, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid #0a1020;
}

.row { display: flex; gap: 6px; flex-wrap: wrap; }
.row--buttons { margin-bottom: 11px; }
.row--chips { margin-top: 8px; }

.btn {
  appearance: none;
  flex: 1 1 auto;
  border: 1px solid var(--line);
  background: rgba(150, 175, 210, 0.07);
  color: var(--ink-dim);
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: rgba(150, 175, 210, 0.14); color: var(--ink); }
.btn--primary {
  border-color: rgba(255, 176, 88, 0.4);
  background: rgba(255, 176, 88, 0.14);
  color: var(--amber-soft);
}
.btn--primary:hover { background: rgba(255, 176, 88, 0.24); }

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 10px;
  padding: 4px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { color: var(--amber-soft); border-color: rgba(255,176,88,0.4); }
.chip.is-active { color: var(--amber-soft); border-color: rgba(255,176,88,0.5); background: rgba(255,176,88,0.12); }

.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.toggle::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  flex: 0 0 auto;
}
.toggle.is-on { color: var(--blue); border-color: rgba(106, 168, 255, 0.4); background: rgba(106,168,255,0.10); }
.toggle.is-on::before { opacity: 1; box-shadow: 0 0 8px currentColor; }

.diag { margin: 0; font-family: var(--mono); font-size: 11px; }
.diag > div { display: flex; justify-content: space-between; padding: 3px 0; }
.diag dt { color: var(--ink-faint); }
.diag dd { margin: 0; color: var(--amber-soft); }

/* ----------------------------------------------------------- info card -- */

.info {
  position: absolute;
  left: 20px;
  bottom: 58px;
  width: 292px;
  padding: 14px 16px 16px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 6;
}
.info[hidden] { display: none; }
.info__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.info__head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--amber-soft);
}
.info__close {
  appearance: none; border: 0; background: transparent;
  color: var(--ink-faint); font-size: 17px; cursor: pointer; line-height: 1; padding: 0 2px;
}
.info__close:hover { color: var(--ink); }

.info__stats, .info__facts { margin: 0 0 10px; font-size: 11px; }
.info__stats > div, .info__facts > div {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(150,175,210,0.07);
}
.info__stats dt, .info__facts dt { color: var(--ink-faint); flex: 0 0 auto; }
.info__stats dd, .info__facts dd {
  margin: 0; font-family: var(--mono); color: var(--ink); text-align: right;
}
.info__facts { border-top: 1px solid var(--line); padding-top: 8px; }
.info__facts dd { font-family: var(--sans); color: var(--ink-dim); }

/* ---------------------------------------------------------------- help -- */

.help {
  position: absolute;
  left: 20px;
  bottom: 16px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: var(--ink-faint);
  pointer-events: none;
  z-index: 5;
}
kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: rgba(150,175,210,0.12);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink-dim);
  margin-right: 3px;
}

/* -------------------------------------------------------------- labels -- */

.label-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.label {
  position: absolute;
  top: 0; left: 0;
  appearance: none;
  border: 0;
  background: transparent;
  display: none;
  align-items: center;
  gap: 5px;
  padding: 3px 7px 3px 3px;
  color: var(--ink-dim);
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  border-radius: 20px;
  transition: color 0.15s, background 0.15s;
}
.label:hover { color: var(--ink); background: rgba(10,16,28,0.6); }
.label--selected { color: var(--amber-soft); }
.label__dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 7px currentColor;
  flex: 0 0 auto;
}
.label--moon { font-size: 9.5px; opacity: 0.7; }
.label--star { color: var(--amber-soft); font-size: 11.5px; }

/* ---------------------------------------------------------------- boot -- */

.boot {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: grid;
  place-items: center;
  z-index: 20;
  transition: opacity 0.5s ease;
}
.boot.is-done { opacity: 0; pointer-events: none; }
.boot__inner { text-align: center; }
.boot__spinner {
  width: 46px; height: 46px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,176,88,0.18);
  border-top-color: var(--amber);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot p {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}
.boot--error .boot__spinner { display: none; }
.boot--error p { color: #ff8a7a; max-width: 520px; line-height: 1.7; text-align: left; }

/* -------------------------------------------------------------- mobile -- */

@media (max-width: 860px) {
  .panel { width: min(300px, 84vw); top: 10px; right: 10px; bottom: 10px; }
  .bodies {
    top: auto; bottom: 86px; left: 10px; right: 10px;
    transform: none;
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 4px;
  }
  .body-btn { flex: 0 0 auto; background: var(--glass); border: 1px solid var(--line); }
  .body-btn--moon { padding-left: 8px; }
  .info { left: 10px; right: 10px; width: auto; bottom: 140px; }
  .help { display: none; }
  .masthead { top: 10px; left: 12px; }
  .masthead h1 { font-size: 15px; }
}
