:root {
  --paper: #f4f0e6;
  --paper-light: #fcfaf4;
  --ink: #2f2a24;
  --muted: #766d61;
  --rule: #d7cebd;
  --rule-dark: #b8aa94;
  --cinnabar: #88483d;
  --green: #347365;
  --ochre: #b1783e;
  --ui-font: "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --reading-font: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", STSong, SimSun, serif;
  --shadow: 0 12px 32px rgba(54, 43, 31, .09);
  --detail-width: 440px;
  --timeline-height: 250px;
}

* { box-sizing: border-box; }
html { height: 100%; scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(92, 73, 47, .025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 28px;
  font-family: var(--reading-font);
  font-size: 16px;
  line-height: 1.6;
}

button, input, select { font-family: var(--ui-font); }
button { color: inherit; }
a { color: var(--cinnabar); }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.skip-link {
  position: fixed;
  z-index: 99;
  top: -60px;
  left: 1rem;
  padding: .55rem .8rem;
  color: #fff;
  background: var(--cinnabar);
}
.skip-link:focus { top: .5rem; }

.page-shell {
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) 8px var(--timeline-height) auto;
}

.site-header {
  min-width: 0;
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  color: #fdf9ee;
  background: #3c352e;
  border-bottom: 3px solid var(--cinnabar);
}

.title-mark {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  color: #fff8e8;
  background: var(--cinnabar);
  border: 1px solid rgba(255,255,255,.35);
  font-size: 27px;
  line-height: 1;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.08);
}

.title-copy h1 {
  margin: 0;
  font-size: clamp(20px, 2vw, 27px);
  font-weight: 600;
  letter-spacing: .12em;
}
.title-copy p { margin: 3px 0 0; color: #cfc6b9; font-size: 12px; letter-spacing: .05em; }

.header-counts { display: flex; flex-wrap: wrap; gap: 18px; color: #d8d0c5; font-family: var(--ui-font); font-size: 12px; }
.header-counts span { display: grid; justify-items: end; }
.header-counts b { color: #fff7e8; font-size: 18px; font-weight: 500; line-height: 1.1; }

.toolbar {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  min-height: 54px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 22px;
  background: rgba(252, 250, 244, .96);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 3px 12px rgba(62, 49, 35, .05);
}

.search-box {
  min-width: 220px;
  flex: 0 1 270px;
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) auto;
  align-items: center;
  border: 1px solid var(--rule-dark);
  background: #fff;
}
.search-box label { padding: 0 10px; color: var(--cinnabar); font-family: var(--ui-font); font-size: 13px; font-weight: 700; }
.search-box input { min-width: 0; height: 38px; padding: 0 9px; border: 0; border-left: 1px solid var(--rule); outline: 0; background: transparent; font-size: 14px; }
.search-box input:focus { box-shadow: inset 0 -2px var(--cinnabar); }
.search-box button, #fit-graph {
  height: 38px;
  padding: 0 11px;
  color: var(--cinnabar);
  border: 0;
  border-left: 1px solid var(--rule);
  background: #f7f1e5;
  cursor: pointer;
}
.search-box button:hover, #fit-graph:hover { background: #eee3d1; }

.type-filters { min-width: 560px; min-inline-size: 0; flex: 1 1 610px; display: flex; align-items: center; gap: 3px; margin: 0; padding: 0; overflow-x: auto; border: 0; scrollbar-width: thin; }
.type-filters label, .fixed-layer, .type-filters button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  color: var(--muted);
  border: 1px solid var(--rule);
  background: transparent;
  font-family: var(--ui-font);
  font-size: 13px;
  white-space: nowrap;
}
.type-filters label, .type-filters button { cursor: pointer; }
.type-filters label:has(input:checked) { color: var(--ink); border-color: var(--rule-dark); background: #fff; box-shadow: inset 0 -2px var(--cinnabar); }
.type-filters label:hover, .type-filters button:hover { color: var(--ink); background: #f3ecdf; }
.type-filters input { width: 14px; height: 14px; margin: 0; accent-color: var(--cinnabar); }
.fixed-layer { color: var(--cinnabar); background: #f7eee7; border-color: #c9a89f; }
.filter-actions { display: inline-flex; gap: 2px; }
.filter-actions button { border-color: transparent; padding: 0 7px; font-size: 12px; }
.research-filters {
  min-width: 0;
  flex: 0 1 360px;
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0;
  padding: 0;
  border: 0;
}
.research-filters label {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding-left: 7px;
  color: var(--muted);
  border: 1px solid var(--rule);
  background: #fffdf8;
  font-family: var(--ui-font);
  font-size: 12px;
  white-space: nowrap;
}
.research-filters select {
  min-width: 0;
  max-width: 168px;
  height: 36px;
  padding: 0 22px 0 6px;
  color: var(--ink);
  border: 0;
  border-left: 1px solid var(--rule);
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.research-filters label:focus-within { border-color: var(--cinnabar); box-shadow: inset 0 -2px var(--cinnabar); }
.toolbar button[aria-busy="true"] { color: var(--muted); background: #eee5d7; cursor: progress; opacity: .75; }
.is-source-loading #network { cursor: progress; }
.language-toggle {
  height: 38px;
  padding: 0 11px;
  color: var(--cinnabar);
  border: 1px solid var(--rule);
  background: #fffdf8;
  cursor: pointer;
  font-family: var(--ui-font);
  font-size: 13px;
  white-space: nowrap;
}
.language-toggle:hover { background: #f3e8d7; }
.type-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; }
.type-dot.is-ancestor { background: var(--cinnabar); }
.type-dot.is-monastic { background: var(--green); transform: rotate(45deg); border-radius: 1px; }
.type-dot.is-official { background: #9b6032; border-radius: 1px; }
.type-dot.is-literati { background: #81623f; }
.type-dot.is-imperial { background: #725779; border-radius: 1px; transform: rotate(45deg); }
.type-dot.is-other { background: #91897d; border-radius: 1px; transform: rotate(45deg); }

.relation-legend { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-family: var(--ui-font); font-size: 12px; white-space: nowrap; }
.relation-legend span { display: inline-flex; align-items: center; gap: 4px; }
.relation-legend i { width: 20px; height: 0; border-top: 2px solid var(--line); }
.relation-legend i.is-dashed { border-top-style: dashed; }

.main-grid {
  min-width: 0;
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 8px min(var(--detail-width), 44vw);
  background: var(--paper-light);
  border-bottom: 1px solid var(--rule-dark);
}

.graph-pane { min-width: 0; min-height: 0; position: relative; overflow: hidden; border-right: 0; background: #f9f6ee; }
.graph-pane::before {
  content: "";
  position: absolute;
  inset: 52px 0 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 45%, rgba(177, 120, 62, .07), transparent 42%),
    linear-gradient(90deg, transparent 49.9%, rgba(113, 94, 67, .045) 50%, transparent 50.1%),
    linear-gradient(transparent 49.9%, rgba(113, 94, 67, .045) 50%, transparent 50.1%);
  background-size: auto, 120px 120px, 120px 120px;
}

.pane-head {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px 8px 18px;
  background: rgba(249, 246, 238, .92);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(6px);
}
.pane-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .1em; }
.pane-head p { margin: 3px 0 0; color: var(--muted); font-family: var(--ui-font); font-size: 12px; line-height: 1.45; }
#fit-graph { border: 1px solid var(--rule); }
.pane-actions { display: flex; align-items: center; gap: 6px; }
.pane-actions a { height: 38px; display: inline-flex; align-items: center; padding: 0 11px; color: var(--cinnabar); border: 1px solid var(--rule); background: #fffdf8; font-family: var(--ui-font); text-decoration: none; font-size: 12px; }
.pane-actions a:hover { background: #eee3d1; }

#network { position: absolute; inset: 52px 0 26px; }
.graph-tip { position: absolute; z-index: 3; left: 12px; bottom: 5px; margin: 0; color: #766d61; font-family: var(--ui-font); font-size: 11px; }
.graph-error { position: absolute; z-index: 6; inset: 52px 0 0; display: grid; place-items: center; color: var(--cinnabar); background: #faf7ef; }

.panel-splitter { position: relative; z-index: 5; min-width: 8px; background: var(--rule); cursor: col-resize; touch-action: none; outline: none; }
.panel-splitter::after { content: ""; position: absolute; top: 50%; left: 2px; width: 4px; height: 42px; border-top: 1px solid var(--rule-dark); border-bottom: 1px solid var(--rule-dark); transform: translateY(-50%); }
.panel-splitter:hover, .panel-splitter.is-dragging, .panel-splitter:focus-visible { background: var(--cinnabar); }
.timeline-splitter { position: relative; z-index: 5; min-height: 8px; background: var(--rule); cursor: row-resize; touch-action: none; outline: none; }
.timeline-splitter::after { content: ""; position: absolute; top: 2px; left: 50%; width: 42px; height: 4px; border-left: 1px solid var(--rule-dark); border-right: 1px solid var(--rule-dark); transform: translateX(-50%); }
.timeline-splitter:hover, .timeline-splitter.is-dragging, .timeline-splitter:focus-visible { background: var(--cinnabar); }
.detail-pane { min-width: 0; min-height: 0; overflow: hidden; background: #fffdf8; }
#detail { height: 100%; max-height: none; overflow-y: auto; scrollbar-color: var(--rule-dark) transparent; }
.detail-loading, .detail-welcome { padding: 58px 30px; color: var(--muted); text-align: center; }
.detail-welcome .seal { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 18px; color: var(--cinnabar); border: 2px solid var(--cinnabar); transform: rotate(-4deg); }
.detail-welcome h2 { margin: 0 0 12px; color: var(--ink); font-size: 24px; font-weight: 500; }
.detail-welcome p { margin: 8px 0; font-family: FangSong, STFangsong, serif; font-size: 14px; line-height: 1.75; }
.truth-note { padding-top: 12px; border-top: 1px dotted var(--rule-dark); font-size: 12px !important; }

.person-detail { padding: 24px 24px 42px; }
.person-title { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.person-title p { margin: 0 0 7px; color: var(--muted); font-family: var(--ui-font); font-size: 13px; }
.person-title h2 { margin: 0; color: var(--cinnabar); font-size: 32px; font-weight: 650; letter-spacing: .05em; line-height: 1.2; }
.person-title strong { display: block; margin-top: 7px; color: #6e5545; font-size: 14px; font-weight: 500; }
.person-kind { display: inline-block; margin-right: 7px; padding: 2px 6px; color: #fff; }
.person-kind.is-ancestor { background: var(--cinnabar); }
.person-kind.is-monastic { background: var(--green); }
.person-kind.is-official { background: #9b6032; }
.person-kind.is-literati { background: #81623f; }
.person-kind.is-imperial { background: #725779; }
.person-kind.is-other { color: #fffdf6; background: #91897d; }
.review-badge { align-self: start; padding: 5px 8px; border: 1px solid currentColor; font-family: var(--ui-font); font-size: 12px; white-space: nowrap; }
.review-badge.is-accepted, .is-accepted { color: #2e6f5f; }
.review-badge.is-pending, .is-pending { color: #9a6840; }

.person-meta { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 18px; border-bottom: 1px solid var(--rule); }
.person-meta div { min-width: 0; display: grid; grid-template-columns: 48px 1fr; gap: 8px; padding: 10px 5px; border-bottom: 1px dotted var(--rule); }
.person-meta div:nth-last-child(-n+2) { border-bottom: 0; }
.person-meta dt { color: var(--muted); font-family: var(--ui-font); font-size: 12px; letter-spacing: .1em; }
.person-meta dd { margin: 0; overflow-wrap: anywhere; font-family: var(--reading-font); font-size: 14px; line-height: 1.6; }
.time-admission-note { margin: -5px 0 16px; padding: 9px 11px; border-left: 3px solid var(--ochre); background: #faf3e5; color: #76583d; font-family: var(--reading-font); font-size: 13px; line-height: 1.7; }
.time-admission-note.is-undated { border-left-color: var(--cinnabar); background: #f8eee8; }
.candidate-note { margin: -5px 0 16px; padding: 10px 12px; border-left: 3px solid #91897d; background: #f1eee8; color: #625b53; font-family: var(--reading-font); font-size: 13px; line-height: 1.7; }
.source-candidate-research { margin-top: 18px; }
.candidate-evidence-note { margin: 10px 0 14px; padding: 10px 11px; color: var(--muted); background: #f5efe4; border-left: 2px solid var(--ochre); font-size: 13px; line-height: 1.7; }
.pilot-review-section { margin: 18px -4px 0; padding: 0 4px 10px; border-top: 3px solid #81623f; background: linear-gradient(180deg, rgba(129,98,63,.06), transparent 84px); }
.pilot-review-section .section-title { margin-top: 0; }
.pilot-summary { margin: 10px 0; padding: 10px 11px; color: #625545; background: #f5efe4; border-left: 2px solid #81623f; font-size: 13px; line-height: 1.7; }
.pilot-badge { display: inline-block; margin-right: 6px; padding: 2px 6px; color: #fffdf8; background: #81623f; font-family: var(--ui-font); font-size: 11px; letter-spacing: .03em; }
.pilot-entry-card.is-mention { background: #f8f6f0; border-color: #aaa194; }
.pilot-review-card { border-color: #9b6032; box-shadow: inset 3px 0 #9b6032; }
.pilot-no-line { color: var(--cinnabar) !important; font-family: var(--ui-font) !important; font-size: 12px !important; font-weight: 650; }

.section-title { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 22px; border-bottom: 1px solid var(--rule-dark); }
.section-title h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .08em; }
.section-title span { color: var(--muted); font-family: var(--ui-font); font-size: 12px; }
.source-intro h4 { margin: 13px 0 5px; font-size: 16px; }
.source-intro blockquote, .source-card blockquote {
  margin: 10px 0;
  padding: 10px 12px;
  color: #443b33;
  background: #f7f1e5;
  border-left: 3px solid var(--cinnabar);
  font-family: FangSong, STFangsong, serif;
  font-size: 15px;
  line-height: 1.9;
}
.person-profile-summary { margin: 12px 0; color: #443b33; font-family: var(--reading-font); font-size: 15px; line-height: 1.9; }
.person-profile-facts { margin: 0; border-top: 1px dotted var(--rule); }
.person-profile-facts div { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 10px; padding: 8px 3px; border-bottom: 1px dotted var(--rule); }
.person-profile-facts dt { color: var(--muted); font-family: var(--ui-font); font-size: 12px; }
.person-profile-facts dd { margin: 0; overflow-wrap: anywhere; font-family: var(--reading-font); font-size: 14px; line-height: 1.65; }
.person-sources { margin-top: 14px; overflow: hidden; color: var(--muted); border: 1px solid var(--rule); background: rgba(255,255,255,.6); font-family: var(--ui-font); font-size: 12px; line-height: 1.55; }
.person-sources-heading { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; background: #f4eee2; border-bottom: 1px solid var(--rule); }
.person-sources-heading b { color: var(--ink); font-size: 13px; }
.person-sources-heading span { white-space: nowrap; font-size: 11px; }
.person-source-list { display: grid; }
.person-source-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px; border-bottom: 1px dotted var(--rule); }
.person-source-row:last-child { border-bottom: 0; }
.person-source-copy { min-width: 0; display: grid; gap: 2px; }
.person-source-copy strong { overflow-wrap: anywhere; color: var(--ink); font-family: var(--reading-font); font-size: 13px; font-weight: 650; line-height: 1.55; }
.person-source-copy span { overflow-wrap: anywhere; color: #665d54; font-family: var(--reading-font); font-size: 12px; }
.person-source-copy code { overflow-wrap: anywhere; color: #7b6d60; background: transparent; font-family: Consolas, "SFMono-Regular", monospace; font-size: 10.5px; }
.source-link-button { min-width: 92px; min-height: 34px; display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 9px; color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 42%, var(--rule)); background: #f8fbf7; text-decoration: none; white-space: nowrap; }
.source-link-button:hover { background: #edf3ec; border-color: var(--green); }
.source-link-button i { font-style: normal; }
.source-link-missing { white-space: nowrap; font-size: 11px; }
.person-sources.is-compact { margin-top: 11px; }
.person-sources.is-compact .person-sources-heading { background: #f8f4ec; }
.citation-row { display: grid !important; grid-template-columns: minmax(0, 1fr); gap: 6px !important; }
.citation-link { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 7px 9px; color: var(--green); border: 1px dotted color-mix(in srgb, var(--green) 55%, var(--rule)); background: #f8fbf7; text-decoration: none; }
.citation-link:hover { background: #edf3ec; }
.citation-link b { font-size: 11px; letter-spacing: .04em; }
.citation-link span { min-width: 0; overflow-wrap: anywhere; color: #375f55; font-family: var(--reading-font); font-size: 12px; }
.citation-link i { font-style: normal; }
.citation-missing { padding: 6px 8px; background: #f4eee2; }
.event-card a, .source-card footer a { color: var(--green); text-decoration: none; border-bottom: 1px dotted currentColor; }

.focused-relation { margin: 20px -8px 0; padding: 0 12px 14px; background: #faf5e9; border: 1px solid color-mix(in srgb, var(--relation) 42%, #ddd); border-top: 4px solid var(--relation); }
.focused-relation .section-title { margin-top: 0; }
.relation-perspective { margin: 12px 0 0; padding: 9px 11px; color: var(--cinnabar); background: rgba(136,72,61,.07); font-size: 14px; line-height: 1.7; }
.relation-statement { display: flex; align-items: center; justify-content: center; gap: 9px; margin: 15px 0 10px; font-size: 15px; }
.relation-statement i { color: var(--relation); font-style: normal; }
.relation-note { margin: 8px 0; color: var(--muted); font-size: 14px; line-height: 1.65; text-align: center; }
.evidence-status { margin: 12px 0; padding: 9px 11px; background: rgba(255,255,255,.7); font-family: var(--ui-font); font-size: 12px; line-height: 1.65; }
.other-person { display: block; margin: 14px 0 0 auto; padding: 5px 0; color: var(--cinnabar); border: 0; border-bottom: 1px solid currentColor; background: transparent; cursor: pointer; font-size: 13px; }

.relation-list { margin: 0; padding: 0; list-style: none; }
.relation-list li { border-bottom: 1px solid var(--rule); }
.relation-list li.is-focused { background: #f7f0e4; }
.relation-list button { border: 0; background: transparent; cursor: pointer; }
.relation-person { width: 100%; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 10px 9px 13px; text-align: left; }
.relation-person:hover { background: #f9f4ea; }
.relation-person b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.relation-person span { color: var(--muted); font-family: var(--ui-font); font-size: 11px; white-space: nowrap; }
.relation-group-items { display: grid; margin-left: 12px; padding: 0 0 7px 10px; border-left: 1px dotted var(--rule); }
.relation-item { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; box-shadow: inset 3px 0 var(--relation); }
.relation-item.is-focused { background: rgba(255,255,255,.58); }
.relation-source { min-width: 0; display: grid; justify-items: start; gap: 2px; padding: 8px 9px 8px 12px; color: var(--cinnabar); text-align: left; }
.relation-source:hover { background: #f1e8d8; }
.relation-wording { overflow-wrap: anywhere; color: var(--relation); font-family: var(--reading-font); font-size: 13px; line-height: 1.55; }
.relation-source small { display: block; font-family: var(--ui-font); font-size: 10.5px; line-height: 1.45; }
.relation-cbeta { min-width: 72px; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 8px; color: var(--green); border-left: 1px dotted var(--rule); text-align: center; text-decoration: none; white-space: nowrap; font-family: var(--ui-font); font-size: 11px; }
.relation-cbeta:hover { background: #edf3ec; }

.source-card { margin-top: 12px; padding: 12px 13px; border: 1px solid var(--rule); background: #fff; box-shadow: 0 2px 8px rgba(63,48,33,.035); }
.source-card.is-candidate { border-style: dashed; background: #fffaf0; }
.source-card header { display: flex; justify-content: space-between; gap: 10px; font-family: var(--ui-font); font-size: 13px; }
.source-card header b { font-size: 14px; }
.source-card header span { color: var(--muted); font-size: 11px; }
.source-card .evidence-meta { margin: 7px 0 9px; color: #6e6256; font-family: var(--ui-font); font-size: 11px; line-height: 1.55; letter-spacing: .01em; }
.source-card p { margin: 9px 0; color: #534a42; font-family: var(--reading-font); font-size: 13px; line-height: 1.7; }
.source-card blockquote { margin: 9px 0; padding: 9px 11px; font-size: 14px; line-height: 1.85; }
.source-card footer, .citation-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 7px; margin-top: 9px; color: var(--muted); font-family: var(--ui-font); font-size: 11px; line-height: 1.55; }

.event-card { padding: 9px 0; border-bottom: 1px dotted var(--rule); }
.event-card h4 { margin: 0; font-size: 15px; }
.event-card p { margin: 5px 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.event-card a { margin-right: 9px; font-family: var(--ui-font); font-size: 12px; }
.empty-note, .more-note { margin: 12px 0; color: var(--muted); font-family: var(--reading-font); font-size: 13px; line-height: 1.7; }
.reading-disclosure { margin-top: 22px; border-top: 1px solid var(--rule-dark); }
.reading-disclosure > summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink); cursor: pointer; list-style: none; font-size: 17px; font-weight: 650; letter-spacing: .08em; }
.reading-disclosure > summary::-webkit-details-marker { display: none; }
.reading-disclosure > summary::after { content: "＋"; width: 24px; height: 24px; display: grid; place-items: center; color: var(--cinnabar); border: 1px solid var(--rule); background: #fff; font-family: var(--ui-font); font-size: 16px; line-height: 1; }
.reading-disclosure[open] > summary::after { content: "−"; }
.reading-disclosure > summary small { margin-left: auto; color: var(--muted); font-family: var(--ui-font); font-size: 12px; font-weight: 400; letter-spacing: 0; }
.reading-disclosure-body { padding-bottom: 4px; }
.excerpt-disclosure { margin: 8px 0; }
.excerpt-disclosure > summary { display: inline-flex; align-items: center; gap: 5px; padding: 4px 0; color: var(--cinnabar); cursor: pointer; font-family: var(--ui-font); font-size: 12px; }
.excerpt-disclosure > summary::before { content: "＋"; }
.excerpt-disclosure[open] > summary::before { content: "−"; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 2px; }
.more-note { text-align: center; }

.timeline-pane { min-width: 0; width: 100%; min-height: 0; overflow: hidden; display: grid; grid-template-rows: auto 61px auto minmax(0, 1fr); padding: 10px 22px 13px; background: #eee8dc; border-top: 1px solid #fff; }
.timeline-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.timeline-head h2 { margin: 0; font-size: 17px; letter-spacing: .1em; }
.timeline-head output { margin-left: 8px; color: var(--cinnabar); font-size: 16px; letter-spacing: .03em; }
.timeline-head p { margin: 3px 0 0; color: var(--muted); font-family: var(--ui-font); font-size: 12px; line-height: 1.45; }
.timeline-controls { display: flex; align-items: center; gap: 4px; }
.timeline-controls label { color: var(--muted); font-size: 12px; }
.timeline-controls select, .timeline-controls button, .timeline-pan-row button { height: 32px; padding: 0 9px; border: 1px solid var(--rule-dark); background: #fffdf8; color: var(--ink); cursor: pointer; font-size: 12px; }
.timeline-controls button:hover, .timeline-pan-row button:hover { background: #f3e8d7; }
.timeline-controls #time-zoom-in, .timeline-controls #time-zoom-out { width: 30px; padding: 0; color: var(--cinnabar); font-size: 16px; }

.timeline-ruler { position: relative; height: 61px; overflow: hidden; background: rgba(255,255,255,.78); border: 1px solid var(--rule-dark); cursor: grab; touch-action: none; user-select: none; outline: none; }
.timeline-ruler:focus-visible { box-shadow: 0 0 0 2px var(--cinnabar); }
.timeline-ruler.is-dragging { cursor: grabbing; }
.timeline-density { position: absolute; inset: 5px 0 18px; }
.density-life { position: absolute; top: calc(var(--lane) * 5px); height: 3px; min-width: 3px; opacity: .42; border-radius: 3px; }
.density-life.is-ancestor { background: var(--cinnabar); }
.density-life.is-monastic { background: var(--green); }
.density-life.is-official { background: #9b6032; }
.density-life.is-literati { background: #81623f; }
.density-life.is-imperial { background: #725779; }
.density-life.is-other { background: #91897d; }
.density-life.is-partial { width: 4px !important; height: 4px; border-radius: 50%; opacity: .8; }
.timeline-window { position: absolute; top: 0; bottom: 16px; min-width: 10px; border: 2px solid var(--cinnabar); background: rgba(136,72,61,.12); box-shadow: 0 0 14px rgba(136,72,61,.13); pointer-events: none; }
.timeline-window::before, .timeline-window::after { content: ""; position: absolute; top: 13px; width: 4px; height: 17px; border-left: 1px solid rgba(136,72,61,.6); border-right: 1px solid rgba(136,72,61,.6); }
.timeline-window::before { left: 4px; }
.timeline-window::after { right: 4px; }
.timeline-window span { position: absolute; left: 50%; top: 50%; padding: 2px 6px; color: #fff; background: var(--cinnabar); font-family: var(--ui-font); font-size: 11px; transform: translate(-50%,-50%); white-space: nowrap; }
.timeline-ticks { position: absolute; inset: auto 0 0; height: 16px; border-top: 1px solid var(--rule); }
.timeline-ticks i { position: absolute; top: 0; width: 1px; height: 5px; background: var(--rule-dark); }
.timeline-ticks b { position: absolute; top: 4px; color: var(--muted); font-family: var(--ui-font); font-size: 10px; font-style: normal; font-weight: 400; transform: translateX(-50%); white-space: nowrap; }
.timeline-pan-row { display: grid; grid-template-columns: 32px minmax(0,1fr) 32px; gap: 6px; align-items: center; margin: 5px 0 7px; }
.timeline-pan-row input { width: 100%; accent-color: var(--cinnabar); cursor: ew-resize; }
.timeline-pan-row button { width: 32px; padding: 0; }
.timeline-residents { min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 6px 8px; background: rgba(255,255,255,.58); border: 1px solid var(--rule); }
.timeline-resident-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; color: var(--muted); font-family: var(--ui-font); font-size: 11px; }
.timeline-resident-head b { color: var(--ink); font-size: 13px; }
.timeline-person-list { min-height: 0; flex: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; overflow-y: auto; }
.time-person { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 8px; color: var(--ink); border: 1px solid var(--rule); border-left: 3px solid currentColor; background: #fffdf8; cursor: pointer; }
.time-person:hover, .time-person.is-selected { background: #f4eadc; border-color: var(--rule-dark); }
.time-person.is-ancestor { color: var(--cinnabar); }
.time-person.is-monastic { color: var(--green); }
.time-person.is-official { color: #9b6032; }
.time-person.is-literati { color: #81623f; }
.time-person.is-imperial { color: #725779; }
.time-person.is-other { color: #91897d; }
.time-person b { color: var(--ink); font-size: 13px; }
.time-person small { color: var(--muted); font-size: 11px; }
.timeline-empty, .timeline-overflow { margin: 7px; color: var(--muted); font-size: 12px; }
.timeline-overflow { align-self: center; }

footer { min-height: 34px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 20px; padding: 7px 18px; color: #c3b7a8; background: #3c352e; font-family: var(--ui-font); font-size: 11px; }
footer a { color: #dac9b3; }

@media (max-width: 1500px) {
  .relation-legend { display: none; }
  .search-box { order: 1; }
  .research-filters { order: 2; flex-basis: 360px; }
  .language-toggle { order: 3; }
  .type-filters { order: 4; min-width: 0; width: 100%; flex: 1 1 100%; flex-wrap: wrap; overflow: visible; }
}

@media (max-width: 1100px) {
  .site-header { gap: 9px; padding-inline: 14px; }
  .header-counts { gap: 10px; }
  .header-counts b { font-size: 15px; }
  .toolbar { padding-inline: 14px; }
}
.source-card footer, .citation-row { min-height: 0; padding: 0; color: var(--muted); background: transparent; justify-content: space-between; }
.noscript { margin: 0; padding: 1rem; color: #fff; background: var(--cinnabar); text-align: center; }

@media (max-width: 1120px) {
  .relation-legend { display: none; }
  .main-grid { grid-template-columns: minmax(300px, 1fr) 8px min(var(--detail-width), 44vw); }
  .header-counts { gap: 10px; }
}

@media (max-width: 820px) {
  .page-shell { height: auto; max-height: none; min-height: 100vh; overflow: visible; display: block; }
  .site-header { grid-template-columns: auto 1fr; }
  .header-counts { grid-column: 1 / -1; justify-content: flex-start; padding-left: 60px; }
  .header-counts span { display: inline-flex; gap: 4px; align-items: baseline; }
  .header-counts b { font-size: 14px; }
  .toolbar { align-items: stretch; flex-direction: column; gap: 6px; padding: 8px 12px; }
  .search-box { order: 1; min-width: 0; width: 100%; flex: none; }
  .type-filters { order: 2; min-width: 0; width: 100%; height: 42px; min-height: 42px; flex: none; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
  .type-filters label, .fixed-layer, .type-filters button { min-height: 42px; }
  .research-filters { order: 3; width: 100%; flex: none; }
  .language-toggle { order: 4; align-self: flex-start; }
  .research-filters label { flex: 1 1 50%; }
  .research-filters select { width: 100%; max-width: none; }
  .main-grid { display: block; }
  .graph-pane { height: 520px; min-height: 0; border-right: 0; border-bottom: 1px solid var(--rule-dark); }
  .detail-pane { overflow: hidden; }
  .panel-splitter { display: none; }
  .timeline-splitter { display: none; }
  #detail { max-height: 620px; overflow-y: auto; }
  .timeline-head { align-items: stretch; flex-direction: column; }
  .timeline-controls { flex-wrap: wrap; }
  .timeline-resident-head { align-items: flex-start; flex-direction: column; gap: 2px; }
}

@media (max-width: 480px) {
  .site-header { padding: 10px 12px; }
  .title-mark { width: 40px; height: 40px; }
  .title-copy p { font-size: 11px; }
  .header-counts { padding-left: 54px; font-size: 10px; }
  .graph-pane { height: 440px; }
  .pane-head { padding-left: 12px; }
  .graph-tip { display: none; }
  #network { bottom: 0; }
  .person-detail { padding: 20px 16px 32px; }
  .person-title h2 { font-size: 28px; }
  .person-meta { grid-template-columns: 1fr; }
  .person-meta div:nth-last-child(-n+2) { border-bottom: 1px dotted var(--rule); }
  .person-meta div:last-child { border-bottom: 0; }
  .timeline-pane { padding-inline: 12px; }
}
