/* Sapkota वंशावली: one stylesheet for every page. Tokens first; dark mode redefines them. */
:root {
  --bg: #f6f0e4;
  --bg-deep: #efe6d4;
  --surface: #fffcf6;
  --text: #2a211a;
  --muted: #76695b;
  --line: #e2d5bf;
  --line-strong: #c9b697;
  --accent: #9b2f1d;
  --accent-hover: #7c2414;
  --accent-soft: #f5e3d6;
  --gold: #a8843c;
  --son: #2d6482;
  --son-soft: #e3eef3;
  --daughter: #9b3f6d;
  --daughter-soft: #f5e6ee;
  --highlight: #f7e3a3;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 4px 14px rgba(60, 40, 20, 0.06);
  --shadow-lift: 0 2px 4px rgba(60, 40, 20, 0.08), 0 10px 28px rgba(60, 40, 20, 0.12);
  --radius: 12px;
  --font: "Noto Sans Devanagari", "Kohinoor Devanagari", "Devanagari Sangam MN", "Mukta",
    "Nirmala UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Noto Serif Devanagari", "Tiro Devanagari Hindi", "Devanagari MT", "Kohinoor Devanagari",
    "Nirmala UI", Georgia, serif;
  --header-h: 3.6rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120e;
    --bg-deep: #1d1813;
    --surface: #221c16;
    --text: #efe6d8;
    --muted: #ab9d8a;
    --line: #382f26;
    --line-strong: #5a4b3b;
    --accent: #e8916a;
    --accent-hover: #f2a988;
    --accent-soft: #3b2519;
    --gold: #d4b26d;
    --son: #8cc2dc;
    --son-soft: #1c2a31;
    --daughter: #e6a3c6;
    --daughter-soft: #321f29;
    --highlight: #54431b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 1rem); }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80rem 30rem at 50% -8rem, var(--bg-deep), transparent);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); }
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.35; letter-spacing: 0.005em; }
h1 { font-size: 2.2rem; margin: 0.25rem 0 0.75rem; }
h2 { font-size: 1.35rem; margin: 2.5rem 0 0.75rem; }
ol { list-style-type: devanagari; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.js .no-js, html:not(.js) .js-only { display: none !important; }

/* ---------------------------------------------------------------- frame */

header.site {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
header.site .bar {
  max-width: 72rem;
  margin: 0 auto;
  min-height: var(--header-h);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.5rem;
  padding: 0.35rem 16px;
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--text); text-decoration: none; }
.brand span { font-family: var(--display); font-weight: 700; font-size: 1.2rem; }
.brand:hover { color: var(--text); }
.mark { width: 1.6rem; height: 1.6rem; color: var(--accent); fill: var(--gold); flex: none; }
header.site nav { display: flex; gap: 0.25rem; }
header.site nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}
header.site nav a:hover { color: var(--text); background: var(--accent-soft); }
header.site nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.quick-search { margin-left: auto; }
header.site .quick-search input { width: 13rem; padding-left: 2.1rem; background-image: var(--search-icon); background-repeat: no-repeat; background-position: 0.7rem 50%; background-size: 1rem; }
.search-page .quick-search, .home-page .quick-search { visibility: hidden; }

main { width: 100%; max-width: 56rem; margin: 0 auto; padding: 1.5rem 16px 4rem; flex: 1; }
.tree-page main { max-width: 80rem; }
footer.site { color: var(--muted); font-size: 0.85rem; padding: 0 16px 2.5rem; text-align: center; }
footer.site p { max-width: 40rem; margin: 0.75rem auto 0; }

/* Two fading rules and a dot between them. */
.ornament {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 16rem;
  min-height: 12px;
  margin: 0 auto;
  background: radial-gradient(circle, var(--gold) 0 3px, transparent 3.5px) center / 100% 100% no-repeat;
}
.ornament::before, .ornament::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.ornament::after { transform: scaleX(-1); }

/* ---------------------------------------------------------------- controls */

input[type="search"] {
  font: inherit;
  font-size: 1rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background-color: var(--surface);
  color: var(--text);
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
:root { --search-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='rgb(118,105,91)' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5'/%3E%3Cpath d='M13,13L17,17'/%3E%3C/svg%3E"); }
button, .button {
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  padding: 0.5rem 1.15rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--surface); }
button:active, .button:active { transform: translateY(1px); }
.button.secondary, button.quiet { background: transparent; color: var(--accent); border-color: var(--line-strong); }
.button.secondary:hover, button.quiet:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent); }

.lede { color: var(--muted); font-size: 1.08rem; margin-top: 0; }
.note { color: var(--muted); font-size: 0.9rem; }
.center { text-align: center; }
.code { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85em; }
.house { color: var(--muted); }
.dates { color: var(--muted); font-size: 0.85em; white-space: nowrap; }
.doubt { color: var(--accent); font-size: 0.8em; cursor: help; }
.redacted { background: var(--accent-soft); color: var(--muted); border-radius: 4px; padding: 0 0.3em; font-size: 0.85em; cursor: help; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.page-head { margin-bottom: 1.5rem; }

/* ---------------------------------------------------------------- home */

.hero { text-align: center; padding: 2.5rem 0 1rem; }
.eyebrow { color: var(--gold); font-size: 0.9rem; letter-spacing: 0.04em; margin: 1.25rem 0 0; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 3.6rem); margin: 0.25rem 0 0.5rem; }
.hero .lede { max-width: 34rem; margin: 0 auto; }
.hero .credits { font-size: 0.9rem; color: var(--muted); margin: 0 0 0.75rem; }
.hero .credits a { color: inherit; }
form.search { display: flex; gap: 0.5rem; margin: 1rem 0; }
form.search input { flex: 1; font-size: 1.1rem; }
.hero-search {
  max-width: 34rem;
  margin: 1.75rem auto 0 !important;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.hero-search input { border: none; background: transparent; padding-left: 2.4rem; background-image: var(--search-icon); background-repeat: no-repeat; background-position: 0.9rem 50%; background-size: 1.1rem; }
.hero-search input:focus { box-shadow: none; }
.hero-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.stats { list-style: none; padding: 0; margin: 2rem auto 1.5rem; display: flex; justify-content: center; flex-wrap: wrap; }
.stats li { display: flex; flex-direction: column; align-items: center; padding: 0 1.6rem; }
.stats li + li { border-left: 1px solid var(--line-strong); }
.stats strong { font-family: var(--display); font-size: 2rem; line-height: 1.2; color: var(--accent); font-weight: 600; }
.stats span { color: var(--muted); font-size: 0.9rem; }
.actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.75rem; }
.section-title { text-align: center; margin-top: 3.5rem; }
.section-title::after { content: ""; display: block; width: 3rem; height: 2px; margin: 0.6rem auto 0; background: var(--gold); border-radius: 2px; }

ol.branches { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr)); gap: 0.75rem; }
.branch {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.85rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.branch:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); border-color: var(--line-strong); }
.branch .num {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.branch .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.branch .name { font-weight: 600; text-decoration: none; color: var(--text); }
.branch .name:hover { color: var(--accent); }
.branch .meta { font-size: 0.85rem; color: var(--muted); }
.branch .size { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 0.5rem; margin-top: 0.3rem; }
.meter { flex: 0 0 4.5rem; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: 3px; }
.to-tree { flex: none; padding: 0.35rem; border-radius: 8px; color: var(--muted); line-height: 0; }
.to-tree .mark { width: 1.25rem; height: 1.25rem; color: currentColor; fill: currentColor; }
.to-tree:hover { background: var(--accent-soft); color: var(--accent); }

ol.sections { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; counter-reset: section; }
ol.sections li { counter-increment: section; }
ol.sections a {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0.85rem 1rem 0.85rem 3.1rem;
  position: relative;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s;
}
ol.sections a::before {
  content: counter(section, devanagari);
  position: absolute;
  left: 1rem;
  top: 0.85rem;
  font-family: var(--display);
  color: var(--gold);
  font-size: 1.15rem;
}
ol.sections a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
ol.sections .title { font-family: var(--display); font-weight: 600; }
ol.sections .note { font-size: 0.8rem; }

/* ---------------------------------------------------------------- tree page */

.ancestors { margin: 0 0 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ancestors summary { cursor: pointer; color: var(--muted); padding: 0.6rem 1rem; list-style: none; }
.ancestors summary::-webkit-details-marker { display: none; }
.ancestors summary::before { content: "›"; display: inline-block; margin-right: 0.6rem; color: var(--accent); transition: transform 0.2s; }
.ancestors[open] summary::before { transform: rotate(90deg); }
.ancestors-title { font-family: var(--display); color: var(--text); font-weight: 600; margin-right: 0.4rem; }
.ancestors ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0; margin: 0; padding: 0.25rem 1rem 1rem; list-style: none; font-size: 0.92rem; }
.ancestors li:not(:last-child)::after { content: "→"; color: var(--line-strong); margin: 0 0.5rem; }

.tree-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: 0 0 0.75rem; }
.tree-tools button { padding: 0.3rem 0.85rem; font-size: 0.9rem; }
.segmented { display: inline-flex; padding: 3px; background: var(--bg-deep); border: 1px solid var(--line); border-radius: 999px; }
.segmented button { background: transparent; border: none; color: var(--muted); padding: 0.25rem 0.95rem; }
.segmented button:hover { background: transparent; color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); font-weight: 600; }
.zoom { display: inline-flex; gap: 0.25rem; }
.zoom button { min-width: 2.2rem; }
.legend { color: var(--muted); font-size: 0.88rem; margin-left: auto; }
.swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin: 0 0.3rem 0 0.6rem; vertical-align: -0.05em; }
.swatch.son { background: var(--son); }
.swatch.daughter { background: var(--daughter); }
.tree-page[data-view="list"] .zoom { display: none; }
.tree-chart { display: none; }
.js .tree-page:not([data-view="list"]) .tree-chart { display: block; }
.js .tree-page:not([data-view="list"]) .tree-list { display: none; }

/* The chart: cards on a stage the script lays out, connectors in one SVG under them. */
.tree-chart {
  position: relative;
  height: calc(100vh - var(--header-h) - 7rem);
  min-height: 26rem;
  overflow: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--line-strong) 45%, transparent) 1px, transparent 1.5px) 0 0 / 22px 22px,
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 3px rgba(60, 40, 20, 0.05);
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}
.tree-chart.panning { cursor: grabbing; }
.tc-gens {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 2rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.tc-gens span { position: absolute; top: 0; height: 2rem; line-height: 2rem; text-align: center; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.tc-gens b { color: var(--gold); font-weight: 600; }
.tc-sizer { position: relative; }
.tc-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tc-lines { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.tc-lines path { fill: none; stroke-linecap: round; }
.tc-lines .edges { stroke: var(--line-strong); stroke-width: 1.4; }
.tc-lines .path { stroke: var(--accent); stroke-width: 2.4; }
.tc-card {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 1.4rem 0 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: var(--shadow);
  line-height: 1.35;
  cursor: default;
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
.tc-card.son { border-left-color: var(--son); }
.tc-card.daughter { border-left-color: var(--daughter); }
.tc-card:hover { box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
.tc-card.son:hover { border-left-color: var(--son); }
.tc-card.daughter:hover { border-left-color: var(--daughter); }
.tc-card.on-path { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.tc-card.target { background: var(--highlight); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-lift); }
.tc-name { font-weight: 600; font-size: 0.92rem; color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-name:hover { color: var(--accent); text-decoration: underline; }
.tc-meta { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-toggle {
  position: absolute;
  right: -0.85rem;
  top: 50%;
  transform: translateY(-50%);
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  background: var(--surface);
  color: var(--accent);
  border: 1.5px solid var(--accent);
  box-shadow: var(--shadow);
}
.tc-toggle:hover { background: var(--accent); color: var(--surface); }
.tc-toggle[aria-expanded="true"] { background: var(--accent); color: var(--surface); }
.tc-toggle:active { transform: translateY(-50%) scale(0.94); }

/* The list: nested <details>, the whole tree without JavaScript. */
.tree-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1rem 1rem 0.75rem; }
ul.tree, ul.tree ul { list-style: none; margin: 0; padding: 0; }
ul.tree ul { margin-left: 0.6rem; padding-left: 1rem; border-left: 1px solid var(--line); }
ul.tree li { margin: 0.1rem 0; position: relative; }
ul.tree ul > li::before { content: ""; position: absolute; left: -1rem; top: 0.95rem; width: 0.75rem; border-top: 1px solid var(--line); }
.tree .node { display: block; padding: 0.1rem 0.4rem; border-radius: 6px; }
.tree summary.node { cursor: pointer; list-style: none; }
.tree summary.node:hover { background: var(--bg); }
.tree summary.node::-webkit-details-marker { display: none; }
.tree .node::before { content: ""; display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.45rem; vertical-align: 0.1em; background: var(--line-strong); }
.tree li.son > .node::before, .tree li.son > details > summary::before { background: var(--son); }
.tree li.daughter > .node::before, .tree li.daughter > details > summary::before { background: var(--daughter); }
.tree details > summary.node::after { content: "+"; display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; margin-left: 0.4rem; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--muted); font-size: 0.8rem; line-height: 1; vertical-align: 0.05em; }
.tree details[open] > summary.node::after { content: "−"; }
.tree li.target > .node, .tree li.target > details > summary.node { background: var(--highlight); }

/* ---------------------------------------------------------------- person */

.lineage { font-size: 0.85rem; color: var(--muted); line-height: 1.9; }
.lineage a { color: var(--muted); text-decoration: none; }
.lineage a:hover { color: var(--accent); text-decoration: underline; }
.lineage .sep { color: var(--line-strong); margin: 0 0.15rem; }
.person-head { margin: 1.25rem 0 1.25rem; }
.person-head h1 { font-size: clamp(2rem, 6vw, 2.8rem); margin: 0.2rem 0 0; }
.kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; margin: 0; color: var(--muted); font-size: 0.9rem; }
.badge { display: inline-block; padding: 0.05rem 0.65rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
.badge.son { background: var(--son-soft); color: var(--son); }
.badge.daughter { background: var(--daughter-soft); color: var(--daughter); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0; margin: 0; padding: 0.4rem 1.25rem; }
.facts dt, .facts dd { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); padding-right: 1.5rem; font-size: 0.92rem; }
.facts dd { margin: 0; }
.facts dt:nth-last-of-type(1), .facts dd:last-of-type { border-bottom: none; }
.spouses { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; }
.spouses li { padding: 0.75rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.spouses .label { display: block; color: var(--gold); font-size: 0.8rem; font-weight: 600; }
.spouses .place, .spouses .counts { display: block; color: var(--muted); font-size: 0.88rem; }
.more { margin-top: 0.75rem; color: var(--muted); font-size: 0.92rem; }

/* The family chart: tiers joined by a stem. A few children hang from a bracket; more than
   four, or any on a small screen, hang from a rail as a list. */
.family-chart { --gap: 1.6rem; --drop: 0.9rem; padding: 1.5rem 1rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tier { display: flex; flex-direction: column; align-items: center; position: relative; }
.tier + .tier { padding-top: var(--gap); }
.tier + .tier::before { content: ""; position: absolute; top: 0; left: 50%; height: var(--gap); border-left: 1.5px solid var(--line-strong); }
.tier-label { margin: 0 0 0.3rem; font-size: 0.75rem; color: var(--gold); font-weight: 600; letter-spacing: 0.03em; }
.tier.children .tier-label { position: absolute; top: 0.15rem; left: calc(50% + 0.6rem); margin: 0; }
.tier-row { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; }
.pcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 9rem;
  max-width: 14rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-strong);
  border-radius: 10px;
  line-height: 1.45;
  position: relative;
}
.pcard.son { border-top-color: var(--son); }
.pcard.daughter { border-top-color: var(--daughter); }
.pcard .name { font-weight: 600; text-decoration: none; color: var(--text); }
a.name:hover { color: var(--accent); text-decoration: underline; }
.pcard .meta, .pcard .dates, .pcard .spouse, .pcard .count { font-size: 0.78rem; color: var(--muted); }
.pcard .count { color: var(--gold); }
.pcard.self { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-lift); padding: 0.7rem 1.2rem; min-width: 12rem; }
.pcard.self.son { border-top-color: var(--son); }
.pcard.self.daughter { border-top-color: var(--daughter); }
.pcard.self .name { font-family: var(--display); font-size: 1.15rem; }
/* Bracket: each child draws a drop line and its share of the bar above the row. */
.tier.children .pcard { margin: var(--drop) 0.4rem 0; }
.tier.children .pcard::before { content: ""; position: absolute; top: calc(-1 * var(--drop) - 3px); left: 50%; height: var(--drop); border-left: 1.5px solid var(--line-strong); }
.tier.children .pcard::after { content: ""; position: absolute; top: calc(-1 * var(--drop) - 3px); left: calc(-0.4rem - 1px); right: calc(-0.4rem - 1px); border-top: 1.5px solid var(--line-strong); }
.tier.children .pcard:first-child::after { left: 50%; }
.tier.children .pcard:last-child::after { right: 50%; }
.tier.children .pcard:only-child::after { display: none; }
/* Rail: the children as a list hanging from the stem. */
.tier.children.many { align-items: stretch; }
.tier.children.many .tier-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; margin-left: 50%; padding: 0.6rem 0 0 1.1rem; }
.tier.children.many .pcard { margin: 0; align-items: flex-start; text-align: left; max-width: 100%; }
.tier.children.many .pcard::before { top: 50%; left: calc(-1.1rem - 1px); height: 0; width: 1.1rem; border-left: none; border-top: 1.5px solid var(--line-strong); }
/* Each card draws the rail beside it, so the rail stops at the last child. Offsets of 3px and
   1px step over the card's top and left borders. */
.tier.children.many .pcard::after { display: block; top: calc(-0.5rem - 3px); bottom: 0; left: calc(-1.1rem - 1px); right: auto; border-top: none; border-left: 1.5px solid var(--line-strong); }
.tier.children.many .pcard:first-child::after { top: calc(-0.6rem - 3px); }
.tier.children.many .pcard:last-child::after { bottom: auto; height: calc(50% + 0.5rem + 3px); }
.tier.children.many .pcard:only-child::after { height: calc(50% + 0.6rem + 3px); }

.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0.15rem 0.8rem 0.15rem 0.6rem; font-size: 0.92rem; }
.chip::before { content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; margin-right: 0.4rem; background: var(--line-strong); vertical-align: 0.1em; }
.chip.son::before { background: var(--son); }
.chip.daughter::before { background: var(--daughter); }
.chip a { text-decoration: none; color: var(--text); }
.chip a:hover { color: var(--accent); }
.chip.self { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.sources ol { padding-left: 0; list-style: none; counter-reset: src; }
.sources li { margin: 0.75rem 0; }
.sources .where { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 0.2rem; }
.sources .page { color: var(--gold); font-weight: 600; margin-right: 0.3rem; }
.sources .line { display: block; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; padding: 0.45rem 0.85rem; font-family: var(--display); }
/* A correction is the family's word, not the book's: plain type and a quieter rule. */
.corrections .line { font-family: var(--font); border-left-color: var(--line-strong); }

/* ---------------------------------------------------------------- search */

.search-page form.search { flex-direction: column; }
.search-page form.search label { color: var(--muted); font-size: 0.9rem; }
.search-page form.search input { padding: 0.7rem 1.1rem 0.7rem 2.6rem; font-size: 1.15rem; background-image: var(--search-icon); background-repeat: no-repeat; background-position: 1rem 50%; background-size: 1.1rem; box-shadow: var(--shadow); }
.results { padding-left: 0; list-style: none; display: grid; gap: 0.5rem; }
.results li { padding: 0.7rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; transition: border-color 0.15s; }
.results li:hover { border-color: var(--line-strong); }
.results a { font-weight: 600; text-decoration: none; }
.results .meta { display: block; color: var(--muted); font-size: 0.86rem; }

/* ---------------------------------------------------------------- book */

.narrative { max-width: 40rem; margin: 0 auto; font-family: var(--display); font-size: 1.08rem; line-height: 1.85; }
.narrative h1 { text-align: center; }
.narrative h1::after { content: ""; display: block; width: 3rem; height: 2px; margin: 0.75rem auto 1.5rem; background: var(--gold); border-radius: 2px; }
.narrative p { margin: 0 0 1.1rem; }
.narrative .signature { text-align: right; font-weight: 600; }
/* The title page: credits as the book lays them out, centred, names in a grid. */
.title-page { text-align: center; }
.title-page .eyebrow { margin-top: 0; }
.title-page h1 { font-size: clamp(2rem, 6vw, 2.8rem); margin: 0.25rem 0 0; }
.title-page h1::after { display: none; }
.title-page .year { color: var(--gold); font-size: 1.3rem; margin-bottom: 1.75rem; }
.title-page h2 { font-size: 1.2rem; margin: 2.25rem 0 1rem; }
.title-page ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem 1rem; }
.title-page .credits { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; }
.title-page .credits li { padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.title-page .role { display: block; color: var(--muted); font-family: var(--font); font-size: 0.85rem; }
.title-page .credits .name { font-weight: 600; font-size: 1.15rem; }
.title-page .names { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); font-family: var(--font); font-size: 0.95rem; line-height: 1.5; }
.title-page .names span { display: block; }
.title-page img { display: block; width: 100%; aspect-ratio: 5 / 6; object-fit: cover; border-radius: 6px; margin: 0 auto 0.5rem; background: var(--line); }
.title-page .credits img { max-width: 9rem; }
.title-page .names img { max-width: 7rem; }
.title-page .names span + span { color: var(--muted); font-size: 0.88rem; }
.narrative > .note { font-family: var(--font); border-top: 1px solid var(--line); padding-top: 0.75rem; margin-top: 2rem; }
.table-wrap { overflow-x: auto; margin: 1.25rem 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-family: var(--font); }
table { border-collapse: collapse; font-size: 0.92rem; min-width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 0.45rem 0.75rem; text-align: left; }
th + th, td + td { border-left: 1px solid var(--line); }
td:not(:first-child):not(:nth-child(2)) { text-align: right; font-variant-numeric: tabular-nums; }
th { background: var(--bg-deep); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; font-weight: 600; }
.pager { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; max-width: 40rem; margin: 2rem auto 0; }
.pager a { text-decoration: none; padding: 0.6rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager a[rel="next"] { margin-left: auto; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 640px) {
  body { font-size: 16px; }
  h1 { font-size: 1.85rem; }
  /* Two rows of header would take a fifth of a phone screen, so it scrolls away. */
  header.site { position: static; }
  header.site .bar { gap: 0.3rem 0.75rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  header.site nav { margin-left: auto; }
  header.site nav a { padding: 0.2rem 0.55rem; }
  .quick-search { margin-left: 0; width: 100%; }
  header.site .quick-search input { width: 100%; }
  .search-page .quick-search, .home-page .quick-search { display: none; }
  html { scroll-padding-top: 1rem; }
  main { padding-top: 1rem; }
  .hero { padding-top: 1.25rem; }
  .stats li { padding: 0 0.9rem; }
  .stats strong { font-size: 1.6rem; }
  ul.tree ul { margin-left: 0.3rem; padding-left: 0.7rem; }
  ul.tree ul > li::before { left: -0.7rem; width: 0.5rem; }
  .tree-list { padding: 0.75rem 0.5rem; }
  .legend { margin-left: 0; width: 100%; }
  .tree-chart { height: calc(100vh - 6rem); min-height: 22rem; }
  .facts { grid-template-columns: 1fr; padding: 0.4rem 1rem; }
  .facts dt { border-bottom: none; padding-bottom: 0; font-size: 0.82rem; }
  .facts dd { padding-top: 0; }
  /* The chart aligns left on a phone, and every child list hangs from the rail. */
  .family-chart { padding: 1.25rem 0.75rem 0.75rem; }
  .tier { align-items: flex-start; }
  .tier + .tier::before { left: 2rem; }
  .tier.children .tier-label { left: 2.6rem; }
  .pcard { align-items: flex-start; text-align: left; }
  .tier.children { align-items: stretch; }
  .tier.children .tier-row, .tier.children.many .tier-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; margin-left: 2rem; padding: 0.6rem 0 0 1.1rem; }
  .tier.children .pcard { margin: 0; max-width: 100%; }
  .tier.children .pcard::before { top: 50%; left: calc(-1.1rem - 1px); height: 0; width: 1.1rem; border-left: none; border-top: 1.5px solid var(--line-strong); }
  .tier.children .pcard::after { display: block; top: calc(-0.5rem - 3px); bottom: 0; left: calc(-1.1rem - 1px); right: auto; border-top: none; border-left: 1.5px solid var(--line-strong); }
  .tier.children .pcard:first-child::after { top: calc(-0.6rem - 3px); }
  .tier.children .pcard:last-child::after { bottom: auto; height: calc(50% + 0.5rem + 3px); }
  .tier.children .pcard:only-child::after { height: calc(50% + 0.6rem + 3px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
