/* SATURN ATLAS — 深蓝黑 + 金象牙色系，无彩虹无霓虹 */
:root {
  --bg: #070a14;
  --bg-2: #0c1120;
  --ink: #e8e6df;
  --ink-dim: #9a968a;
  --ink-faint: rgba(232, 230, 223, 0.42);
  --accent: #d8b26a;
  --accent-soft: rgba(216, 178, 106, 0.16);
  --line: rgba(232, 230, 223, 0.12);
  --panel: rgba(9, 13, 24, 0.62);
  --panel-solid: rgba(9, 13, 24, 0.88);
  --radius: 10px;
  --font: "Manrope", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

#scene-root {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#scene-root canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.overlay {
  position: fixed;
  z-index: 10;
  pointer-events: none;
}

.overlay > * {
  pointer-events: auto;
}

/* ---------- 标题 ---------- */
.header {
  top: clamp(20px, 3.4vh, 40px);
  left: clamp(20px, 3vw, 48px);
  max-width: min(420px, 44vw);
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--ink-dim);
  text-transform: uppercase;
  margin-bottom: 10px;
}

h1 {
  margin: 0;
  font-weight: 600;
  font-size: clamp(30px, 4.4vw, 54px);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.header .sub {
  margin: 12px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-dim);
  max-width: 34em;
}

/* ---------- 科普面板 ---------- */
.panel {
  top: clamp(20px, 3.4vh, 40px);
  right: clamp(20px, 3vw, 48px);
  width: min(370px, 40vw);
  max-height: calc(100vh - 190px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-bottom: 6px;
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.icon-btn {
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.panel-body {
  padding: 14px 18px 4px;
  overflow-y: auto;
  scrollbar-width: thin;
  flex: 1 1 auto;
}

#explanation {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.72;
  color: var(--ink);
}

.bullets {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.bullets li {
  position: relative;
  margin: 0 0 8px;
  padding-left: 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-dim);
}

.bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 1px;
  background: var(--accent);
}

.source {
  margin: 12px 0 4px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-faint);
}

.source a {
  color: var(--ink-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.source a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- 层选区 ---------- */
.layer-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
}

.layer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.layer-btn:hover {
  color: var(--ink);
  border-color: rgba(216, 178, 106, 0.5);
}

.layer-btn[aria-pressed="true"] {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.dot[data-dot="envelope"] {
  background: #c9b48a;
}
.dot[data-dot="helium"] {
  background: #8f9bc0;
}
.dot[data-dot="metallic"] {
  background: #4f6f96;
}
.dot[data-dot="core"] {
  background: #a9704a;
}

/* ---------- 工具条 ---------- */
.toolbar {
  left: 50%;
  bottom: clamp(16px, 2.6vh, 30px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar::-webkit-scrollbar {
  display: none;
}

.tbtn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.tbtn:hover {
  color: var(--ink);
  background: rgba(232, 230, 223, 0.06);
}

.tbtn.primary {
  border-color: rgba(216, 178, 106, 0.55);
  color: var(--accent);
}

.tbtn[aria-pressed="true"] {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.t-sep {
  flex: none;
  width: 1px;
  height: 20px;
  background: var(--line);
}

.t-spacer {
  flex: 1 1 auto;
  min-width: 4px;
}

.rate {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  color: var(--ink-dim);
  font-size: 12.5px;
}

.rate select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 22px 6px 10px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
    linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

.rate select option {
  background: var(--bg-2);
  color: var(--ink);
}

.tbtn.lang {
  width: 34px;
  padding: 8px 0;
}

/* ---------- 图例 & 基线 ---------- */
.legend,
.baseline {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  bottom: clamp(16px, 2.6vh, 30px);
}

.legend {
  left: clamp(20px, 3vw, 48px);
  font-size: 11.5px;
  color: var(--ink-dim);
}

.lg {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sw {
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

.sw.c {
  color: rgba(216, 205, 178, 0.55);
}
.sw.b {
  color: rgba(233, 222, 196, 0.95);
}
.sw.a {
  color: rgba(214, 196, 158, 0.8);
}
.sw.gap {
  color: transparent;
  border-top: 2px dashed rgba(232, 230, 223, 0.35);
  height: 0;
}

.baseline {
  right: clamp(20px, 3vw, 48px);
  font-size: 11px;
  color: var(--ink-faint);
  justify-content: flex-end;
  pointer-events: none;
}

/* ---------- 载入 ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 1.4s linear infinite;
}

.loader-txt {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- focus & reduced motion ---------- */
button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.panel.collapsed .panel-body,
.panel.collapsed .layer-nav {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .loader-ring {
    animation: none;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  html,
  body {
    overflow: auto; /* 窄屏：说明栏随页面滚动，3D 区固定在顶部独立区域 */
  }
  #scene-root {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: max(360px, 45vh); /* 独立 3D 区：保证足够高度，renderer 按此真实尺寸创建 */
    min-height: 360px;
  }
  .header {
    top: 12px;
    left: 16px;
    max-width: 60vw;
  }
  h1 {
    font-size: 26px;
  }
  .header .sub {
    display: none;
  }
  .panel {
    position: relative;
    top: auto;
    bottom: auto;
    right: auto;
    left: auto;
    margin: calc(max(360px, 45vh) + 8px) 12px 0;
    width: auto;
    max-height: none;
  }
  .layer-nav {
    grid-template-columns: 1fr 1fr;
  }
  .legend {
    display: none;
  }
  .baseline {
    display: none;
  }
  .toolbar {
    position: fixed;
    bottom: 12px;
    border-radius: 14px;
    padding: 6px;
    z-index: 20; /* 固定工具栏在说明栏滚动层之上 */
  }
  body {
    padding-bottom: 76px; /* 给固定工具栏留出底部空间，说明栏可完整滚动到底 */
  }
  .tbtn {
    padding: 8px 11px;
    font-size: 12px;
  }
}

@media (max-width: 560px) {
  .tbtn[data-view] {
    display: none;
  }
  .rate {
    display: none;
  }
}
