/* Kindred Atlas — light theme, system fonts, no framework. */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --text: #1f2328;
  --muted: #667085;
  --border: #e3e1dc;
  --border-strong: #cfccc4;
  --input-border: #8f8a7e;
  --accent: #2d3a4a;
  --accent-ink: #ffffff;
  --link: #1f5f8b;
  --danger: #b42318;
  --warn: #b54708;
  --warn-bg: #fff6e5;
  --ok: #067647;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --header-h: 60px;

  --conf-confirmed: #0e6b4c;
  --conf-confirmed-bg: #e3f6ec;
  --conf-probable: #1f63b8;
  --conf-probable-bg: #e5eefb;
  --conf-possible: #8a5300;
  --conf-possible-bg: #fff2d9;
  --conf-tree: #6b7280;
  --conf-tree-bg: #f1f2f4;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.md a, .tl-body a, .facts dd a, .event-list a, .grouped a, .lead a, .card p a, .notice a, .doc-src a, .mini-facts a {
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); text-underline-offset: 2px;
}
.md a:hover, .tl-body a:hover, .facts dd a:hover, .event-list a:hover, .grouped a:hover, .card p a:hover { text-decoration-color: currentColor; }
.tl-body a.src-ref, .event-list a.src-ref { text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; margin-top: .25em; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.1em 0 .4em; }
h2.inline { display: inline; }
code, .mono { font-family: var(--mono); font-size: .9em; }
pre { white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); }
.warn-text { color: var(--warn); }
.missing { color: var(--danger); border-bottom: 1px dashed var(--danger); cursor: help; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #2f6fd0; outline-offset: 2px; }
.nav a:focus-visible, .btn:focus-visible { outline-offset: 3px; }

/* ---------- header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 1.25rem;
  min-height: var(--header-h);
  padding: .5rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
}
.brand-link { display: flex; flex-direction: column; color: var(--text); }
.brand-link:hover { text-decoration: none; }
.app-title { font-weight: 750; font-size: 1.1rem; letter-spacing: -.01em; }
.app-subtitle { font-size: .75rem; color: var(--muted); max-width: 26rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; gap: .15rem; flex-wrap: wrap; }
.nav a {
  padding: .4rem .7rem; border-radius: 999px; color: var(--text); font-weight: 500; font-size: .92rem;
}
.nav a:hover { background: #eceae5; text-decoration: none; }
.nav a.active:hover { background: var(--accent); }
.nav a.active { background: var(--accent); color: var(--accent-ink); }
.search-wrap { position: relative; margin-left: auto; }
#search {
  width: 15rem; padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--input-border);
  background: var(--surface-2); font: inherit;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: #fff; }
.search-results {
  position: absolute; right: 0; top: calc(100% + 6px); width: 22rem; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  z-index: 1100;
}
.search-item { display: block; padding: .5rem .8rem; color: var(--text); border-bottom: 1px solid var(--border); }
.search-item:last-child { border-bottom: 0; }
.search-item:hover { background: var(--surface-2); text-decoration: none; }
.search-item.active { background: #e9eef5; box-shadow: inset 3px 0 0 var(--accent); text-decoration: none; }
.search-empty { padding: .6rem .8rem; }
.nav .short { display: none; }
.mode-indicator { font-size: .72rem; color: var(--muted); white-space: nowrap; }
body.editable .mode-indicator { color: var(--ok); }

/* ---------- layout ---------- */

.main { min-height: calc(100vh - var(--header-h)); }
.page { max-width: 1320px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.page-wide { max-width: 1320px; }
.page-full { max-width: none; padding: .9rem 1.25rem 0; }
.page-full .page-head { margin-bottom: .5rem; }
.page-full h1 { font-size: 1.5rem; }
.skip-link { position: absolute; left: .5rem; top: .5rem; z-index: 2000; padding: .5rem .9rem; background: var(--accent); color: #fff; border: 0; border-radius: var(--radius-sm); font: inherit; cursor: pointer; }
/* Hidden until reached with the keyboard (Tab), as is usual for skip links. */
.skip-link:not(:focus-visible) { clip-path: inset(50%); width: 1px; height: 1px; padding: 0; overflow: hidden; white-space: nowrap; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1, .page-head h2 { margin-bottom: .2rem; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 .5rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.15rem; box-shadow: var(--shadow); margin-bottom: 1rem; min-width: 0;
}
.two-col > .card { margin-bottom: 0; }
.notice { background: #eef4fb; border: 1px solid #cddcf0; border-radius: var(--radius-sm); padding: .6rem .9rem; margin: 0 0 1rem; }
.notice.warn { background: var(--warn-bg); border-color: #f5d49a; color: #6a3a00; }
.notice ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------- buttons, badges, chips ---------- */

.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: #b9b5ab; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1f2a36; border-color: #1f2a36; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fef3f2; border-color: #f3b5ae; }
.btn-small { padding: .25rem .6rem; font-size: .8rem; }
.btn-icon { padding: .15rem .5rem; font-size: .95rem; line-height: 1.2; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row label { font-size: .85rem; color: var(--muted); display: inline-flex; gap: .4rem; align-items: center; }

.badge {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  letter-spacing: .02em; border: 1px solid transparent; vertical-align: middle; white-space: nowrap;
}
.badge.conf-confirmed, .badge.conf-probable, .badge.conf-possible, .badge.conf-tree { color: #2b313a; background: #f1f2f4; }
.badge.conf-confirmed { border: 1px solid #5b6472; }
.badge.conf-probable { border: 1px dashed #7a8291; }
.badge.conf-possible { border: 1px dotted #7a8291; color: #4a5260; }
.badge.conf-tree { border: 1px solid #d0d4da; color: #4a5260; }
.badge.conf-confirmed::before { content: "✓ "; } .badge.conf-probable::before { content: "≈ "; } .badge.conf-possible::before { content: "? "; }
.conf-unknown { color: var(--danger); background: #fef3f2; }
.level-error { color: #fff; background: var(--danger); }
.level-warning { color: #6a3a00; background: #fde7b8; }

.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .05rem .5rem .05rem .4rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  color: color-mix(in srgb, var(--chip) 55%, black); background: color-mix(in srgb, var(--chip) 12%, white);
  border: 1px solid color-mix(in srgb, var(--chip) 35%, white); margin-right: .2rem; white-space: nowrap;
}
.chip::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--chip); }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 4px; background: #eef0f3; color: #3f4753; }
.swatch { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; vertical-align: baseline; flex: none; }
.swatch-lg { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 4px; flex: none; }
.years { color: var(--muted); font-size: .85em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.person-link { white-space: nowrap; }
.src-refs { display: inline-flex; gap: .2rem; flex-wrap: wrap; }
.src-ref {
  display: inline-block; min-width: 1.5rem; text-align: center; font-size: .78rem; font-weight: 600;
  padding: .05rem .35rem; border-radius: 4px; background: #eef4fb; border: 1px solid #cddcf0;
}
.src-ref.missing { background: #fef3f2; border-color: #f3b5ae; color: var(--danger); }
.id-label { font-family: var(--mono); font-size: .75rem; }

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

.hero { padding: 1.5rem 0 1rem; }
.hero h1 { font-size: 2.2rem; margin-bottom: .2rem; }
.hero-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 1rem 0 1.5rem; }
.stat {
  display: flex; flex-direction: column; padding: .8rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text);
}
a.stat:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }
a.stat .stat-label::after { content: " ›"; color: var(--link); }
.stat-n { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-bad .stat-n { color: var(--danger); }
.stat-good .stat-n { color: var(--ok); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.person-card { display: flex; flex-direction: column; margin: 0; }
.person-card h3 { font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 .1rem; }
.person-card .lifespan { color: var(--muted); font-variant-numeric: tabular-nums; }
.missing-card { border-style: dashed; }
.mini-facts { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; font-size: .85rem; margin: .6rem 0; }
.mini-facts dt { color: var(--muted); }
.mini-facts dd { margin: 0; }
.card-foot { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; margin-top: auto; padding-top: .5rem; }
.card-actions { display: flex; gap: .4rem; margin-top: .6rem; }
.branch-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .6rem; }
.branch-item {
  display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.branch-item > div { flex: 1; min-width: 0; }
.branch-item .count { font-weight: 700; font-variant-numeric: tabular-nums; }
a.branch-item { color: var(--text); }
a.branch-item:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.branch-item .go { color: var(--link); font-size: .88rem; white-space: nowrap; }

/* ---------- tables & filters ---------- */

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
input, select, textarea { font: inherit; color: inherit; }
.filters input[type=search], .filters select, .page-head select, .btn-row select, .tree-opts select {
  padding: .4rem .6rem; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--surface);
}
.filters input[type=search] { min-width: 16rem; }
.check { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.table-wrap { overflow-x: clip; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { padding: .55rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.data-table th { white-space: nowrap; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); position: sticky; top: var(--header-h); z-index: 1; }
.th-sort { all: unset; cursor: pointer; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; }
.th-sort:hover { color: var(--text); }
.data-table th:not(.sorted) .th-sort::after { content: " ⇅"; opacity: .45; }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.data-table th.sorted { color: var(--text); }
.data-table th.sorted .th-sort::after { content: " " attr(data-dir); }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.data-table tbody tr:hover { background: #fbfaf7; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table.compact td, .data-table.compact th { padding: .35rem .6rem; }
.data-table.fixed { table-layout: fixed; }
.data-table.fixed td { overflow-wrap: anywhere; }
.card .data-table th { position: static; }

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

.person-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap;
  padding: 1.1rem 1.25rem; margin-bottom: 1rem; background: var(--surface); border: 1px solid var(--border);
  border-left: 6px solid var(--branch, #8a8f98); border-radius: var(--radius); box-shadow: var(--shadow);
}
.person-head h1 { margin-bottom: 0; }
.person-id { display: flex; gap: 1rem; align-items: center; min-width: 0; }
.portrait { flex: none; display: block; line-height: 0; }
.portrait img { width: 84px; height: 104px; object-fit: cover; object-position: 50% 20%; border-radius: 6px; border: 1px solid var(--border); background: #eee; }
.sec-story .md p:first-child { margin-top: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.photo { margin: 0; }
.photo img { display: block; width: 100%; max-height: 260px; object-fit: contain; background: #f3f1ec; border: 1px solid var(--border); border-radius: 4px; }
.photo figcaption { font-size: .85rem; margin-top: .3rem; }
.sex-mark { font-size: 1.3rem; color: #5b6472; font-weight: 400; }
.lifespan-lg { font-size: 1.1rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.aka { margin-top: .25rem; font-size: .9rem; }
.head-meta { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.person-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: .15rem 0; }
.plain.cols { columns: 2; }
.role { display: inline-block; min-width: 4.2rem; color: var(--muted); font-size: .8rem; }
.spouse-block { padding: .6rem 0; border-top: 1px solid var(--border); }
.spouse-block:first-of-type { border-top: 0; }
.children { margin: .3rem 0 .3rem; padding-left: 1.4rem; }
.todo { padding-left: 1.2rem; margin: 0; }
.todo li { padding: .15rem 0; }
.todo li::marker { color: var(--muted); }
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md img { max-width: 100%; }
.md table { border-collapse: collapse; }
.md td, .md th { border: 1px solid var(--border); padding: .25rem .5rem; }
.mini-map { height: 280px; border-radius: var(--radius-sm); overflow: hidden; background: #e8eef0; }
.mini-map.empty { height: auto; background: none; }
.map-fallback { padding: .5rem 0; margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 .8rem; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.grouped { list-style: none; padding: 0; margin: 0; }
.grouped > li { padding: .5rem 0; border-top: 1px solid var(--border); }
.grouped > li:first-child { border-top: 0; }
.grouped ul { margin: .25rem 0 0; padding-left: 1.2rem; font-size: .9rem; }
.files { padding-left: 1.2rem; overflow-wrap: anywhere; }
.event-list li { padding: .35rem 0; border-top: 1px solid var(--border); }
.event-list li:first-child { border-top: 0; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.tl-item { display: grid; grid-template-columns: 7.5rem 1rem 1fr; gap: .5rem; padding: .45rem 0; position: relative; }
.tl-item::before {
  content: ""; position: absolute; left: calc(7.5rem + .5rem + .5rem - 1px); top: 0; bottom: 0; width: 2px; background: var(--border);
}
.tl-item:first-child::before { top: 1rem; }
.tl-item:last-child::before { bottom: calc(100% - 1rem); }
.tl-date { text-align: right; font-variant-numeric: tabular-nums; font-size: .88rem; padding-top: .05rem; white-space: nowrap; }
.tl-dot { width: .8rem; height: .8rem; margin: .3rem auto 0; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); position: relative; z-index: 1; }
.tl-type-birth .tl-dot, .tl-type-baptism .tl-dot { background: var(--accent); }
.tl-type-death .tl-dot, .tl-type-burial .tl-dot { background: #444; border-color: #444; }
.tl-family .tl-dot { border-color: #b5651d; background: #fde9d7; }
.tl-child .tl-dot { width: .6rem; height: .6rem; border-color: #9aa1ab; margin-top: .4rem; }
.tl-child .tl-title { color: var(--muted); font-size: .9rem; }
.tl-title { font-weight: 600; }
.tl-child .tl-title { font-weight: 400; }
.tl-place { font-size: .9rem; }
.tl-place::before {
  content: ""; display: inline-block; width: .55rem; height: .55rem; margin-right: .35rem;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #7a8291; vertical-align: .05rem;
}
.tl-desc { font-size: .9rem; }

/* ---------- pedigree ---------- */

.ped-legend { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.ped-key { display: inline-flex; align-items: center; gap: .3rem; }
.ped-key i { display: inline-block; width: 16px; height: 11px; border-radius: 3px; border-width: 2px; border-style: solid; border-color: #c9c6bf; background: var(--surface); }
.ped-key i.conf-border-confirmed { border-color: #4b5563; }
.ped-key i.conf-border-probable { border-color: #6b7280; border-style: dashed; }
.ped-key i.conf-border-possible { border-color: #6b7280; border-style: dotted; }
.ped-scroll { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; height: calc(100vh - 200px); min-height: 420px; }
.ped-sizer { position: relative; }
#ped-scroll { position: relative; } /* offsets of the sizer are measured from here */
.ped-scroll { cursor: grab; user-select: none; }
.ped-scroll.dragging { cursor: grabbing; user-select: none; }
.ped-scroll.dragging .ped-box, .ped-scroll.dragging a { cursor: grabbing; }
.ped-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ped-lines, .ped-regions, .ped-centuries { position: absolute; left: 0; top: 0; pointer-events: none; }
.ped-centuries .band-odd { fill: #efece4; opacity: .55; }
.ped-centuries .band-even { fill: transparent; }
.ped-centuries text { font-size: 12px; font-weight: 600; fill: #a39e92; letter-spacing: .04em; }
.zoom-ctl { display: inline-flex; align-items: center; }
.zoom-ctl .btn { border-radius: 0; margin-left: -1px; }
.zoom-ctl .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.zoom-ctl .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.zoom-ctl .btn-small { padding: .4rem .65rem; font-size: .88rem; }
.zoom-level { min-width: 3.4rem; font-variant-numeric: tabular-nums; }
.ped-region-label {
  position: absolute; z-index: 1; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 10.5px; line-height: 14px; padding: 0 6px; border-radius: 4px; pointer-events: auto;
}
.ped-region-area { transform: translateY(-50%); background: var(--region); color: #fff; font-weight: 600; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 4px; }
.ped-region-area .flag { flex: none; border-radius: 1px; }
.flag { vertical-align: -2px; }
.country-legend { gap: .3rem .9rem; margin-top: -.2rem; }
.country-key { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.country-key i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid; }
.ped-region-place { transform: translateY(-50%); background: var(--region-bg); color: #3d3d3d; border: 1px dashed var(--region); }
.ped-region-place:hover { text-decoration: none; color: var(--link); }
.ped-lines path { fill: none; stroke: #b9b5ab; stroke-width: 1.5; }
.ped-lines path.faint { stroke-dasharray: 3 3; stroke: #d6d3cc; }
.ped-lines path.marriage { stroke: #c0587e; stroke-width: 2.2; }
.ped-key i.ped-marr-key { border: 2.5px solid #c0587e; border-right: none; border-radius: 0; background: none; width: 7px; }
.ped-box {
  position: absolute; display: flex; flex-direction: column; justify-content: center;
  padding: .25rem .6rem .25rem .85rem; border-radius: 8px; background: var(--surface);
  border: 2px solid #c9c6bf; cursor: pointer; overflow: hidden; box-shadow: var(--shadow);
}
.ped-box::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--branch, #8a8f98); }
.ped-box:hover, .ped-box:focus { box-shadow: 0 0 0 3px rgba(45, 58, 74, .28); outline: none; }
.ped-box.ped-focus, .ped-box.ped-focus:hover, .ped-box.ped-focus:focus { box-shadow: 0 0 0 4px #f2c14e, var(--shadow); }
/* All relatives: people off the direct line are shaded; spouses who married in are in italics. */
.ped-box.ped-rel { background: #f1efea; box-shadow: none; }
.ped-inlaw .ped-name { font-style: italic; font-weight: 500; }
.tree-wrap { display: flex; gap: .9rem; align-items: flex-start; }
.ped-stage { flex: 1; min-width: 0; position: relative; }
/* Zoom controls float over the chart's top left corner. */
.tree-zoom { position: absolute; left: .6rem; top: .6rem; z-index: 3; display: flex; gap: .35rem; align-items: center; }
.tree-zoom .btn { box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
/* The tree's options and key, in a sidebar to the left of the chart. */
.page-tree { padding-top: .6rem; }
.tree-side { flex: none; width: 15rem; overflow-y: auto; display: flex; flex-direction: column; gap: .9rem; padding: .1rem .15rem .6rem 0; }
.tree-side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .4rem; }
.tree-side h1 { font-size: 1.15rem; line-height: 1.25; margin: .15rem 0 0; }
.tree-side h2 { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .15rem; }
.tree-side-toggle { flex: none; padding: .25rem .55rem; font-size: 1rem; line-height: 1; }
.tree-side-body { display: flex; flex-direction: column; gap: 1.1rem; }
.tree-opts { display: flex; flex-direction: column; gap: .6rem; }
.tree-opts label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--muted); }
.tree-opts label.check { flex-direction: row; align-items: center; gap: .45rem; font-size: .9rem; color: var(--text); }
.tree-opts select { width: 100%; }
.tree-opts > .btn { align-self: flex-start; }
.tree-side .ped-legend { flex-direction: column; align-items: flex-start; gap: .3rem; margin: 0; }
.tree-side .ped-hint { margin: 0; }
.tree-side.collapsed { width: auto; }
.tree-side.collapsed h1, .tree-side.collapsed .tree-side-body { display: none; }
.ped-key i.ped-stripe-key { border-color: #c9c6bf; border-left: 5px solid #8a8f98; }
.ped-key i.ped-line-key { border-color: #c9c6bf; }
.ped-key i.ped-rel-key { background: #f1efea; }

/* Zoom levels (set on the canvas by the view): --fs scales text, --lw lines
   and --bw borders, so that they stay readable when zoomed out. lod-1: one
   line of name; lod-2: no dates, first given name only; lod-3: surname only.
   Place outlines and labels go below 50%; countries stay. */
.ped-canvas { --fs: 1; --lw: 1; --bw: 1; --ls: 1; }
.ped-canvas .ped-box { border-width: calc(2px * var(--bw)); }
.ped-canvas .ped-box::before { width: calc(6px * var(--bw)); }
.ped-canvas .ped-name { font-size: calc(.86rem * var(--fs)); }
.ped-canvas .ped-years { font-size: calc(.8rem * var(--fs)); }
.ped-canvas .ped-box.ped-focus { box-shadow: 0 0 0 calc(4px * var(--lw)) #f2c14e, var(--shadow); }
.ped-canvas .ped-lines path { stroke-width: calc(1.5px * var(--lw)); }
.ped-canvas .ped-lines path.marriage { stroke-width: calc(2.2px * var(--lw)); }
.ped-canvas .ped-regions path.area { stroke-width: calc(2.2px * var(--bw)); }
.ped-canvas .ped-region-area { font-size: calc(10.5px * var(--ls)); line-height: 1.35; padding: 0 .5em; }
.ped-canvas .ped-region-label { max-width: calc(190px * var(--ls)); }
/* Zoomed right out, only the larger groups keep a country label; the colours and the key do the rest. */
.lod-3 .ped-region-few { display: none; }
.ped-canvas .ped-region-area .flag { width: 1.45em; height: .97em; }
.ped-canvas a.ped-family, .ped-canvas span.ped-family { font-size: calc(.82rem * min(var(--ls), 2.5)); transform: translateY(-50%); padding-top: .2em; padding-bottom: .2em; white-space: normal; line-height: 1.15; border-radius: 1.2em; }
.lod-1:not(.ped-v) .ped-name { -webkit-line-clamp: 1; }
.lod-2 .ped-years, .lod-3 .ped-years, .lod-2 .pn-unknown, .lod-3 .pn-unknown, .lod-2 .pn-rest, .lod-3 .pn-rest, .lod-3 .pn-first:not(.pn-keep) { display: none; }
.lod-2 .ped-open, .lod-3 .ped-open, .lod-2 .ped-conf, .lod-3 .ped-conf { display: none; }
.lod-2 .ped-box, .lod-3 .ped-box { padding-top: 2px; padding-bottom: 2px; }
.lod-2 .ped-name, .lod-3 .ped-name { padding-right: 0; line-height: 1.1; display: block; white-space: nowrap; text-overflow: ellipsis; }
.ped-v.lod-2 .ped-name { display: -webkit-box; -webkit-line-clamp: 2; white-space: normal; }
.lod-2 .ped-empty > *, .lod-3 .ped-empty > * { display: none; }
.lod-2 .ped-regions .place, .lod-3 .ped-regions .place, .lod-2 .ped-region-place, .lod-3 .ped-region-place { display: none; }
.lod-2 .ped-lines path:not(.marriage):not(.faint), .lod-3 .ped-lines path:not(.marriage):not(.faint) { stroke: #8f8a7e; }
.lod-2 .ped-lines path.faint, .lod-3 .ped-lines path.faint { stroke: #bdb9b0; }
.side-panel { flex: none; width: 440px; overflow-y: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; }
.side-panel-bar { position: sticky; top: -.6rem; z-index: 2; display: flex; justify-content: space-between; gap: .5rem; background: var(--bg); padding: .1rem 0 .5rem; }
.side-panel .page { padding: 0; max-width: none; }
.side-panel .person-head { padding: .8rem .9rem; }
.side-panel .person-head h1 { font-size: 1.35rem; }
.side-panel .portrait img { width: 64px; height: 80px; }
.side-panel .person-head .btn-row { display: none; }
.side-panel .person-grid { display: flex; flex-direction: column; gap: 0; }
.side-panel .person-main, .side-panel .person-side { display: contents; }
.side-panel .sec-story { order: 0; } .side-panel .sec-photos { order: 3; }
.side-panel .sec-family { order: 1; } .side-panel .sec-timeline { order: 2; } .side-panel .sec-places { order: 3; }
.side-panel .sec-notes { order: 4; } .side-panel .sec-sources { order: 5; } .side-panel .sec-docs { order: 6; } .side-panel .sec-todo { order: 7; }
.side-panel .tl-item { grid-template-columns: 1rem 1fr; }
.side-panel .tl-item::before { left: calc(.5rem - 1px); }
.side-panel .tl-date { grid-column: 2; grid-row: 1; text-align: left; font-size: .82rem; color: var(--muted); }
.side-panel .tl-dot { grid-column: 1; grid-row: 1 / span 2; }
.side-panel .tl-body { grid-column: 2; }
.side-panel .card { padding: .8rem .9rem; }
@media (max-width: 1000px) {
  .side-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(100%, 460px); height: auto !important; z-index: 1500; border-radius: 0; box-shadow: -8px 0 24px rgba(0, 0, 0, .18); }
}
.ped-name { font-weight: 600; font-size: .86rem; line-height: 1.18; overflow: hidden; padding-right: 1rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ped-small .ped-name { -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; display: block; }
.ped-years { font-size: .8rem; line-height: 1.2; color: var(--muted); font-variant-numeric: tabular-nums; }
.ped-open { position: absolute; right: 0; top: 0; width: 1.6rem; height: 1.7rem; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 700; color: var(--muted); border-radius: 0 6px 0 6px; }
.ped-open:hover { background: var(--surface-2); }
.ped-open:hover { color: var(--link); text-decoration: none; }
.ped-conf { position: absolute; right: .3rem; bottom: .2rem; font-size: .8rem; font-weight: 700; line-height: 1; color: #374151; background: #f1f2f4; border-radius: 3px; padding: .05rem .2rem; }
.ped-empty { border: 2px dashed #d6d3cc; background: var(--surface-2); cursor: default; box-shadow: none; font-size: .8rem; flex-direction: row; justify-content: space-between; align-items: center; }
.ped-empty::before { display: none; }
.ped-family { position: absolute; display: flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--surface-2); border: 1.5px solid var(--border-strong); color: var(--muted); font-size: .85rem; font-weight: 600; text-align: center; padding: 0 .6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ped-family:hover { color: var(--link); text-decoration: none; border-color: var(--link); }
.ped-family.ped-family-long { white-space: normal; line-height: 1.15; border-radius: 18px; font-size: .8rem; }
.ped-empty-short { padding-top: 0; padding-bottom: 0; font-size: .72rem; border-width: 1.5px; border-radius: 6px; }
.ped-box.conf-border-confirmed { border-color: #4b5563; }
.ped-box.conf-border-probable { border-color: #6b7280; border-style: dashed; }
.ped-box.conf-border-possible { border-color: #6b7280; border-style: dotted; }
/* Timeline boxes: an estimated birth or death fades out at that end. */
.ped-time-h.ped-est-start { border-left-color: transparent; border-top-left-radius: 0; border-bottom-left-radius: 0; background: linear-gradient(to right, transparent, var(--surface) 30px); }
.ped-time-h.ped-est-end { border-right-color: transparent; border-top-right-radius: 0; border-bottom-right-radius: 0; background: linear-gradient(to left, transparent, var(--surface) 30px); }
.ped-time-h.ped-est-start.ped-est-end { background: linear-gradient(to right, transparent, var(--surface) 30px, var(--surface) calc(100% - 30px), transparent); }
.ped-time-v.ped-est-start { border-top-color: transparent; border-top-left-radius: 0; border-top-right-radius: 0; background: linear-gradient(to bottom, transparent, var(--surface) 30px); }
.ped-time-v.ped-est-end { border-bottom-color: transparent; border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: linear-gradient(to top, transparent, var(--surface) 30px); }
.ped-time-v.ped-est-start.ped-est-end { background: linear-gradient(to bottom, transparent, var(--surface) 30px, var(--surface) calc(100% - 30px), transparent); }
.ped-time.ped-est-start, .ped-time.ped-est-end { box-shadow: none; }
.ped-time-h { padding-top: 1px; padding-bottom: 1px; }
.ped-time-v { justify-content: flex-start; }
.conf-border-missing { border-color: var(--danger); border-style: dotted; }

/* descendants */
.desc-tree, .desc-tree ul { list-style: none; margin: 0; padding: 0; }
.desc-tree ul { padding-left: 1.4rem; margin-left: .4rem; }
.desc-tree ul > li { position: relative; }
.desc-tree ul > li::before { content: ""; position: absolute; left: -1rem; top: 0; bottom: 0; border-left: 2px solid var(--border); }
.desc-tree ul > li:last-child::before { bottom: auto; height: 1.05rem; }
.desc-tree ul > li::after { content: ""; position: absolute; left: -1rem; top: 1.05rem; width: .75rem; border-top: 2px solid var(--border); }
.desc-person { padding: .2rem .5rem; border-left: 4px solid var(--branch, #8a8f98); background: var(--surface); border-radius: 4px; margin: .2rem 0; display: inline-block; }
.desc-fam { padding: .1rem 0 .3rem; }
.desc-marr { font-size: .88rem; }

/* ---------- map page ---------- */

.map-layout { display: flex; height: calc(100vh - var(--header-h)); }
.map-layout > .map-panel { flex: none; width: 290px; }
.map-layout > .map-main { flex: 1; min-width: 0; }
.map-layout.filters-hidden > .map-panel { display: none; }
.map-layout > .side-panel { width: 420px; height: auto; border-radius: 0; border-width: 0 0 0 1px; }
.tl-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1000; background: rgba(255, 255, 255, .95); border-top: 1px solid var(--border); padding: .35rem .8rem .2rem; box-shadow: 0 -2px 8px rgba(0, 0, 0, .06); }
.tl-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.tl-buttons { display: inline-flex; }
.tl-buttons .btn { border-radius: 0; margin-left: -1px; min-width: 2.2rem; justify-content: center; }
.tl-buttons .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.tl-buttons .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tl-speed select { padding: .15rem .3rem; border: 1px solid var(--input-border); border-radius: var(--radius-sm); }
.tl-now { font-size: .9rem; flex: 1; min-width: 12rem; }
.tl-axis { display: block; width: 100%; height: 40px; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.tl-axis:focus-visible { outline: 3px solid #2f6fd0; outline-offset: 0; }
.tl-base { stroke: #b9b5ab; stroke-width: 1.5; }
.tl-tick { stroke: #b9b5ab; }
.tl-year { font-size: 11px; fill: var(--muted); text-anchor: middle; }
.tl-ev { stroke-width: 1.5; opacity: .75; }
.tl-cursor { stroke: #1f2328; stroke-width: 2; }
.tl-knob { fill: #f2c14e; stroke: #1f2328; stroke-width: 1.5; }
.map-main .leaflet-bottom { bottom: 84px; }
.person-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0 .3rem; }
.person-chip { all: unset; cursor: pointer; font-size: .85rem; padding: .1rem .5rem; border-radius: 999px; background: #e9eef5; border: 1px solid #cddcf0; }
.person-chip:hover { background: #dbe4f0; }
.person-chip:focus-visible, .link-btn:focus-visible { outline: 3px solid #2f6fd0; }
.link-btn { all: unset; cursor: pointer; color: var(--link); font-size: .85rem; }
#pf-person { width: 100%; padding: .35rem .5rem; border: 1px solid var(--input-border); border-radius: var(--radius-sm); }
.map-toggle { position: absolute; top: 10px; left: 54px; z-index: 1000; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.map-panel { padding: 1rem 1rem 2rem; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); }
.map-panel h1 { font-size: 1.4rem; }
.map-panel h3 { margin-top: 1.2rem; }
.map-main { position: relative; min-height: 400px; }
.atlas-map { position: absolute; inset: 0; background: #dfe8ea; }
.seg { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg label { flex: 1; text-align: center; padding: .4rem .5rem; cursor: pointer; font-size: .9rem; font-weight: 550; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -3px; }
.branch-checks, .event-checks { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .3rem; }
.year-range { display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem; }
.year-range input { width: 6rem; padding: .35rem .5rem; border: 1px solid var(--input-border); border-radius: var(--radius-sm); }
.map-legend { margin: 1.2rem 0 .8rem; padding: .6rem .7rem; background: var(--surface-2); border-radius: var(--radius-sm); display: grid; gap: .3rem; }
.legend-dot, .legend-pie, .legend-line { display: inline-block; vertical-align: middle; margin-right: .3rem; }
.legend-dot { width: 14px; height: 14px; border-radius: 50%; background: #2f6f4f; border: 2px solid #fff; box-shadow: 0 0 0 1px #999; }
.legend-pie { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(#2f6f4f 0 50%, #b03030 0 100%); border: 2px solid #fff; box-shadow: 0 0 0 1px #999; }
.legend-line { width: 22px; height: 0; border-top: 2.5px solid #2b5d9b; }
.ka-marker { background: none; border: 0; }
.ka-pie {
  border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; opacity: .92;
}
.ka-pie span { color: #fff; font-size: 11px; font-weight: 700; text-shadow: 0 0 3px rgba(0, 0, 0, .7); }
.ka-marker:hover .ka-pie { opacity: 1; transform: scale(1.08); }
.ka-arrow { background: none; border: 0; pointer-events: none; }
.ka-arrow-head {
  width: 0; height: 0; margin: 2px 0 0 2px;
  border-left: 11px solid #333; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  transform-origin: 50% 50%; filter: drop-shadow(0 0 1px #fff);
}
.map-popup .popup-title { font-weight: 700; font-size: 1rem; }
.popup-list { list-style: none; padding: 0; margin: .4rem 0 0; }
.popup-list li { padding: .12rem 0; }
ol.popup-list { list-style: decimal; padding-left: 1.2rem; }
.leaflet-popup-content { margin: 10px 14px; font-family: var(--font); font-size: .85rem; line-height: 1.4; }
.leaflet-container { font-family: var(--font); isolation: isolate; z-index: 0; }
.pick-map { height: 320px; border-radius: var(--radius-sm); overflow: hidden; cursor: crosshair; }

/* ---------- forms ---------- */

.edit-page { max-width: 1000px; }
.edit-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1rem 1.1rem; margin: 0 0 1rem; }
.edit-form legend { font-weight: 650; padding: 0 .4rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; }
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 550; color: #344054; margin-bottom: .5rem; }
.form-grid .field { margin-bottom: 0; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.help { font-weight: 400; color: var(--muted); font-size: .82rem; }
.edit-form input:not([type=checkbox]):not([type=radio]), .edit-form select, .edit-form textarea {
  width: 100%; padding: .42rem .6rem; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: #fff; font-weight: 400;
}
.edit-form input[readonly] { background: var(--surface-2); color: var(--muted); }
.edit-form input:focus, .edit-form select:focus, .edit-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.edit-form textarea { resize: vertical; }
.ev-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .6rem; }
.ev-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; padding: .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.ev-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .45rem .6rem; }
.ev-grid label { display: flex; flex-direction: column; font-size: .75rem; color: var(--muted); gap: .15rem; }
.ev-actions { display: flex; flex-direction: column; gap: .3rem; }
.slot-row { display: flex; gap: .4rem; }
.slot-row input { flex: 1; }
.slot-new { margin-top: .5rem; padding: .6rem; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.child-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.form-error { white-space: pre-line; background: #fef3f2; border: 1px solid #f3b5ae; color: var(--danger); padding: .7rem .9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.form-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 1rem 0 .5rem; }

/* toast */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translate(-50%, 20px); opacity: 0;
  background: #1f2328; color: #fff; padding: .6rem 1.1rem; border-radius: 999px; z-index: 3000;
  transition: all .25s ease; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); }

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .person-grid { display: flex; flex-direction: column; gap: 0; }
  .person-main, .person-side { display: contents; }
  .person-grid .sec-story { order: 0; } .person-grid .sec-photos { order: 3; }
  .person-grid .sec-family { order: 1; } .person-grid .sec-timeline { order: 2; } .person-grid .sec-places { order: 3; }
  .person-grid .sec-notes { order: 4; } .person-grid .sec-sources { order: 5; } .person-grid .sec-docs { order: 6; } .person-grid .sec-todo { order: 7; }
  .site-header { flex-wrap: wrap; gap: .5rem 1rem; }
  .search-wrap { margin-left: 0; flex: 1; }
  #search { width: 100%; }
  .person-grid { grid-template-columns: 1fr; }
  .ev-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map-layout > .map-panel { width: 240px; }
}
@media (max-width: 760px) {
  .site-header { position: static; padding: .5rem .75rem; gap: .4rem .75rem; }
  .app-subtitle { display: none; }
  .nav { order: 3; width: 100%; gap: .1rem 0; margin: 0 -.3rem; }
  .nav a { white-space: nowrap; padding: .3rem .6rem; }
  .search-wrap { order: 2; }
  .site-header { position: relative; }
  .search-wrap { position: static; }
  .search-results { width: auto; left: .75rem; right: .75rem; top: calc(100% - .25rem); }
  .nav a { font-size: .85rem; padding: .3rem .5rem; }
  .nav .long { display: none; }
  .nav .short { display: inline; }
  .mode-indicator { display: none; }
  .page { padding: 1rem .75rem 2.5rem; }
  h1 { font-size: 1.45rem; }
  .hero { padding-top: .5rem; }
  .hero h1 { font-size: 1.6rem; }
  .data-table.stack thead { display: none; }
  .data-table.stack, .data-table.stack tbody, .data-table.stack tr, .data-table.stack td { display: block; width: 100%; }
  .data-table.stack tr { padding: .55rem .75rem; border-bottom: 1px solid var(--border); }
  .data-table.stack td { border: 0; padding: .1rem 0; }
  .data-table.stack td[data-label]:not(:empty)::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .data-table.stack td.num { text-align: left; }
  .map-panel { padding: .8rem .9rem; }
  .map-panel h1 { margin-bottom: .2rem; }
  .stats { display: flex; flex-wrap: wrap; gap: .5rem; }
  .stats .stat { flex: 1 1 30%; }
  .person-card .mini-facts { display: none; }
  .card-grid { gap: .6rem; }
  .person-card { padding: .75rem .9rem; }
  .stat { padding: .5rem .6rem; }
  .stat-n { font-size: 1.3rem; }
  .tl-item { grid-template-columns: 1rem 1fr; }
  .tl-item::before { left: calc(.5rem - 1px); }
  .tl-date { grid-column: 2; grid-row: 1; text-align: left; font-size: .82rem; color: var(--muted); }
  .tl-dot { grid-column: 1; grid-row: 1 / span 2; }
  .tl-body { grid-column: 2; }
  .ped-scroll { height: calc(100vh - 120px); padding: .5rem; }
  .ped-hint { display: none; }
  .tree-wrap { flex-direction: column; align-items: stretch; }
  .tree-side { width: auto; overflow: visible; }
  .tree-side.collapsed h1 { display: block; }
  .tree-opts { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
  .tree-opts label:not(.check) { flex: 1 1 8rem; }
  .desc-tree ul { padding-left: .8rem; margin-left: .2rem; }
  .desc-tree .person-link { white-space: normal; }
  .filters input[type=search] { min-width: 0; flex: 1 1 12rem; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .ev-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-layout { flex-direction: column; height: auto; }
  .map-layout > .map-panel { width: auto; }
  .map-layout > .map-main { height: 65vh; flex: none; }
  .map-toggle { display: none; }
  .map-panel { border-right: 0; border-bottom: 1px solid var(--border); max-height: none; }
  .plain.cols { columns: 1; }
}

/* ---------- print ---------- */

@media (pointer: coarse), (max-width: 760px) {
  .nav a { min-height: 2.5rem; display: inline-flex; align-items: center; }
  .src-ref { min-width: 1.75rem; min-height: 1.6rem; line-height: 1.5rem; }
  .map-panel .small a { display: inline-block; padding: .3rem .2rem; }
  .zoom-ctl .btn-small { min-width: 2.4rem; min-height: 2.2rem; justify-content: center; }
  .ped-open { width: 2rem; }
  .tl-place a, .facts a, .plain a { display: inline-block; padding: .15rem 0; }
}
.map-filters > summary { display: none; }
@media (max-width: 760px) {
  .map-filters > summary { display: list-item; cursor: pointer; font-weight: 600; color: var(--link); margin: .2rem 0; }
}

@media print {
  :root { --bg: #fff; }
  body { font-size: 11pt; background: #fff; }
  .site-header, .no-print, .btn, .btn-row, .no-print-map, .toast { display: none !important; }
  .page { padding: 0; max-width: none; }
  .card, .person-head { box-shadow: none; break-inside: avoid; }
  .person-grid { grid-template-columns: 1fr; }
  a { color: inherit; }
  .ped-scroll { max-height: none; overflow: visible; border: 0; }
  .ped-region-label { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .ped-regions { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---------- documents ---------- */
.doc-groups { display: flex; flex-direction: column; gap: .7rem; }
.doc-group { border-top: 1px solid var(--border); padding-top: .45rem; }
.doc-group:first-child { border-top: 0; padding-top: 0; }
.doc-group > summary { cursor: pointer; font-weight: 600; font-size: .92rem; list-style-position: outside; margin-left: 1rem; }
.doc-group > summary .count { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: .3rem; }
.doc-group[open] > summary { margin-bottom: .35rem; }
.doc-group .doc-src { font-size: .85rem; margin: 0 0 .3rem 1rem; }
.doc-group .doc-list { margin-left: .6rem; }
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.doc-list a { display: flex; align-items: center; gap: .55rem; padding: .2rem .3rem; border-radius: var(--radius-sm); color: var(--text); }
.doc-list a:hover { background: var(--surface-2); text-decoration: none; }
.doc-list li { display: flex; align-items: center; gap: .4rem; }
.doc-list li > a:first-child { flex: 1; min-width: 0; }
.doc-list a.doc-alt { flex: none; font-size: .78rem; padding: .1rem .4rem; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--link); }
.doc-list img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); flex: none; }
.doc-list .doc-kind { flex: none; min-width: 4.6rem; text-align: center; font-size: .78rem; color: #4a5260; background: #eef0f3; border-radius: 4px; padding: .1rem .35rem; }
.doc-list .doc-file { font-size: .9rem; overflow-wrap: anywhere; color: var(--link); }
.doc-list a:hover .doc-file { text-decoration: underline; }
.doc-tools { display: flex; gap: .4rem; margin-bottom: .6rem; }
.badge.badge-icon { padding: 0 .35rem; min-width: 1.4rem; text-align: center; }
.badge.badge-icon::before { margin: 0; }
.badge.conf-confirmed.badge-icon::before { content: "✓"; } .badge.conf-probable.badge-icon::before { content: "≈"; } .badge.conf-possible.badge-icon::before { content: "?"; }
.map-key { list-style: none; padding: 0; margin: .6rem 0 0; font-size: .92rem; }
.map-key li { padding: .15rem 0; }
.table-key { margin: -.3rem 0 .6rem; }
.todo-groups { columns: 2 22rem; column-gap: 2rem; }
.todo-group { break-inside: avoid; margin-bottom: .7rem; }
.todo-who { text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--text); margin: 0 0 .2rem; }
.search-all { color: var(--link); font-weight: 600; }
.page-sources ol { margin: 0; padding-left: 1.6rem; font-size: .92rem; }
.page-sources li { padding: .15rem 0; }
.doc-more summary { cursor: pointer; color: var(--link); font-weight: 550; margin: .4rem 0; }
.doc-more[open] summary { margin-bottom: .7rem; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin: 0.5rem 0; }
.doc-card { display: flex; flex-direction: column; border: 1px solid var(--border, #ddd); border-radius: 8px; overflow: hidden; background: var(--card, #fff); text-decoration: none; color: inherit; }
.doc-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.doc-thumb { height: 110px; display: flex; align-items: center; justify-content: center; background: #f3f1ec; overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-icon { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: #555; padding: 0.4rem 0.6rem; border: 1px solid #ccc; border-radius: 4px; background: #fff; }
.doc-k-pdf { color: #a33; } .doc-k-data { color: #2b5d9b; } .doc-k-text { color: #2f6f4f; } .doc-k-page { color: #8e3b8e; }
.doc-name { font-size: 0.8rem; padding: 0.35rem 0.5rem; overflow-wrap: anywhere; line-height: 1.25; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .doc-layout { grid-template-columns: 1fr; } }
.doc-view { padding: 0.5rem; }
.doc-frame { width: 100%; height: 75vh; border: 1px solid #ddd; border-radius: 6px; background: #fff; }
.doc-image { text-align: center; }
.doc-image img { max-width: 100%; max-height: 85vh; border-radius: 4px; cursor: zoom-in; }
.doc-image .doc-hint { font-size: .85rem; margin-top: .3rem; }
.doc-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin: -.4rem 0 1rem; }
.doc-fallback { margin: .5rem 0 0; font-size: .88rem; }
.doc-tabs { display: inline-flex; margin-bottom: .6rem; }
.doc-tab { all: unset; cursor: pointer; padding: .35rem .8rem; font-size: .9rem; font-weight: 550; }
.doc-tab.on { background: var(--accent); color: var(--accent-ink); }
.doc-tab:focus-visible { outline: 3px solid #2f6fd0; outline-offset: -3px; }
.doc-shot { max-height: 80vh; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.doc-shot img { display: block; width: 100%; height: auto; }
.doc-shot img + img { border-top: 4px solid var(--border); }
object.doc-frame { display: block; }
.doc-summary { background: #f4f7fb; border: 1px solid #d9e3ef; border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.doc-summary h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .3rem; }
.doc-summary p { margin: 0; }
.map-places { margin-top: .6rem; }
.map-places summary { cursor: pointer; font-weight: 600; }
.map-places ul { list-style: none; padding: 0; margin: .3rem 0 0; max-height: 40vh; overflow: auto; }
.map-places button { all: unset; cursor: pointer; display: block; padding: .2rem .3rem; border-radius: 4px; color: var(--link); font-size: .9rem; }
.map-places button:hover { background: var(--surface-2); }
.map-places button:focus-visible { outline: 3px solid #2f6fd0; }
.more-row { display: flex; justify-content: center; padding: .8rem; }
div.doc-text { max-height: 75vh; overflow: auto; color: inherit; }
div.doc-text pre { white-space: pre-wrap; font-size: 0.85rem; }
.doc-meta ul { list-style: none; padding-left: 0; margin: 0.3rem 0 0.8rem; }
.doc-meta li { margin-bottom: 0.4rem; }
.side-panel .two-col { grid-template-columns: 1fr; }

/* ---------- history ---------- */
.hist-head { display: flex; flex-direction: column; gap: .85rem; margin-bottom: 1.25rem; }
.hist-tabs { display: flex; gap: .5rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.hist-tab {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .45rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 550; font-size: .92rem;
}
.hist-tab:hover { background: var(--surface-2); text-decoration: none; border-color: #b9b5ab; }
.hist-tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.hist-badge-full, .hist-badge-stub {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: .05rem .4rem; border-radius: 999px;
}
.hist-badge-full { background: #e3f6ec; color: #0e6b4c; }
.hist-tab.active .hist-badge-full { background: rgba(255, 255, 255, .2); color: #fff; }
.hist-badge-stub { background: #eef0f3; color: #5b6472; }
.hist-tab.active .hist-badge-stub { background: rgba(255, 255, 255, .18); color: #e5e7eb; }

.hist-layout { display: flex; gap: 1.25rem; align-items: flex-start; }
.hist-main { flex: 1; min-width: 0; }
.hist-layout > .side-panel {
  position: sticky; top: calc(var(--header-h) + 1rem);
  max-height: calc(100vh - var(--header-h) - 2rem);
}

.hist-hero {
  background: linear-gradient(135deg, #ffffff 0%, #f7f4ee 100%);
  border-left: 6px solid #8c6239;
}
.hist-hero-stub { border-left-color: #5b6472; }
.hist-kicker { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #8c6239; margin-bottom: .25rem; }
.hist-hero-stub .hist-kicker { color: var(--muted); }
.hist-toc { display: flex; gap: .4rem; flex-wrap: wrap; margin: .85rem 0 .65rem; }
.hist-tip { margin-bottom: 0; padding-top: .5rem; border-top: 1px solid var(--border); }

.hist-section h2 { font-size: 1.35rem; margin-bottom: .6rem; }
.hist-section h3 {
  font-size: 1.05rem; text-transform: none; letter-spacing: 0; color: var(--text);
  margin: 1.35rem 0 .45rem; font-weight: 650;
}
.hist-section h4 { font-size: .95rem; margin: 0 0 .35rem; font-weight: 650; }
.hist-sec-head { margin-bottom: .75rem; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }
.hist-sec-num { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #8c6239; display: block; margin-bottom: .15rem; }
.hist-article a.place-link {
  text-decoration: underline; text-decoration-style: dotted; text-decoration-color: var(--link); text-underline-offset: 2px;
  font-weight: 500;
}
.hist-article a.place-link::before { content: "⌖ "; font-size: .85em; opacity: .75; }

.hist-dual-diagram {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: .85rem; align-items: stretch;
  margin: 1rem 0 1.25rem;
}
.hist-dual-col {
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: .9rem 1rem;
  background: var(--surface-2); display: flex; flex-direction: column; gap: .5rem;
}
.hist-cisleithania { border-top: 4px solid #7a52a8; background: #faf8fc; }
.hist-transleithania { border-top: 4px solid #b9834d; background: #fcf9f5; }
.hist-dual-head { display: flex; flex-direction: column; }
.hist-crown { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hist-dual-boxes { display: flex; flex-direction: column; gap: .5rem; margin-top: auto; }
.hist-dual-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .75rem; }
.hist-dual-center { display: flex; flex-direction: column; align-items: center; justify-content: center; max-width: 8.5rem; gap: .4rem; }
.hist-dual-badge {
  background: var(--accent); color: #fff; font-weight: 700; font-size: .85rem;
  text-align: center; padding: .5rem .7rem; border-radius: 999px; line-height: 1.2;
}
@media (max-width: 860px) {
  .hist-dual-diagram { grid-template-columns: 1fr; }
  .hist-dual-center { max-width: none; flex-direction: row; }
}

.hist-forces-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .75rem; margin-top: .6rem; }
.hist-force-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .9rem; }
.hist-force-card p { margin: 0; }

.hist-map-toolbar { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .65rem; }
.hist-map-toolbar .btn.active, .hist-tl-filters .btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hist-map { height: 420px; border-radius: var(--radius-sm); border: 1px solid var(--border); overflow: hidden; background: #dfe8ea; }
.hist-map-caption { margin-top: .5rem; padding: .45rem .7rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }

.hist-spec-box {
  background: #fdf9f0; border: 1px solid #ead8b1; border-left: 4px solid #c48a2c;
  border-radius: var(--radius-sm); padding: .8rem 1rem; margin: 1rem 0;
}
.hist-spec-title { font-weight: 650; font-size: .95rem; margin-bottom: .4rem; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.hist-spec-badge {
  display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: #f5e6c4; color: #734b08; padding: .1rem .45rem; border-radius: 4px;
}
.hist-spec-box p:last-child, .hist-spec-box ul:last-child, .hist-spec-box ol:last-child { margin-bottom: 0; }

.hist-quote {
  margin: .9rem 0; padding: .65rem 1rem; border-left: 4px solid #8c6239;
  background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.hist-list { padding-left: 1.35rem; margin: .5rem 0 .9rem; }
.hist-list li { margin-bottom: .45rem; }

.hist-tl-filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.hist-dot-empire { background: #8c6239 !important; border-color: #8c6239 !important; }
.hist-dot-family { background: #1f5f8b !important; border-color: #1f5f8b !important; }

.hist-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; margin: .8rem 0 1.25rem; }
.hist-fig {
  margin: 0; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; display: flex; flex-direction: column;
}
.hist-fig > a { display: block; height: 170px; background: #ece9e2; overflow: hidden; }
.hist-fig img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.hist-fig > a:hover img { transform: scale(1.03); }
.hist-fig figcaption { padding: .6rem .75rem; line-height: 1.38; }

.hist-place-pills { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 1rem; }
.hist-place-pill {
  display: inline-block; padding: .2rem .55rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; font-size: .88rem;
}
.hist-ext-links { padding-left: 1.2rem; }
.hist-ext-links li { margin-bottom: .45rem; }

