:root {
  --ink: #1c1917;
  --ink-mid: #57534e;
  --muted: #78716c;
  --paper: #faf8f3;
  --surface: #ffffff;
  --border: #e7e5e0;
  --gold: #facc15;
  --blue: #2563eb;
  --orange: #ea580c;
  --purple: #7c3aed;
  --red: #e11d48;
  --teal: #0f766e;
  --brown: #a16207;
  --shadow: 0 16px 40px rgba(28, 25, 23, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, select, a { font: inherit; }
button, select { color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
button { cursor: pointer; }

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 56px;
  padding: 0 clamp(20px, 4vw, 48px);
  color: rgba(255,255,255,.52);
  background: rgba(28,25,23,.98);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand { font-size: 13px; letter-spacing: .08em; }
.brand strong { color: rgba(255,255,255,.92); }
.topbar-links { display: flex; gap: 28px; font-size: 13px; }
.topbar a:hover, .topbar a:focus-visible { color: white; }

.hero {
  position: relative;
  overflow: hidden;
  padding: 72px clamp(24px, 5vw, 64px) 78px;
  color: white;
  background: var(--ink);
}
.hero::before {
  position: absolute;
  top: -132px;
  right: -36px;
  color: rgba(255,255,255,.025);
  content: "诗";
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 540px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}
.hero-deco {
  position: absolute;
  top: 72px;
  right: clamp(24px, 4vw, 52px);
  color: rgba(255,255,255,.15);
  font-size: 12px;
  letter-spacing: .24em;
  writing-mode: vertical-rl;
}
.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: end;
  gap: 80px;
  width: min(1224px, 100%);
  margin: 0 auto;
}
.hero-copy { max-width: 760px; }
.hero-eyebrow, .section-kicker, .detail-kicker {
  color: rgba(255,255,255,.42);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
}
.hero-eyebrow { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.hero-eyebrow::after { width: 42px; border-top: 1px solid rgba(255,255,255,.24); content: ""; }
h1 {
  margin-bottom: 22px;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(42px, 5.5vw, 68px);
  font-weight: 300;
  line-height: 1.16;
}
h1 strong {
  color: var(--gold);
  font-weight: 800;
}
.hero-desc { max-width: 620px; margin-bottom: 0; color: rgba(255,255,255,.58); font-size: 16px; line-height: 1.9; }
.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  background: rgba(255,255,255,.08);
}
.hero-stat { padding: 22px; background: rgba(28,25,23,.9); }
.hero-stat strong { display: block; margin-bottom: 7px; color: var(--gold); font-size: 34px; line-height: 1; }
.hero-stat span { color: rgba(255,255,255,.42); font-size: 11px; letter-spacing: .1em; }

.section { width: min(1320px, 100%); margin: 0 auto; padding: 58px 48px 68px; }
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}
.section-header h2 { margin-bottom: 0; font-size: 28px; }
.section-header > p, .section-header > div > p:last-child { max-width: 600px; margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.section-kicker { margin-bottom: 7px; color: var(--teal); }

.figures-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 292px);
  align-items: stretch;
  gap: 18px;
}
.network-panel, .people-panel, .map-view {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.network-panel { display: flex; flex-direction: column; }
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px 15px;
  border-bottom: 1px solid var(--border);
}
.panel-heading h3 { margin-bottom: 4px; font-size: 18px; }
.panel-heading span { color: var(--muted); font-size: 11px; }
.network-heading { align-items: center; }
.period-controls { display: flex; align-items: center; gap: 8px; }
.period-controls label { color: var(--muted); font-size: 11px; white-space: nowrap; }
.period-controls select, .quiet-button {
  min-height: 34px;
  border: 1px solid #d6d3d1;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
}
.period-controls select { max-width: 160px; padding: 0 28px 0 10px; }
.quiet-button { padding: 0 10px; color: var(--teal); }
.quiet-button:hover { background: #f0fdfa; }

.relation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.relation-legend button {
  border: 0;
  border-bottom: 3px solid;
  padding: 3px 1px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  opacity: .4;
}
.relation-legend button.is-active { color: var(--ink); font-weight: 700; opacity: 1; }
.legend-edu { border-color: var(--purple) !important; }
.legend-social { border-color: #0284c7 !important; }
.legend-literary { border-color: var(--red) !important; }
.legend-office { border-color: var(--orange) !important; }
.legend-kin { border-color: var(--brown) !important; }

.network-scroll { display: flex; flex: 1; overflow-x: auto; }
.knowledge-graph {
  position: relative;
  flex: 1;
  min-width: 900px;
  height: 1600px;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 12%, rgba(13,115,119,.09), transparent 27%),
    radial-gradient(circle at 82% 76%, rgba(124,58,237,.08), transparent 28%),
    linear-gradient(rgba(231,229,224,.55) 1px, transparent 1px),
    linear-gradient(90deg, rgba(231,229,224,.55) 1px, transparent 1px),
    #fcfbf8;
  background-size: auto, auto, 40px 40px, 40px 40px, auto;
}
.knowledge-timeline {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 4;
  width: 142px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(250,248,243,.98), rgba(250,248,243,.82) 78%, rgba(250,248,243,0));
}
.knowledge-timeline::after {
  position: absolute;
  top: 38px;
  right: 15px;
  bottom: 38px;
  width: 1px;
  background: rgba(120,113,108,.35);
  content: "";
}
.timeline-title {
  position: absolute;
  top: 18px;
  right: 25px;
  color: #78716c;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  writing-mode: vertical-rl;
}
.timeline-mark {
  position: absolute;
  right: 15px;
  width: 10px;
  min-height: 2px;
  border-right: 3px solid var(--teal);
  transform: translateY(0);
}
.timeline-mark.is-zhou { border-color: var(--purple); }
.timeline-mark::after {
  position: absolute;
  top: 50%;
  right: -4px;
  width: 8px;
  border-top: 1px solid currentColor;
  content: "";
}
.timeline-label {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 94px;
  color: #57534e;
  line-height: 1.12;
  text-align: right;
  transform: translateY(-50%);
  white-space: nowrap;
}
.timeline-label strong { display: block; font-size: 10px; }
.timeline-label small { display: block; margin-top: 2px; color: #a8a29e; font-size: 8px; }
.graph-svg { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; }
.life-track { stroke: #d6d3d1; stroke-width: 3; stroke-linecap: round; }
.selected-period { fill: rgba(250,204,21,.13); stroke: rgba(161,98,7,.35); stroke-width: 1; }
.graph-edge { fill: none; stroke-width: 2.2; opacity: .72; transition: opacity .18s, stroke-width .18s; }
.graph-edge.is-edu { stroke-width: 4; }
.graph-edge-label {
  fill: #57534e;
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fcfbf8;
  stroke-linejoin: round;
  stroke-width: 6px;
  pointer-events: none;
}
.graph-node { cursor: pointer; transition: opacity .18s; }
.graph-node .node-halo { fill: rgba(255,255,255,.82); stroke: rgba(255,255,255,.96); stroke-width: 8; }
.graph-node .node-circle { fill: #fff; stroke: var(--node-color, var(--blue)); stroke-width: 3; filter: drop-shadow(0 8px 8px rgba(28,25,23,.16)); }
.graph-node .node-name { fill: var(--ink); font-size: 13px; font-weight: 700; pointer-events: none; }
.graph-node .node-years { fill: var(--muted); font-size: 9px; pointer-events: none; }
.graph-node:hover .node-circle, .graph-node:focus .node-circle, .graph-node.is-selected .node-circle { fill: #fef3c7; stroke-width: 5; }
.graph-node:focus { outline: none; }
.knowledge-graph.has-focus .graph-node:not(.is-related),
.knowledge-graph.has-focus .graph-edge:not(.is-related),
.knowledge-graph.has-focus .graph-edge-label:not(.is-related),
.knowledge-graph.has-focus .life-track:not(.is-related) { opacity: .12; }
.knowledge-graph.has-focus .graph-edge.is-related { opacity: 1; stroke-width: 3.4; }
.knowledge-graph.has-focus .graph-edge.is-edu.is-related { stroke-width: 5; }
.knowledge-graph.has-focus .graph-node.is-related { opacity: 1; }
.network-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.network-meta p { margin-bottom: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.network-meta strong { color: var(--ink-mid); }

.people-panel { display: flex; flex-direction: column; background: #f3f0ea; }
.people-panel > .panel-heading { background: #fff; }
.people-list { display: grid; gap: 8px; max-height: 1080px; padding: 10px; overflow-y: auto; }
.person-button {
  display: grid;
  grid-template-columns: 8px minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  transition: transform .16s, border-color .16s, box-shadow .16s;
}
.person-button:hover, .person-button:focus-visible { border-color: #a8a29e; transform: translateY(-1px); box-shadow: 0 6px 14px rgba(28,25,23,.07); }
.person-button.is-active { border-color: var(--blue); background: #eff6ff; }
.person-color { width: 8px; height: 30px; border-radius: 4px; background: var(--person-color, var(--blue)); }
.person-button strong { font-size: 14px; }
.person-button small { color: var(--muted); font-size: 9px; white-space: nowrap; }
.person-button em { color: var(--muted); font-size: 9px; font-style: normal; }
.person-detail { min-height: 300px; padding: 18px; border-top: 1px solid var(--border); background: #fffdf7; }
.detail-placeholder { color: var(--muted); font-size: 12px; line-height: 1.7; }
.detail-kicker { margin-bottom: 6px; color: var(--blue); }
.person-detail h3 { margin-bottom: 5px; font-family: "Songti SC", serif; font-size: 27px; }
.person-detail p { margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.relation-list { display: grid; gap: 7px; margin: 13px 0 0; padding: 0; list-style: none; }
.relation-list li { padding-top: 7px; border-top: 1px solid var(--border); color: var(--ink-mid); font-size: 11px; }
.relation-list strong { color: var(--ink); }
.relation-source { display: block; margin-top: 3px; color: var(--muted); }
.error-message { color: #b91c1c !important; }

.map-section { padding-top: 8px; }
.map-section-header { align-items: center; }
.map-toggle {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  color: white;
  background: var(--ink);
  font-weight: 700;
}
.map-toggle:hover { background: var(--teal); }
.map-view { position: relative; }
.map-view[hidden] { display: none; }
.map-toolbar, .map-source-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 15px;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
}
.map-toolbar { border-bottom: 1px solid var(--border); }
.map-source-bar { border-top: 1px solid var(--border); }
.map-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.dot { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; }
.dot-blue { background: var(--blue); }
.dot-orange { background: var(--orange); }
#map { z-index: 1; min-height: 680px; background: #dbeafe; }
.map-notice {
  position: absolute;
  z-index: 500;
  top: 64px;
  left: 50%;
  max-width: 78%;
  padding: 9px 12px;
  border: 1px solid #fdba74;
  border-radius: 9px;
  color: #9a3412;
  background: rgba(255,247,237,.95);
  font-size: 12px;
  transform: translateX(-50%);
}
.leaflet-control-layers { border: 1px solid var(--border) !important; border-radius: 10px !important; box-shadow: var(--shadow) !important; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  padding: 28px max(24px, calc((100vw - 1224px) / 2)) 38px;
  color: var(--muted);
  background: #eeebe4;
  font-size: 12px;
}
.site-footer p { max-width: 820px; margin-bottom: 0; }
.site-footer nav { display: flex; gap: 16px; white-space: nowrap; }
.site-footer a { color: var(--teal); }

@media (max-width: 1040px) {
  .hero-content { grid-template-columns: 1fr; gap: 36px; }
  .hero-stats { max-width: 420px; }
  .figures-layout { grid-template-columns: 1fr; }
  .people-panel { display: grid; grid-template-columns: minmax(0,1fr) minmax(280px,.7fr); }
  .people-panel > .panel-heading { grid-column: 1 / -1; }
  .people-list { max-height: 440px; }
  .person-detail { border-top: 0; border-left: 1px solid var(--border); }
}

@media (max-width: 720px) {
  .topbar { height: auto; min-height: 56px; padding-block: 12px; }
  .topbar-links { gap: 14px; }
  .hero { padding-top: 54px; }
  .hero-deco { display: none; }
  .section { padding: 44px 18px 54px; }
  .section-header, .map-section-header, .network-heading, .site-footer { align-items: flex-start; flex-direction: column; }
  .section-header { gap: 14px; }
  .period-controls { width: 100%; flex-wrap: wrap; }
  .period-controls select { flex: 1; max-width: none; }
  .knowledge-graph { min-width: 760px; }
  .network-meta { grid-template-columns: 1fr; gap: 9px; }
  .people-panel { display: flex; }
  .people-list { max-height: 420px; }
  .person-detail { border-top: 1px solid var(--border); border-left: 0; }
  .map-toggle { width: 100%; }
  #map { min-height: 540px; }
  .map-toolbar, .map-source-bar { align-items: flex-start; flex-direction: column; }
  .site-footer nav { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .topbar-links a:last-child { display: none; }
  h1 { font-size: 40px; }
  .hero-stats { width: 100%; }
  .hero-stat { padding: 18px; }
}
