/* ==========================================================================
   3D 太阳系运行教学系统 — 界面样式
   深空 HUD 风格：低饱和玻璃面板 + 细边框 + 等宽数字 + 轻微辉光
   ========================================================================== */

:root {
  --bg: #04060c;
  --panel-bg: rgba(10, 16, 29, 0.76);
  --panel-bg-solid: #0a1020;
  --panel-border: rgba(110, 156, 214, 0.20);
  --panel-border-strong: rgba(110, 156, 214, 0.36);
  --text: #d9e5f6;
  --text-strong: #f2f7ff;
  --muted: #7f93b0;
  --muted-dim: #5b6c86;
  --accent: #4ea8ff;
  --accent-soft: rgba(78, 168, 255, 0.16);
  --warm: #ffb347;
  --danger: #ff6b6b;
  --ok: #58d68d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --top-h: 58px;
  --left-w: 252px;
  --right-w: 330px;
  --tool-w: 92px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  /* 深空底色：极淡的星云渐变，避免纯黑显得死板 */
  background-image:
    radial-gradient(1100px 700px at 18% 8%, rgba(38, 70, 130, 0.20), transparent 62%),
    radial-gradient(900px 620px at 88% 92%, rgba(96, 44, 120, 0.16), transparent 60%),
    radial-gradient(700px 500px at 60% 40%, rgba(20, 40, 80, 0.12), transparent 70%);
}

button, input, select { font: inherit; color: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(110, 156, 214, 0.24); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(110, 156, 214, 0.42); }

/* ============================== 通用组件 ============================== */

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border-strong);
  background: rgba(30, 48, 80, 0.5);
  color: var(--text);
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, transform 0.1s, color 0.16s;
  white-space: nowrap;
}
.btn:hover { background: rgba(52, 84, 138, 0.62); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-icon {
  width: 34px; height: 34px; padding: 0;
  border-radius: 9px;
}
.btn-icon svg { width: 17px; height: 17px; fill: currentColor; }

.btn-mini {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 7px;
  background: rgba(30, 48, 80, 0.42);
}

.btn-ghost {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); background: rgba(52, 84, 138, 0.28); }

.btn-play .icon-pause { display: none; }
.btn-play.is-playing .icon-play { display: none; }
.btn-play.is-playing .icon-pause { display: block; }
.btn-play.is-reverse { color: var(--warm); border-color: rgba(255, 179, 71, 0.5); }

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(20, 34, 58, 0.5);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--panel-border-strong); }
.chip.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #cfe7ff;
  box-shadow: 0 0 12px rgba(78, 168, 255, 0.22);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(78, 168, 255, 0.5), rgba(110, 156, 214, 0.18));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #dbe9ff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 8px rgba(78, 168, 255, 0.6);
}
.range::-moz-range-track {
  height: 4px; border-radius: 3px;
  background: rgba(110, 156, 214, 0.3);
}
.range::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: #dbe9ff; border: 2px solid var(--accent);
}
.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.mini-label { font-size: 11px; color: var(--muted-dim); letter-spacing: 0.08em; text-transform: uppercase; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--panel-border-strong);
  background: rgba(20, 34, 58, 0.8);
  font-family: var(--mono);
  font-size: 11px;
  color: #cfe0f5;
  text-align: center;
}

/* ============================== 视口与标签层 ============================== */

.viewport {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.label-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.label {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  background: rgba(8, 14, 26, 0.62);
  border: 1px solid rgba(110, 156, 214, 0.28);
  color: #cddcf0;
  font-size: 11.5px;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.2s, border-color 0.2s, background 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.label:hover { background: rgba(24, 44, 76, 0.86); border-color: var(--accent); color: #fff; }
.label.is-active { background: rgba(30, 62, 110, 0.9); border-color: var(--accent); color: #fff; }
.label-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  flex: none;
}
.label small { color: var(--muted-dim); font-size: 10px; margin-left: 2px; }
.label.is-moon { font-size: 10.5px; padding: 1px 6px 1px 4px; opacity: 0.86; }

.hover-tip {
  position: absolute;
  z-index: 6;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(6, 12, 22, 0.9);
  border: 1px solid var(--panel-border-strong);
  font-size: 12px;
  pointer-events: none;
  transform: translate(12px, 12px);
  white-space: nowrap;
}

/* ============================== 顶栏 ============================== */

.topbar {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  height: var(--top-h);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ffe9a8 0%, #ff9d1c 42%, #b8450a 100%);
  box-shadow: 0 0 14px rgba(255, 157, 28, 0.7), 0 0 34px rgba(255, 100, 10, 0.34);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid rgba(120, 170, 240, 0.4);
  transform: rotate(-22deg) scaleY(0.34);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.18; min-width: 0; }
.brand-text strong { font-size: 14.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-strong); }
.brand-text small { font-size: 10px; color: var(--muted-dim); letter-spacing: 0.14em; text-transform: uppercase; }

.clock {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding-left: 16px;
  border-left: 1px solid var(--panel-border);
  min-width: 196px;
}
.clock-date {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  /* 日期是一个整体，换行会把顶栏撑成三行并与品牌图标重叠 */
  white-space: nowrap;
  color: #eaf3ff;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.clock-meta {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--muted-dim);
  font-family: var(--mono);
}
.clock-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-dim); }

.rate {
  display: flex; align-items: center; gap: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--panel-border);
}
.rate-value { display: flex; flex-direction: column; line-height: 1.25; min-width: 92px; }
#rate-label { font-size: 13px; color: #dbe9ff; font-family: var(--mono); }
.rate-real { font-size: 10.5px; color: var(--muted-dim); font-family: var(--mono); }

.topbar-actions { margin-left: auto; display: flex; gap: 6px; }

/* ============================== 侧栏 ============================== */

.sidebar {
  position: absolute;
  top: calc(12px + var(--top-h) + 10px);
  bottom: 12px;
  width: var(--left-w);
  z-index: 5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
}
.sidebar-right { width: var(--right-w); }

#sidebar-left { left: 12px; }
#sidebar-right { right: 12px; }

.sidebar.is-collapsed { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
.sidebar-right.is-collapsed { transform: translateX(calc(100% + 20px)); }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 12px 9px;
  border-bottom: 1px solid var(--panel-border);
  flex: none;
}
.panel-head h2 {
  margin: 0; font-size: 12px; font-weight: 600;
  letter-spacing: 0.10em; text-transform: uppercase; color: var(--muted);
}

/* ---------------------------- 面板「耳朵」 ----------------------------
   贴在面板右边缘的竖条把手。面板收起后会滑到屏幕左边缘，所以它必须：
     1) 是面板的兄弟节点，不能长在面板内部（面板收起时 pointer-events:none）；
     2) 自己的 z-index 高于面板，收起动画结束后仍可点击。            */
.panel-ear {
  position: absolute;
  z-index: 6;
  top: calc(12px + var(--top-h) + 10px + 88px);
  height: 104px;
  width: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-border-strong);
  border-left: none;
  border-radius: 0 9px 9px 0;
  background: rgba(14, 24, 42, 0.9);
  backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.16s, color 0.16s, border-color 0.16s;
}
.panel-ear-left { left: calc(12px + var(--left-w)); }
.panel-ear:hover { color: #cfe7ff; border-color: var(--accent); background: rgba(28, 52, 88, 0.94); }
.panel-ear:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.panel-ear-label { writing-mode: vertical-rl; letter-spacing: 0.2em; white-space: nowrap; }

/* 面板收起时耳朵跟着贴到左边缘，并且补回左边框 */
#app.left-collapsed .panel-ear-left {
  left: 12px;
  border-left: 1px solid var(--panel-border-strong);
  border-radius: 9px;
}

.search-wrap { padding: 9px 11px 6px; flex: none; }
.search {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(6, 12, 22, 0.66);
  color: var(--text);
  font-size: 13px;
}
.search::placeholder { color: var(--muted-dim); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(78, 168, 255, 0.14); }

.body-list { flex: 1; overflow-y: auto; padding: 4px 8px 10px; }

.group-title {
  padding: 9px 6px 4px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.body-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, border-color 0.14s;
}
.body-item:hover { background: rgba(52, 84, 138, 0.26); }
.body-item.is-active { background: var(--accent-soft); border-color: rgba(78, 168, 255, 0.5); }
.body-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.body-swatch {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6) inset;
}
.body-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.body-name { font-size: 13px; }
.body-sub { font-size: 10.5px; color: var(--muted-dim); font-family: var(--mono); }
.body-item.is-moon { padding-left: 22px; }

.panel-foot {
  flex: none;
  padding: 8px 11px 11px;
  border-top: 1px solid var(--panel-border);
}

/* ============================== 工具条 ============================== */

.toolbar {
  position: absolute;
  right: calc(12px + var(--right-w) + 10px);
  top: calc(12px + var(--top-h) + 10px);
  width: var(--tool-w);
  z-index: 5;
  padding: 9px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
#app.right-collapsed .toolbar { right: 12px; }
#app.right-collapsed #sidebar-right { transform: translateX(calc(100% + 20px)); opacity: 0; pointer-events: none; }

.tool-group { display: flex; flex-wrap: wrap; gap: 5px; }
.tool-group-col { flex-direction: column; flex-wrap: nowrap; }
.tool-sep { height: 1px; background: var(--panel-border); margin: 1px 2px; }

.tool {
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid var(--panel-border);
  background: rgba(20, 34, 58, 0.5);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.tool:hover { color: var(--text); border-color: var(--panel-border-strong); background: rgba(52, 84, 138, 0.42); }
.tool.is-on { color: #cfe7ff; border-color: var(--accent); background: var(--accent-soft); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.switch {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 2px;
  user-select: none;
}
.switch input {
  -webkit-appearance: none;
  appearance: none;
  width: 26px; height: 15px;
  border-radius: 999px;
  background: rgba(60, 80, 110, 0.6);
  border: 1px solid var(--panel-border);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background 0.18s;
  margin: 0;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 1.5px; left: 2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #93a7c2;
  transition: transform 0.18s, background 0.18s;
}
.switch input:checked { background: rgba(78, 168, 255, 0.45); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(11px); background: #eaf4ff; }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch:has(input:checked) { color: #cfe0f5; }

/* ============================== 底栏 ============================== */

.bottombar {
  position: absolute;
  left: calc(12px + var(--left-w) + 10px);
  right: calc(12px + var(--right-w) + var(--tool-w) + 20px);
  bottom: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) minmax(180px, 1fr) minmax(200px, 1fr);
  gap: 16px;
  padding: 10px 14px 12px;
  transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
#app.left-collapsed .bottombar { left: 12px; }
#app.right-collapsed .bottombar { right: 12px; }

.time-block, .speed-block, .scale-block { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.time-row { display: flex; flex-direction: column; }
.time-row-2 { flex-direction: row; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

.time-marks {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--muted-dim); font-family: var(--mono);
  padding: 0 2px; margin-top: -3px;
}

.date-input {
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid var(--panel-border);
  background: rgba(6, 12, 22, 0.7);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  color-scheme: dark;
}
.date-input:focus { outline: none; border-color: var(--accent); }

.speed-presets { display: flex; flex-wrap: wrap; gap: 5px; }
.slider-row {
  display: grid;
  grid-template-columns: 62px 1fr 40px;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
}
.slider-row output { font-family: var(--mono); font-size: 11px; color: #b9cde6; text-align: right; }

/* ============================== 信息面板 ============================== */

.info-scroll { flex: 1; overflow-y: auto; padding: 12px 13px 18px; }
.info-empty { color: var(--muted-dim); font-size: 12.5px; line-height: 1.7; margin: 6px 0; }

.info-hero {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 12px;
}
.info-hero-ball {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset, 0 6px 18px rgba(0, 0, 0, 0.6);
}
.info-hero-text { min-width: 0; }
.info-hero-text h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text-strong); }
.info-hero-text p { margin: 2px 0 0; font-size: 11px; color: var(--muted-dim); font-family: var(--mono); }

.info-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 12px; }
.tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  background: rgba(20, 34, 58, 0.4);
}
.tag.is-accent { border-color: rgba(78, 168, 255, 0.5); color: #a9d2ff; background: rgba(78, 168, 255, 0.12); }

.info-summary {
  font-size: 12.5px; line-height: 1.78; color: #b9c9dd;
  margin: 0 0 12px;
}

.info-section { margin-bottom: 14px; }
.info-section h4 {
  margin: 0 0 7px;
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted-dim);
  display: flex; align-items: center; gap: 7px;
}
.info-section h4::after { content: ""; flex: 1; height: 1px; background: var(--panel-border); }

.data-grid { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 12px; }
.data-grid dt { color: var(--muted-dim); white-space: nowrap; }
.data-grid dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 11.5px; color: #d3e2f4; }
.data-grid dd small { color: var(--muted-dim); font-size: 10px; margin-left: 3px; }

.bar-list { display: flex; flex-direction: column; gap: 7px; }
.bar-row { font-size: 11.5px; }
.bar-row-head { display: flex; justify-content: space-between; margin-bottom: 3px; color: var(--muted); }
.bar-row-head b { color: #d3e2f4; font-family: var(--mono); font-weight: 500; }
.bar-track { height: 5px; border-radius: 3px; background: rgba(110, 156, 214, 0.16); overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #3b7fd4, #6fc2ff);
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.fact-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.fact-list li {
  position: relative;
  padding-left: 16px;
  font-size: 12px;
  line-height: 1.68;
  color: #b0c1d6;
}
.fact-list li::before {
  content: "";
  position: absolute; left: 3px; top: 8px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 7px rgba(78, 168, 255, 0.8);
}

.info-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ============================== 弹窗 ============================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 5, 10, 0.68);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  padding: 24px;
}
.modal-bottom { align-items: flex-end; }

.modal-card {
  width: min(680px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg-solid);
  border: 1px solid var(--panel-border-strong);
  border-radius: 14px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.72);
  overflow: hidden;
}
.modal-wide { width: min(1020px, 100%); }
.modal-quiz { width: min(620px, 100%); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-border);
  flex: none;
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-strong); }
.modal-body { padding: 16px; overflow-y: auto; }

.help-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 22px; margin-bottom: 16px; }
.help-grid h3, .modal-body h3 {
  margin: 0 0 9px; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted-dim);
}
.kv { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.kv li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #b0c1d6; }
.kv li kbd { flex: none; }
.help-note { font-size: 12.5px; line-height: 1.8; color: #a4b6cc; margin: 0 0 10px; }
.help-note em { color: #cfe0f5; font-style: normal; }

/* 测验 */
.quiz-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.quiz-head h3 { margin: 0; font-size: 14px; color: var(--text-strong); text-transform: none; letter-spacing: 0; }
.quiz-head span { font-size: 11px; color: var(--muted-dim); font-family: var(--mono); }
.quiz-progress { height: 3px; background: rgba(110, 156, 214, 0.18); border-radius: 3px; margin-bottom: 16px; }
.quiz-progress i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.3s; }
.quiz-q { font-size: 14.5px; line-height: 1.65; margin: 0 0 14px; color: var(--text-strong); }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: rgba(20, 34, 58, 0.4);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  transition: all 0.15s;
}
.quiz-opt:hover { border-color: var(--panel-border-strong); background: rgba(52, 84, 138, 0.4); }
.quiz-opt .key {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  display: grid; place-items: center;
  background: rgba(110, 156, 214, 0.16);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.quiz-opt.is-correct { border-color: var(--ok); background: rgba(88, 214, 141, 0.14); }
.quiz-opt.is-correct .key { background: rgba(88, 214, 141, 0.3); color: #d6ffe6; }
.quiz-opt.is-wrong { border-color: var(--danger); background: rgba(255, 107, 107, 0.12); }
.quiz-opt.is-wrong .key { background: rgba(255, 107, 107, 0.28); }
.quiz-opt:disabled { cursor: default; }
.quiz-explain {
  margin-top: 14px; padding: 11px 13px;
  border-radius: 9px;
  border-left: 3px solid var(--accent);
  background: rgba(78, 168, 255, 0.09);
  font-size: 12.5px; line-height: 1.75; color: #b8cbe0;
}
.quiz-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 10px; }
.quiz-score { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.quiz-result { text-align: center; padding: 20px 0; }
.quiz-result .big { font-size: 40px; font-family: var(--mono); color: var(--accent); }
.quiz-result p { color: var(--muted); font-size: 13px; }

/* 对比 */
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 14px; align-items: end; }
/* 太阳那一组：太阳独占一行占满宽度，行星三个等分在下一行。
   以前太阳和行星挤在同一行四等分格子里，300px 的圆必然顶出弹窗左边界。 */
.compare-grid-sun { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compare-grid-sun .compare-item[data-body="sun"] { grid-column: 1 / -1; }
.compare-item { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
/* 尺寸只由 --d 决定，并用 min() 兜底：即使脚本没跑到也绝不会溢出格子 */
.compare-ball {
  width: min(var(--d, 40px), 100%);
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6) inset, 0 4px 14px rgba(0, 0, 0, 0.5);
}
.compare-name { font-size: 11px; color: var(--muted); text-align: center; }
.compare-name b { display: block; color: #d3e2f4; font-size: 12px; font-weight: 500; }
.compare-note { font-size: 11.5px; color: var(--muted-dim); line-height: 1.75; margin: 16px 0 0; }

/* ============================== 食象模拟 ============================== */

.eclipse-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 30% 20%, #0b1526 0%, #05080f 60%, #02040a 100%);
}

.eclipse-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(8, 14, 26, 0.72);
}
.eclipse-title h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: 0.04em; }
.eclipse-title span { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted-dim); }

.eclipse-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px 1fr; }

.eclipse-side {
  min-height: 0; overflow-y: auto;
  padding: 12px;
  border-right: 1px solid var(--panel-border);
  background: rgba(8, 14, 26, 0.55);
}

.eclipse-types { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 10px; }
.eclipse-type {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 10px;
  text-align: left;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: rgba(20, 34, 58, 0.5);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.eclipse-type b { font-size: 13px; font-weight: 600; color: #cfe0f5; }
.eclipse-type-en { font-size: 10px; color: var(--muted-dim); font-family: var(--mono); }
.eclipse-type-date { font-size: 10.5px; color: var(--muted-dim); font-family: var(--mono); margin-top: 2px; }
.eclipse-type:hover { border-color: var(--panel-border-strong); background: rgba(52, 84, 138, 0.4); }
.eclipse-type.is-on { border-color: var(--accent); background: var(--accent-soft); }
.eclipse-type.is-on b { color: #ffffff; }
.eclipse-next { width: 100%; margin-bottom: 14px; }

.eclipse-facts-title { margin-top: 4px; }
.eclipse-facts { margin: 8px 0 0; }
.eclipse-fact { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed rgba(110, 156, 214, 0.12); }
.eclipse-fact dt { font-size: 11px; color: var(--muted-dim); white-space: nowrap; }
.eclipse-fact dd { margin: 0; font-size: 11.5px; color: #d3e2f4; font-family: var(--mono); text-align: right; }

.eclipse-stage { position: relative; min-height: 0; }
.eclipse-canvas { position: absolute; inset: 0; }
.eclipse-canvas canvas { display: block; }
.eclipse-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.eclipse-label {
  position: absolute;
  transform: translate(-50%, -140%);
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(6, 12, 22, 0.72);
  border: 1px solid var(--panel-border);
  font-size: 10.5px;
  color: #cfe0f5;
  white-space: nowrap;
  font-family: var(--mono);
}

/* 俯视图里那条夹角读数：给点重量，它是这一屏的主角 */
.eclipse-label.is-angle {
  background: rgba(8, 26, 22, 0.86);
  border-color: rgba(98, 214, 168, 0.55);
  color: #8ff0c8;
  font-size: 11.5px;
  padding: 2px 8px;
}

.eclipse-viewbar {
  position: absolute; left: 12px; top: 12px;
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(8, 14, 26, 0.78);
  backdrop-filter: blur(8px);
}
.eclipse-hint {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  font-size: 11.5px; color: var(--muted-dim); line-height: 1.6;
  pointer-events: none;
}

.eclipse-foot {
  flex: none;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 16px 13px;
  border-top: 1px solid var(--panel-border);
  background: rgba(8, 14, 26, 0.72);
}
.eclipse-foot-row { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 10px; }
.eclipse-clock { font-size: 12px; color: #d3e2f4; font-family: var(--mono); white-space: nowrap; }
.eclipse-foot-note { grid-column: 2 / -1; font-size: 10.5px; color: var(--muted-dim); line-height: 1.6; }
.eclipse-foot-row-2 { grid-template-columns: 74px 1fr auto; }
.eclipse-foot output { font-size: 11.5px; color: #d3e2f4; font-family: var(--mono); }

/* 「示意放大」在哪些视角生效 —— 不生效时把整行压暗，并说明原因。
   不这么做的话，用户在「锥尖特写」里拖滑块会觉得控件坏了。 */
.eclipse-boost-scope { display: block; margin-top: 2px; color: #7fb2e8; }
.eclipse-boost-scope::before { content: '· '; }
.eclipse-foot-row.is-inert .eclipse-boost-scope { color: #c9a06a; }
.eclipse-foot-row.is-inert label,
.eclipse-foot-row.is-inert output { opacity: 0.55; }

@media (max-width: 900px) {
  .eclipse-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  /* 侧栏吃掉的高度直接等于画布损失的高度。矮屏上 38vh 太奢侈 —— 实测
     360×640 时画布只剩 125px 高，几乎没法看。 */
  .eclipse-side {
    border-right: none; border-bottom: 1px solid var(--panel-border);
    max-height: min(30vh, 200px);
  }
  .eclipse-types { flex-direction: row; flex-wrap: wrap; }
  .eclipse-type { flex: 1 1 46%; }
  .eclipse-foot { padding: 8px 12px 10px; gap: 6px; }
  .eclipse-foot-row { grid-template-columns: 58px 1fr; }
  .eclipse-clock { grid-column: 1 / -1; }
  .eclipse-foot-note { grid-column: 1 / -1; }
  /* 长说明是参考资料，矮屏上它会把画布挤没；动态的那一行留着 */
  .eclipse-note-long { display: none; }
}

@media (max-width: 640px) {
  .eclipse-head { padding: 8px 12px; }
  .eclipse-title span { display: none; }
}

/* ============================== 加载与错误 ============================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 620px at 50% 38%, rgba(28, 52, 96, 0.42), transparent 66%),
    #04060c;
  padding: 24px;
}

.loader { width: min(460px, 100%); text-align: center; }
.loader-orbit {
  position: relative;
  width: 108px; height: 108px;
  margin: 0 auto 22px;
}
.orbit-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(120, 170, 240, 0.22);
  border-top-color: rgba(120, 170, 240, 0.72);
  animation: spin 3.4s linear infinite;
}
.orbit-ring:nth-child(2) { inset: 15px; animation-duration: 2.3s; animation-direction: reverse; border-top-color: rgba(255, 179, 71, 0.7); }
.orbit-ring:nth-child(3) { inset: 30px; animation-duration: 1.6s; border-top-color: rgba(120, 240, 200, 0.6); }
.orbit-core {
  position: absolute;
  inset: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 34%, #ffeaa8, #ff9d1c 46%, #b8450a);
  box-shadow: 0 0 22px rgba(255, 157, 28, 0.8), 0 0 50px rgba(255, 100, 10, 0.4);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }

.loader-title { margin: 0 0 5px; font-size: 21px; font-weight: 600; color: var(--text-strong); letter-spacing: 0.01em; }
.loader-sub { margin: 0 0 24px; font-size: 12px; color: var(--muted-dim); letter-spacing: 0.05em; }

.progress { margin-bottom: 16px; }
.progress-track {
  height: 5px;
  border-radius: 4px;
  background: rgba(110, 156, 214, 0.16);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, #2f6fd0, #6fc2ff 55%, #a8e0ff);
  box-shadow: 0 0 14px rgba(78, 168, 255, 0.7);
  transition: width 0.28s ease-out;
}
.progress-meta {
  display: flex; justify-content: space-between;
  margin-top: 8px;
  font-size: 11.5px; color: var(--muted-dim); font-family: var(--mono);
}
.loader-steps {
  list-style: none; margin: 0 0 20px; padding: 0;
  display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: center;
  font-size: 11px; color: var(--muted-dim);
}
.loader-steps li { display: flex; align-items: center; gap: 5px; }
.loader-steps li::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: rgba(110, 156, 214, 0.4);
}
.loader-steps li.is-done::before { background: var(--ok); box-shadow: 0 0 6px rgba(88, 214, 141, 0.8); }
.loader-steps li.is-active::before { background: var(--accent); box-shadow: 0 0 8px rgba(78, 168, 255, 0.9); }

.loader-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.fatal-card {
  width: min(620px, 100%);
  background: var(--panel-bg-solid);
  border: 1px solid rgba(255, 107, 107, 0.34);
  border-radius: 14px;
  padding: 22px 24px 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
}
.fatal-card h2 { margin: 0 0 10px; font-size: 17px; color: #ffc9c9; }
.fatal-msg {
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: #ffb3b3; margin: 0 0 14px;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(255, 107, 107, 0.09);
  border-left: 3px solid rgba(255, 107, 107, 0.6);
  word-break: break-word;
}
.fatal-tips { font-size: 12.5px; color: #a9bbd0; line-height: 1.8; }
.fatal-tips ol { margin: 6px 0 12px; padding-left: 20px; }
.fatal-tips li { margin-bottom: 4px; }
.fatal-tips code {
  font-family: var(--mono); font-size: 11.5px;
  background: rgba(110, 156, 214, 0.14); padding: 1px 5px; border-radius: 4px;
}
.fatal-detail-label { color: var(--muted-dim); font-size: 11px; margin: 0 0 4px; }
#fatal-detail {
  max-height: 130px; overflow: auto;
  font-family: var(--mono); font-size: 11px; line-height: 1.6;
  color: #8fa4bd; background: rgba(6, 12, 22, 0.7);
  padding: 9px 11px; border-radius: 8px; margin: 0;
  white-space: pre-wrap; word-break: break-all;
}

/* ============================== 提示条 ============================== */

.toast-stack {
  position: absolute;
  left: 50%;
  bottom: 200px;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(8, 16, 30, 0.9);
  border: 1px solid var(--panel-border-strong);
  font-size: 12.5px;
  color: #cfe0f5;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.24s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================== 窄屏适配 ============================== */

/* 面板开关必须在所有宽度下都可见：折叠按钮本身长在面板内部，面板一旦
   translateX 出屏并 pointer-events:none，就没有任何入口能把它叫回来。
   这两个顶栏按钮是唯一的「复位」出口，因此不能只在窄屏显示。 */
.topbar-toggles { display: flex; gap: 6px; }

@media (max-width: 1500px) {
  :root { --right-w: 300px; --left-w: 232px; }
}

@media (max-width: 1280px) {
  .bottombar { grid-template-columns: 1fr 1fr; }
  .scale-block { grid-column: 1 / -1; }
  .slider-row { grid-template-columns: 58px 1fr 38px; }
}

@media (max-width: 1080px) {
  :root { --left-w: 218px; --right-w: 282px; --tool-w: 84px; }
  .brand-text small { display: none; }
  .clock { min-width: 0; }
  .rate-real { display: none; }
}

@media (max-width: 900px) {
  /* 顶栏在窄屏矮了 6px，同步 --top-h，否则工具栏/底栏会跟它错开一条缝 */
  :root { --top-h: 52px; }
  .topbar { gap: 10px; padding: 0 10px; height: var(--top-h); }
  .brand-text strong { font-size: 13px; }
  .clock-date { font-size: 14px; }
  .clock { padding-left: 10px; min-width: 0; }
  .clock-meta { display: none; }
  .rate { padding-left: 10px; }
  #rate-label { font-size: 11.5px; }
  .topbar-toggles { display: flex; }

  /* 「耳朵」是桌面端折叠面板的入口；窄屏改用抽屉 + 顶栏按钮，故隐藏 */
  .panel-ear { display: none; }

  .sidebar {
    top: auto;
    bottom: 0;
    left: 0 !important;
    right: 0 !important;
    width: 100%;
    max-height: 62vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
    z-index: 8;
  }
  .sidebar.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar.is-collapsed { transform: translateY(110%); }

  /* 工具栏从「贴着右栏的竖条」改为「顶栏下方的一横排」。
     之前它挂在 bottom: calc(12px + 130px)，130px 是拍脑袋的固定值，
     底栏一变高就会互相压住。挪到顶栏下面既不再重叠，也把顶栏与画布之间
     那条空白用了起来。内容超宽时横向滚动，而不是换行把画布顶下去。 */
  .toolbar {
    top: calc(12px + var(--top-h) + 8px);
    bottom: auto;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  #app.right-collapsed .toolbar { right: 10px; }
  .toolbar .tool-group { flex: none; flex-wrap: nowrap; }
  .toolbar .tool-group-col { flex-direction: row; flex-wrap: nowrap; }
  .toolbar .tool-sep { display: none; }
  .toolbar .tool { flex: none; white-space: nowrap; }
  .toolbar .switch { flex: none; white-space: nowrap; padding: 4px 7px; border-radius: 7px; }
  .toolbar .switch:hover { background: rgba(52, 84, 138, 0.35); }

  .bottombar {
    left: 10px !important;
    right: 10px !important;
    bottom: 10px;
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 9px 12px 11px;
    max-height: 44vh;
    overflow-y: auto;
  }
  .help-grid { grid-template-columns: 1fr; gap: 16px; }
  .modal { padding: 12px; }
  .modal-card { max-height: 88vh; }
  .toast-stack { bottom: 260px; }
}

@media (max-width: 560px) {
  .brand-text { display: none; }
  .speed-presets .chip:nth-child(n + 5) { display: none; }
  .time-row-2 .btn { padding: 3px 7px; font-size: 11px; }

  /* 430px 宽的顶栏要放下品牌、时钟、播放控制和 4 个图标按钮。
     这里给每一项定死伸缩行为，并把非必需的文案去掉，避免互相挤压。 */
  .topbar { gap: 8px; padding: 0 8px; }
  .brand { flex: 0 0 auto; }
  .clock { flex: 1 1 auto; min-width: 0; padding-left: 8px; overflow: hidden; }
  .clock-date { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  .rate { flex: 0 0 auto; padding-left: 8px; gap: 5px; }
  /* .rate-value 有 min-width:92px，即使里面两行文字都被隐藏，它仍然占着 92px，
     把时钟挤成一条缝。窄屏下整块去掉 —— 时间流速在底部控制栏里有完整显示。 */
  .rate-value { display: none; }
  .topbar-actions { flex: 0 0 auto; gap: 4px; }
  .topbar-toggles { gap: 4px; }
  /* 全屏在手机上很少用，且可用 F 键触发；腾出位置给时钟 */
  #btn-fullscreen { display: none; }
}

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