/* ============================================================================
 * 日食 · 月食 模拟器 —— 样式
 * 浅色界面 + 深色天幕，与桌面环境明暗一致
 * ========================================================================== */
:root {
  --bg:        #f4f6f9;
  --panel:     #ffffff;
  --panel-2:   #fafbfd;
  --line:      #e2e6ee;
  --line-soft: #eef1f6;
  --ink:       #182031;
  --ink-2:     #59637a;
  --ink-3:     #8b95a8;
  --accent:    #d9551a;
  --accent-2:  #1f6fb2;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(20, 30, 50, .05), 0 6px 18px -8px rgba(20, 30, 50, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ------------------------------------------------------------- 顶栏 */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.brand { display: flex; align-items: baseline; gap: 10px; }

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .2px;
}

.brand .sub {
  color: var(--ink-3);
  font-size: 12px;
}

header .spacer { flex: 1; }

.src {
  color: var(--ink-3);
  font-size: 11.5px;
  text-align: right;
  line-height: 1.4;
}

.src b { color: var(--ink-2); font-weight: 600; }

/* ------------------------------------------------------------- 布局 */
.main {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 348px;
  min-height: 0;
}

.col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.col.left  { border-right: 1px solid var(--line); }
.col.right { border-left: 1px solid var(--line); }

.col-head {
  padding: 11px 14px 9px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}

.col-head h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .6px;
  color: var(--ink-2);
  text-transform: uppercase;
}

/* ------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px 0;
  flex: none;
}

.tab {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: .14s;
}

.tab:hover { background: #fff; color: var(--ink); }

.tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* -------------------------------------------------------- 事件列表 */
.ev-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ev {
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-areas: "date badge mag" "where where where";
  align-items: center;
  gap: 3px 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: .14s;
}

.ev:hover { border-color: #cdd5e2; background: #fff; }

.ev.is-active {
  border-color: var(--accent);
  background: #fff7f2;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.ev.is-next::after {
  content: "下一次";
  grid-area: mag;
  justify-self: end;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: #ffece1;
  border-radius: 20px;
  padding: 1px 7px;
}

.ev-date { grid-area: date; font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }

.ev-badge {
  grid-area: badge;
  font-size: 11px;
  font-weight: 700;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border-radius: 20px;
  padding: 1px 8px;
  white-space: nowrap;
}

.ev-mag {
  grid-area: mag;
  justify-self: end;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.ev.is-next .ev-mag { display: none; }

.ev-where {
  grid-area: where;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --------------------------------------------------------- 舞台 */
.stage {
  position: relative;
  min-height: 0;
  background: #05070f;
  overflow: hidden;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
  pointer-events: none;
}

.stage-top > * { pointer-events: auto; }

.seg {
  display: flex;
  background: rgba(14, 20, 34, .78);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 9px;
  padding: 3px;
  backdrop-filter: blur(8px);
}

.seg button {
  border: 0;
  background: transparent;
  color: #a9b6cd;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: .14s;
}

.seg button:hover { color: #fff; }
.seg button.is-active { background: rgba(255, 255, 255, .92); color: #10151f; }

.tools {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tools button, .tools select {
  background: rgba(14, 20, 34, .78);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #c6d1e4;
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.tools button:hover { color: #fff; border-color: rgba(255,255,255,.28); }

.legend {
  position: absolute;
  left: 12px;
  bottom: 66px;
  z-index: 3;
  background: rgba(14, 20, 34, .78);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 9px;
  padding: 9px 12px;
  color: #a9b6cd;
  font-size: 11.5px;
  line-height: 1.7;
  backdrop-filter: blur(8px);
  max-width: 320px;
}

.legend b { color: #e8eefb; font-weight: 600; }
.legend .k { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }

/* 肉眼视角右下角的「太阳特写」小窗 —— 只画边框，画面由 WebGL 直接渲染在
   画布的同一位置（见 scene-naked.js 的 render 里第二遍渲染）。
   边框尺寸与 INSET_* 常量必须保持一致。 */
.inset-frame {
  position: absolute;
  right: 18px;
  bottom: 78px;
  width: 230px;
  height: 230px;
  z-index: 3;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 6px 22px rgba(0, 0, 0, .45);
  pointer-events: none;
}
.inset-frame span {
  position: absolute;
  left: 9px;
  top: 6px;
  font-size: 11px;
  color: #cfd8ea;
  letter-spacing: .04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}

/* ------------------------------------------------------- 时间轴 */
.timebar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(14, 20, 34, .82);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 11px;
  padding: 9px 14px;
  backdrop-filter: blur(8px);
}

.timebar .stage-legend-off { display: none; }

#playBtn {
  border: 0;
  background: rgba(255, 255, 255, .92);
  color: #10151f;
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}

#timeSlider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .2);
  outline: none;
}

#timeSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
}

#timeSlider::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
}

#timeLabel {
  color: #dbe4f4;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-width: 62px;
  text-align: right;
}

/* ------------------------------------------------------- 数据面板 */
.info {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 28px;
}

.info-head { margin-bottom: 10px; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border-radius: 20px;
  padding: 2px 10px;
  margin-bottom: 7px;
}

.info-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: .2px;
}

.info-head .sub {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
}

.desc {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--panel-2);
  border-left: 3px solid var(--line);
  border-radius: 0 7px 7px 0;
  padding: 9px 12px;
}

.grp { margin-bottom: 15px; }

.grp h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .7px;
  color: var(--ink-3);
  text-transform: uppercase;
}

.grp dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 10px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  overflow: hidden;
}

.grp dt, .grp dd {
  margin: 0;
  padding: 6px 11px;
  background: var(--panel);
  font-size: 12.5px;
}

.grp dt { color: var(--ink-2); white-space: nowrap; }

.grp dd {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.grp dd b { font-weight: 650; }

.note {
  margin: 0 0 14px;
  font-size: 12px;
  color: #8a5a12;
  background: #fff9ec;
  border: 1px solid #f4e3c2;
  border-radius: 8px;
  padding: 8px 11px;
  line-height: 1.5;
}

.live {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--panel-2);
}

.live-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 11px;
  font-size: 12px;
}

.live-row + .live-row { border-top: 1px solid var(--line-soft); }
.live-row span { color: var(--ink-2); }
.live-row b { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--accent); }

/* --------------------------------------------------------- 术语 */
.glossary-wrap { border-top: 1px solid var(--line); flex: none; }

.glossary-wrap summary {
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .5px;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.glossary-wrap summary::-webkit-details-marker { display: none; }
.glossary-wrap summary::before { content: "▸ "; color: var(--ink-3); }
.glossary-wrap[open] summary::before { content: "▾ "; }

.glossary {
  max-height: 250px;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.term { margin-bottom: 11px; }

.term h4 {
  margin: 0 0 2px;
  font-size: 12.5px;
  font-weight: 650;
}

.term h4 span {
  margin-left: 6px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
}

.term p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.55;
}

/* ------------------------------------------------------ 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfd6e2; border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: #b6c0d0; }

/* ------------------------------------------------------ 响应式 */
@media (max-width: 1280px) {
  .main { grid-template-columns: 232px minmax(0, 1fr) 306px; }
}

@media (max-width: 1040px) {
  body { overflow: auto; }
  .main { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .col.left { border-right: 0; border-bottom: 1px solid var(--line); }
  .col.right { border-left: 0; border-top: 1px solid var(--line); }
  .ev-list { max-height: 260px; }
  .stage { height: 62vh; min-height: 420px; }
  .info { max-height: none; }
}
