:root {
  --bg: #f7f1e6;
  --surface: #fffaf2;
  --ink: #2b1d14;
  --muted: #6f5d4e;
  --accent: #a8431c;
  --accent-ink: #fffaf2;
  --vine: #a88a5c;
  --line: #e4d7c3;
  --flag: #d99a00;
  --hl: #ffe3a6;
  --shadow: 0 1px 2px rgb(60 40 20 / 8%), 0 4px 16px rgb(60 40 20 / 6%);
  --serif: "Tiro Devanagari Hindi", Georgia, serif;
  --sans: "Hind", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1410; --surface: #251c16; --ink: #f2e7d7; --muted: #b9a68f;
    --accent: #e48a5e; --accent-ink: #1a1410; --vine: #8c7455; --line: #3b2f26;
    --flag: #f0b429; --hl: #5a4419; --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1410; --surface: #251c16; --ink: #f2e7d7; --muted: #b9a68f;
  --accent: #e48a5e; --accent-ink: #1a1410; --vine: #8c7455; --line: #3b2f26;
  --flag: #f0b429; --hl: #5a4419; --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
[lang="hi"]:not(html), .nm { font-family: var(--serif); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.2; }
h2 { font-size: 1.7rem; margin: 0 0 .4rem; }
h3 { font-size: 1.2rem; margin: 1.6rem 0 .6rem; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Top bar and search */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 1rem; align-items: center;
  padding: .6rem 16px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { text-decoration: none; color: var(--ink); white-space: nowrap; font-size: 1.15rem; }
.brand-en { color: var(--muted); font-size: .9rem; margin-left: .25rem; }
.search { position: relative; flex: 1; max-width: 26rem; margin-left: auto; }
.search input {
  width: 100%; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: .3rem;
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); max-height: 60vh; overflow: auto;
}
.results button {
  display: block; width: 100%; text-align: left; padding: .5rem .6rem; border: 0; border-radius: 8px;
  background: none; cursor: pointer;
}
.results button:hover, .results button:focus-visible, .results button[aria-selected="true"] { background: var(--hl); outline: none; }
.results .sub { display: block; color: var(--muted); font-size: .85rem; }
.results .empty { padding: .5rem .6rem; color: var(--muted); }

main { max-width: 52rem; margin: 0 auto; padding: 0 16px 3rem; }
section { padding: 2.5rem 0 1rem; }
.section-note { color: var(--muted); margin: 0 0 1.4rem; }

/* Hero */
.hero { padding-top: 3.5rem; text-align: center; }
.eyebrow { color: var(--accent); margin: 0 0 .5rem; letter-spacing: .02em; }
.hero h1 { margin: 0; font-size: clamp(2.6rem, 9vw, 4.2rem); }
.h1-en { display: block; font-size: .42em; color: var(--muted); margin-top: .35rem; }
.lede { max-width: 32rem; margin: 1rem auto 1.5rem; font-size: 1.1rem; }
.stats { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; padding: 0; margin: 0 0 1.6rem; list-style: none; }
.stats li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .9rem; }
.stats strong { font-weight: 600; }
.cta { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.btn {
  display: inline-block; padding: .6rem 1.1rem; border-radius: 999px; border: 1px solid var(--accent);
  color: var(--accent); text-decoration: none; font-weight: 500;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }

/* Story and journey */
.story p { max-width: 40rem; }
.journey { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .2rem; padding: 0; margin: 0; list-style: none; }
.journey li { display: flex; align-items: center; gap: .2rem; }
.journey li + li::before { content: "→"; color: var(--vine); margin: 0 .2rem; }
.place {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: .25rem .6rem;
  cursor: pointer; text-align: left; line-height: 1.25;
}
.place small { display: block; color: var(--muted); font-size: .75rem; }
.place:hover, .place:focus-visible { border-color: var(--accent); outline: none; }
.journey-later { color: var(--muted); }
.journey-later button { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Person buttons */
.person {
  position: relative; display: inline-flex; flex-direction: column; align-items: flex-start; text-align: left;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: .4rem .75rem;
  cursor: pointer; transition: border-color .15s, background-color .3s;
}
.person:hover, .person:focus-visible { border-color: var(--accent); outline: none; }
.person .nm { font-size: 1.15rem; line-height: 1.3; }
.person .en { font-size: .9rem; color: var(--muted); }
.person .nick { font-style: italic; }
.person .meta { font-size: .8rem; color: var(--muted); margin-top: .1rem; }
/* A couple: two equal cards joined by a marriage mark; stacked on narrow screens. */
.couple-row { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.couple-row .wed { color: var(--accent); font-size: .85rem; }
@media (max-width: 599px) {
  .couple-row { flex-direction: column; align-items: flex-start; gap: .15rem; }
  .couple-row .wed { margin-left: 1rem; line-height: 1; }
}
.person.hl { background: var(--hl); border-color: var(--accent); }
.flag { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--flag); }
.person .flag { position: absolute; top: .45rem; right: .45rem; }
.tag { font-size: .7rem; color: var(--accent); border: 1px solid currentColor; border-radius: 999px; padding: 0 .4rem; margin-top: .2rem; }

/* Trunk */
.trunk { list-style: none; margin: 0; padding: 0; position: relative; }
.trunk::before { content: ""; position: absolute; left: 1.05rem; top: .8rem; bottom: .8rem; border-left: 3px solid var(--vine); border-radius: 2px; }
.gen-row { position: relative; display: flex; gap: .9rem; padding: .45rem 0; }
.gen-dot {
  flex: none; z-index: 1; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: 2px solid var(--vine); font-size: .85rem; font-weight: 600; color: var(--muted);
}
.gen-body { min-width: 0; }
.gen-label { display: block; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: .1rem 0 .25rem; }
.person.main .nm { font-size: 1.3rem; }
.moved { margin: .35rem 0 0; font-size: .9rem; color: var(--accent); }
.others { margin: .35rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.others > span { font-size: .8rem; color: var(--muted); margin-right: .2rem; }
.person.chip { padding: .15rem .55rem; border-radius: 999px; flex-direction: row; gap: .35rem; align-items: baseline; }
.person.chip .nm { font-size: .95rem; }
.person.chip .en { font-size: .8rem; }
.person.chip .flag { position: static; align-self: center; }

/* Branch tree */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 1.3rem; }
.tree li { position: relative; padding: .3rem 0 .3rem 1.3rem; }
.tree ul > li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 2px solid var(--vine); }
.tree ul > li:last-child::before { bottom: auto; height: 1.75rem; }
.tree ul > li::after { content: ""; position: absolute; left: 0; top: 1.75rem; width: 1.1rem; border-top: 2px solid var(--vine); }
.tree > li { padding-left: 0; }
.tree > li + li { margin-top: 1rem; }
.toggle {
  position: absolute; left: -.15rem; top: .55rem; width: 1.5rem; height: 1.5rem; z-index: 1;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer;
  display: grid; place-items: center; font-size: .8rem; line-height: 1; color: var(--muted);
}
.tree > li > .toggle { left: -1.7rem; }
.toggle::before { content: "−"; }
.toggle[aria-expanded="false"]::before { content: "+"; }
.tree > li { margin-left: 1.7rem; }
.ghost .person { border-style: dotted; background: transparent; }

/* Detail panel */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 30%); z-index: 30; }
.panel {
  position: fixed; z-index: 40; background: var(--surface); box-shadow: var(--shadow); overflow: auto;
  left: 0; right: 0; bottom: 0; max-height: 82vh; border-radius: 18px 18px 0 0; padding: 1.2rem 16px 1.6rem;
  border-top: 1px solid var(--line);
}
.panel-close {
  position: sticky; top: 0; float: right; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.panel h2 { margin: 0; font-size: 2rem; }
.panel .p-en { margin: .1rem 0 .2rem; color: var(--muted); font-size: 1.05rem; }
.panel .p-gen { margin: 0 0 1rem; font-size: .9rem; color: var(--accent); }
.panel dl { margin: 0; }
.panel dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: .9rem; }
.panel dd { margin: .15rem 0 0; }
.plink { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); text-align: left; }
.plink:hover, .plink:focus-visible { text-decoration: underline; outline: none; }
.plinks { display: flex; flex-wrap: wrap; gap: .2rem .9rem; }
.check { margin-top: 1rem; padding: .6rem .8rem; border-radius: 10px; background: color-mix(in srgb, var(--flag) 16%, transparent); border: 1px solid color-mix(in srgb, var(--flag) 45%, transparent); }
.check strong { display: block; font-weight: 600; }
.error { color: var(--accent); }

@media (min-width: 900px) {
  .scrim { display: none; }
  .panel { left: auto; top: 0; bottom: 0; width: 24rem; max-height: none; border-radius: 0; border-top: 0; border-left: 1px solid var(--line); padding-top: 4.5rem; }
  body.panel-open main, body.panel-open .footer { margin-right: 25rem; }
}
@media (min-width: 900px) and (max-width: 1240px) {
  body.panel-open main { margin-left: 16px; }
}

.footer { max-width: 52rem; margin: 0 auto; padding: 1.5rem 16px 3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .person { transition: none; } }

/* Tabs */
.tabs { display: flex; gap: .25rem; justify-content: center; padding: .5rem 16px 0; border-bottom: 1px solid var(--line); }
.tabs a {
  padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent;
  font-weight: 500; white-space: nowrap; font-size: .95rem;
}
.tabs a [lang="hi"] { font-size: .85em; margin-left: .2rem; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* Map view */
.map-view { max-width: 72rem; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.map-head { text-align: center; margin-bottom: 1rem; }
.map-head h2 { font-size: clamp(1.6rem, 6vw, 2.4rem); }
.map-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; list-style: none; padding: 0; margin: .6rem 0 0; }
.map-stats li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .25rem .85rem; }
.map-stats strong { font-weight: 600; color: var(--accent); }
.map-layout { display: grid; gap: 1rem; }
.map { height: 58vh; min-height: 320px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); z-index: 0; }
.chapter { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.chapter-sub { margin: 0; color: var(--accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.chapter h3 { margin: .2rem 0 .4rem; font-size: 1.5rem; }
.chapter p:not(.chapter-sub) { margin: 0 0 1rem; }
.chapter-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.chapter-nav .btn { background: none; cursor: pointer; }
.chapter-nav .btn.primary { background: var(--accent); }
.chapter-nav .btn:disabled { opacity: .35; cursor: default; }
.chapter-dots { display: flex; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.chapter-dots button { width: .7rem; height: .7rem; border-radius: 50%; border: 1px solid var(--vine); background: none; padding: 0; cursor: pointer; }
.chapter-dots button[aria-current="step"] { background: var(--accent); border-color: var(--accent); }
@media (min-width: 900px) {
  .map-layout { grid-template-columns: 1fr 22rem; align-items: start; }
  .map { height: 70vh; }
  .chapter { position: sticky; top: 5rem; }
}
.places-list { margin-top: 2rem; }
.places-list h4 { margin: 1.2rem 0 .5rem; font-weight: 600; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.place-rows { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0; }
.place-rows .place small { max-width: 18rem; }

/* Manuscript (book) view */
.book-view { max-width: 44rem; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.book-head h2 { font-size: clamp(1.6rem, 6vw, 2.2rem); margin-bottom: .3rem; }
.book-jump { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: var(--muted); }
.book-jump select { font: inherit; max-width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.book-page { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem 1.2rem; margin: 1rem 0; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.book-page h3 { font-size: 1.3rem; margin: 1.1rem 0 .5rem; }
.book-page h3:first-child, .b-where + div h3:first-child, .b-langnote + div h3:first-child { margin-top: .3rem; }
.b-where { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .3rem 1rem; margin: 0 0 .6rem; color: var(--accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.b-langnote { margin: 0 0 .6rem; color: var(--muted); font-size: .95rem; }
.book-page .verse { font-family: var(--serif); padding-left: 1rem; border-left: 3px solid var(--line); }
.b-note { font-style: italic; color: var(--muted); }
.b-sign { text-align: right; font-style: italic; }
.b-fields dt { font-weight: 600; margin-top: .7rem; }
.b-fields dd { margin: .15rem 0 0; }
.b-table { overflow-x: auto; margin: .6rem 0; }
.b-table table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.b-table th, .b-table td { text-align: left; vertical-align: top; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
.b-table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.b-table td:first-child, .b-table th:first-child { white-space: nowrap; color: var(--muted); }
/* On phones, a 3-column table (No. · Question · Answer) stacks the last two columns. */
@media (max-width: 599px) {
  .b-table.cols-3 thead { display: none; }
  .b-table.cols-3 tr { display: grid; grid-template-columns: 2rem 1fr; border-bottom: 1px solid var(--line); padding: .45rem 0; }
  .b-table.cols-3 td { border: 0; padding: .1rem .3rem; }
  .b-table.cols-3 td:nth-child(2) { font-weight: 600; }
  .b-table.cols-3 td:nth-child(3) { grid-column: 2; }
}
.book-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .95rem; }
.book-nav .btn { background: none; cursor: pointer; font: inherit; }
.book-nav .btn.primary { background: var(--accent); }
.book-nav .btn:disabled { opacity: .35; cursor: default; }
.events { list-style: none; padding: 0; margin: 0; }
.events li + li { margin-top: .5rem; }
.ev-kind { display: inline-block; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-right: .2rem; }

/* Find yourself: the glowing line, the line list and the share card */
.person.on-line { box-shadow: 0 0 0 2px var(--accent), 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent); }
.gen-row.on-line .gen-dot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.p-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0 .8rem; }
.p-actions .btn { font: inherit; font-size: .95rem; cursor: pointer; background: none; }
.p-actions .btn.primary { background: var(--accent); }
.line-box, .card-box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .8rem; margin-bottom: 1rem; }
.line-h { margin: 0 0 .5rem; font-weight: 600; }
.line-list { list-style: none; margin: 0; padding: 0; max-height: 18rem; overflow-y: auto; }
.line-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; padding: .15rem 0; }
.line-list small { flex-basis: 100%; padding-left: 2.2rem; color: var(--muted); }
.ln-gen { width: 1.7rem; text-align: right; color: var(--muted); font-size: .85rem; }
.card-box img { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.card-acts { display: flex; gap: .5rem; margin-top: .6rem; }
.card-acts .btn { font: inherit; cursor: pointer; background: none; }
.card-acts .btn.primary { background: var(--accent); }
.card-tip { margin: .5rem 0 0; color: var(--muted); font-size: .85rem; }
.cta button.btn { font: inherit; cursor: pointer; background: none; }

/* How are we related? */
.rel-box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .8rem; margin-bottom: 1rem; }
.rel-head { display: block; margin: 0 0 .4rem; font-weight: 600; font-size: 1.1rem; }
.rel-word { margin: 0 0 .4rem; }
.rel-word strong { font-family: var(--serif); font-size: 1.2rem; color: var(--accent); font-weight: 400; }
.rel-word span { color: var(--muted); }
.rel-lca { margin: 0 0 .5rem; color: var(--muted); }
.rel-path { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; margin: .3rem 0 .5rem; }
.rel-path .lca { box-shadow: 0 0 0 2px var(--accent); }
.rel-arrow, .rel-more { color: var(--muted); font-size: .9rem; }
.rel-note { margin: 0 0 .4rem; color: var(--muted); font-size: .85rem; }
.rel-change { font: inherit; font-size: .85rem; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.rel-box input { width: 100%; font: inherit; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.rel-hits { list-style: none; margin: .4rem 0 0; padding: 0; }
.rel-hits button { width: 100%; text-align: left; font: inherit; background: none; border: 0; border-bottom: 1px solid var(--line); padding: .45rem .2rem; color: var(--ink); cursor: pointer; }
.rel-hits small { display: block; color: var(--muted); }
.rel-hits .empty { color: var(--muted); padding: .4rem .2rem; }

/* Leaflet popups in the site's colours */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content { margin: .7rem .9rem; font: 15px/1.45 var(--sans); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-tooltip { font: 13px var(--sans); }
.muted { color: var(--muted); font-size: .85em; }
.pop-list { margin: .4rem 0 0; padding-left: 1rem; }
.pop-list li { margin: .15rem 0; }

/* Soften the OpenStreetMap tiles to sit with the page; darken them in dark mode */
.map .leaflet-tile-pane { filter: saturate(.55) sepia(.15); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) saturate(.4); }
}
:root[data-theme="dark"] .map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) saturate(.4); }

/* Language switch */
.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.lang-switch button {
  border: 0; background: var(--surface); color: var(--muted); padding: .4rem .7rem; cursor: pointer;
  font-size: .9rem; font-weight: 600; min-width: 2.6rem;
}
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.lang-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lang-switch [lang="hi"] { font-family: var(--sans); }
.search { min-width: 0; }
@media (max-width: 520px) { .topbar { gap: .5rem; } .brand { font-size: 1rem; } }
