:root {
  --ink: #172f49;
  --ink-soft: #3f5367;
  --paper: #f7f4ec;
  --paper-deep: #ece5d7;
  --white: #fffdf8;
  --gold: #b9852e;
  --gold-soft: #ead4a6;
  --line: #c8b88f;
  --open: #a9523a;
  --shadow: 0 20px 60px rgba(23, 47, 73, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, rgba(216, 173, 85, .13), transparent 26rem),
    linear-gradient(180deg, #faf8f2 0%, var(--paper) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a { color: inherit; }
button, input { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(23, 47, 73, .12);
  background: rgba(250, 248, 242, .9);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50% 50% 46% 54%;
  color: var(--white);
  background: var(--ink);
  font-family: Georgia, serif;
  font-size: 24px;
  box-shadow: inset 0 0 0 2px rgba(216,173,85,.6);
}
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 20px; line-height: 1; }
.brand small { margin-top: 3px; color: var(--ink-soft); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
nav { display: flex; gap: clamp(14px, 3vw, 34px); }
nav a { color: var(--ink-soft); font-size: 14px; font-weight: 650; text-decoration: none; }
nav a:hover, nav a:focus-visible { color: var(--gold); }

main { width: min(1440px, 100%); margin: 0 auto; }
.intro {
  min-height: 350px;
  padding: clamp(66px, 10vw, 128px) clamp(20px, 6vw, 88px) 62px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 64px;
}
.eyebrow { margin: 0 0 10px; color: var(--gold); font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -.025em; }
h1 { max-width: 780px; font-size: clamp(42px, 7vw, 82px); line-height: .98; }
h2 { font-size: clamp(30px, 4vw, 48px); line-height: 1.06; }
.lede { max-width: 700px; margin: 26px 0 0; color: var(--ink-soft); font-size: clamp(18px, 2vw, 22px); }
.stats { margin: 0; display: grid; grid-template-columns: repeat(3, auto); gap: 22px; }
.stats div { min-width: 110px; padding-left: 18px; border-left: 1px solid var(--line); }
.stats dt { font-family: Georgia, serif; font-size: 38px; line-height: 1; }
.stats dd { margin: 7px 0 0; color: var(--ink-soft); font-size: 13px; }

.tree-section {
  margin: 0 clamp(12px, 3vw, 48px);
  padding: clamp(24px, 4vw, 48px);
  overflow: hidden;
  border: 1px solid rgba(23, 47, 73, .14);
  border-radius: 28px;
  background: rgba(255, 253, 248, .88);
  box-shadow: var(--shadow);
}
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.section-head.compact { align-items: center; }
.tree-actions { display: flex; gap: 10px; align-items: center; }
.search-wrap { position: relative; display: block; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; width: 19px; height: 19px; transform: translateY(-50%); fill: none; stroke: var(--ink-soft); stroke-width: 1.8; }
.search-wrap input {
  width: min(300px, 48vw);
  height: 46px;
  padding: 0 14px 0 42px;
  border: 1px solid rgba(23,47,73,.2);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
}
.search-wrap input:focus { outline: 3px solid rgba(185,133,46,.22); border-color: var(--gold); }
.ghost-button, .filter-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(23,47,73,.18);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}
.ghost-button:hover, .filter-button:hover, .filter-button.active { border-color: var(--ink); background: var(--ink); color: var(--white); }
.branch-switcher { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.branch-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(23,47,73,.18);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}
.branch-button:hover, .branch-button:focus-visible, .branch-button.active { border-color: var(--gold); background: var(--ink); color: var(--white); outline: none; }
.tree-help { margin: 18px 0 12px; color: var(--ink-soft); font-size: 14px; }
.tree-frame {
  min-height: 700px;
  overflow: auto;
  border: 1px solid rgba(23,47,73,.1);
  border-radius: 20px;
  background:
    linear-gradient(rgba(23,47,73,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23,47,73,.035) 1px, transparent 1px),
    #fbfaf6;
  background-size: 28px 28px;
  scrollbar-color: var(--gold-soft) transparent;
}
#family-tree { display: block; min-width: 100%; }
.tree-edge { fill: none; stroke: #b8a575; stroke-width: 2; }
.tree-node { cursor: pointer; }
.tree-node rect { fill: #fffdf8; stroke: #92a0ab; stroke-width: 1.5; filter: drop-shadow(0 7px 9px rgba(23,47,73,.09)); transition: .18s ease; }
.tree-node:hover rect, .tree-node:focus rect, .tree-node.highlight rect { fill: #fff8e9; stroke: var(--gold); stroke-width: 3; }
.tree-node.root rect { fill: var(--ink); stroke: var(--gold); stroke-width: 2; }
.tree-node.open rect { stroke: var(--open); stroke-dasharray: 6 5; }
.tree-name { fill: var(--ink); font-size: 15px; font-weight: 750; pointer-events: none; }
.tree-sub { fill: #617181; font-size: 12px; pointer-events: none; }
.tree-node.root .tree-name { fill: var(--white); }
.tree-node.root .tree-sub { fill: #dfd6c3; }
.legend { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 14px; color: var(--ink-soft); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { display: inline-block; width: 22px; height: 13px; border-radius: 4px; background: var(--white); border: 1px solid #92a0ab; }
.legend .legend-pair { box-shadow: inset 6px 0 var(--gold-soft); }
.legend .legend-open { border-color: var(--open); border-style: dashed; }

.origin-section {
  margin: clamp(80px, 10vw, 132px) clamp(12px, 3vw, 48px) 0;
  padding: clamp(34px, 6vw, 76px);
  overflow: hidden;
  border: 1px solid rgba(23,47,73,.12);
  border-radius: 28px;
  background:
    radial-gradient(circle at 96% 8%, rgba(216,173,85,.2), transparent 24rem),
    var(--white);
  box-shadow: var(--shadow);
}
.origin-intro {
  display: grid;
  grid-template-columns: minmax(240px, .75fr) minmax(0, 1.25fr);
  gap: clamp(28px, 6vw, 90px);
  align-items: start;
}
.origin-lede { margin: 0; color: var(--ink-soft); font-size: clamp(18px, 2vw, 23px); line-height: 1.55; }
.origin-lede strong { color: var(--ink); }
.origin-grid {
  margin-top: clamp(44px, 7vw, 84px);
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr);
  gap: clamp(34px, 7vw, 96px);
  align-items: start;
}
.origin-summary {
  position: sticky;
  top: 106px;
  padding: clamp(26px, 4vw, 42px);
  border-radius: 22px;
  background: var(--ink);
  color: var(--white);
}
.origin-kicker { margin: 0 0 12px; color: var(--gold-soft); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.origin-summary h3 { margin: 0 0 22px; font: 500 clamp(28px, 3.5vw, 43px)/1.05 Georgia, serif; }
.origin-summary p { color: #e1e6e9; }
.origin-summary cite { color: var(--white); }
.origin-summary .origin-caution { margin: 26px 0 0; padding-top: 24px; border-top: 1px solid rgba(255,255,255,.18); color: #cbd3da; font-size: 14px; }
.origin-timeline { margin: 0; padding: 0; list-style: none; }
.origin-timeline li { position: relative; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 24px; padding: 0 0 42px; }
.origin-timeline li::before { content: ""; position: absolute; left: 35px; top: 40px; bottom: 0; width: 1px; background: var(--line); }
.origin-timeline li:last-child { padding-bottom: 0; }
.origin-timeline li:last-child::before { display: none; }
.origin-timeline time { position: relative; z-index: 1; display: grid; place-items: center; width: 72px; height: 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font-family: Georgia, serif; font-weight: 700; }
.origin-timeline h3 { margin: 3px 0 8px; font: 500 24px/1.15 Georgia, serif; }
.origin-timeline p { margin: 0; color: var(--ink-soft); }
.evidence-tag { display: inline-flex; margin-top: 13px; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.evidence-tag.documented, .evidence-tag.literature { background: #e6efe9; color: #356044; }
.evidence-tag.context { background: #e8eef5; color: #365673; }
.evidence-tag.research { background: #f5e9e4; color: #8d432f; }
.origin-sources { margin-top: clamp(42px, 7vw, 76px); padding-top: 28px; border-top: 1px solid rgba(23,47,73,.14); }
.origin-sources > p:first-child { margin: 0 0 10px; font-family: Georgia, serif; font-size: 20px; }
.origin-sources ul { margin: 0; padding-left: 20px; color: var(--ink-soft); }
.origin-sources li + li { margin-top: 7px; }
.origin-sources a { text-decoration-color: rgba(185,133,46,.55); text-underline-offset: 3px; }
.origin-sources a:hover, .origin-sources a:focus-visible { color: var(--gold); }
.source-note { max-width: 820px; margin: 20px 0 0; color: var(--ink-soft); font-size: 14px; }

.generations { padding: clamp(80px, 10vw, 130px) clamp(20px, 6vw, 88px); }
.generation-filters { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.filter-button { min-height: 40px; padding: 0 14px; font-size: 14px; }
.people-grid { margin-top: 34px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.person-card {
  min-height: 132px;
  padding: 20px;
  text-align: left;
  border: 1px solid rgba(23,47,73,.14);
  border-radius: 18px;
  background: rgba(255,253,248,.7);
  color: var(--ink);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.person-card:hover, .person-card:focus-visible { transform: translateY(-3px); border-color: var(--gold); box-shadow: 0 12px 28px rgba(23,47,73,.1); outline: none; }
.person-card small { display: block; color: var(--gold); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.person-card strong { display: block; margin-top: 8px; font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.person-card span { display: block; margin-top: 8px; color: var(--ink-soft); font-size: 14px; }

.source-section {
  margin: 0 clamp(12px, 3vw, 48px) 70px;
  padding: clamp(36px, 6vw, 74px);
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: clamp(34px, 7vw, 100px);
  border-radius: 28px;
  color: var(--white);
  background: var(--ink);
}
.source-copy { color: #e2e5e8; font-size: 18px; }
.source-copy p:first-child { margin-top: 0; }

footer { max-width: 1340px; margin: 0 auto; padding: 24px clamp(20px, 6vw, 60px) 46px; display: flex; justify-content: space-between; gap: 20px; color: var(--ink-soft); font-size: 13px; }

.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(12,27,41,.38); backdrop-filter: blur(3px); }
.person-panel {
  position: fixed;
  z-index: 90;
  top: 0;
  right: 0;
  width: min(440px, 92vw);
  height: 100dvh;
  padding: 64px 34px 34px;
  overflow-y: auto;
  background: var(--white);
  box-shadow: -18px 0 55px rgba(12,27,41,.22);
  transform: translateX(105%);
  transition: transform .25s ease;
}
.person-panel.open { transform: translateX(0); }
.panel-close { position: absolute; top: 18px; right: 20px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--paper-deep); color: var(--ink); font-size: 28px; cursor: pointer; }
.panel-role { margin: 10px 0 30px; color: var(--ink-soft); font-size: 18px; }
.person-panel dl { margin: 0; }
.person-panel dl div { padding: 15px 0; border-top: 1px solid rgba(23,47,73,.12); }
.person-panel dt { color: var(--ink-soft); font-size: 13px; }
.person-panel dd { margin: 3px 0 0; font-weight: 700; }
.panel-note { margin-top: 26px; padding: 16px; border-left: 3px solid var(--gold); background: var(--paper); color: var(--ink-soft); }

@media (max-width: 980px) {
  .intro { grid-template-columns: 1fr; gap: 40px; }
  .stats { justify-content: start; }
  .origin-intro, .origin-grid { grid-template-columns: 1fr; }
  .origin-summary { position: static; }
  .people-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-section { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .site-header { min-height: 66px; }
  nav { display: none; }
  .intro { min-height: auto; padding-top: 58px; }
  .stats { width: 100%; gap: 0; justify-content: space-between; }
  .stats div { min-width: 0; padding: 0 12px; }
  .stats div:first-child { padding-left: 0; border-left: 0; }
  .stats dt { font-size: 30px; }
  .section-head, .section-head.compact { align-items: stretch; flex-direction: column; }
  .tree-actions { align-items: stretch; }
  .search-wrap { flex: 1; }
  .search-wrap input { width: 100%; }
  .tree-section { padding: 22px 16px; border-radius: 22px; }
  .tree-frame { min-height: 620px; }
  .origin-section { padding: 30px 20px; border-radius: 22px; }
  .origin-timeline li { grid-template-columns: 62px minmax(0, 1fr); gap: 16px; }
  .origin-timeline li::before { left: 29px; }
  .origin-timeline time { width: 60px; font-size: 14px; }
  .generation-filters { justify-content: start; }
  .people-grid { grid-template-columns: 1fr; }
  .person-card { min-height: 110px; }
  .source-section { border-radius: 22px; }
  footer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
