:root {
  --bg: #14100d;
  --bg-2: #1c1712;
  --panel: #241d16;
  --panel-2: #2d251b;
  --line: #443626;
  --gold: #d4a349;
  --gold-2: #b8862a;
  --gold-soft: #ecd39a;
  --red: #b13a2e;
  --red-2: #8a2c22;
  --text: #f2e6d2;
  --text-2: #c9b48f;
  --text-dim: #8a7c65;

  /* 朝代主色 */
  --c-myth: #7a5da8;
  --c-ancient: #8a7c4b;
  --c-xia: #6f7f4e;
  --c-shang: #7a5c3a;
  --c-zhou: #a37b3e;
  --c-qin: #4c4a52;
  --c-han: #b13a2e;
  --c-xin: #7e5533;
  --c-wei: #5c6a7a;
  --c-shu: #2f6b52;
  --c-wu: #3a5f8a;
  --c-jin: #a8894a;
  --c-shiliu: #6b5a4a;
  --c-nchao: #7a4a6a;
  --c-bchao: #4a6a7a;
  --c-sui: #6a5a8a;
  --c-tang: #c15d4a;
  --c-wudai: #8a6a4a;
  --c-shiguo: #6a7a5a;
  --c-song: #4d8a76;
  --c-liao: #6a8ca8;
  --c-xixia: #b8834a;
  --c-jin2: #a89050;
  --c-yuan: #4a5a8c;
  --c-ming: #b13a2e;
  --c-qing: #8a5a3a;
  --c-mg: #4a7ab8;
  --c-prc: #d4453a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
               "STFangsong", "STKaiti", "KaiTi", serif;
  overflow-x: hidden;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 8%, rgba(212, 163, 73, 0.06), transparent 45%),
    radial-gradient(circle at 88% 82%, rgba(177, 58, 46, 0.05), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

/* ============ 顶栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(180deg, #1c1611 0%, #14100d 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-2) 100%);
  color: #fff8e6;
  border-radius: 6px;
  font-size: 26px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 160, 0.35),
              0 3px 10px rgba(177, 58, 46, 0.4);
  font-family: "STKaiti", "KaiTi", serif;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gold-soft);
}

.brand-sub {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-top: 2px;
}

.view-tabs { display: flex; gap: 4px; }
.view-tab {
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
  padding: 8px 18px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  transition: all 0.2s;
  font-family: inherit;
  letter-spacing: 2px;
}
.view-tab:hover { background: rgba(212,163,73,0.08); color: var(--gold-soft); }
.view-tab.active {
  background: linear-gradient(180deg, #3b2a1c 0%, #2a1f17 100%);
  color: var(--gold);
  border-color: var(--gold-2);
}

/* ============ 时代筛选栏 ============ */
.era-bar {
  position: sticky;
  top: 76px;
  z-index: 29;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  background: rgba(20,16,13,0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(74,56,38,0.5);
  flex-wrap: wrap;
}

.era {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
  letter-spacing: 1px;
}
.era:hover { border-color: var(--gold-2); color: var(--gold-soft); }
.era.active {
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  color: #14100d;
  border-color: var(--gold);
  font-weight: 700;
}

.search-wrap { margin-left: auto; }
#search {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
  width: 200px;
  outline: none;
  transition: all 0.2s;
}
#search:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212,163,73,0.15); }

.view { display: none; position: relative; z-index: 1; }
.view.active { display: block; }

/* ============ 朝代脉络 ============ */
.dyn-timeline {
  max-width: 1280px;
  margin: 30px auto 60px;
  padding: 0 24px;
}

/* 时代段落 */
.era-block {
  margin-bottom: 40px;
  position: relative;
}

.era-title {
  font-size: 22px;
  color: var(--gold-soft);
  letter-spacing: 6px;
  font-family: "STKaiti", "KaiTi", serif;
  padding-left: 14px;
  border-left: 3px solid var(--gold);
  margin-bottom: 4px;
}
.era-range {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 2px;
  padding-left: 16px;
  margin-bottom: 18px;
}
.era-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.85;
  padding-left: 16px;
  margin-bottom: 20px;
  max-width: 900px;
}

.dyn-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 单朝代（独占一行） */
.dyn-row.single .dyn-card { width: 100%; }

/* 并行朝代（多列） */
.dyn-row.parallel {
  display: grid;
  gap: 12px;
}
.dyn-row.parallel.cols-2 { grid-template-columns: 1fr 1fr; }
.dyn-row.parallel.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.dyn-row.parallel.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.dyn-parallel-hint {
  font-size: 11px;
  color: var(--gold-2);
  letter-spacing: 2px;
  padding-left: 4px;
  margin-bottom: -4px;
}

.dyn-card {
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--line);
  border-left: 5px solid var(--dyn-color, var(--gold));
  border-radius: 6px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
}

.dyn-card:hover {
  transform: translateY(-2px);
  border-color: var(--dyn-color, var(--gold));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
}

.dyn-card.hidden { display: none; }

.dyn-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.dyn-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 3px;
  font-family: "STKaiti", "KaiTi", serif;
}
.dyn-full {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.dyn-range {
  margin-left: auto;
  font-size: 12px;
  color: var(--dyn-color, var(--gold));
  letter-spacing: 1px;
  font-weight: 600;
}

.dyn-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.dyn-meta b { color: var(--text-2); font-weight: 500; }

.dyn-brief {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.75;
}
.dyn-brief .kw { color: var(--gold-soft); font-weight: 600; }
.dyn-brief .kw-red { color: #ff9d85; font-weight: 600; }

.dyn-highlights {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hl-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(212,163,73,0.1);
  border: 1px solid rgba(212,163,73,0.25);
  color: var(--gold-soft);
}

.dyn-more {
  margin-top: 10px;
  font-size: 11px;
  color: var(--gold-2);
  letter-spacing: 2px;
}
.dyn-more::after {
  content: " →";
  transition: transform 0.2s;
  display: inline-block;
}
.dyn-card:hover .dyn-more::after { transform: translateX(3px); }

/* ============ 帝王卡库 ============ */
.ruler-wrap {
  max-width: 1280px;
  margin: 30px auto 60px;
  padding: 0 24px;
}

.ruler-section {
  margin-bottom: 32px;
}

.ruler-section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.rs-name {
  font-size: 20px;
  color: var(--gold-soft);
  letter-spacing: 4px;
  font-family: "STKaiti", "KaiTi", serif;
}
.rs-range { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; }
.rs-count { margin-left: auto; font-size: 12px; color: var(--gold-2); letter-spacing: 1px; }

.ruler-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.ruler-card {
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--line);
  border-left: 3px solid var(--dyn-color, var(--gold));
  border-radius: 4px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.ruler-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.ruler-card.hidden { display: none; }

.rc-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.rc-title {
  font-size: 16px;
  color: var(--gold-soft);
  letter-spacing: 2px;
  font-family: "STKaiti", "KaiTi", serif;
  font-weight: 700;
}
.rc-name { font-size: 12px; color: var(--text-2); }
.rc-reign {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.rc-brief {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
  margin-top: 6px;
}
.rc-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.rc-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(212,163,73,0.1);
  color: var(--gold-soft);
  border: 1px solid rgba(212,163,73,0.2);
}
.rc-tag.death { background: rgba(193,93,74,0.15); border-color: rgba(193,93,74,0.35); color: #e69987; }
.rc-tag.ascend { background: rgba(139,179,122,0.12); border-color: rgba(139,179,122,0.3); color: #a8cf94; }
.rc-tag.coup { background: rgba(193,93,74,0.15); border-color: rgba(193,93,74,0.3); color: #e69987; }

/* ============ 大事记 ============ */
.events-wrap {
  max-width: 900px;
  margin: 30px auto 60px;
  padding: 0 24px;
  position: relative;
}
.events-wrap::before {
  content: "";
  position: absolute;
  left: 40px;
  top: 20px;
  bottom: 20px;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--gold-2), var(--red-2), transparent);
  opacity: 0.7;
}

.event-item {
  display: flex;
  gap: 20px;
  margin-bottom: 22px;
  position: relative;
}
.event-item.hidden { display: none; }

.ev-year-col {
  flex-shrink: 0;
  width: 80px;
  text-align: right;
  padding-top: 12px;
  position: relative;
  z-index: 1;
}
.ev-year-col::after {
  content: "";
  position: absolute;
  right: -22px;
  top: 20px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--gold-2);
}
.event-item.big .ev-year-col::after {
  background: var(--red);
  box-shadow: 0 0 0 2px var(--red-2), 0 0 10px rgba(200,60,40,0.4);
  width: 14px;
  height: 14px;
}
.ev-year {
  font-size: 14px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 1px;
  font-family: "STKaiti", "KaiTi", serif;
}
.ev-year-full {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

.ev-content {
  flex: 1;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 4px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 12px;
}
.ev-content:hover {
  transform: translateX(3px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  border-left-color: var(--gold);
}
.event-item.big .ev-content { border-left-color: var(--red); border-left-width: 5px; }

.ev-name {
  font-size: 16px;
  color: var(--gold-soft);
  font-weight: 700;
  letter-spacing: 2px;
  font-family: "STKaiti", "KaiTi", serif;
  margin-bottom: 4px;
}
.event-item.big .ev-name { color: #ffb8a3; font-size: 18px; }

.ev-context {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.ev-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.75;
}
.ev-desc .kw { color: var(--gold-soft); font-weight: 600; }
.ev-desc .kw-red { color: #ff9d85; font-weight: 600; }

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 4, 3, 0.78);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }

.modal-box {
  background: linear-gradient(180deg, #2f2318 0%, #241a12 100%);
  border: 1px solid var(--gold-2);
  border-radius: 8px;
  max-width: 720px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px 30px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 10px;
}
.modal-close:hover { color: var(--gold); }

.md-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 16px;
}
.md-title {
  font-size: 26px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 4px;
  font-family: "STKaiti", "KaiTi", serif;
  margin-bottom: 4px;
}
.md-sub {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.md-section { margin-bottom: 16px; }
.md-label {
  color: var(--gold-2);
  font-size: 12px;
  letter-spacing: 3px;
  margin-bottom: 6px;
}
.md-content {
  color: var(--text);
  line-height: 1.85;
  font-size: 14px;
}
.md-content .kw { color: var(--gold-soft); font-weight: 600; }
.md-content .kw-red { color: #ff9d85; font-weight: 600; }

.ruler-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.ruler-list .ruler-card { border-left-width: 2px; padding: 8px 10px; }
.ruler-list .rc-title { font-size: 14px; }
.ruler-list .rc-brief { font-size: 11px; }

.md-event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.md-event-tags .ev-mini {
  font-size: 11px;
  padding: 3px 10px;
  background: rgba(177,58,46,0.15);
  border: 1px solid rgba(200,60,40,0.4);
  border-radius: 999px;
  color: #ffb8a3;
  cursor: pointer;
  transition: all 0.2s;
}
.md-event-tags .ev-mini:hover { background: rgba(177,58,46,0.3); }

/* ============ Footer ============ */
.footer {
  text-align: center;
  padding: 20px 20px 30px;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 1px;
  border-top: 1px solid var(--line);
  margin-top: 20px;
  line-height: 1.7;
}

/* ============ Responsive ============ */
@media (max-width: 820px) {
  .dyn-row.parallel.cols-2,
  .dyn-row.parallel.cols-3,
  .dyn-row.parallel.cols-4 { grid-template-columns: 1fr; }
  .brand-title { font-size: 16px; }
  .view-tab { padding: 6px 10px; font-size: 12px; }
  .events-wrap::before { left: 22px; }
  .ev-year-col { width: 48px; }
  .ev-year { font-size: 12px; }
}

/* ============================================================
   顶部 Gantt 全览条
   ============================================================ */
.gantt-wrap {
  max-width: 1280px;
  margin: 20px auto 0;
  padding: 16px 24px;
  background: linear-gradient(180deg, rgba(36,29,22,0.7), rgba(28,23,18,0.7));
  border: 1px solid var(--line);
  border-radius: 8px;
  position: relative;
}

.gantt-title {
  font-size: 12px;
  color: var(--gold-2);
  letter-spacing: 3px;
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.gantt-title .gantt-hint {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-left: auto;
}

.gantt-svg {
  width: 100%;
  display: block;
  overflow: visible;
}
.gantt-bar { transition: opacity 0.2s; }
.gantt-bar:hover rect {
  opacity: 1 !important;
  stroke: var(--gold);
  stroke-width: 1.2;
}
.gantt-svg text { font-family: "PingFang SC", "STKaiti", serif; }

.gantt-bar {
  cursor: pointer;
  transition: opacity 0.15s;
}
.gantt-bar:hover { opacity: 0.7; }

.gantt-bar-label {
  fill: #f2e6d2;
  font-size: 10px;
  pointer-events: none;
  font-family: "STKaiti", "KaiTi", serif;
  letter-spacing: 1px;
}
.gantt-axis-line { stroke: rgba(212,163,73,0.35); stroke-width: 1; }
.gantt-axis-tick { stroke: rgba(212,163,73,0.5); stroke-width: 1; }
.gantt-axis-label { fill: var(--text-dim); font-size: 10px; }

.gantt-tooltip {
  position: absolute;
  background: #1a1410;
  border: 1px solid var(--gold-2);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--gold-soft);
  pointer-events: none;
  z-index: 40;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  display: none;
}

/* ============================================================
   朝代间过渡指示 (箭头)
   ============================================================ */
.dyn-transition {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 -4px 6px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.dyn-transition .tr-arrow {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 14px;
  background: rgba(0,0,0,0.3);
}
.dyn-transition.type-peaceful .tr-arrow { border-color: var(--ascend-inherit, #8bb37a); color: #8bb37a; }
.dyn-transition.type-battle   .tr-arrow { border-color: var(--red); color: #ff9d85; }
.dyn-transition.type-coup     .tr-arrow { border-color: #b48ad8; color: #b48ad8; }
.dyn-transition.type-usurp    .tr-arrow { border-color: var(--gold); color: var(--gold); }
.dyn-transition.type-uprising .tr-arrow { border-color: #e07d4a; color: #e07d4a; }
.dyn-transition.type-migration .tr-arrow { border-color: #7ea8d4; color: #7ea8d4; }

.dyn-transition .tr-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
  max-width: 100px;
}

/* ============================================================
   朝代卡片增强 - 查看详情按钮
   ============================================================ */
.dyn-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.dyn-btn {
  display: inline-block;
  padding: 4px 12px;
  font-size: 11px;
  border-radius: 3px;
  border: 1px solid var(--dyn-color, var(--gold));
  color: var(--dyn-color, var(--gold));
  text-decoration: none;
  letter-spacing: 1px;
  transition: all 0.2s;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}
.dyn-btn:hover {
  background: var(--dyn-color, var(--gold));
  color: #1a1410;
}
.dyn-btn.primary {
  background: var(--dyn-color, var(--gold));
  color: #1a1410;
  font-weight: 700;
}
.dyn-btn.primary:hover {
  filter: brightness(1.15);
}

/* 朝代内小型持续时间条 */
.dyn-duration-bar {
  margin-top: 8px;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.dyn-duration-bar .fill {
  height: 100%;
  background: var(--dyn-color, var(--gold));
  border-radius: 2px;
  opacity: 0.7;
}
.dyn-duration-info {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
  letter-spacing: 0.5px;
}

/* 时代块头部数据 */
.era-stats {
  display: flex;
  gap: 20px;
  margin: 4px 0 12px 16px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.era-stats b { color: var(--gold-2); font-weight: 500; margin-right: 3px; }

/* ============================================================
   朝代详情页 (dynasty.html) 专属样式
   ============================================================ */
.dp-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.dp-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  margin-bottom: 12px;
  transition: all 0.2s;
}
.dp-back:hover { color: var(--gold); border-color: var(--gold-2); }

.dp-title-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.dp-title {
  font-size: 40px;
  font-weight: 700;
  color: var(--dyn-color, var(--gold));
  letter-spacing: 8px;
  font-family: "STKaiti", "KaiTi", serif;
  text-shadow: 0 0 20px rgba(212, 163, 73, 0.15);
}
.dp-fullname {
  font-size: 14px;
  color: var(--gold-soft);
  letter-spacing: 3px;
}
.dp-range {
  font-size: 14px;
  color: var(--dyn-color, var(--gold));
  letter-spacing: 2px;
  margin-left: auto;
  font-family: "STKaiti", "KaiTi", serif;
}

.dp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 12px;
  color: var(--text-dim);
  margin: 6px 0 12px;
  letter-spacing: 1px;
}
.dp-meta b { color: var(--text-2); font-weight: 500; }

.dp-brief {
  max-width: 900px;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.85;
  margin-bottom: 12px;
}
.dp-brief .kw { color: var(--gold-soft); font-weight: 600; }
.dp-brief .kw-red { color: #ff9d85; font-weight: 600; }

.dp-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dp-highlights .hl-tag { cursor: default; }

/* 时间线 */
.dp-timeline {
  position: relative;
  max-width: 1180px;
  margin: 40px auto 60px;
  padding: 0 24px;
}
.dp-timeline::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: linear-gradient(180deg,
    transparent 0%,
    var(--dyn-color, var(--gold)) 6%,
    var(--dyn-color, var(--gold)) 94%,
    transparent 100%);
  opacity: 0.85;
  box-shadow: 0 0 8px currentColor;
  color: var(--dyn-color, var(--gold));
  border-radius: 3px;
}

.dp-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 0;
  margin-bottom: 30px;
  min-height: 120px;
}

.dp-row.event-row { min-height: unset; margin-bottom: 20px; }

.dp-node {
  grid-column: 2 / 3;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.dp-node-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 3px solid var(--dyn-color, var(--gold));
  box-shadow: 0 0 0 4px rgba(20, 16, 13, 1),
              0 0 10px currentColor;
  color: var(--dyn-color, var(--gold));
  position: relative;
  z-index: 3;
}
.dp-node-marker.coup    { border-color: #c15d4a; color: #c15d4a; }
.dp-node-marker.eunuch  { border-color: #b48ad8; color: #b48ad8; }
.dp-node-marker.battle  { border-color: #e07d4a; color: #e07d4a; }
.dp-node-marker.abdicate{ border-color: var(--gold); color: var(--gold); }

.dp-node-year {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  letter-spacing: 1px;
}

.dp-order-badge {
  position: absolute;
  top: -20px;
  font-size: 10px;
  color: var(--gold-2);
  letter-spacing: 2px;
}

/* 皇帝卡片（同 tang-timeline 样式） */
.dp-card {
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 2;
}
.dp-card:hover {
  border-color: var(--dyn-color, var(--gold));
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(212, 163, 73, 0.18);
}

.dp-card.left  { grid-column: 1 / 2; margin-right: 24px; text-align: right; }
.dp-card.right { grid-column: 3 / 4; margin-left: 24px; text-align: left; }

.dp-card::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 22px;
  height: 2px;
  background: var(--line);
  transform: translateY(-1px);
}
.dp-card.left::after  { right: -22px; }
.dp-card.right::after { left: -22px; }

.dp-c-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.dp-card.left .dp-c-head { justify-content: flex-end; }

.dp-c-order {
  font-size: 10px;
  color: var(--gold-2);
  letter-spacing: 2px;
  padding: 1px 6px;
  border: 1px solid var(--gold-2);
  border-radius: 3px;
}
.dp-c-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 2px;
  font-family: "STKaiti", "KaiTi", serif;
}
.dp-c-name {
  font-size: 12px;
  color: var(--text-2);
}
.dp-c-reign {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.dp-c-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.dp-card.left .dp-c-tags { justify-content: flex-end; }

.dp-c-brief {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
}
.dp-c-brief .kw { color: var(--gold-soft); font-weight: 600; }
.dp-c-brief .kw-red { color: #ff9d85; font-weight: 600; }

/* 事件（内嵌在时间线） */
.dp-event-inline {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  margin: 2px 0;
  position: relative;
  z-index: 2;
}
.dp-event-box {
  background: linear-gradient(135deg, rgba(177, 58, 46, 0.18), rgba(139, 30, 20, 0.1));
  border: 1px solid rgba(200, 60, 40, 0.5);
  border-left: 3px solid var(--red);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 12px;
  color: #eecbb2;
  cursor: pointer;
  max-width: 720px;
  transition: all 0.2s;
}
.dp-event-box:hover {
  background: linear-gradient(135deg, rgba(177, 58, 46, 0.3), rgba(139, 30, 20, 0.2));
}
.dp-event-box .ev-year {
  color: var(--gold);
  font-weight: 700;
  margin-right: 8px;
}
.dp-event-box .ev-name {
  color: #ffb8a3;
  font-weight: 700;
  margin-right: 6px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 13px;
}
.dp-event-box.big {
  border-left-width: 5px;
  background: linear-gradient(135deg, rgba(200, 60, 40, 0.28), rgba(139, 30, 20, 0.15));
}
.dp-event-box.big .ev-name { font-size: 14px; }

/* 简介概要栏（大事变时间线下方或独立视图） */
.dp-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 1px;
}
.dp-empty a { color: var(--gold); }

/* 手机适配 */
@media (max-width: 820px) {
  .dp-title { font-size: 30px; letter-spacing: 4px; }
  .dp-timeline { padding: 0 12px; }
  .dp-timeline::before { left: 32px; }
  .dp-row { grid-template-columns: 64px 1fr; }
  .dp-node { grid-column: 1 / 2; }
  .dp-card.left, .dp-card.right {
    grid-column: 2 / 3;
    text-align: left;
    margin-left: 20px;
    margin-right: 0;
  }
  .dp-card.left .dp-c-head,
  .dp-card.left .dp-c-tags { justify-content: flex-start; }
  .dp-card.left::after { left: -20px; right: auto; }
  .gantt-svg { height: 100px; }
}

/* ============================================================
   顶部 AI 免责声明栏
   ============================================================ */
.ai-notice {
  position: relative;
  z-index: 40;
  text-align: center;
  padding: 6px 16px;
  font-size: 11.5px;
  letter-spacing: 1px;
  color: #e8d3a8;
  background: linear-gradient(90deg,
    rgba(139, 30, 20, 0.5) 0%,
    rgba(177, 58, 46, 0.55) 50%,
    rgba(139, 30, 20, 0.5) 100%);
  border-bottom: 1px solid rgba(212, 163, 73, 0.35);
}
.ai-notice a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px dotted var(--gold-2);
  padding-bottom: 1px;
}
.ai-notice a:hover { color: #ffe9bd; }

/* 顶栏与筛选栏的 sticky 偏移需让开公告栏，改为不吸顶更稳妥 */
.topbar { top: 0; }

@media (max-width: 820px) {
  .ai-notice { font-size: 10.5px; letter-spacing: 0; padding: 5px 10px; }
}

/* ============================================================
   帝王画像 / 事件配图
   ============================================================ */

/* --- 通用画像框 ---
   占位字与 <img> 需「叠放」而非上下排列：
   img 绝对定位铺满，有图时完全遮住占位字；
   图片加载失败时 onerror 移除 img，占位字自然显露。 */
.portrait {
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: linear-gradient(160deg, #3a2c1e, #241a12);
  border: 1px solid var(--line);
  position: relative;
  display: grid;
  place-items: center;
}
.portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  display: block;
  /* 透明 PNG 需自带底色，否则会透出下层占位字 */
  background: linear-gradient(160deg, #3a2c1e, #241a12);
}
/* 无画像时的占位：用姓名首字 */
.portrait .ph-fallback {
  font-family: "STKaiti", "KaiTi", serif;
  color: rgba(212, 163, 73, 0.5);
  font-weight: 700;
  user-select: none;
  line-height: 1;
}

/* 帝王卡库卡片内的小头像 */
.ruler-card .rc-body {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.ruler-card .portrait {
  width: 52px;
  height: 66px;
}
.ruler-card .portrait .ph-fallback { font-size: 24px; }
.ruler-card .rc-text { flex: 1; min-width: 0; }

/* 朝代详情页时间线卡片内的头像 */
.dp-card .dp-c-body {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.dp-card.left .dp-c-body { flex-direction: row-reverse; }
.dp-card .portrait {
  width: 66px;
  height: 84px;
}
.dp-card .portrait .ph-fallback { font-size: 30px; }
.dp-card .dp-c-text { flex: 1; min-width: 0; }

/* 弹窗内的大画像 */
.md-portrait-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.md-portrait {
  flex-shrink: 0;
  width: 132px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--gold-2);
  background: linear-gradient(160deg, #3a2c1e, #241a12);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.md-portrait img {
  width: 100%;
  display: block;
  object-fit: cover;
}
.md-portrait .ph-fallback {
  display: grid;
  place-items: center;
  height: 168px;
  font-size: 56px;
  font-family: "STKaiti", "KaiTi", serif;
  color: rgba(212, 163, 73, 0.45);
}
.md-portrait-body { flex: 1; min-width: 0; }

/* 图片来源标注 */
.img-credit {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 5px;
  letter-spacing: 0.5px;
  line-height: 1.5;
}
.img-credit a { color: var(--gold-2); text-decoration: none; }
.img-credit a:hover { color: var(--gold); }

/* --- 事件配图 --- */
.ev-thumb {
  float: right;
  width: 128px;
  margin: 0 0 8px 14px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #241a12;
}
.ev-thumb img { width: 100%; display: block; }

.md-event-img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--line);
  margin-bottom: 12px;
  display: block;
}

/* 大事记列表中的事件缩略图 */
.event-item .ev-content { overflow: hidden; }

@media (max-width: 640px) {
  .ev-thumb { width: 92px; margin-left: 10px; }
  .md-portrait { width: 100px; }
  .md-portrait .ph-fallback { height: 128px; font-size: 42px; }
  .md-portrait-row { gap: 12px; }
}

/* ============================================================
   长河演义 · 动画演示
   ============================================================ */
.view-tab.saga-tab { color: var(--gold); }
.view-tab.saga-tab.active {
  background: linear-gradient(135deg, var(--red-2), var(--red));
  color: #fff3dc;
  border-color: var(--gold);
}

/* --- 控制栏 --- */
.saga-bar {
  position: sticky;
  top: 76px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 28px;
  background: rgba(20, 16, 13, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.saga-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 1px;
  transition: all 0.2s;
}
.saga-btn:hover { border-color: var(--gold-2); color: var(--gold-soft); }
.saga-btn.primary {
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  border-color: var(--gold);
  color: #1a1410;
  font-weight: 700;
}
.saga-btn.primary:hover { filter: brightness(1.12); }

.saga-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.saga-sp {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  padding: 3px 9px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  transition: all 0.2s;
}
.saga-sp:hover { border-color: var(--gold-2); }
.saga-sp.active {
  background: var(--gold-2);
  border-color: var(--gold);
  color: #1a1410;
  font-weight: 700;
}
.saga-check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.saga-check input { accent-color: var(--gold); cursor: pointer; }

.saga-status {
  font-size: 12px;
  color: var(--gold-soft);
  letter-spacing: 1px;
  margin-left: auto;
  min-width: 200px;
  text-align: right;
}
.saga-progress {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 2px;
  overflow: hidden;
}
.saga-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-2), var(--gold), var(--red));
  transition: width 0.25s linear;
}

/* --- 舞台与河道 --- */
.saga-stage {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 50px 24px 220px;
}

.saga-river { position: relative; }

/* 河道主线 */
.saga-river-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  transform: translateX(-50%);
  background: linear-gradient(180deg,
    rgba(212, 163, 73, 0.05) 0%,
    rgba(212, 163, 73, 0.35) 4%,
    rgba(212, 163, 73, 0.35) 96%,
    rgba(177, 58, 46, 0.1) 100%);
  border-radius: 2px;
}

/* 已流过的部分（发光轨迹） */
.saga-river-line::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--flowed, 0px);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold), var(--red));
  border-radius: 2px;
  box-shadow: 0 0 12px rgba(212, 163, 73, 0.65);
}

/* 能量球 */
.saga-orb {
  position: absolute;
  left: 50%;
  top: 0;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}
.saga-orb.on { opacity: 1; }

.orb-core {
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6d8, var(--gold) 55%, var(--red) 100%);
  box-shadow: 0 0 14px 4px rgba(212, 163, 73, 0.7),
              0 0 34px 10px rgba(177, 58, 46, 0.35);
  animation: orbPulse 1.5s ease-in-out infinite;
}
.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(212, 163, 73, 0.55);
  animation: orbRing 1.9s ease-out infinite;
}
@keyframes orbPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}
@keyframes orbRing {
  0%   { transform: scale(0.7); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* --- 站点 --- */
.saga-stations { position: relative; }

.saga-station {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 34px;
}

/* 时代分隔 */
.saga-station.era { margin-bottom: 26px; }
.st-era {
  text-align: center;
  padding: 8px 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 16, 13, 0.9);
  opacity: 0.4;
  transition: all 0.5s;
}
.st-era .st-era-name {
  font-size: 17px;
  color: var(--gold-soft);
  letter-spacing: 6px;
  font-family: "STKaiti", "KaiTi", serif;
}
.st-era .st-era-range {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-top: 2px;
}
.saga-station.era.reached .st-era {
  opacity: 1;
  border-color: var(--gold-2);
  box-shadow: 0 0 20px rgba(212, 163, 73, 0.25);
}

/* 朝代节点 */
.st-dyn {
  min-width: 260px;
  max-width: 380px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-left: 4px solid var(--st-color, var(--gold));
  border-radius: 6px;
  padding: 11px 16px;
  opacity: 0.32;
  transform: scale(0.95);
  transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
}
.saga-station.dyn.reached .st-dyn {
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45),
              0 0 0 1px rgba(212, 163, 73, 0.15);
}
.saga-station.dyn.active .st-dyn {
  border-color: var(--st-color, var(--gold));
  box-shadow: 0 0 26px rgba(212, 163, 73, 0.4);
  transform: scale(1.03);
}
.st-dyn-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
}
.st-dyn-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 3px;
  font-family: "STKaiti", "KaiTi", serif;
}
.st-dyn-range {
  font-size: 11px;
  color: var(--st-color, var(--gold));
  letter-spacing: 1px;
  margin-left: auto;
}
.st-dyn-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* 事件节点（小菱标） */
.saga-station.ev { margin-bottom: 26px; }
.st-ev {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(177, 58, 46, 0.12);
  border: 1px solid rgba(200, 60, 40, 0.3);
  font-size: 12px;
  color: #e8b9a6;
  opacity: 0.3;
  transition: all 0.5s;
  cursor: pointer;
  letter-spacing: 1px;
}
.saga-station.ev.reached .st-ev {
  opacity: 1;
  border-color: rgba(200, 60, 40, 0.6);
}
.saga-station.ev.active .st-ev {
  background: rgba(200, 60, 40, 0.3);
  box-shadow: 0 0 20px rgba(200, 60, 40, 0.5);
  transform: scale(1.06);
}
.st-ev-year { color: var(--gold); font-weight: 700; }

/* 起点 / 终点 */
.st-cap {
  text-align: center;
  font-family: "STKaiti", "KaiTi", serif;
  letter-spacing: 8px;
  padding: 14px 30px;
  border-radius: 6px;
  border: 1px solid var(--gold-2);
  background: linear-gradient(135deg, rgba(122, 93, 168, 0.2), rgba(36, 26, 18, 0.9));
  color: var(--gold-soft);
  font-size: 22px;
  opacity: 0.4;
  transition: all 0.6s;
}
.saga-station.cap.reached .st-cap {
  opacity: 1;
  box-shadow: 0 0 30px rgba(212, 163, 73, 0.35);
}
.st-cap.end {
  background: linear-gradient(135deg, rgba(212, 69, 58, 0.28), rgba(36, 26, 18, 0.9));
  border-color: var(--red);
  color: #ffdcc8;
}
.st-cap-sub {
  display: block;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-top: 6px;
  font-family: inherit;
}

/* ============================================================
   事件气泡 · 打字机
   ============================================================ */
.saga-bubble {
  position: fixed;
  right: 40px;
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  width: 400px;
  max-width: calc(100vw - 60px);
  max-height: 74vh;
  overflow-y: auto;
  z-index: 60;
  background: linear-gradient(165deg, #33261b 0%, #241a12 100%);
  border: 1px solid var(--gold-2);
  border-radius: 10px;
  padding: 18px 20px 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7),
              0 0 40px rgba(212, 163, 73, 0.14);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.2, 1.2, 0.3, 1);
  cursor: pointer;
}
.saga-bubble.show {
  opacity: 1;
  transform: translateY(-50%) scale(1);
  pointer-events: auto;
}
.saga-bubble.hidden { display: none; }

/* 指向能量球的小尾巴 */
.bub-tail {
  position: absolute;
  left: -9px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%) rotate(45deg);
  background: #33261b;
  border-left: 1px solid var(--gold-2);
  border-bottom: 1px solid var(--gold-2);
}

.bub-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
  margin-bottom: 9px;
}
.bub-year {
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 1px;
  font-family: "STKaiti", "KaiTi", serif;
}
.bub-name {
  font-size: 20px;
  color: #ffdcbe;
  font-weight: 700;
  letter-spacing: 3px;
  font-family: "STKaiti", "KaiTi", serif;
}
.bub-context {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* 正文 · 打字区 */
.bub-text {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.85;
  white-space: pre-wrap;
  min-height: 1.85em;
}
.bub-text .kw { color: var(--gold-soft); font-weight: 600; }
.bub-text .kw-red { color: #ff9d85; font-weight: 600; }

/* 光标 */
.bub-text .caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--gold);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: caretBlink 0.75s step-end infinite;
}
@keyframes caretBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* 图片：打字结束后淡入 */
.bub-img-wrap {
  margin-top: 12px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.6s ease, opacity 0.6s ease, margin-top 0.4s;
}
.bub-img-wrap.show {
  max-height: 250px;
  opacity: 1;
}
.bub-img-wrap img {
  width: 100%;
  max-height: 230px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
}
.bub-img-credit {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* 底部：提示与 5 秒停留倒计时 */
.bub-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px solid rgba(74, 56, 38, 0.5);
}
.bub-hint {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  white-space: nowrap;
}
.bub-timer {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.bub-timer i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--red));
}

/* 演义进行时压暗其他 UI，聚焦长河 */
body.saga-running .era-bar { opacity: 0.35; pointer-events: none; }

@media (max-width: 900px) {
  .saga-bubble {
    right: 50%;
    top: auto;
    bottom: 20px;
    transform: translate(50%, 0) scale(0.95);
    width: calc(100vw - 32px);
    max-height: 56vh;
  }
  .saga-bubble.show { transform: translate(50%, 0) scale(1); }
  .bub-tail { display: none; }
  .saga-status { min-width: 0; }
  .st-dyn { min-width: 0; }
}

/* ============================================================
   长河演义 · 特效层
   ============================================================ */

/* 粒子画布：固定视口大小，不随河道高度膨胀 */
#saga-fx {
  position: fixed;
  inset: 0;
  z-index: 9;              /* 卡片之上、能量球(12)与气泡(60)之下 */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;
}
#saga-fx.on { opacity: 1; }

/* 时代色调：随演进变换环境光 */
#saga-tint {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease, background 2.4s ease;
  background:
    radial-gradient(ellipse 120% 65% at 50% 0%,
      rgba(var(--tint, 212, 163, 73), 0.16) 0%, transparent 60%),
    radial-gradient(ellipse 120% 65% at 50% 100%,
      rgba(var(--tint, 212, 163, 73), 0.12) 0%, transparent 60%);
}

/* 演义进行时，能量球加强发光 */
body.saga-running .orb-core {
  box-shadow: 0 0 18px 6px rgba(212, 163, 73, 0.85),
              0 0 48px 16px rgba(177, 58, 46, 0.45);
}

/* 当前站点的呼吸光环 */
.saga-station.active .st-dyn,
.saga-station.active .st-ev {
  animation: stationGlow 1.6s ease-in-out infinite;
}
@keyframes stationGlow {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.18); }
}

/* 尊重系统减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  #saga-fx { display: none; }
  .orb-core, .orb-ring { animation: none; }
  .saga-station.active .st-dyn,
  .saga-station.active .st-ev { animation: none; }
}

/* ============================================================
   世系图（朝代详情页）
   ============================================================ */
.lineage-wrap {
  position: relative;
  max-width: 1400px;
  margin: 30px auto 70px;
  padding: 0 24px 40px;
  overflow-x: auto;
}

.lineage-note {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 20px;
  line-height: 1.7;
}
.lineage-note b { color: var(--gold-2); font-weight: 500; }

.lineage-inner { position: relative; display: inline-block; min-width: 100%; }

.lineage-svg {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.lin-gens { position: relative; z-index: 2; }

.lin-gen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 46px;
  flex-wrap: nowrap;
}

.lin-gen-label {
  position: absolute;
  left: 0;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  padding-top: 26px;
  white-space: nowrap;
}

.lin-node {
  width: 128px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1.5px solid var(--line);
  border-top: 3px solid var(--dyn-color, var(--gold));
  border-radius: 6px;
  padding: 8px 8px 9px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  position: relative;
}
.lin-node:hover {
  transform: translateY(-3px);
  border-color: var(--dyn-color, var(--gold));
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}

/* 非正统 / 特殊身份 */
.lin-node.consort {
  border-top-color: #d4536b;
  border-style: dashed;
}
.lin-node.inherited {
  border-top-style: dotted;
}

.lin-portrait {
  width: 46px;
  height: 58px;
  margin: 0 auto 6px;
  border-radius: 3px;
  overflow: hidden;
  background: linear-gradient(160deg, #3a2c1e, #241a12);
  border: 1px solid var(--line);
  position: relative;
  display: grid;
  place-items: center;
}
.lin-portrait img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  background: linear-gradient(160deg, #3a2c1e, #241a12);
}
.lin-portrait .ph-fallback {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 22px;
  color: rgba(212, 163, 73, 0.5);
  font-weight: 700;
}

.lin-order {
  font-size: 9px;
  color: var(--gold-2);
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.lin-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 1px;
  font-family: "STKaiti", "KaiTi", serif;
  line-height: 1.3;
}
.lin-name { font-size: 10.5px; color: var(--text-2); margin-top: 1px; }
.lin-reign { font-size: 9px; color: var(--text-dim); margin-top: 3px; letter-spacing: 0; }

/* 关系标签 */
.lin-rel {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #2a1f17;
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
  z-index: 3;
}
.lin-node.consort .lin-rel { border-color: #d4536b; color: #e59aad; }

/* 承自他朝的提示 */
.lin-from {
  font-size: 9px;
  color: var(--gold-2);
  margin-top: 4px;
  letter-spacing: 0;
  border-top: 1px dashed var(--line);
  padding-top: 3px;
}

/* 图例 */
.lin-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.lin-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lin-legend i {
  width: 18px; height: 0;
  border-top: 2px solid var(--gold-2);
  display: inline-block;
}
.lin-legend i.dashed { border-top-style: dashed; border-top-color: #d4536b; }
.lin-legend i.dotted { border-top-style: dotted; }

@media (max-width: 820px) {
  .lin-gen { justify-content: flex-start; }
  .lin-node { width: 108px; }
}

/* ============================================================
   时代黑屏大字过场（长河演义）
   ============================================================ */
.era-curtain {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: #07050400;
  backdrop-filter: blur(0px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease, background 0.8s ease, backdrop-filter 0.8s ease;
}
.era-curtain.on {
  opacity: 1;
  background: #070504f2;
  backdrop-filter: blur(6px);
}
.era-curtain.hidden { display: none; }

.curtain-inner {
  text-align: center;
  position: relative;
  padding: 0 24px;
}

/* 主标题：逐字入场 */
.curtain-title {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(48px, 11vw, 132px);
  font-weight: 700;
  letter-spacing: 0.22em;
  line-height: 1.1;
  color: var(--gold-soft);
  text-shadow: 0 0 30px rgba(212, 163, 73, 0.5),
               0 0 80px rgba(212, 163, 73, 0.25);
  display: flex;
  justify-content: center;
  gap: 0.04em;
}
.curtain-title .ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(38px) scale(1.5) rotateX(50deg);
  filter: blur(10px);
  animation: chIn 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes chIn {
  to { opacity: 1; transform: translateY(0) scale(1) rotateX(0); filter: blur(0); }
}

/* 上下横线自中间拉开 */
.curtain-rule {
  height: 1px;
  margin: 22px auto;
  width: 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: ruleOut 1.1s 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes ruleOut { to { width: min(560px, 84vw); } }

.curtain-range {
  font-size: clamp(14px, 2.4vw, 22px);
  color: var(--gold);
  letter-spacing: 0.55em;
  font-family: "STKaiti", "KaiTi", serif;
  opacity: 0;
  animation: fadeUp 0.9s 0.7s ease forwards;
}
.curtain-meta {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-dim);
  letter-spacing: 3px;
  opacity: 0;
  animation: fadeUp 0.9s 0.95s ease forwards;
}
.curtain-desc {
  margin: 20px auto 0;
  max-width: 660px;
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 2;
  letter-spacing: 1px;
  opacity: 0;
  animation: fadeUp 1s 1.2s ease forwards;
}
.curtain-desc .kw { color: var(--gold-soft); font-weight: 600; }
.curtain-desc .kw-red { color: #ff9d85; font-weight: 600; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 背景光晕，随时代取色 */
.curtain-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130vw;
  height: 130vw;
  transform: translate(-50%, -50%) scale(0.6);
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(var(--curtain-tint, 212, 163, 73), 0.16) 0%,
    transparent 55%);
  pointer-events: none;
  opacity: 0;
  animation: glowIn 1.6s ease forwards;
  z-index: -1;
}
@keyframes glowIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* 装饰性四角边框 */
.curtain-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(212, 163, 73, 0.55);
  opacity: 0;
  animation: fadeUp 0.8s 1.4s ease forwards;
}
.curtain-corner.tl { top: -26px; left: -18px; border-right: 0; border-bottom: 0; }
.curtain-corner.tr { top: -26px; right: -18px; border-left: 0; border-bottom: 0; }
.curtain-corner.bl { bottom: -26px; left: -18px; border-right: 0; border-top: 0; }
.curtain-corner.br { bottom: -26px; right: -18px; border-left: 0; border-top: 0; }

@media (prefers-reduced-motion: reduce) {
  .curtain-title .ch,
  .curtain-rule, .curtain-range, .curtain-meta,
  .curtain-desc, .curtain-glow, .curtain-corner {
    animation-duration: 0.01s !important;
    animation-delay: 0s !important;
  }
}
/* ============================================================
   并存政权泳道时间线（三国、十六国、十国、南北朝等）

   设计要点：把「时长准确」与「文字可读」分离 ——
   左侧窄条按真实年数绘制（不做避让，位置绝对准确），
   右侧信息卡紧凑等高并在重叠时下推（保证可读）。
   否则在位 40 年的刘禅会被拉成巨大空盒，
   而在位 2 年的刘备又会被最小高度挤到与后继者重叠。
   ============================================================ */
.lanes-wrap {
  max-width: 1320px;
  margin: 24px auto 70px;
  padding: 0 24px;
}

.lanes-note {
  font-size: 12.5px;
  color: var(--text-2);
  background: linear-gradient(90deg, rgba(177, 58, 46, 0.12), rgba(177, 58, 46, 0.03));
  border: 1px solid rgba(200, 60, 40, 0.22);
  border-left: 3px solid var(--red);
  border-radius: 5px;
  padding: 10px 15px;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
  line-height: 1.75;
}
.lanes-note b { color: var(--gold-soft); font-weight: 600; }

/* ---------- 泳道头 ---------- */
.lanes-head {
  display: flex;
  gap: 14px;
  margin-left: 54px;
  margin-bottom: 10px;
}
.lane-head {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 9px 8px 8px;
  border-radius: 6px;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line);
  border-top: 2.5px solid var(--lane-color);
  position: relative;
}
.lane-head::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -1px;
  width: 60%; height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--lane-color), transparent);
  opacity: 0.5;
}
.lane-head-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--lane-color);
  letter-spacing: 4px;
  font-family: "STKaiti", "KaiTi", serif;
  filter: brightness(1.45);
}
.lane-head-range {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  margin-top: 2px;
}
.lane-head-count {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
  opacity: 0.75;
}

/* ---------- 主体 ---------- */
.lanes-body {
  position: relative;
  display: flex;
  gap: 14px;
  margin-left: 54px;
}

.lanes-axis {
  position: absolute;
  left: -54px;
  top: 0; bottom: 0;
  width: 46px;
}
.lanes-axis-tick {
  position: absolute;
  right: 0;
  width: 100%;
  text-align: right;
  font-size: 10.5px;
  color: var(--text-dim);
  transform: translateY(-50%);
  padding-right: 9px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.lanes-axis-tick::after {
  content: "";
  position: absolute;
  right: 0; top: 50%;
  width: 5px; height: 1px;
  background: rgba(212, 163, 73, 0.45);
}
.lanes-gridline {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: rgba(212, 163, 73, 0.06);
  pointer-events: none;
}

.lane-col {
  flex: 1;
  min-width: 0;
  position: relative;
  border-radius: 6px;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0.008));
  box-shadow: inset 0 0 0 1px rgba(212, 163, 73, 0.07);
}

/* ---------- 左侧真实时长条 ---------- */
.lane-span {
  position: absolute;
  left: 8px;
  width: 7px;
  border-radius: 4px;
  background: linear-gradient(180deg,
    var(--lane-color), color-mix(in srgb, var(--lane-color) 45%, #000));
  box-shadow: 0 0 8px -1px var(--lane-color);
  opacity: 0.85;
  transition: opacity 0.2s, width 0.2s;
}
.lane-span::before,
.lane-span::after {
  content: "";
  position: absolute;
  left: -3px; right: -3px;
  height: 1.5px;
  background: var(--lane-color);
  border-radius: 2px;
}
.lane-span::before { top: 0; }
.lane-span::after  { bottom: 0; }

.lane-card.hot ~ .lane-span,
.lane-span.hot { opacity: 1; width: 9px; }

/* ---------- 右侧信息卡 ---------- */
.lane-card {
  position: absolute;
  left: 24px;
  right: 8px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 6px;
  cursor: pointer;
  background: linear-gradient(160deg, #33261c 0%, #251b13 100%);
  border: 1px solid var(--line);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.lane-card::before {
  /* 指回左侧时长条的引线 */
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  width: 16px;
  height: 1px;
  background: linear-gradient(90deg, var(--lane-color), transparent);
  opacity: 0.6;
}
.lane-card:hover {
  transform: translateX(2px);
  border-color: var(--lane-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6),
              0 0 0 1px color-mix(in srgb, var(--lane-color) 40%, transparent);
  z-index: 6;
}

.lane-card .portrait {
  width: 34px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 4px;
}
.lane-card .portrait .ph-fallback { font-size: 17px; }

.lane-card-text { flex: 1; min-width: 0; }

.lane-card-line1 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.lane-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 1px;
  font-family: "STKaiti", "KaiTi", serif;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lane-card-name {
  font-size: 10.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
}
.lane-card-line2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  white-space: nowrap;
}
.lane-card-yr {
  font-size: 10px;
  color: var(--lane-color);
  font-weight: 600;
  filter: brightness(1.4);
  font-variant-numeric: tabular-nums;
}
.lane-card-len {
  font-size: 9.5px;
  color: var(--text-dim);
}
/* 结局用小圆点表示，避免挤占横向空间 */
.lane-card-fate {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #8bb37a;
  box-shadow: 0 0 5px currentColor;
}
.lane-card-fate.bad     { background: #c15d4a; }
.lane-card-fate.suicide { background: #b06a9c; }
.lane-card-fate.unknown { background: #8a7c65; }

@media (max-width: 900px) {
  .lanes-head, .lanes-body { margin-left: 38px; gap: 8px; }
  .lanes-axis { left: -38px; width: 32px; }
  .lanes-axis-tick { font-size: 9.5px; padding-right: 6px; }
  .lane-head-name { font-size: 13px; letter-spacing: 1px; }
  .lane-card { left: 18px; right: 5px; height: 46px; gap: 6px; }
  .lane-card .portrait { display: none; }
  .lane-span { left: 5px; width: 5px; }
  .lane-card::before { left: -12px; width: 12px; }
}

/* ============================================================
   演义 · 朝代世系「先全景后点亮」

   要点：世系图一开始就完整呈现（灰暗态），
   再由能量流自上而下逐代点亮，并自动滚动跟随。
   ============================================================ */
.dyn-lineage-stage {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: rgba(7, 5, 4, 0.94);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.dyn-lineage-stage.on { opacity: 1; pointer-events: auto; }
.dyn-lineage-stage.hidden { display: none; }

/* 固定头部 */
.dls-head {
  flex-shrink: 0;
  text-align: center;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(212, 163, 73, 0.18);
  background: linear-gradient(180deg, rgba(20, 16, 13, 0.95), transparent);
}
.dls-title {
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 700;
  color: var(--dls-color, var(--gold));
  letter-spacing: 0.2em;
  font-family: "STKaiti", "KaiTi", serif;
  text-shadow: 0 0 26px rgba(212, 163, 73, 0.35);
}
.dls-sub {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 3px;
  margin-top: 3px;
}
.dls-progress {
  margin: 9px auto 0;
  width: 220px;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.dls-progress i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--red));
  transition: width 0.45s ease;
}
.dls-hint {
  font-size: 11px;
  color: var(--gold-2);
  letter-spacing: 2px;
  margin-top: 7px;
  opacity: 0.85;
}

/* 滚动区 */
.dls-inner {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px 20px 60vh;   /* 底部留白，末代也能滚到中间 */
  scrollbar-width: thin;
}
.dls-inner::-webkit-scrollbar { width: 7px; }
.dls-inner::-webkit-scrollbar-thumb {
  background: rgba(212, 163, 73, 0.3);
  border-radius: 4px;
}

.dls-gens {
  position: relative;
  width: min(1100px, 100%);
  margin: 0 auto;
}

/* ---------- 中轴与能量流 ---------- */
.dls-spine {
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: rgba(212, 163, 73, 0.13);
  border-radius: 2px;
  z-index: 0;
}
.dls-flow {
  position: absolute;
  left: 50%;
  top: 0;
  width: 3px;
  height: 0;
  transform: translateX(-50%);
  background: linear-gradient(180deg,
    var(--dls-color, var(--gold)), #fff6d8);
  box-shadow: 0 0 14px 2px var(--dls-color, var(--gold));
  border-radius: 2px;
  z-index: 1;
  transition: height 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
/* 流头的能量球 */
.dls-orb {
  position: absolute;
  left: 50%;
  top: 0;
  width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: top 0.55s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}
.dls-orb.on { opacity: 1; }
.dls-orb::before {
  content: "";
  position: absolute; inset: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e2, var(--gold) 55%, var(--red));
  box-shadow: 0 0 14px 4px rgba(212, 163, 73, 0.8),
              0 0 34px 10px rgba(177, 58, 46, 0.4);
}
.dls-orb::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(212, 163, 73, 0.6);
  animation: dlsRing 1.6s ease-out infinite;
}
@keyframes dlsRing {
  0%   { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.1); opacity: 0; }
}

/* ---------- 世代行：默认灰暗全景 ---------- */
.dls-gen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 34px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
  /* 全景态：可见但灰暗 */
  filter: grayscale(0.92) brightness(0.5);
  opacity: 0.5;
  transition: filter 0.65s ease, opacity 0.65s ease, transform 0.5s ease;
}
.dls-gen.lit {
  filter: none;
  opacity: 1;
}
/* 正在点亮的一代额外强调 */
.dls-gen.active {
  transform: scale(1.04);
}
.dls-gen.active .dls-node {
  border-color: var(--dls-color, var(--gold));
  box-shadow: 0 0 22px -2px var(--dls-color, var(--gold)),
              0 6px 20px rgba(0, 0, 0, 0.6);
}

.dls-gen-tag {
  position: absolute;
  left: 0;
  top: -18px;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  white-space: nowrap;
}
.dls-gen.lit .dls-gen-tag { color: var(--gold-2); }

/* ---------- 君主卡 ---------- */
.dls-node {
  width: 108px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-top: 3px solid var(--dls-color, var(--gold));
  border-radius: 6px;
  padding: 7px 6px 8px;
  position: relative;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
  transition: border-color 0.4s, box-shadow 0.4s;
}
.dls-node.consort { border-top-color: #d4536b; border-style: dashed; }

.dls-portrait {
  width: 44px; height: 54px;
  margin: 0 auto 5px;
  border-radius: 3px;
  overflow: hidden;
  background: linear-gradient(160deg, #3a2c1e, #241a12);
  border: 1px solid var(--line);
  position: relative;
  display: grid;
  place-items: center;
}
.dls-portrait img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 20%;
  background: linear-gradient(160deg, #3a2c1e, #241a12);
}
.dls-portrait .ph-fallback {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 21px; font-weight: 700;
  color: rgba(212, 163, 73, 0.5);
}
.dls-node-title {
  font-size: 13px; font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 1px;
  font-family: "STKaiti", "KaiTi", serif;
  line-height: 1.25;
}
.dls-node-name { font-size: 10px; color: var(--text-2); }
.dls-node-yr { font-size: 9px; color: var(--text-dim); margin-top: 2px; }
.dls-node-rel {
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%);
  font-size: 8.5px;
  padding: 0 5px;
  border-radius: 999px;
  background: #2a1f17;
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}

@media (max-width: 820px) {
  .dls-node { width: 92px; }
  .dls-title { letter-spacing: 0.1em; }
}
@media (prefers-reduced-motion: reduce) {
  .dls-gen, .dls-flow, .dls-orb { transition-duration: 0.01s; }
  .dls-orb::after { animation: none; }
}

/* ============================================================
   常驻浮动控制条
   全屏覆盖层（幕布 z80 / 世系 z70）会挡住顶部控制栏，
   演示中就点不到暂停，故设一条 z95 的常驻控制条。
   ============================================================ */
#saga-float {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120%);
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(20, 16, 13, 0.94);
  border: 1px solid var(--gold-2);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.7),
              0 0 24px rgba(212, 163, 73, 0.15);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s;
}
#saga-float.on {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.fc-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-family: inherit;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.fc-btn:hover { border-color: var(--gold); color: var(--gold-soft); }
.fc-btn.main {
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  border-color: var(--gold);
  color: #14100d;
  font-weight: 700;
  min-width: 78px;
}
.fc-btn.main:hover { filter: brightness(1.12); }

.fc-sep {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 2px;
}
.fc-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fc-speed { display: inline-flex; gap: 3px; }
.fc-sp {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 10.5px;
  font-family: inherit;
  cursor: pointer;
}
.fc-sp.active {
  background: var(--gold-2);
  border-color: var(--gold);
  color: #14100d;
  font-weight: 700;
}

/* 暂停时给全局一个明确的视觉反馈 */
body.saga-paused .dls-orb::after,
body.saga-paused .orb-core { animation-play-state: paused; }
body.saga-paused #saga-float {
  border-color: var(--red);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.7),
              0 0 24px rgba(200, 60, 40, 0.25);
}

@media (max-width: 720px) {
  #saga-float { gap: 5px; padding: 7px 10px; bottom: 12px; }
  .fc-label, .fc-speed { display: none; }
}

/* ============================================================
   君主讲解面板（世系舞台内）
   ============================================================ */
.dls-narrate {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%) translateX(24px);
  width: 356px;
  max-width: calc(100vw - 40px);
  max-height: 72vh;
  overflow-y: auto;
  z-index: 78;
  background: linear-gradient(165deg, #33261b, #221a12);
  border: 1px solid var(--gold-2);
  border-radius: 10px;
  padding: 16px 18px 14px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.75),
              0 0 34px rgba(212, 163, 73, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.dls-narrate.on {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}

.nr-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 11px;
}
.nr-portrait {
  width: 46px; height: 56px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: linear-gradient(160deg, #3a2c1e, #241a12);
  border: 1px solid var(--line);
  position: relative;
  display: grid;
  place-items: center;
}
.nr-portrait img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 20%;
  background: linear-gradient(160deg, #3a2c1e, #241a12);
}
.nr-portrait .ph-fallback {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 22px; color: rgba(212, 163, 73, 0.5); font-weight: 700;
}
.nr-id { flex: 1; min-width: 0; }
.nr-title {
  font-size: 19px; font-weight: 700;
  color: var(--gold-soft);
  letter-spacing: 2px;
  font-family: "STKaiti", "KaiTi", serif;
}
.nr-name { font-size: 11.5px; color: var(--text-2); }
.nr-reign { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }

/* 登基 / 退位 两段 */
.nr-block { margin-bottom: 11px; }
.nr-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 5px;
}
.nr-label.up {
  color: #a8cf94;
  background: rgba(139, 179, 122, 0.12);
  border: 1px solid rgba(139, 179, 122, 0.35);
}
.nr-label.down {
  color: #e69987;
  background: rgba(193, 93, 74, 0.12);
  border: 1px solid rgba(193, 93, 74, 0.35);
}
.nr-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.85;
  white-space: pre-wrap;
}
.nr-text .kw { color: var(--gold-soft); font-weight: 600; }
.nr-text .kw-red { color: #ff9d85; font-weight: 600; }
.nr-text .caret {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--gold);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: caretBlink 0.75s step-end infinite;
}

.nr-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(74, 56, 38, 0.5);
  padding-top: 9px;
  margin-top: 4px;
}
.nr-src {
  font-size: 9.5px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.nr-src.brief { color: #b09a6a; }
.nr-count {
  margin-left: auto;
  font-size: 10px;
  color: var(--gold-2);
  letter-spacing: 1px;
  white-space: nowrap;
}

/* 正在讲解的君主卡高亮 */
.dls-node.narrating {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 2px rgba(212, 163, 73, 0.5),
              0 0 26px -2px var(--gold) !important;
  transform: scale(1.07);
  z-index: 5;
}
.dls-node { transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s; }

@media (max-width: 1100px) {
  .dls-narrate {
    right: 50%;
    top: auto;
    bottom: 76px;
    transform: translate(50%, 20px);
    width: calc(100vw - 28px);
    max-height: 44vh;
  }
  .dls-narrate.on { transform: translate(50%, 0); }
}

/* ============================================================
   长河演义 · 终幕国旗背景层
   国旗须在站点卡片「之下」飘过，故独立一张低层级画布，
   不与粒子层（在卡片之上，z9）共用。
   ============================================================ */
#saga-flag {
  position: fixed;
  inset: 0;
  z-index: 2;              /* 高于时代色调层(1)，低于站点内容(4) */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease;
  filter: drop-shadow(0 0 40px rgba(222, 41, 16, 0.35));
}
#saga-flag.on { opacity: 1; }

/* 站点内容需明确高于国旗层，否则卡片会被旗面盖住 */
.saga-stations { z-index: 4; }

/* 终幕节点在国旗映衬下加强存在感 */
.saga-station.cap.reached .st-cap.end {
  box-shadow: 0 0 44px rgba(222, 41, 16, 0.5),
              0 0 100px rgba(255, 222, 0, 0.18);
  border-color: #ffde00;
}

@media (prefers-reduced-motion: reduce) {
  #saga-flag { display: none; }
}

/* ============================================================
   终幕国旗 · three.js 布料模拟层

   作为背景存在：整块画布经虚化并压低透明度，
   另有 mask 使四周融入页面，故不遮挡正文。
   ============================================================ */
#flag3d {
  position: fixed;
  inset: 0;
  z-index: 2;                    /* 高于时代色调层(1)，低于站点内容(4) */
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
  /* 虚化 + 略微降饱和，退到背景 */
  filter: blur(7px) saturate(0.88) brightness(0.92);
  /* 仅柔化最外缘，使旗面融入页面。
     此前用 78%×72% 的椭圆会把满屏旗面又裁回一小块，
     故放宽到 120%×115%，只在四边留出渐隐带。 */
  -webkit-mask-image: radial-gradient(ellipse 120% 115% at 50% 50%,
      #000 62%, rgba(0, 0, 0, 0.72) 84%, transparent 100%);
  mask-image: radial-gradient(ellipse 120% 115% at 50% 50%,
      #000 62%, rgba(0, 0, 0, 0.72) 84%, transparent 100%);
  will-change: opacity;
}
#flag3d.on { opacity: 0.42; }

/* 旗面显现时，正文一侧略作压暗，保证可读性 */
body.saga-flag-on .saga-stations { position: relative; z-index: 4; }
body.saga-flag-on .st-dyn,
body.saga-flag-on .st-ev,
body.saga-flag-on .st-era {
  backdrop-filter: blur(2px);
  background-color: rgba(20, 16, 13, 0.72);
}

/* 终幕节点在国旗映衬下加强存在感 */
body.saga-flag-on .saga-station.cap.reached .st-cap.end {
  background: linear-gradient(135deg,
    rgba(222, 41, 16, 0.42), rgba(20, 16, 13, 0.9));
  border-color: #ffde00;
  box-shadow: 0 0 48px rgba(222, 41, 16, 0.55),
              0 0 110px rgba(255, 222, 0, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  #flag3d { display: none; }
}

/* ============================================================
   历史长廊 · 3D 视图（第四视图）

   文字不进 WebGL：标签是真实 DOM，由 corridor.js
   按三维坐标投影定位，故清晰、可选中、屏幕阅读器可读。
   ============================================================ */
.view-tab.cor-tab { color: #8ecad4; }
.view-tab.cor-tab.active {
  background: linear-gradient(135deg, #1d5560, #123a44);
  color: #d6f4fa;
  border-color: #4fa8bb;
}

.cor-bar {
  position: sticky;
  top: 76px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 28px;
  background: rgba(11, 9, 7, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.cor-sp {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}
.cor-sp.active {
  background: #4fa8bb;
  border-color: #7fd0e0;
  color: #06181d;
  font-weight: 700;
}
.cor-hint {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* 舞台：铺满可视区余下高度 */
.cor-stage {
  position: relative;
  width: 100%;
  height: calc(100vh - 190px);
  min-height: 460px;
  overflow: hidden;
  background: radial-gradient(ellipse 70% 60% at 50% 42%, #16110c 0%, #0b0907 70%);
}
#corridor-canvas { display: block; width: 100%; height: 100%; }

/* 标签层：覆盖在画布之上，本身不拦事件，仅标签可点 */
.cor-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.cor-label {
  position: absolute;
  left: 0; top: 0;
  transform-origin: 50% 50%;
  pointer-events: auto;
  cursor: pointer;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 5px;
  background: rgba(11, 9, 7, 0.74);
  border: 1px solid var(--cor-color, var(--gold-2));
  border-left-width: 3px;
  backdrop-filter: blur(3px);
  transition: background-color 0.25s, box-shadow 0.25s;
  will-change: transform, opacity;
}
.cor-label .cl-title {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--gold-soft);
  line-height: 1.25;
}
.cor-label .cl-sub {
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-top: 1px;
}

/* 时代 / 起终点：更醒目 */
.cor-label.era .cl-title { font-size: 20px; letter-spacing: 5px; color: var(--gold); }
.cor-label.cap .cl-title { font-size: 22px; letter-spacing: 6px; color: #ffe9bd; }
.cor-label.cap { border-width: 2px; border-left-width: 4px; }

/* 事件：小一号，重大事件偏红 */
.cor-label.ev .cl-title { font-size: 13px; letter-spacing: 1px; color: #e8c9a8; }
.cor-label.ev.big .cl-title { color: #ffb8a3; font-size: 15px; }

/* 临近与当前 */
.cor-label.near {
  background: rgba(20, 16, 13, 0.9);
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.6);
}
.cor-label.active {
  background: rgba(30, 23, 16, 0.95);
  box-shadow: 0 0 0 1px var(--cor-color, var(--gold)),
              0 0 34px -4px var(--cor-color, var(--gold));
}
.cor-label.active .cl-title { color: #fff6e0; }
.cor-label:hover { background: rgba(40, 30, 20, 0.95); }

/* WebGL 不可用时的说明 */
.cor-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
  line-height: 2;
  letter-spacing: 1px;
  padding: 24px;
}
.cor-fallback.hidden { display: none; }
.cor-fallback b { color: var(--gold); }

@media (max-width: 820px) {
  .cor-stage { height: calc(100vh - 230px); }
  .cor-hint { display: none; }
  .cor-label .cl-title { font-size: 13px; letter-spacing: 1px; }
  .cor-label.era .cl-title { font-size: 16px; letter-spacing: 3px; }
}
