/* ══════════════════════════════════════════════════════════════════
   地球运动3D互动课堂 · 深空主题
   设计原则：信息层级清晰、数字可读、控件不喧宾夺主
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* 背景层次：从深到浅三级 */
  --bg-0: #05070d;
  --bg-1: #0a0e18;
  --bg-2: #111827;
  --bg-3: #1a2333;

  /* 边框 */
  --line: #1e2a42;
  --line-hi: #2c3d5c;

  /* 文字 */
  --fg-0: #dfe8f5;
  --fg-1: #8ea3c0;
  --fg-2: #5c6f8c;

  /* 强调色（与三维场景保持一致） */
  --acc-green: #6ee7a0;
  --acc-cyan: #4dd0e1;
  --acc-amber: #ffd88a;
  --acc-orange: #ff9f43;
  --acc-red: #ff4d4d;
  --acc-purple: #9b7bff;
  --acc-blue: #7bb8ff;

  --topbar-h: 56px;
  --bottombar-h: 68px;
  --left-w: 232px;
  --right-w: 340px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--bottombar-h);
}

/* ══════════ 顶栏 ══════════ */
#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-icon { display: flex; }
.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 9px;
  color: var(--fg-2);
  letter-spacing: 1.2px;
  white-space: nowrap;
}

/* 顶栏读数 */
.top-readouts { display: flex; gap: 14px; margin-left: auto; }
.ro { display: flex; flex-direction: column; line-height: 1.25; }
.ro label { font-size: 9px; color: var(--fg-2); letter-spacing: .4px; }
.ro span {
  font-size: 12px;
  color: var(--acc-cyan);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 视角切换 */
.view-tabs {
  display: flex;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
}
.view-tab {
  padding: 7px 14px;
  background: transparent;
  border: none;
  color: var(--fg-1);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.view-tab:hover { background: var(--bg-3); color: var(--fg-0); }
.view-tab.active {
  background: var(--acc-green);
  color: #06210f;
  font-weight: 600;
}

.top-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--fg-1);
  cursor: pointer;
  transition: all .15s;
}
.icon-btn:hover { border-color: var(--line-hi); color: var(--fg-0); }
.icon-btn.active { color: var(--acc-green); border-color: rgba(110,231,160,.4); }

/* ══════════ 主体 ══════════ */
#main {
  display: grid;
  grid-template-columns: var(--left-w) 1fr var(--right-w);
  min-height: 0;
  overflow: hidden;
}
body.panel-hidden #main { grid-template-columns: var(--left-w) 1fr 0; }
body.panel-hidden #right-panel { opacity: 0; pointer-events: none; }

/* ───── 左栏 ───── */
#left-panel {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px 8px;
  flex-shrink: 0;
}
.panel-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--fg-0);
}
.panel-hint { font-size: 9px; color: var(--fg-2); text-align: right; }

.layer-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 6px 8px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .12s;
  user-select: none;
}
.layer-row:hover { background: var(--bg-2); }
.layer-row input {
  appearance: none;
  width: 13px; height: 13px;
  border: 1.5px solid var(--line-hi);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.layer-row input:checked {
  background: var(--acc-green);
  border-color: var(--acc-green);
}
.layer-row input:checked::after {
  content: '';
  position: absolute;
  left: 3.5px; top: .5px;
  width: 3px; height: 7px;
  border: solid #06210f;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.layer-swatch {
  width: 11px; height: 2.5px;
  border-radius: 2px;
  flex-shrink: 0;
}
.layer-name { flex: 1; font-size: 12px; color: var(--fg-1); }
.layer-row input:checked ~ .layer-name { color: var(--fg-0); }
.layer-info {
  width: 14px; height: 14px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--fg-2);
  font-size: 9px;
  font-style: italic;
  cursor: help;
  flex-shrink: 0;
}
.layer-row:hover .layer-info { background: var(--acc-cyan); color: var(--bg-0); }

.panel-foot {
  padding: 9px 12px 11px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.note {
  font-size: 10px;
  line-height: 1.55;
  color: var(--fg-2);
}
.note strong { color: var(--acc-amber); font-weight: 600; }

/* ───── 中央视口 ───── */
#center { position: relative; min-width: 0; overflow: hidden; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; }

#status-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5,7,13,.85);
  color: var(--fg-1);
  font-size: 13px;
  z-index: 5;
}

/* 侧视小窗 */
#inset-host {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 168px;
  z-index: 4;
}
#inset-host canvas {
  width: 168px;
  height: 168px;
  display: block;
  border: 1px solid var(--line-hi);
  border-radius: 8px;
  background: #080b12;
  box-shadow: 0 4px 20px rgba(0,0,0,.55);
}
.inset-label {
  text-align: center;
  font-size: 9px;
  color: var(--fg-2);
  margin-bottom: 4px;
  letter-spacing: .2px;
}

#view-note {
  position: absolute;
  left: 12px; bottom: 12px;
  font-size: 10px;
  color: var(--fg-2);
  background: rgba(10,14,24,.72);
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--line);
  pointer-events: none;
}

/* ───── 右栏 ───── */
#right-panel {
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
  transition: opacity .2s;
}

.card {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}
.card .panel-head select {
  background: var(--bg-0);
  border: 1px solid var(--line-hi);
  border-radius: 5px;
  color: var(--fg-0);
  font-size: 11px;
  font-family: inherit;
  padding: 4px 6px;
  cursor: pointer;
  max-width: 150px;
}
.card .panel-head select:focus { outline: none; border-color: var(--acc-cyan); }

/* 观测点输入 */
.obs-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 0 12px 9px;
}
.field {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-0);
  border: 1px solid var(--line-hi);
  border-radius: 5px;
  padding: 4px 7px;
}
.field:focus-within { border-color: var(--acc-cyan); }
.field span { font-size: 10px; color: var(--fg-2); flex-shrink: 0; }
.field input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--fg-0);
  font-size: 12px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.field input:focus { outline: none; }
.field em {
  font-size: 10px;
  color: var(--acc-amber);
  font-style: normal;
  flex-shrink: 0;
}

/* 数据网格 */
.obs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.obs-grid .cell {
  background: var(--bg-1);
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.obs-grid .cell.wide { grid-column: span 3; }
.obs-grid label { font-size: 9px; color: var(--fg-2); }
.obs-grid output {
  font-size: 13px;
  color: var(--fg-0);
  font-variant-numeric: tabular-nums;
}
.obs-grid output.hi { color: var(--acc-amber); font-size: 15px; font-weight: 600; }

.subsection-title {
  font-size: 10px;
  color: var(--fg-2);
  padding: 0 12px 5px;
  letter-spacing: .3px;
}

/* 图表 */
.chart {
  width: 100%;
  height: 132px;
  display: block;
  margin: 0 12px;
  width: calc(100% - 24px);
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.chart-slim { height: 96px; }
.chart-note {
  margin: 5px 12px 0;
  font-size: 9.5px;
  color: var(--fg-2);
  line-height: 1.5;
}

/* ══════════ 底栏 ══════════ */
#bottombar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: linear-gradient(0deg, var(--bg-2), var(--bg-1));
  border-top: 1px solid var(--line);
  z-index: 20;
  overflow-x: auto;
}

.ctl-group { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

.slider-label {
  font-size: 10px;
  color: var(--fg-2);
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  white-space: nowrap;
}
.slider-label span {
  font-size: 12px;
  color: var(--fg-0);
  font-variant-numeric: tabular-nums;
}

input[type=range] {
  appearance: none;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--acc-cyan);
  border: 2px solid var(--bg-0);
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb:hover { background: var(--acc-green); }
.date-ctl input { width: 190px; }
.time-ctl input { width: 130px; }
.rotation-ctl input { width: 90px; }

.mini-btn {
  background: var(--bg-0);
  border: 1px solid var(--line-hi);
  border-radius: 5px;
  color: var(--fg-1);
  font-size: 11px;
  font-family: inherit;
  padding: 5px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.mini-btn:hover { border-color: var(--acc-cyan); color: var(--fg-0); }
.mini-btn.active {
  background: var(--acc-green);
  border-color: var(--acc-green);
  color: #06210f;
  font-weight: 600;
}

.season-jump select {
  background: var(--bg-0);
  border: 1px solid var(--line-hi);
  border-radius: 5px;
  color: var(--fg-0);
  font-size: 11px;
  font-family: inherit;
  padding: 5px 7px;
  cursor: pointer;
}
.season-jump select:focus { outline: none; border-color: var(--acc-cyan); }

.play-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-hi);
  background: var(--bg-0);
  color: var(--fg-0);
  font-size: 13px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .15s;
}
.play-btn.playing {
  background: var(--acc-green);
  border-color: var(--acc-green);
  color: #06210f;
}
.play-btn:hover { transform: scale(1.08); }

.speed-label {
  font-size: 11px;
  color: var(--acc-amber);
  font-variant-numeric: tabular-nums;
  min-width: 62px;
  text-align: center;
}

/* ══════════ 说明弹层 ══════════ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3,5,10,.78);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal.show { display: flex; }
.modal-box {
  position: relative;
  max-width: 640px;
  max-height: 84vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line-hi);
  border-radius: 12px;
  padding: 26px 30px;
  line-height: 1.75;
}
.modal-box h2 {
  margin: 0 0 16px;
  font-size: 17px;
  color: var(--acc-green);
}
.modal-box h3 {
  margin: 18px 0 6px;
  font-size: 13px;
  color: var(--acc-cyan);
  font-weight: 600;
}
.modal-box p, .modal-box li { font-size: 12.5px; color: var(--fg-1); }
.modal-box b { color: var(--fg-0); }
.modal-box ul, .modal-box ol { margin: 6px 0; padding-left: 20px; }
.modal-box li { margin: 4px 0; }
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line-hi);
  background: var(--bg-0);
  color: var(--fg-1);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--fg-0); border-color: var(--acc-red); }

/* ══════════ 滚动条 ══════════ */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--line-hi); }

/* ══════════ 窄屏适配 ══════════ */
@media (max-width: 1280px) {
  :root { --right-w: 300px; --left-w: 200px; }
  .top-readouts { display: none; }
}
@media (max-width: 1024px) {
  :root { --right-w: 0px; --left-w: 190px; }
  #right-panel { position: absolute; right: 0; top: var(--topbar-h);
                 bottom: var(--bottombar-h); width: 300px; z-index: 30; }
  body.panel-hidden #right-panel { display: none; }
}