/* ==========================================================
   明代帝系人物谱 — 样式表（浅色主题 / 桌面与移动端）
   ========================================================== */

:root {
  --bg:            #f6f3ec;
  --surface:       #fffdf9;
  --surface-2:     #fbf8f1;
  --surface-3:     #f0ebe0;
  --ink:           #262a2b;
  --ink-2:         #5c615f;
  --ink-3:         #8b908b;
  --line:          #e7e0d2;
  --line-strong:   #d6cbb6;
  --red:           #9c2f27;
  --red-dark:      #7e251f;
  --red-soft:      #f7ebe7;
  --gold:          #a98245;
  --shadow-sm:     0 1px 3px rgba(72, 55, 30, .05);
  --shadow-md:     0 6px 24px rgba(72, 55, 30, .09);
  --shadow-lg:    -12px 0 40px rgba(40, 32, 20, .16);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", "Helvetica Neue", sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
::selection { background: #efd9d2; }

/* ---------- 顶部 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 253, 249, .96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.seal {
  width: 42px; height: 42px; border-radius: 5px;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 25px; line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.22);
  letter-spacing: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text strong { font-family: var(--serif); font-size: 19px; letter-spacing: .06em; }
.brand-text small { color: var(--ink-3); font-size: 11px; letter-spacing: .04em; }
.main-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 9px 15px; border-radius: 7px; white-space: nowrap;
  font-size: 14px; min-width: 0; transition: background .18s, color .18s;
}
.nav-btn:hover { background: var(--surface-3); color: var(--ink); }
.nav-btn.is-active { background: var(--red-soft); color: var(--red); font-weight: 600; }

/* ---------- 统计条 ---------- */
.stat-strip { background: var(--surface-3); border-bottom: 1px solid var(--line); }
.stat-strip-inner {
  max-width: 1180px; margin: 0 auto; padding: 16px 24px;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.stat-item { display: flex; align-items: baseline; gap: 10px; padding: 2px 18px; border-right: 1px solid var(--line-strong); }
.stat-item:first-child { padding-left: 0; }
.stat-item:last-child { border-right: 0; }
.stat-num { font-family: var(--serif); font-size: 27px; line-height: 1; color: var(--red); }
.stat-label { font-size: 12px; color: var(--ink-2); }
.stat-note { font-size: 11px; color: var(--ink-3); margin-left: auto; }

/* ---------- 页面骨架 ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 38px 24px 90px; }
.view { display: none; }
.view.is-active { display: block; }
.view-head { margin-bottom: 26px; }
.eyebrow {
  margin: 0 0 8px; color: var(--red); font-size: 11px;
  letter-spacing: .22em; font-weight: 700;
}
.view-head h1 {
  font-family: var(--serif); font-size: 30px; font-weight: 600;
  letter-spacing: .03em; margin: 0 0 10px; line-height: 1.4;
}
.view-desc { margin: 0; color: var(--ink-2); font-size: 13.5px; max-width: 780px; }

/* ---------- 分期导航 ---------- */
.period-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.period-btn {
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 7px; padding: 8px 14px; font-size: 13px; color: var(--ink-2);
  display: flex; align-items: center; gap: 9px; transition: all .18s;
}
.period-btn:hover { border-color: var(--red); color: var(--red); }
.period-btn b { font-family: var(--serif); font-size: 15px; }
.period-btn span { color: var(--ink-3); font-size: 11px; }

/* ---------- 世系时间轴 ---------- */
.timeline { position: relative; }
.period-divider {
  display: flex; align-items: center; gap: 14px;
  margin: 34px 0 20px; color: var(--red);
}
.period-divider:first-child { margin-top: 0; }
.period-divider .pd-name { font-family: var(--serif); font-size: 20px; letter-spacing: .1em; }
.period-divider .pd-range { font-size: 12px; color: var(--ink-3); }
.period-divider .pd-rule { flex: 1; height: 1px; background: var(--line-strong); }
.period-divider .pd-desc { font-size: 12px; color: var(--ink-2); font-weight: 400; }

.tl-row { display: grid; grid-template-columns: 92px 26px 1fr; gap: 0; position: relative; }
.tl-rail { position: relative; }
.tl-rail::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 2px; background: #c9b691; transform: translateX(-50%);
}
.tl-row:first-of-type .tl-rail::before { top: 22px; }
.tl-row:last-of-type .tl-rail::before { bottom: calc(100% - 22px); }
.tl-dot {
  position: absolute; top: 17px; left: 50%; transform: translateX(-50%);
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--red); z-index: 1;
}
.tl-year {
  padding-top: 13px; text-align: right; padding-right: 14px;
  font-family: var(--serif); font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.tl-year small { display: block; font-family: var(--sans); font-size: 10.5px; color: var(--ink-3); }

.emp-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm); transition: border-color .2s, box-shadow .2s, transform .2s;
  position: relative;
}
.emp-card:hover { border-color: #d3b7ae; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.emp-top { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.emp-order {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 5px;
  background: var(--red-soft); color: var(--red);
  font-family: var(--serif); font-size: 15px;
  display: grid; place-items: center;
}
.emp-name { font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: .04em; }
.emp-temple { font-size: 12px; color: var(--ink-2); margin-left: 8px; }
.era-tag {
  display: inline-block; border: 1px solid var(--line-strong); border-radius: 4px;
  padding: 1px 8px; font-size: 11.5px; color: var(--red); background: #fffaf7;
  margin-left: 2px;
}
.emp-reign { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.emp-succession {
  margin: 10px 0 0; font-size: 12px; color: var(--ink-2);
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.emp-succession::before { content: '↳'; color: var(--gold); font-size: 14px; }
.emp-brief { margin: 10px 0 0; color: var(--ink-2); font-size: 13px; }
.event-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.event-chip {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px; padding: 2px 8px; font-size: 11px; color: var(--ink-2);
}
.emp-foot {
  border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.emp-people-label { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.emp-person-pills { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.person-pill {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 20px; padding: 3px 9px; font-size: 11.5px;
  display: inline-flex; align-items: center; gap: 5px; transition: all .16s;
  color: var(--ink-2);
}
.person-pill:hover { border-color: var(--red); color: var(--red); background: #fff; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; }
.link-btn {
  border: 0; background: transparent; color: var(--red); font-size: 12px;
  padding: 4px 0; white-space: nowrap;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- 筛选面板 ---------- */
.filter-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 22px;
}
.filter-row-top {
  display: grid; grid-template-columns: minmax(220px, 1fr) 210px 158px;
  gap: 12px; margin-bottom: 18px; align-items: end;
}
/* 首行三列统一为「小标签 + 42px 控件」，保证控件框体严格同一水平 */
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field-label {
  font-size: 11px; line-height: 1.7; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-box {
  display: flex; align-items: center; gap: 8px; height: 42px; width: 100%;
  border: 1px solid var(--line-strong); border-radius: 7px;
  padding: 0 12px; background: var(--surface-2);
}
.search-box:focus-within { border-color: var(--red); background: #fff; }
.search-icon { font-size: 20px; color: var(--ink-3); line-height: 1; }
.search-box input { border: 0; background: transparent; outline: 0; width: 100%; min-width: 0; font-size: 13.5px; }
.search-box input::placeholder { color: var(--ink-3); }
.field select {
  height: 42px; width: 100%; border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--surface-2); padding: 0 10px; font-size: 13px; outline: 0;
}
.field select:focus { border-color: var(--red); }
.filter-group { margin-bottom: 14px; }
.filter-label {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  font-size: 11.5px; color: var(--ink-3); letter-spacing: .05em;
}
.mini-btn {
  border: 0; background: transparent; color: var(--red); font-size: 11px; padding: 0 4px;
}
.mini-btn:hover { text-decoration: underline; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 20px; padding: 5px 12px; font-size: 12px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; transition: all .16s;
}
.chip:hover { border-color: var(--red); color: var(--red); }
.chip.is-on { background: var(--cat-color, var(--red)); border-color: var(--cat-color, var(--red)); color: #fff; }
.chip.is-on:hover { color: #fff; filter: brightness(.94); }
.chip .chip-dot { background: currentColor; opacity: .85; }
.chip:not(.is-on) .chip-dot { background: var(--cat-color, var(--red)); }
.chip-count { font-size: 10.5px; opacity: .7; }
.filter-foot {
  border-top: 1px solid var(--line); padding-top: 13px; margin-top: 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.result-count { margin: 0; color: var(--ink-2); font-size: 12.5px; }
.result-count b { color: var(--red); font-size: 15px; font-family: var(--serif); }
.reset-btn {
  border: 1px solid var(--line-strong); background: var(--surface-2);
  border-radius: 6px; padding: 6px 12px; font-size: 12px; color: var(--ink-2);
}
.reset-btn:hover { border-color: var(--red); color: var(--red); }

/* ---------- 人物卡 ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(286px, 1fr)); gap: 14px; }
.person-card {
  position: relative; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 17px 14px; overflow: hidden;
  box-shadow: var(--shadow-sm); transition: border-color .2s, box-shadow .2s, transform .2s;
  display: flex; flex-direction: column; min-height: 190px;
}
.person-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--cat-color, var(--red));
}
.person-card:hover { border-color: #d9c4b9; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.pc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pc-name { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: .03em; }
.pc-arrow { color: var(--ink-3); font-size: 15px; transition: transform .18s, color .18s; }
.person-card:hover .pc-arrow { color: var(--red); transform: translateX(3px); }
.pc-title { color: var(--ink-2); font-size: 11.5px; margin: 3px 0 11px; line-height: 1.5; min-height: 17px; }
.pc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag {
  border-radius: 4px; padding: 2px 7px; font-size: 10.5px; line-height: 1.6;
  border: 1px solid transparent; white-space: nowrap;
}
.tag-cat { color: var(--cat-color); border-color: currentColor; background: #fff; }
.tag-rel { background: var(--surface-3); color: var(--ink-2); }
.pc-note {
  color: var(--ink-2); font-size: 12.5px; line-height: 1.65; margin: 0 0 12px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.pc-foot {
  margin-top: auto; border-top: 1px dashed var(--line); padding-top: 9px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.pc-eras { display: flex; flex-wrap: wrap; gap: 4px; }
.era-mini { font-size: 10.5px; color: var(--ink-3); background: var(--surface-2); border-radius: 3px; padding: 1px 6px; }
.pc-source { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-2); }
.empty-mark { font-size: 40px; color: var(--line-strong); margin: 0 0 8px; }
.empty-state h3 { font-family: var(--serif); font-size: 18px; margin: 0 0 6px; }
.empty-state p { margin: 0; font-size: 13px; }

/* ---------- 世系图 ---------- */
.graph-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 14px; font-size: 12px; color: var(--ink-2); }
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-swatch { width: 18px; height: 12px; border-radius: 3px; border: 1px solid var(--line-strong); background: var(--surface); }
.legend-swatch.branch { border-style: dashed; background: var(--surface-3); }
.legend-line { width: 22px; height: 0; border-top: 2px solid var(--gold); }
.legend-line.dashed { border-top-style: dashed; border-color: var(--red); }
.gen-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.gen-nav-label { font-size: 11px; color: var(--ink-3); margin-right: 4px; letter-spacing: .06em; }
.gen-btn {
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 5px; padding: 3px 9px; font-size: 11.5px; color: var(--ink-2);
  transition: border-color .16s, color .16s;
}
.gen-btn:hover { border-color: var(--red); color: var(--red); }
.graph-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; box-shadow: var(--shadow-sm);
}
.graph-scroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; }
.graph-scroll::-webkit-scrollbar { height: 9px; }
.graph-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
.graph-scroll::-webkit-scrollbar-track { background: var(--surface-2); }
#lineageSvg { display: block; }
.graph-hint { text-align: center; margin: 6px 0 2px; font-size: 11px; color: var(--ink-3); }
.g-grid-line { stroke: #efe9dc; stroke-width: 1; }
.g-gen-label { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); text-anchor: middle; }
.g-edge { fill: none; stroke: var(--gold); stroke-width: 1.6; opacity: .8; }
.g-edge-label { fill: #96763c; font-size: 10px; font-family: var(--sans); text-anchor: middle; }
.g-special { fill: none; stroke: var(--red); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .75; }
.g-special.contested { stroke: #8c4a3b; }
.g-special-label { fill: var(--red); font-size: 9.5px; font-family: var(--sans); text-anchor: middle; }
.g-node { cursor: pointer; }
.g-node rect { fill: #fffdf9; stroke: #cdbfa6; stroke-width: 1.3; rx: 6; }
.g-node:hover rect { stroke: var(--red); stroke-width: 2; fill: #fff8f5; }
.g-node.is-branch rect { fill: var(--surface-3); stroke-dasharray: 4 3; }
.g-node .g-order { fill: #fff; font-size: 10px; font-family: var(--sans); text-anchor: middle; }
.g-node .g-name { fill: var(--ink); font-size: 14px; font-family: var(--serif); font-weight: 600; }
.g-node .g-temple { fill: var(--ink-2); font-size: 10.5px; font-family: var(--sans); }
.g-node .g-era { fill: var(--red); font-size: 10px; font-family: var(--sans); }
.g-node.is-branch .g-name { fill: var(--ink-2); }

/* ---------- 数据说明 ---------- */
.about-section { margin-bottom: 30px; }
.about-section > h2 {
  font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 0 0 12px;
  padding-left: 11px; border-left: 3px solid var(--red); line-height: 1.2;
}
.about-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.about-card + .about-card { margin-top: 12px; }
.about-card p { margin: 0 0 8px; color: var(--ink-2); font-size: 13px; }
.about-card p:last-child { margin-bottom: 0; }
.about-card strong { color: var(--ink); }
.def-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.def-table th, .def-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.def-table th { color: var(--ink-3); font-weight: 500; font-size: 11px; letter-spacing: .06em; background: var(--surface-2); }
.def-table tr:last-child td { border-bottom: 0; }
.def-table td:first-child { white-space: nowrap; font-weight: 600; }
.def-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; }
.source-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.source-item { border: 1px solid var(--line); border-radius: 7px; padding: 11px 13px; background: var(--surface-2); }
.source-item b { font-family: var(--serif); font-size: 15px; }
.source-item span { color: var(--ink-3); font-size: 11px; margin-left: 7px; }
.source-item p { margin: 4px 0 0; font-size: 11.5px; color: var(--ink-2); }
.gap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 11px; }
.gap-card { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 13px 15px; background: var(--surface-2); }
.gap-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.gap-top b { font-family: var(--serif); font-size: 15px; }
.status-tag { font-size: 10.5px; color: var(--red); border: 1px solid #e6c9c2; background: #fff8f6; border-radius: 4px; padding: 1px 7px; }
.gap-card p { margin: 0; font-size: 12px; color: var(--ink-2); }
.code-block {
  background: #2e3231; color: #e9e4d9; border-radius: 8px; padding: 14px 16px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px; line-height: 1.8; overflow-x: auto; margin: 12px 0 0;
}
.code-block .cm { color: #a5b3a9; }
.code-block .k { color: #e5b979; }
.scholar-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.scholar-list span { font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 3px 9px; color: var(--ink-2); }

/* ---------- 详情抽屉 ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(35, 30, 24, .34);
  opacity: 0; transition: opacity .25s;
}
.drawer-backdrop.is-open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(470px, 100%); background: var(--surface);
  box-shadow: var(--shadow-lg); transform: translateX(102%);
  transition: transform .3s cubic-bezier(.22,.7,.3,1);
  display: flex; flex-direction: column; outline: 0;
}
.drawer.is-open { transform: none; }
.drawer-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.drawer-kicker { font-size: 11px; letter-spacing: .16em; color: var(--red); font-weight: 700; }
.drawer-close {
  border: 0; background: transparent; font-size: 26px; line-height: 1;
  color: var(--ink-2); width: 32px; height: 32px; border-radius: 6px;
}
.drawer-close:hover { background: var(--surface-3); color: var(--red); }
.drawer-body { overflow-y: auto; padding: 24px 24px 48px; flex: 1; }
.d-hero { border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 18px; }
.d-hero h2 { font-family: var(--serif); font-size: 29px; margin: 0 0 4px; letter-spacing: .05em; line-height: 1.3; }
.d-hero .d-title { color: var(--ink-2); font-size: 13px; margin: 0 0 12px; }
.d-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.d-tag { font-size: 11.5px; border-radius: 4px; padding: 3px 9px; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface-2); }
.d-tag.cat { color: #fff; border-color: transparent; }
.d-section { margin-bottom: 22px; }
.d-section h3 {
  font-family: var(--serif); font-size: 15px; margin: 0 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.d-section h3::before { content: ''; width: 3px; height: 14px; background: var(--red); border-radius: 2px; }
.d-section p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.85; }
.d-list { margin: 0; display: grid; grid-template-columns: 84px 1fr; gap: 9px 12px; font-size: 13px; }
.d-list dt { color: var(--ink-3); font-size: 12px; }
.d-list dd { margin: 0; color: var(--ink); }
.d-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.d-chip { font-size: 11.5px; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: 20px; padding: 2px 10px; color: var(--ink-2); }
.d-note-box { background: var(--surface-2); border-left: 3px solid var(--gold); border-radius: 0 7px 7px 0; padding: 12px 14px; font-size: 13px; color: var(--ink-2); line-height: 1.85; }
.d-source { font-size: 12px; color: var(--ink-2); background: #fbf6ea; border: 1px solid #eee2c8; border-radius: 7px; padding: 11px 13px; line-height: 1.8; }
.d-links { display: flex; flex-direction: column; gap: 7px; }
.d-link-row {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: 7px; padding: 9px 12px; display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; transition: all .16s;
}
.d-link-row:hover { border-color: var(--red); background: #fff9f7; }
.d-link-row .dl-name { font-family: var(--serif); font-size: 15px; }
.d-link-row .dl-title { color: var(--ink-3); font-size: 11px; margin-left: auto; text-align: right; max-width: 190px; }
.d-event-list { list-style: none; padding: 0; margin: 0; }
.d-event-list li { position: relative; padding-left: 17px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.d-event-list li::before { content: '·'; position: absolute; left: 4px; color: var(--red); font-weight: 700; }
.d-callout { font-size: 12px; color: var(--ink-2); background: var(--red-soft); border-radius: 7px; padding: 10px 13px; line-height: 1.75; }
.d-subhead { font-size: 11px; color: var(--ink-3); letter-spacing: .08em; margin: 16px 0 7px; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line); background: var(--surface-3);
  padding: 24px; text-align: center; color: var(--ink-2); font-size: 12px;
}
.site-footer p { margin: 0 0 4px; }
.footer-note { color: var(--ink-3); font-size: 11px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .header-inner { flex-wrap: wrap; gap: 10px; padding: 10px 18px; }
  .main-nav { width: 100%; }
  .nav-btn { flex: 1; text-align: center; padding: 8px 10px; }
  .stat-strip-inner { grid-template-columns: repeat(2, 1fr); gap: 14px 0; padding: 14px 18px; }
  .stat-item:nth-child(2), .stat-item:nth-child(4), .stat-item:nth-child(5) { border-right: 0; }
  .stat-item:nth-child(3), .stat-item:nth-child(5) { padding-left: 0; }
  .stat-item:nth-child(5) {
    grid-column: 1 / -1; border-top: 1px solid var(--line);
    padding-top: 10px; margin-top: 2px;
  }
  .stat-note { display: none; }
  .page { padding: 28px 18px 70px; }
  .view-head h1 { font-size: 25px; }
  .filter-row-top { grid-template-columns: minmax(150px, 1fr) 188px 148px; gap: 10px; }
  .drawer { width: min(430px, 100%); }
}
@media (max-width: 620px) {
  .brand-text strong { font-size: 17px; }
  .brand-text small { font-size: 10px; }
  .seal { width: 37px; height: 37px; font-size: 22px; }
  .stat-num { font-size: 23px; }
  .stat-item { padding: 2px 12px; }
  .stat-label { font-size: 11px; }
  .page { padding: 24px 14px 60px; }
  .view-head h1 { font-size: 22px; }
  .view-desc { font-size: 12.5px; }
  .tl-row { grid-template-columns: 18px 1fr; }
  .tl-year { grid-column: 2; grid-row: 1; text-align: left; padding: 0 0 6px 22px; font-size: 12px; }
  .tl-year small { display: inline; margin-left: 8px; }
  .tl-rail { grid-column: 1; grid-row: 1 / span 2; }
  .tl-rail::before { left: 5px; transform: none; }
  .tl-dot { left: 5px; top: 4px; }
  .emp-card { grid-column: 2; padding: 15px 14px; margin-left: 8px; }
  .emp-reign { margin-left: 0; width: 100%; }
  .emp-foot { flex-direction: column; align-items: flex-start; }
  .filter-panel { padding: 15px; }
  .filter-row-top { grid-template-columns: minmax(0, 1fr) 140px 118px; gap: 8px; }
  .people-grid { grid-template-columns: 1fr; }
  .person-card { min-height: 0; }
  .drawer { width: 100%; }
  .drawer-body { padding: 20px 18px 44px; }
  .d-hero h2 { font-size: 25px; }
  .d-list { grid-template-columns: 72px 1fr; }
  .d-link-row .dl-title { display: none; }
  .graph-wrap { padding: 8px; }
  .period-divider { flex-wrap: wrap; gap: 6px 12px; }
  .period-divider .pd-desc { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
body.drawer-open { overflow: hidden; }

/* ---------- 视图五：官职机构 ---------- */
.office-notice {
  background: #fbf1ee; border: 1px solid #edd8d1; border-left: 3px solid var(--red);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 15px 18px; margin-bottom: 18px;
}
.notice-head { display: flex; align-items: center; gap: 12px; }
.notice-seal {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 5px;
  background: var(--red); color: #fff; display: grid; place-items: center;
  font-family: var(--serif); font-size: 17px;
}
.notice-head b { display: block; font-family: var(--serif); font-size: 15px; line-height: 1.35; }
.notice-head small { display: block; color: var(--ink-2); font-size: 11.5px; }
.office-notice p { margin: 11px 0 0; font-size: 12.5px; line-height: 1.85; color: var(--ink-2); }
.notice-link {
  border: 0; background: transparent; color: var(--red); font-size: 12px;
  padding: 8px 0 0; font-weight: 600;
}
.notice-link:hover { text-decoration: underline; }

.office-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.office-stat {
  display: flex; align-items: center; gap: 12px; padding: 12px 15px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.os-num { font-family: var(--serif); font-size: 26px; line-height: 1; color: var(--red); }
.os-text { display: flex; flex-direction: column; line-height: 1.4; }
.os-text b { font-size: 12.5px; font-weight: 600; }
.os-text small { font-size: 10.5px; color: var(--ink-3); }

.office-filter-top { grid-template-columns: minmax(240px, 1fr) 168px 200px; }
.mode-switch {
  height: 42px; width: 100%; display: flex; border: 1px solid var(--line-strong);
  border-radius: 7px; overflow: hidden; background: var(--surface-2);
}
.mode-btn {
  flex: 1; border: 0; background: transparent; color: var(--ink-2);
  font-size: 12.5px; transition: background .16s, color .16s;
}
.mode-btn + .mode-btn { border-left: 1px solid var(--line-strong); }
.mode-btn:hover { color: var(--red); }
.mode-btn.is-on { background: var(--red); color: #fff; font-weight: 600; }
.mode-btn.is-on:hover { color: #fff; }

.level-badge {
  display: inline-block; border-radius: 4px; padding: 2px 7px;
  font-size: 10.5px; line-height: 1.6; white-space: nowrap;
  border: 1px solid transparent;
}
.lv-ref   { background: #eaf2ef; border-color: #c6ded6; color: #2f6155; }
.lv-split { background: #faf2e5; border-color: #e8d7b6; color: #8a6527; }
.lv-none  { background: #f6ecea; border-color: #e5cdc7; color: #8c453d; }

.office-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.office-card {
  position: relative; text-align: left; width: 100%; min-height: 232px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 17px 13px; box-shadow: var(--shadow-sm); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.office-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--cat-color, var(--red));
}
.office-card:hover { border-color: #d9c4b9; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.oc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.oc-name { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: .03em; }
.oc-arrow { color: var(--ink-3); font-size: 15px; transition: transform .18s, color .18s; }
.office-card:hover .oc-arrow { color: var(--red); transform: translateX(3px); }
.oc-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 9px 0 8px; }
.oc-rank {
  font-size: 11px; color: var(--ink-3); line-height: 1.5; margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.oc-brief { font-size: 12.5px; line-height: 1.65; color: var(--ink-2); margin-bottom: 11px; }
.oc-modern {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font-size: 11.5px; line-height: 1.65; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.oc-modern-label {
  display: block; font-size: 10px; letter-spacing: .08em;
  color: var(--red); font-weight: 700; margin-bottom: 2px;
}
.oc-foot {
  margin-top: auto; border-top: 1px dashed var(--line); padding-top: 9px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 10.5px; color: var(--ink-3);
}

.compare-wrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-x: auto;
}
.compare-table { width: 100%; min-width: 1060px; border-collapse: collapse; font-size: 12px; }
.compare-table th, .compare-table td {
  text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line);
  vertical-align: top; line-height: 1.7;
}
.compare-table th {
  color: var(--ink-3); font-weight: 500; font-size: 11px; letter-spacing: .06em;
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
.compare-table tbody tr:hover { background: #fffaf7; }
.compare-table tr:last-child td { border-bottom: 0; }
.compare-table td:first-child { min-width: 132px; }
.compare-table td:nth-child(3) { min-width: 250px; }
.compare-table td:nth-child(5) { min-width: 230px; color: var(--ink-2); }
.cmp-name {
  border: 0; background: transparent; padding: 0; color: var(--ink);
  font-family: var(--serif); font-size: 15px; font-weight: 600; text-align: left;
}
.cmp-name:hover { color: var(--red); text-decoration: underline; }
.cmp-meta { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }

.caveat-list { margin: 0; padding-left: 20px; }
.caveat-list li { font-size: 12.5px; color: var(--ink-2); line-height: 1.85; margin-bottom: 9px; }
.caveat-list li:last-child { margin-bottom: 0; }
#officeCaveats { scroll-margin-top: 92px; }

.off-timeline {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.off-tl-item {
  display: grid; grid-template-columns: 138px 1fr; gap: 18px;
  position: relative; padding-bottom: 17px;
}
.off-tl-item:last-child { padding-bottom: 0; }
.off-tl-item::before {
  content: ''; position: absolute; left: 138px; top: 8px; bottom: -4px;
  width: 2px; background: #d9c9a9;
}
.off-tl-item:last-child::before { display: none; }
.off-tl-item::after {
  content: ''; position: absolute; left: 134px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--red); z-index: 1;
}
.off-tl-year { text-align: right; padding-right: 14px; font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
.off-tl-body b { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.off-tl-body p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.75; }

.rank-table td:first-child { width: 96px; color: var(--red); font-family: var(--serif); font-size: 14px; }
.rank-table td:last-child { color: var(--ink-2); }
.glossary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.glossary-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 14px; box-shadow: var(--shadow-sm);
}
.glossary-item b { font-family: var(--serif); font-size: 15px; color: var(--red); }
.glossary-item p { margin: 4px 0 0; font-size: 12px; color: var(--ink-2); line-height: 1.7; }

@media (max-width: 900px) {
  .office-filter-top { grid-template-columns: minmax(150px, 1fr) 140px 180px; gap: 10px; }
  .office-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .office-filter-top { grid-template-columns: minmax(0, 1fr) 118px 150px; gap: 8px; }
  .office-grid { grid-template-columns: 1fr; }
  .office-card { min-height: 0; }
  .office-stats { gap: 8px; }
  .office-stat { padding: 10px 12px; gap: 9px; }
  .os-num { font-size: 22px; }
  .off-tl-item { grid-template-columns: 1fr; gap: 2px; padding-left: 20px; }
  .off-tl-item::before { left: 5px; top: 10px; }
  .off-tl-item::after { left: 1px; top: 6px; }
  .off-tl-year { text-align: left; padding-right: 0; }
  .notice-head { align-items: flex-start; }
  .office-notice { padding: 13px 14px; }
}
/* 手机窄屏才改为纵向堆叠 */
@media (max-width: 480px) {
  .filter-row-top, .office-filter-top { grid-template-columns: 1fr; }
}

/* ---------- 交互态补充 ---------- */
button.stat-item {
  background: transparent; border-top: 0; border-left: 0; border-bottom: 0;
  text-align: left; width: 100%; font-family: inherit;
}
button.stat-item:hover .stat-label { color: var(--red); }
.tl-row.is-first .tl-rail::before { top: 22px; }
.tl-row.is-last .tl-rail::before { bottom: calc(100% - 22px); }
.d-chip[data-person], .d-chip[data-emperor] { cursor: pointer; transition: border-color .16s, color .16s, background .16s; }
.d-chip[data-person]:hover, .d-chip[data-emperor]:hover {
  border-color: var(--red); color: var(--red); background: #fff9f7;
}
.about-card code, .view-desc code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  background: var(--surface-3); padding: 1px 5px; border-radius: 3px; font-size: 12px;
}
@media (max-width: 620px) {
  .tl-row.is-first .tl-rail::before { top: 0; }
  .tl-row.is-last .tl-rail::before { bottom: 0; }
}
