/* 深时 · 地球生命46亿年 —— 深色主题 */
:root {
  --bg: #0a0e14;
  --bg2: #101724;
  --panel: #131c2b;
  --line: #223146;
  --text: #e8e4da;
  --muted: #8b97a8;
  --accent: #3fb8af;
  --chapter: #3fb8af;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  display: flex; flex-direction: column;
  overflow-x: hidden; overflow-y: auto;   /* 矮视口可滚, 避免面板互相挤压重叠 */
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; background: var(--bg2);
  border-bottom: 1px solid var(--line); z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: 2px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.now-playing {
  flex: 1; text-align: center; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; min-width: 0;
}
.now-playing #np-era { color: var(--muted); font-size: 13px; margin-right: 10px; }
.now-playing #np-name { font-size: 17px; font-weight: 600; }
.now-playing #np-age {
  margin-left: 10px; font-size: 13px; color: var(--chapter);
  font-variant-numeric: tabular-nums;
}
.controls { display: flex; gap: 8px; align-items: center; }
button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.active { background: var(--accent); color: #06231f; border-color: var(--accent); font-weight: 600; }
.speed-group { display: flex; gap: 4px; }
.speed-group button { padding: 6px 8px; }

/* ---------- 主布局 ---------- */
#layout {
  flex: 1; display: grid; min-height: 460px;
  grid-template-rows: minmax(0, 1fr);   /* 行高=容器高, 不被内容撑爆 */
  grid-template-columns: minmax(0, 5fr) minmax(0, 4fr) minmax(260px, 3fr);
  gap: 14px; padding: 14px 18px 0;
}
#layout > section, #layout > aside { min-height: 0; }  /* 允许在行内收缩 */

/* 场景 */
#scene-panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#scene-stage {
  position: relative; flex: 1; border-radius: 12px; overflow: hidden;
  background: var(--bg2); border: 1px solid var(--line); min-height: 0;
}
#scene-img {
  width: 100%; height: 100%; object-fit: cover; display: none;
  transition: opacity .5s;
}
#scene-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: var(--muted); font-size: 15px;
  background: repeating-linear-gradient(45deg, #101724 0 18px, #0d1420 18px 36px);
}
.scene-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(10,14,20,.55); border: none; font-size: 26px;
  width: 38px; height: 64px; color: #fff; opacity: 0; transition: opacity .25s;
}
#scene-stage:hover .scene-nav { opacity: .9; }
.scene-nav.prev { left: 4px; } .scene-nav.next { right: 4px; }
#scene-dots { position: absolute; bottom: 46px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
#scene-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.35); cursor: pointer; }
#scene-dots i.on { background: var(--chapter); }
#scene-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 14px 10px;
  background: linear-gradient(transparent, rgba(4,7,11,.88));
  font-size: 13px; color: #dfe6ef;
}
#scene-caption b { display: block; font-size: 15px; margin-bottom: 2px; color: #fff; }
#scene-list { display: flex; gap: 6px; height: 52px; }
#scene-list .thumb {
  flex: 1; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg2); overflow: hidden; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); padding: 4px;
}
#scene-list .thumb.on { border-color: var(--chapter); color: var(--text); }
#scene-list .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* 信息 */
#info-panel { overflow-y: auto; min-width: 0; padding-right: 4px; }
#ch-name { font-size: 34px; line-height: 1.15; letter-spacing: 3px; }
#ch-sub { display: flex; gap: 12px; align-items: baseline; margin: 4px 0 10px; color: var(--muted); font-size: 13px; }
#ch-en { text-transform: uppercase; letter-spacing: 2px; }
#ch-range { color: var(--chapter); font-variant-numeric: tabular-nums; font-size: 14px; }
#ch-tag { color: var(--chapter); font-size: 15px; margin-bottom: 8px; }
#ch-narration { font-size: 14.5px; line-height: 1.85; color: #cfd6e0; margin-bottom: 16px; text-align: justify; }
#info-panel h2 { font-size: 15px; color: var(--muted); margin: 10px 0 8px; font-weight: 600; }
#event-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
#event-list li {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font-size: 13px;
}
#event-list li:hover { border-color: var(--chapter); }
#event-list .ev-age {
  display: inline-block; min-width: 86px; color: var(--chapter);
  font-variant-numeric: tabular-nums; font-weight: 600; margin-right: 8px;
}
#event-list .ev-t { font-weight: 600; margin-right: 6px; }
#event-list .ev-d { color: var(--muted); display: block; margin-top: 3px; line-height: 1.6; }

/* 右栏 */
#side-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
#globe-wrap { position: relative; flex: 1; min-height: 180px; border-radius: 12px; background: #04070d; border: 1px solid var(--line); overflow: hidden; }
#globe-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#globe-label {
  position: absolute; bottom: 6px; left: 0; right: 0; text-align: center;
  font-size: 11px; color: var(--muted);
}
#env-table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
#env-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
#env-table td:first-child { color: var(--muted); white-space: nowrap; width: 64px; }
#env-table td:last-child { color: #cfd6e0; }

/* ---------- 物种卡 ---------- */
#species-section { padding: 12px 18px 6px; }
#species-section h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
#species-strip {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px;
  scroll-behavior: smooth;
}
#species-strip::-webkit-scrollbar { height: 6px; }
#species-strip::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.sp-card {
  flex: 0 0 150px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; cursor: default;
}
.sp-card:hover { border-color: var(--chapter); transform: translateY(-2px); transition: .15s; }
.sp-figure {
  height: 96px; display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: rgba(255,255,255,.85); position: relative; overflow: hidden;
}
.sp-figure img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sp-body { padding: 8px 10px; }
.sp-name { font-size: 14px; font-weight: 600; }
.sp-en { font-size: 10.5px; color: var(--muted); font-style: italic; }
.sp-range { font-size: 11px; color: var(--chapter); margin: 3px 0; font-variant-numeric: tabular-nums; }
.sp-desc { font-size: 11.5px; color: var(--muted); line-height: 1.55; }

/* ---------- 时间轴 ---------- */
#timeline-bar { position: relative; padding: 4px 18px 10px; z-index: 5; }
#timeline-canvas { width: 100%; height: 92px; display: block; cursor: ew-resize; touch-action: none; }
#milestone-tip {
  position: absolute; pointer-events: none; display: none; z-index: 20;
  background: #1b2638; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; transform: translate(-50%, -110%);
  white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
#milestone-tip b { color: var(--accent); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  #layout { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
  #side-panel { flex-direction: row; grid-column: 1 / -1; }
  #globe-wrap { height: 180px; flex: 1; }
  #env-table { flex: 1; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  #layout { grid-template-columns: 1fr; }
  #scene-stage { height: 40vw; min-height: 200px; }
  #globe-wrap { height: 220px; }
  .brand-sub, #np-era { display: none; }
}
