/* =========================================================
   Vekaria Family Tree — styles
   Design tone: warm heritage, calm and legible.
   ========================================================= */

:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #f4ede2;
  --ink: #2b1d14;
  --ink-2: #6b5b4e;
  --line: #e2d6c5;
  --line-strong: #c9b79f;
  --primary: #8a1c2b;          /* deep kumkum red: brand, selected person */
  --primary-ink: #ffffff;
  --accent: #d98a1c;           /* saffron: lineage path highlight */
  --accent-soft: #fbe6c4;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgba(43, 29, 20, .06), 0 8px 24px rgba(43, 29, 20, .08);
  --radius: 12px;
  --header-h: 64px;

  /* Generation colours, adapted from the key on the original chart */
  --g-anc: #8b7d70;
  --g1: #0e9fb3; --g2: #c026d3; --g3: #9f1239; --g4: #16a34a; --g5: #0d9488; --g6: #ea580c;
  --g7: #65a30d; --g8: #2563eb; --g9: #dc2626; --g10: #a16207; --g11: #166534; --g12: #7c3aed;
  --female: #be185d;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15100c; --surface: #201913; --surface-2: #2a211a; --ink: #f3eae0; --ink-2: #b9a998;
    --line: #3a2f26; --line-strong: #5a4a3c; --primary: #e0566a; --primary-ink: #1b0f0a;
    --accent: #f0b04a; --accent-soft: #3d2c14; --focus: #7aa7ff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --g-anc: #a89a8c; --g1: #38c6d8; --g2: #e070ef; --g3: #f0718f; --g4: #4ade80; --g5: #2dd4bf; --g6: #fb923c;
    --g7: #a3e635; --g8: #7aa2ff; --g9: #f87171; --g10: #e3b341; --g11: #5fd28a; --g12: #b794f6; --female: #f472b6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15100c; --surface: #201913; --surface-2: #2a211a; --ink: #f3eae0; --ink-2: #b9a998;
  --line: #3a2f26; --line-strong: #5a4a3c; --primary: #e0566a; --primary-ink: #1b0f0a;
  --accent: #f0b04a; --accent-soft: #3d2c14; --focus: #7aa7ff;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --g-anc: #a89a8c; --g1: #38c6d8; --g2: #e070ef; --g3: #f0718f; --g4: #4ade80; --g5: #2dd4bf; --g6: #fb923c;
  --g7: #a3e635; --g8: #7aa2ff; --g9: #f87171; --g10: #e3b341; --g11: #5fd28a; --g12: #b794f6; --female: #f472b6;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.55 var(--font-body);
  min-height: 100vh; display: flex; flex-direction: column;
}
button, input { font: inherit; color: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; fill: var(--primary); stroke: var(--primary); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font: 700 1.1rem/1.1 var(--font-display); letter-spacing: -.01em; }
.brand-sub { font-size: .74rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-nav { display: flex; gap: 4px; margin-left: auto; }
.main-nav a {
  text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: .92rem;
  padding: 8px 12px; border-radius: 999px; transition: background .2s ease, color .2s ease;
}
.main-nav a:hover { background: var(--surface-2); color: var(--ink); }
.main-nav a.is-active { background: var(--ink); color: var(--bg); }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; cursor: pointer;
  font-size: 1.15rem; line-height: 1; transition: background .2s ease, border-color .2s ease;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle svg { fill: currentColor; stroke: none; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: .9rem; text-decoration: none; color: var(--ink);
  transition: background .2s ease, border-color .2s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); border-color: transparent; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view[hidden] { display: none !important; }

/* ---------- Tree view ---------- */
.view-tree { position: relative; flex: none; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); min-height: 420px; display: flex; flex-direction: column; overflow: hidden; }
body.on-tree .site-footer { display: none; }

.search-card {
  position: absolute; z-index: 20; top: 16px; left: 16px; width: min(440px, calc(100% - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 14px 14px 10px;
}
.search-title { display: block; font: 700 1.15rem/1.25 var(--font-display); margin: 0 2px 10px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box > svg { position: absolute; left: 12px; width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search-box input, .picker input {
  width: 100%; height: 48px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--bg); padding: 0 40px 0 40px; font-size: 1rem; outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.picker input { padding: 0 14px; }
.search-box input:focus, .picker input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.kbd-hint { position: absolute; right: 12px; font: 600 .75rem var(--font-body); color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 7px; background: var(--surface); }
.search-box input:not(:placeholder-shown) ~ .kbd-hint, .search-box input:focus ~ .kbd-hint { display: none; }
.search-hint { margin: 8px 2px 2px; font-size: .8rem; color: var(--ink-2); }
.search-card.is-compact .search-title, .search-card.is-compact .search-hint { display: none; }

.search-results {
  list-style: none; margin: 8px 0 0; padding: 4px; max-height: min(52vh, 440px); overflow: auto;
  border-top: 1px solid var(--line);
}
.search-results[hidden] { display: none; }
.result {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
}
.result[aria-selected="true"], .result:hover { background: var(--surface-2); }
.result .gdot { grid-row: span 2; }
.result-name { font-weight: 650; }
.result-name mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.result-line { grid-column: 2 / 4; font-size: .8rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-gen { font-size: .72rem; color: var(--ink-2); font-weight: 600; }
.result-empty, .result-more { padding: 10px; font-size: .88rem; color: var(--ink-2); }

.gdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--gc, var(--g-anc)); flex: none; }

.tree-toolbar {
  position: absolute; z-index: 15; top: 16px; right: 16px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
}
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; box-shadow: var(--shadow); }
.seg button {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: .85rem; color: var(--ink-2); min-height: 36px; transition: background .2s ease, color .2s ease;
}
.seg button.is-on { background: var(--ink); color: var(--bg); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

.chart-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none;
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; user-select: none; -webkit-user-select: none; }
#chart:active { cursor: grabbing; }

/* chart elements */
.link { fill: none; stroke: var(--line-strong); stroke-width: 1.4; }
.link.on-path { stroke: var(--accent); stroke-width: 3.5; }
.link.stack { stroke-dasharray: none; }
.node { cursor: pointer; }
.node rect.card { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1; }
.node rect.stripe { fill: var(--gc); }
.node text { fill: var(--ink); font: 600 12.5px var(--font-body); pointer-events: none; }
.node text.sub { fill: var(--ink-2); font: 500 9.5px var(--font-body); letter-spacing: .02em; }
.node:hover rect.card { stroke: var(--ink-2); stroke-width: 1.5; }
.node.on-path rect.card { stroke: var(--accent); stroke-width: 2.5; fill: var(--accent-soft); }
.node.is-selected rect.card { fill: var(--primary); stroke: var(--primary); stroke-width: 3; }
.node.is-selected text { fill: var(--primary-ink); }
.node.is-selected text.sub { fill: var(--primary-ink); opacity: .85; }
.node.is-dim { opacity: .35; }
.node.flash rect.card { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { stroke: var(--primary); stroke-width: 5; } }
.halo { fill: none; stroke: var(--primary); stroke-width: 2; opacity: .55; }
@media (prefers-reduced-motion: no-preference) {
  .halo { animation: pulse 2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
  @keyframes pulse { 0% { transform: scale(1); opacity: .6; } 100% { transform: scale(1.35); opacity: 0; } }
}
/* far zoom: names become coloured tiles */
#chart.far .node text { display: none; }
#chart.far .node rect.card { fill: var(--gc); stroke: none; }
#chart.far .node.on-path rect.card { fill: var(--accent); }
#chart.far .node.is-selected rect.card { fill: var(--primary); }
#chart.far .node rect.stripe { display: none; }
#chart.far .link { stroke-width: 3; }
#chart.far .link.on-path { stroke-width: 12; }
.gen-label { font: 700 13px var(--font-body); fill: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; }
#chart.far .gen-label { font-size: 60px; }

.zoom-controls { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 10; }
.zoom-controls .icon-btn { box-shadow: var(--shadow); width: 44px; height: 44px; font-size: 1.3rem; }

.legend {
  position: absolute; left: 16px; bottom: 16px; z-index: 10; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 8px 12px; font-size: .8rem; max-width: 220px;
}
.legend summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 6px; min-height: 28px; }
.legend summary::-webkit-details-marker { display: none; }
.legend summary::after { content: "▾"; margin-left: auto; color: var(--ink-2); }
.legend:not([open]) summary::after { content: "▸"; }
.legend-list { list-style: none; margin: 6px 0 2px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.legend-list li { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink-2); }
.legend-list b { color: var(--ink); font-weight: 600; }

.chart-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0; font-size: .78rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow);
  pointer-events: none; transition: opacity .6s ease; white-space: nowrap; }
.chart-hint.gone { opacity: 0; }

/* ---------- Outline (list) view ---------- */
.outline-wrap { flex: 1; overflow: auto; padding: 150px 16px 40px; }
.outline-wrap[hidden] { display: none; }
.outline-actions { max-width: 900px; margin: 0 auto 8px; display: flex; gap: 6px; justify-content: flex-end; }
.outline { max-width: 900px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 6px; }
.outline ul { list-style: none; margin: 0; padding-left: 20px; border-left: 1px dashed var(--line-strong); margin-left: 9px; }
.outline > ul { border-left: 0; padding-left: 4px; margin-left: 0; }
.outline li { margin: 0; }
.o-row { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 2px 6px; border-radius: 8px; }
.o-row:hover { background: var(--surface-2); }
.o-toggle { width: 26px; height: 26px; border: 0; background: transparent; cursor: pointer; border-radius: 6px; color: var(--ink-2); flex: none; font-size: .8rem; }
.o-toggle:hover { background: var(--line); }
.o-toggle[aria-expanded="true"] { transform: rotate(90deg); }
.o-spacer { width: 26px; flex: none; }
.o-name { border: 0; background: none; padding: 4px 2px; cursor: pointer; font-weight: 600; text-align: left; }
.o-name:hover { text-decoration: underline; }
.o-meta { font-size: .76rem; color: var(--ink-2); }
.o-row.on-path { background: var(--accent-soft); }
.o-row.is-selected { background: var(--primary); color: var(--primary-ink); }
.o-row.is-selected .o-meta, .o-row.is-selected .o-toggle { color: var(--primary-ink); }

/* ---------- Person panel ---------- */
.person-panel {
  position: absolute; z-index: 25; top: 16px; right: 16px; bottom: 16px; width: min(400px, calc(100% - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  overflow: auto; padding: 20px 20px 24px; overscroll-behavior: contain;
}
.person-panel[hidden] { display: none; }
body.panel-open .tree-toolbar { right: calc(min(400px, 100% - 32px) + 32px); }
body.panel-open .zoom-controls { right: calc(min(400px, 100% - 32px) + 32px); }
.panel-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; font-size: .95rem; }
.panel-grip { display: none; }
.p-gen { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.p-name { font: 700 2rem/1.1 var(--font-display); margin: 6px 40px 4px 0; letter-spacing: -.01em; }
.p-fullname { margin: 0 0 6px; color: var(--ink-2); font-size: .95rem; }
.p-note { display: inline-block; font-size: .8rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; margin-bottom: 4px; }
.p-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.p-section { margin-top: 20px; }
.p-section h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 0 0 8px; font-weight: 700; }
.p-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.fact b { display: block; font: 700 1.3rem/1.1 var(--font-display); }
.fact span { font-size: .74rem; color: var(--ink-2); }

.lineage { list-style: none; margin: 0; padding: 0; position: relative; }
.lineage li { position: relative; padding-left: 26px; }
.lineage li::before { content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--line-strong); }
.lineage li:first-child::before { top: 50%; }
.lineage li:last-child::before { bottom: 50%; }
.lineage li .gdot { position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 10px; height: 10px; box-shadow: 0 0 0 3px var(--surface); }
.lineage button {
  display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left; background: none; border: 0;
  padding: 5px 8px; border-radius: 8px; cursor: pointer;
}
.lineage button:hover { background: var(--surface-2); }
.lineage .l-name { font-weight: 600; }
.lineage .l-rel { font-size: .76rem; color: var(--ink-2); margin-left: auto; white-space: nowrap; }
.lineage li.is-self button { background: var(--primary); color: var(--primary-ink); }
.lineage li.is-self .l-rel { color: var(--primary-ink); opacity: .85; }
.lineage .l-fold { font-size: .82rem; color: var(--primary); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 5px 11px 5px 9px; cursor: pointer; font-size: .86rem; font-weight: 600; min-height: 34px;
  transition: background .2s ease, border-color .2s ease;
}
.chip:hover { background: var(--surface-2); border-color: var(--line-strong); }
.chip small { font-weight: 500; color: var(--ink-2); }
.muted { color: var(--ink-2); font-size: .88rem; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .9rem;
  transition: opacity .25s ease, transform .25s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Pages (relation, about) ---------- */
.page { flex: 1; }
.page-inner { max-width: 920px; margin: 0 auto; padding: 40px 16px 64px; }
.page-title { font: 700 clamp(1.8rem, 4vw, 2.6rem)/1.1 var(--font-display); margin: 0 0 10px; letter-spacing: -.015em; }
.lede { font-size: 1.08rem; color: var(--ink-2); margin: 0 0 24px; max-width: 65ch; }
.page h3 { font: 700 1.3rem/1.2 var(--font-display); margin: 40px 0 14px; }

.rel-pickers { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; }
.picker { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.picker label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 8px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.picker .search-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); margin-top: 6px; }
.picked { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.picked[hidden] { display: none; }
.picked .p-mini { flex: 1; min-width: 0; }
.picked .p-mini b { display: block; }
.picked .p-mini span { font-size: .8rem; color: var(--ink-2); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swap-btn { margin-top: 44px; }

.rel-result { margin-top: 28px; }
.rel-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 24px; }
.rel-headline { font: 700 clamp(1.4rem, 3vw, 1.9rem)/1.2 var(--font-display); margin: 0 0 6px; }
.rel-headline em { font-style: normal; color: var(--primary); }
.rel-sub { color: var(--ink-2); margin: 0 0 4px; }
.rel-guj { display: inline-block; margin-top: 6px; background: var(--accent-soft); border-radius: 999px; padding: 3px 12px; font-weight: 600; font-size: .9rem; }
.rel-diagram { margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.rel-top { grid-column: 1 / -1; justify-self: center; text-align: center; margin-bottom: 6px; }
.rel-col { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; }
.rel-col li { position: relative; padding-top: 22px; }
.rel-col li::before { content: ""; position: absolute; left: 50%; top: 0; height: 22px; width: 2px; background: var(--accent); }
.rel-node {
  display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line-strong); background: var(--surface);
  border-radius: 10px; padding: 6px 12px; font-weight: 600; cursor: pointer; font-size: .92rem;
}
.rel-node:hover { border-color: var(--ink-2); }
.rel-node.is-end { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.rel-node.is-top { background: var(--accent-soft); border-color: var(--accent); }
.rel-fork { grid-column: 1 / -1; height: 22px; position: relative; }
.rel-fork::before { content: ""; position: absolute; left: 25%; right: 25%; bottom: 0; height: 2px; background: var(--accent); }
.rel-fork::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.rel-col li:first-child::before { height: 22px; }
.rel-actions { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.rel-placeholder { text-align: center; color: var(--ink-2); padding: 32px 16px; border: 1.5px dashed var(--line-strong); border-radius: 18px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat b { display: block; font: 700 2rem/1 var(--font-display); color: var(--primary); }
.stat span { font-size: .85rem; color: var(--ink-2); }

.ancestor-line { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ancestor-line li { display: flex; align-items: center; gap: 8px; }
.ancestor-line li + li::before { content: "→"; color: var(--ink-2); }
.ancestor-line .chip { cursor: pointer; }

.branch-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.branch-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; cursor: pointer; transition: border-color .2s ease, transform .2s ease; }
.branch-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.branch-card b { font: 700 1.25rem var(--font-display); display: block; }
.branch-card .bc-note { font-size: .8rem; color: var(--ink-2); display: block; min-height: 1.2em; }
.branch-card .bc-count { margin-top: 10px; font-size: .9rem; }
.branch-card .bc-count strong { font-size: 1.4rem; color: var(--primary); font-family: var(--font-display); }

.gen-bars { display: grid; gap: 6px; }
.gen-bar { display: grid; grid-template-columns: 110px 1fr 44px; gap: 10px; align-items: center; font-size: .88rem; }
.gen-bar .track { height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.gen-bar .fill { height: 100%; background: var(--gc); border-radius: 999px; }
.gen-bar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }

.tips { padding-left: 20px; }
.tips li { margin-bottom: 8px; }
.chart-thumb { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; min-height: 120px; }
.chart-thumb a { display: block; text-decoration: none; color: var(--ink); }
.chart-thumb img { display: block; width: 100%; height: auto; animation: fadeIn .6s ease both; }
.chart-thumb span { display: block; padding: 10px 14px; background: var(--surface); font-weight: 600; border-top: 1px solid var(--line); }
.chart-thumb-loading { display: grid; place-items: center; min-height: 160px; color: var(--ink-2); background: var(--surface); font-size: .9rem; }
.small-print { font-size: .85rem; color: var(--ink-2); margin-top: 16px; }

.site-footer { border-top: 1px solid var(--line); padding: 18px 16px; text-align: center; font-size: .8rem; color: var(--ink-2); }
.site-footer p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .brand-sub { display: none; }
  .main-nav a { padding: 8px 9px; font-size: .85rem; }
}
@media (max-width: 720px) {
  :root { --header-h: 108px; }
  .site-header { flex-wrap: wrap; height: auto; min-height: var(--header-h); padding: 8px 16px; row-gap: 6px; }
  .main-nav { order: 3; width: 100%; margin: 0; justify-content: space-between; }
  .main-nav a { flex: 1; text-align: center; padding: 7px 4px; font-size: .82rem; }

  .search-card { top: 10px; left: 10px; right: 10px; width: auto; padding: 10px; border-radius: 14px; }
  .search-title { font-size: 1rem; margin-bottom: 8px; }
  .search-hint { display: none; }
  .kbd-hint { display: none; }
  .tree-toolbar { top: auto; bottom: 12px; left: 10px; right: 64px; justify-content: flex-start; }
  .seg button { padding: 6px 9px; font-size: .78rem; }
  .legend { display: none; }
  .zoom-controls { right: 10px; bottom: 12px; }
  .chart-hint { bottom: 70px; font-size: .72rem; }
  .outline-wrap { padding-top: 112px; padding-bottom: 80px; }

  .person-panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 72vh; border-radius: 20px 20px 0 0;
    padding-top: 26px; border-bottom: 0; box-shadow: 0 -8px 30px rgba(0,0,0,.18);
  }
  .panel-grip { display: block; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); }
  body.panel-open .tree-toolbar, body.panel-open .zoom-controls { display: none; }
  .p-name { font-size: 1.7rem; }

  .rel-pickers { grid-template-columns: 1fr; }
  .swap-btn { margin: 0 auto; transform: rotate(90deg); }
  .rel-card { padding: 18px; }
  .gen-bar { grid-template-columns: 92px 1fr 36px; }
}
.lineage .l-name small { display: block; font-weight: 500; font-size: .74rem; color: var(--ink-2); }
.lineage li.is-self .l-name small { color: var(--primary-ink); }
.lineage button { align-items: center; }
a.chip { text-decoration: none; color: var(--ink); }

.nav-short { display: none; }
@media (max-width: 720px) {
  .nav-long { display: none; }
  .nav-short { display: inline; }
  :root { --header-h: 100px; }
  .chart-hint { display: none; }
  .person-panel { max-height: 48vh; transition: max-height .3s ease; }
  .person-panel.is-expanded { max-height: 86vh; }
  .panel-grip { border: 0; padding: 0; cursor: pointer; width: 64px; height: 20px; top: 2px; background: transparent; }
  .panel-grip::before { content: ""; display: block; width: 40px; height: 4px; margin: 8px auto; border-radius: 4px; background: var(--line-strong); }
  body.panel-open .search-card .search-title { display: none; }
}

@media (min-width: 721px) {
  body.panel-open .outline-wrap { padding-right: calc(min(400px, 100% - 32px) + 32px); }
}

/* =========================================================
   Password gate
   ========================================================= */
body.is-locked { overflow: hidden; }
body.is-locked .site-header, body.is-locked main, body.is-locked .site-footer { visibility: hidden; }
.gate {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%), var(--bg);
  overflow: auto;
}
.gate[hidden] { display: none; }
.gate-art { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; pointer-events: none; }
.gate-branches path { stroke: var(--line-strong); stroke-width: 2; }
.gate-dots circle { fill: var(--line-strong); }
.gate-dots circle:nth-child(1) { animation-delay: .1s; fill: var(--primary); }
.gate-dots circle:nth-child(n+2):nth-child(-n+3) { animation-delay: .9s; }
.gate-dots circle:nth-child(n+4):nth-child(-n+7) { animation-delay: 1.7s; }
.gate-dots circle:nth-child(n+8) { animation-delay: 2.5s; }
@keyframes gateDraw { to { stroke-dashoffset: 0; } }
.gate-card {
  position: relative; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: 0 2px 4px rgba(43,29,20,.06), 0 24px 60px rgba(43,29,20,.16);
  padding: 32px 28px 22px; text-align: center; visibility: hidden;
}
.gate.is-ready .gate-card { visibility: visible; }
.gate.is-instant { display: none; }
.gate.is-leaving { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .gate-branches path { stroke-dasharray: 1600; stroke-dashoffset: 1600; animation: gateDraw 3.2s ease .2s forwards; }
  .gate-dots circle { opacity: 0; animation: fadeIn .6s ease forwards; }
  .gate.is-ready .gate-card { opacity: 0; transform: translateY(14px); animation: cardIn .6s cubic-bezier(.2,.8,.2,1) .15s forwards; }
  .gate.is-leaving { opacity: 1; animation: gateOut .65s ease forwards; }
  .gate.is-leaving .gate-card { visibility: visible; opacity: 1; transform: none; animation: cardOut .5s ease forwards; }
  .gate-card.shake { animation: shake .45s ease; opacity: 1; transform: none; }
}
@keyframes cardIn { to { opacity: 1; transform: none; } }
@keyframes cardOut { to { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes gateOut { 60% { opacity: 1; } to { opacity: 0; } }
.gate-mark { width: 52px; height: 52px; fill: var(--primary); stroke: var(--primary); margin: 0 auto 10px; display: block; }
.gate-kicker { margin: 0; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.gate-title { font: 700 2rem/1.1 var(--font-display); margin: 6px 0 10px; letter-spacing: -.015em; }
.gate-lede { margin: 0 0 20px; color: var(--ink-2); font-size: .95rem; }
.gate-field { position: relative; }
.gate-field input {
  width: 100%; height: 52px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: var(--bg);
  padding: 0 52px 0 16px; font-size: 1.05rem; outline: none; transition: border-color .2s ease, box-shadow .2s ease; letter-spacing: .04em;
}
.gate-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
.gate-eye { position: absolute; right: 6px; top: 6px; width: 40px; height: 40px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.gate-eye:hover { background: var(--surface-2); }
.gate-eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.gate-eye[aria-pressed="true"] { color: var(--primary); }
.gate-remember { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 14px 0 16px; font-size: .88rem; color: var(--ink-2); cursor: pointer; }
.gate-remember input { width: 18px; height: 18px; accent-color: var(--primary); }
.gate-submit { width: 100%; justify-content: center; min-height: 50px; font-size: 1rem; border-radius: 12px; position: relative; }
.gate-submit:disabled { opacity: .85; cursor: progress; }
.spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.gate-submit.is-busy .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.gate-msg { min-height: 1.4em; margin: 10px 0 0; color: var(--primary); font-weight: 600; font-size: .9rem; }
.gate-help { margin: 6px 0 0; font-size: .8rem; color: var(--ink-2); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- header actions, theme icon ---------- */
.header-actions { display: flex; gap: 8px; }
.theme-toggle .i-sun { display: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; } :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; } }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
.theme-toggle svg { transition: transform .4s ease; }
.theme-toggle:active svg { transform: rotate(40deg) scale(.9); }
.lock-btn svg { fill: none; stroke: currentColor; stroke-width: 2; }

/* ---------- minimap ---------- */
.minimap {
  position: absolute; right: 72px; bottom: 16px; z-index: 10; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; line-height: 0;
}
.minimap canvas { cursor: pointer; border-radius: 6px; touch-action: none; }
body.panel-open .minimap { right: calc(min(400px, 100% - 32px) + 88px); }

/* ---------- me row, relation-to-me, buttons ---------- */
.me-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 2px 2px; }
.me-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: .85rem; min-height: 34px; }
.me-chip:hover { border-color: var(--line-strong); }
.me-link { font-size: .82rem; font-weight: 600; }
.p-relme { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .86rem; }
.p-relme:hover { border-color: var(--primary); }
.btn-me.is-me { background: var(--accent-soft); border-color: var(--accent); }
body.has-selection .search-card .search-title, body.has-selection .search-card .search-hint { display: none; }

/* =========================================================
   Animations (all disabled for people who prefer reduced motion)
   ========================================================= */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  /* tree grows in on first view */
  #chart.intro .node { animation: fadeIn .45s ease both; animation-delay: calc(var(--gi, 0) * 140ms); }
  #chart.intro .link { stroke-dasharray: 1; animation: drawLine .5s ease both; animation-delay: calc(var(--gi, 0) * 140ms - 120ms); }
  @keyframes drawLine { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
  /* the selected person's line draws from Gova Bapa down */
  .link.on-path.drawing { stroke-dasharray: 1; animation: drawLine .35s ease-out both; animation-delay: calc(350ms + var(--pi, 0) * 75ms); }
  .node.drawing rect.card { animation: pathPop .45s ease both; animation-delay: calc(350ms + var(--pi, 0) * 75ms); }
  @keyframes pathPop { 0% { stroke-width: 1; } 50% { stroke-width: 6; } 100% { } }
  /* panels and lists */
  .person-panel.anim-in { animation: panelIn .38s cubic-bezier(.2,.8,.2,1); }
  .person-panel.anim-swap #person-body { animation: fadeUp .3s ease; }
  @keyframes panelIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
  .search-results .result { animation: fadeUp .22s ease both; }
  .search-results .result:nth-child(2) { animation-delay: 20ms; } .search-results .result:nth-child(3) { animation-delay: 40ms; }
  .search-results .result:nth-child(4) { animation-delay: 60ms; } .search-results .result:nth-child(5) { animation-delay: 80ms; }
  .search-results .result:nth-child(n+6) { animation-delay: 100ms; }
  .view.page:not([hidden]) .page-inner { animation: fadeUp .4s ease both; }
  .view-tree:not([hidden]) .outline-wrap:not([hidden]) .outline { animation: fadeUp .35s ease both; }
  /* about page */
  .view-about.play .stat, .view-about.play .branch-card { animation: fadeUp .5s ease both; }
  .view-about.play .stat:nth-child(2), .view-about.play .branch-card:nth-child(2) { animation-delay: 80ms; }
  .view-about.play .stat:nth-child(3), .view-about.play .branch-card:nth-child(3) { animation-delay: 160ms; }
  .view-about.play .stat:nth-child(4), .view-about.play .branch-card:nth-child(4) { animation-delay: 240ms; }
  .view-about.play .gen-bar .fill { transform-origin: left; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; }
  .view-about.play .gen-bar:nth-child(n) .fill { animation-delay: calc(var(--i, 0) * 60ms); }
  @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  /* relationship diagram */
  .rel-card { animation: fadeUp .4s ease both; }
  .rel-diagram .rel-top, .rel-diagram .rel-col li { animation: fadeUp .35s ease both; }
  .rel-col li:nth-child(1) { animation-delay: .15s; } .rel-col li:nth-child(2) { animation-delay: .25s; }
  .rel-col li:nth-child(3) { animation-delay: .35s; } .rel-col li:nth-child(4) { animation-delay: .45s; }
  .rel-col li:nth-child(n+5) { animation-delay: .55s; }
  .btn, .chip, .icon-btn { transition: background .2s ease, border-color .2s ease, transform .15s ease; }
  .btn:active, .chip:active, .icon-btn:active { transform: scale(.97); }
}
@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
  @keyframes panelIn { from { transform: translateY(40%); opacity: .6; } to { transform: none; opacity: 1; } }
}
@media (max-width: 720px) {
  .minimap { display: none; }
  .gate-card { padding: 26px 20px 18px; }
  .gate-title { font-size: 1.7rem; }
}

/* =========================================================
   Print: a clean lineage sheet for the selected person
   ========================================================= */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; display: block; }
  .site-header, .site-footer, .search-card, .tree-toolbar, .chart-wrap, .outline-wrap, .gate, .toast,
  .panel-close, .panel-grip, .p-actions, .p-relme, .view-relation, .view-about { display: none !important; }
  .view-tree { height: auto !important; overflow: visible !important; }
  .person-panel { position: static !important; width: auto !important; max-height: none !important; box-shadow: none !important; border: 0 !important; padding: 0 !important; overflow: visible !important; }
  #person-body::before { content: "Vekaria Family Tree · Patel Nathabhai Vekaria of Baladia, Kutch"; display: block; font-size: 10pt; color: #555; margin-bottom: 8pt; }
  .lineage li.is-self button { background: #eee !important; color: #000 !important; }
  .chip, .fact { border: 1px solid #bbb; background: #fff; }
}
@media (max-width: 720px) { body.panel-open .me-row { display: none !important; } }
.gate-art { opacity: .38; }

/* =========================================================
   Daughters
   ========================================================= */
.node.is-daughter rect.card { stroke: color-mix(in srgb, var(--female) 55%, var(--line-strong)); fill: color-mix(in srgb, var(--female) 7%, var(--surface)); }
.node.is-daughter rect.stripe { display: none; }
.node.is-daughter text.sub { fill: color-mix(in srgb, var(--female) 75%, var(--ink-2)); }
#chart.far .node.is-daughter rect.card { fill: var(--gc); }
.gpill { display: inline-block; width: 16px; height: 10px; border-radius: 6px; flex: none; border: 1.5px solid var(--female); background: color-mix(in srgb, var(--female) 12%, var(--surface)); }
.legend-f { grid-column: 1 / -1; }
.chip-f { border-color: color-mix(in srgb, var(--female) 40%, var(--line)); }
.o-row.is-daughter .o-name { color: color-mix(in srgb, var(--female) 70%, var(--ink)); }
.p-extra { margin: 6px 0 0; font-size: .86rem; color: var(--ink-2); }

/* =========================================================
   Admin
   ========================================================= */
body.is-admin .admin-btn { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.admin-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.p-admin {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; padding: 10px 12px;
  border: 1.5px dashed var(--accent); border-radius: 12px; background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.p-admin-label { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-right: 4px; }
.p-admin-note { font-size: .8rem; color: var(--ink-2); }
.btn-small { min-height: 34px; padding: 5px 11px; font-size: .84rem; }
.btn-danger { color: #b91c1c; border-color: color-mix(in srgb, #b91c1c 35%, var(--line)); }
:root[data-theme="dark"] .btn-danger { color: #fca5a5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { color: #fca5a5; } }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.modal {
  border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(460px, calc(100% - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 70px rgba(0,0,0,.28);
}
.modal::backdrop { background: rgba(20, 12, 8, .45); backdrop-filter: blur(2px); }
.modal-body { padding: 22px 22px 18px; }
.modal-title { font: 700 1.5rem/1.2 var(--font-display); margin: 0 0 6px; }
.editor-context { margin: 0 0 14px; font-size: .9rem; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .8rem; font-weight: 700; color: var(--ink-2); margin-bottom: 5px; }
.field em { color: var(--primary); font-style: normal; }
.field input { width: 100%; height: 46px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--bg); padding: 0 12px; font-size: 1rem; outline: none; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); }
.field-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.sex-toggle { border: 0; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sex-toggle label { position: relative; }
.sex-toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.sex-toggle span { display: flex; align-items: center; justify-content: center; min-height: 44px; border: 1.5px solid var(--line-strong); border-radius: 10px; font-weight: 700; cursor: pointer; transition: background .2s ease, border-color .2s ease; }
.sex-toggle input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.sex-toggle input[value="F"]:checked + span { background: var(--female); border-color: var(--female); color: #fff; }
.sex-toggle input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.sex-toggle input:disabled + span { opacity: .5; cursor: not-allowed; }
.form-msg { min-height: 1.3em; margin: 4px 0 10px; color: var(--primary); font-weight: 600; font-size: .88rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (prefers-reduced-motion: no-preference) {
  .modal[open] { animation: fadeUp .25s ease; }
  .modal form.shake { animation: shake .45s ease; }
}

.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.admin-warn { background: color-mix(in srgb, #b91c1c 10%, var(--surface)); border: 1px solid color-mix(in srgb, #b91c1c 35%, var(--line)); border-radius: 12px; padding: 10px 14px; }
.admin-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.admin-item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.admin-item .ai-main { flex: 1; min-width: 0; }
.admin-item .ai-main small { display: block; color: var(--ink-2); margin-top: 2px; }
.admin-item .ai-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.admin-item.is-published, .admin-item.is-orphan { opacity: .75; border-style: dashed; }
.page code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
@media (max-width: 720px) {
  .admin-item { flex-wrap: wrap; }
  .admin-item .ai-btns { width: 100%; justify-content: flex-start; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
}
@media print { .p-admin, .modal { display: none !important; } }
@media (max-width: 720px) {
  .header-actions { margin-left: auto; gap: 6px; }
  .header-actions .icon-btn { width: 36px; height: 36px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-name { font-size: 1rem; white-space: nowrap; }
  .site-header { column-gap: 10px; }
}
/* selected daughter: solid card with high-contrast name (light and dark themes) */
.node.is-daughter.is-selected rect.card { fill: var(--female); stroke: var(--female); stroke-width: 3; }
.node.is-daughter.is-selected text, .node.is-daughter.is-selected text.sub { fill: var(--primary-ink); opacity: 1; }
.halo { stroke: var(--primary); }
.node.is-daughter + .halo, .node.is-daughter .halo { stroke: var(--female); }
/* editing a person from the 1999 chart: only wife/husband and year of birth */
#person-form.is-details .sex-toggle, #person-form.is-details .field-note { display: none; }
#person-form.is-details #f-name { background: var(--surface-2); color: var(--ink-2); cursor: not-allowed; }
.field > span small { font-weight: 500; color: var(--ink-2); }
.field-row { grid-template-columns: 1fr 1fr; }
.field input[type="date"] { padding: 0 10px; }
.field input[readonly]:not(#f-name) { background: var(--surface-2); color: var(--ink-2); }
.field-help { margin: -4px 0 8px; font-size: .78rem; color: var(--ink-2); }
.p-extra strong { color: var(--ink); }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; gap: 0; } }
