/* Heirloom palette: brightened from the original archive-desk look (same bones — warm paper,
   ink, serif headings) with a four-color tile system doing the work a single accent used to.
   Sketched and approved 2026-10-10 ("Let's do this for now and see how it turns out"), see
   WORKLOG.md. Deliberately not a "genealogy site" look — no scrolls, no sepia photo frames. */

:root {
  --paper:      #fbf6ec;
  --paper-2:    #ffffff;
  --ink:        #2b2420;
  --ink-2:      #6b5f52;
  --ink-3:      #9c9184;
  --rule:       #e9dfc9;
  --accent:     #9a3326;   /* ember — decisions, needs attention */
  --accent-2:   #4f7a5e;   /* sage — confirmed, evidenced, places */
  --warn:       #9a6b1f;
  --terracotta: #c1573a;   /* people */
  --gold:       #b9842a;   /* facts, highlights */
  --denim:      #3e7693;   /* documents, records */
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-scale: 1;
}

/* Theme: "system" (the default — no attribute set) follows the OS; an explicit choice stamps
   data-theme on <html> and wins in both directions, same pattern used for Claude-published
   artifacts. Keep every themed color declared ONLY through these three blocks, never inline in a
   component rule, or it silently fails to flip with the rest of the page. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1c1812; --paper-2: #241f17; --ink: #f3ecdd; --ink-2: #c9bfae;
    --ink-3: #948a79; --rule: #3a3326; --accent: #e08478; --accent-2: #7fb294;
    --warn: #d8a850; --terracotta: #e08465; --gold: #e3b35c; --denim: #6facc9;
  }
}
:root[data-theme="dark"] {
  --paper: #1c1812; --paper-2: #241f17; --ink: #f3ecdd; --ink-2: #c9bfae;
  --ink-3: #948a79; --rule: #3a3326; --accent: #e08478; --accent-2: #7fb294;
  --warn: #d8a850; --terracotta: #e08465; --gold: #e3b35c; --denim: #6facc9;
}

/* Font size: every font-size/font shorthand in this file is wrapped in calc(...*var(--font-scale))
   (see WORKLOG.md, 2026-10-10) so one number here scales the whole platform's type uniformly —
   built for family members who want larger text, not just a per-component tweak. */
:root[data-font-size="small"]  { --font-scale: 0.9; }
:root[data-font-size="large"]  { --font-scale: 1.15; }
:root[data-font-size="xlarge"] { --font-scale: 1.3; }

/* Reduce motion: honors the OS-level preference automatically, and the in-app Settings toggle
   for anyone whose OS default they can't change (a shared/managed family computer). Near-zero
   rather than `none` so nothing that happens to key off transitionend silently breaks. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after {
  transition-duration: .001ms !important; animation-duration: .001ms !important;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: calc(15px * var(--font-scale))/1.55 var(--ui);
  /* faint paper grain — a texture cue, not a pattern you're meant to notice */
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 5%, transparent) .6px, transparent .6px);
  background-size: 14px 14px; background-attachment: fixed;
}

header {
  position: sticky; top: 0; z-index: 20;
  background: var(--paper-2); border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.header-row {
  display: flex; align-items: center; gap: 18px; flex-wrap: nowrap;
  padding: 12px 22px; max-width: 1400px; margin: 0 auto;
}
header h1 { margin: 0; font: 600 calc(19px * var(--font-scale))/1 var(--sans); letter-spacing: .01em; white-space: nowrap; flex: 0 0 auto; }
header h1 a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { font-size: calc(20px * var(--font-scale)); line-height: 1; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--rule); border-radius: 7px;
  background: var(--paper); cursor: pointer; flex: 0 0 auto;
}
.nav-toggle span { display: block; width: 16px; height: 1.5px; background: var(--ink-2); }
.nav-toggle:hover { border-color: var(--ink-3); }

nav#main-nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }

.header-right { display: flex; align-items: center; gap: 14px; margin-left: auto; flex: 0 0 auto; }

@media (max-width: 880px) {
  .nav-toggle { display: flex; }
  nav#main-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--paper-2); border-bottom: 1px solid var(--rule);
    flex-direction: column; gap: 0; padding: 8px; box-shadow: 0 10px 22px rgba(0,0,0,.1);
    max-height: calc(100vh - 56px); overflow-y: auto;
  }
  nav#main-nav.open { display: flex; }
  nav#main-nav a { padding: 11px 12px; }
  header h1 { font-size: calc(17px * var(--font-scale)); }
  .header-row { padding: 10px 14px; gap: 10px; }
}

main { padding: 20px; max-width: 1150px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.panel {
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 8px;
  padding: 18px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.panel h2 {
  margin: 0 0 12px; font: 600 calc(16px * var(--font-scale))/1.2 var(--sans);
  display: flex; align-items: center; gap: 10px;
}

.dash-hero { margin-bottom: 18px; }
.dash-hero h2 { margin: 0 0 4px; font: 600 calc(25px * var(--font-scale))/1.25 var(--sans); letter-spacing: .01em; }
.dash-hero p { margin: 0; color: var(--ink-2); font-size: calc(14.5px * var(--font-scale)); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 14px 12px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.stat b { display: block; font: 600 calc(26px * var(--font-scale))/1.1 var(--sans); font-variant-numeric: tabular-nums; }
.stat span { font-size: calc(12px * var(--font-scale)); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.stat.alert b { color: var(--accent); }
a.stat:hover { border-color: var(--ink-3); transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,.06); }

/* icon tiles — category color sets both the icon badge and the hover border */
.stat .icon {
  width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: var(--rule); color: var(--ink-3); margin-bottom: 10px;
}
.stat .icon svg { width: 16px; height: 16px; }
.stat.c-people .icon { background: color-mix(in srgb, var(--terracotta) 16%, transparent); color: var(--terracotta); }
.stat.c-places .icon { background: color-mix(in srgb, var(--accent-2) 16%, transparent); color: var(--accent-2); }
.stat.c-facts  .icon { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
.stat.c-docs   .icon { background: color-mix(in srgb, var(--denim) 16%, transparent); color: var(--denim); }
.stat.alert .icon { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.stat.c-people:hover { border-color: var(--terracotta); }
.stat.c-places:hover { border-color: var(--accent-2); }
.stat.c-facts:hover  { border-color: var(--gold); }
.stat.c-docs:hover   { border-color: var(--denim); }
.stat.alert:hover    { border-color: var(--accent); }

.note { color: var(--ink-3); font-size: calc(13px * var(--font-scale)); margin: 8px 0; }
.pill {
  font: 500 calc(12px * var(--font-scale)) var(--ui); background: var(--rule); color: var(--ink-2);
  padding: 2px 8px; border-radius: 999px;
}

.search {
  width: 100%; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--paper); color: var(--ink); font: inherit; margin-bottom: 10px;
}

.list { display: flex; flex-direction: column; }
.item {
  padding: 11px 2px; border-bottom: 1px solid var(--rule); cursor: pointer;
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--paper); }
.item .name { font-weight: 600; }
.item .meta { color: var(--ink-3); font-size: calc(13px * var(--font-scale)); }
.item .meta.mono { font-family: var(--mono); font-size: calc(12px * var(--font-scale)); }
.grow { flex: 1; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; display: inline-block;
}
.status-dot.living { background: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 20%, transparent); }
.status-dot.dead { background: var(--ink-3); }

form label { display: block; margin-bottom: 10px; font-size: calc(13px * var(--font-scale)); color: var(--ink-2); }
form input, form select, form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--rule); border-radius: 6px;
  background: var(--paper); color: var(--ink); font: inherit;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1 1 180px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.check-row input[type="checkbox"] { display: inline-block; width: auto; margin: 0; }

button.primary {
  background: var(--ink); color: var(--paper-2); border: 0; padding: 9px 16px;
  border-radius: 6px; cursor: pointer; font: inherit; font-weight: 500;
  transition: background .15s, transform .08s;
}
button.primary:hover { background: var(--accent); }
button.primary:active { transform: translateY(1px); }
button.link { background: none; border: 0; color: var(--ink-2); cursor: pointer; font: inherit; padding: 4px 0; }
button.small {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 5px;
  padding: 4px 10px; cursor: pointer; font: inherit; font-size: calc(13px * var(--font-scale)); color: var(--ink-2);
}
button.small:hover { border-color: var(--ink-3); color: var(--ink); }

.tag {
  font: 500 calc(11px * var(--font-scale)) var(--ui); padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .05em;
}
.tag.living { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.dead   { background: var(--rule); color: var(--ink-3); }
.tag.ai     { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.tag.ok     { background: color-mix(in srgb, var(--accent-2) 18%, transparent); color: var(--accent-2); }
.tag.pending { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.score { font: 700 calc(16px * var(--font-scale)) var(--ui); font-variant-numeric: tabular-nums; min-width: 2.5em; text-align: right; }

.evidence { border-left: 2px solid var(--rule); padding-left: 14px; margin: 10px 0; }
.evidence .fact { font-weight: 600; font-family: var(--sans); }
.evidence .src { font-size: calc(12px * var(--font-scale)); color: var(--ink-3); }
.evidence a { color: var(--accent-2); }

table { width: 100%; border-collapse: collapse; font-size: calc(14px * var(--font-scale)); }
th, td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font: 600 calc(12px * var(--font-scale)) var(--ui); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.scroll-x { overflow-x: auto; }

#modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
#modal[hidden] { display: none !important; }
.modal-box {
  background: var(--paper-2); border-radius: 10px; padding: 20px; max-width: 540px; width: 100%;
  max-height: 85vh; overflow: auto; border: 1px solid var(--rule);
}
.modal-box h3 { margin: 0 0 10px; font: 600 calc(17px * var(--font-scale)) var(--sans); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink); cursor: pointer; font: inherit; }

.spinner { color: var(--ink-3); font-size: calc(13px * var(--font-scale)); }
.empty { color: var(--ink-3); padding: 18px 0; font-size: calc(14px * var(--font-scale)); }

/* ── profile ───────────────────────────────────────────────────────────── */
.profile-head .counts { display: flex; gap: 20px; margin: 10px 0 14px; flex-wrap: wrap; }
.profile-head .counts b { font: 600 calc(19px * var(--font-scale)) var(--sans); font-variant-numeric: tabular-nums; }
.profile-head .counts span { color: var(--ink-3); font-size: calc(13px * var(--font-scale)); }

/* mini family tree */
.tree { display: flex; flex-direction: column; gap: 10px; }
.band { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.band-label {
  font: 600 calc(11px * var(--font-scale)) var(--ui); text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); min-width: 86px;
}
.band.self { padding: 8px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 999px;
  padding: 4px 12px; cursor: pointer; font: inherit; font-size: calc(13px * var(--font-scale)); color: var(--ink);
}
.chip:hover { border-color: var(--ink-3); }
.chip.me { background: var(--ink); color: var(--paper-2); border-color: var(--ink); cursor: default; }
.chip.stated { border-style: dashed; }
.chip.ghost { color: var(--ink-3); border-style: dashed; cursor: default; }
.chip.add { border-style: dashed; color: var(--ink-3); background: none; }
.chip.add:hover { color: var(--accent); border-color: var(--accent); }
.chip.add:disabled { opacity: .45; cursor: not-allowed; }
.chip.add:disabled:hover { color: var(--ink-3); border-color: var(--rule); }

/* life history */
.life-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.life-row:last-of-type { border-bottom: 0; }
.life-year {
  font-family: var(--mono); font-size: calc(13px * var(--font-scale)); color: var(--ink-3);
  min-width: 46px; font-variant-numeric: tabular-nums;
}
.life-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 7px; font-size: calc(11px * var(--font-scale)); line-height: 1;
  background: var(--rule); color: var(--ink-3); margin-top: 1px;
}
.life-icon.terracotta { background: color-mix(in srgb, var(--terracotta) 16%, transparent); color: var(--terracotta); }
.life-icon.gold       { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
.life-icon.denim      { background: color-mix(in srgb, var(--denim) 16%, transparent); color: var(--denim); }
.life-icon.sage       { background: color-mix(in srgb, var(--accent-2) 16%, transparent); color: var(--accent-2); }
.life-body { flex: 1; }
.life-body .src { font-size: calc(12px * var(--font-scale)); color: var(--ink-3); margin-top: 2px; }
.life-body .src a { color: var(--accent-2); }
/* Edit/delete controls on a single self-entered fact or name — same buttons as .actions,
   just closer to the row they act on rather than a whole panel's header area. */
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

.strand { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--rule); }

/* ── profile page tabs (Family / Life / Gallery / Documents / Names / Search) ──
   One card (same bones as .panel) with a strip of tabs across the top instead of stacking five
   separate panels down the page — the content is the same, it's just not all on screen at once. */
.tabbed-panel {
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 8px;
  margin-bottom: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.03); overflow: hidden;
}
.tab-bar {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 6px 0; overflow-x: auto;
  border-bottom: 1px solid var(--rule); background: var(--paper);
}
.tab-btn {
  display: flex; align-items: center; gap: 7px; padding: 10px 14px; border: 0; background: none;
  font: 600 calc(13.5px * var(--font-scale)) var(--ui); color: var(--ink-2); cursor: pointer; white-space: nowrap;
  border-radius: 7px 7px 0 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: background .15s, color .15s;
}
.tab-btn:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); color: var(--ink); }
.tab-btn[aria-selected="true"] {
  color: var(--ink); background: var(--paper-2); border-bottom-color: var(--tab-color, var(--accent));
}
.tab-btn .tab-icon { font-size: calc(14px * var(--font-scale)); color: var(--tab-color, var(--ink-3)); }
.tab-btn .tab-count {
  font-size: calc(11px * var(--font-scale)); color: var(--ink-3); background: var(--rule); border-radius: 10px;
  padding: 1px 6px; font-variant-numeric: tabular-nums;
}
.tab-btn[aria-selected="true"] .tab-count {
  background: color-mix(in srgb, var(--tab-color, var(--accent)) 18%, transparent);
  color: var(--tab-color, var(--accent));
}
.tab-btn.c-terracotta { --tab-color: var(--terracotta); }
.tab-btn.c-gold       { --tab-color: var(--gold); }
.tab-btn.c-sage       { --tab-color: var(--accent-2); }
.tab-btn.c-denim      { --tab-color: var(--denim); }
.tab-panel-body { padding: 18px; }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery-item {
  position: relative; display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--rule); background: var(--rule);
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item .gallery-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: calc(11.5px * var(--font-scale));
  color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.6));
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}

/* A quick-add form sitting above a panel's existing list (life events, document uploads) —
   separated from what follows, not from what came before. */
.panel-form { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.strand h3 {
  margin: 0 0 8px; font: 600 calc(12px * var(--font-scale)) var(--ui); text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3);
}
.strand-row { display: flex; gap: 12px; padding: 3px 0; font-size: calc(14px * var(--font-scale)); }

/* document cards with explanations */
.doc { border: 1px solid var(--rule); border-radius: 7px; margin-bottom: 8px; background: var(--paper); }
.doc summary {
  padding: 10px 12px; cursor: pointer; display: flex; gap: 10px;
  align-items: baseline; flex-wrap: wrap;
}
.doc summary::-webkit-details-marker { display: none; }
.doc summary::before { content: '▸'; color: var(--ink-3); }
.doc[open] summary::before { content: '▾'; }
.doc-title { font-weight: 600; font-family: var(--sans); }
.doc-body { padding: 0 12px 12px 30px; font-size: calc(14px * var(--font-scale)); }
.doc-body p { margin: 7px 0; }
.doc-body .what { color: var(--ink); }
.doc-body a { color: var(--accent-2); }
.role-note {
  background: color-mix(in srgb, var(--accent-2) 9%, transparent);
  padding: 7px 10px; border-radius: 5px;
}

/* ── routing-era additions ─────────────────────────────────────────────── */
nav a {
  padding: 7px 12px; border-radius: 6px; color: var(--ink-2);
  text-decoration: none; font: inherit; font-size: calc(13.5px * var(--font-scale)); white-space: nowrap;
  transition: background .12s, color .12s;
}
nav a:hover { background: var(--rule); color: var(--ink); }
nav a.active { background: var(--ink); color: var(--paper-2); }
nav a[hidden] { display: none; }

.busy {
  margin-left: auto; font-size: calc(12px * var(--font-scale)); color: var(--ink-3);
  font-family: var(--mono); animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .busy { animation: none } }

.crumbs { margin: 0 0 12px; }
.crumbs a, .plink { color: var(--accent-2); text-decoration: none; }
.crumbs a:hover, .plink:hover { text-decoration: underline; }

a.item, a.stat { text-decoration: none; color: inherit; display: flex; }
a.stat { flex-direction: column; }

.steps { margin: 10px 0 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
.steps a { color: var(--accent-2); }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule);
}
.pager a.small { text-decoration: none; }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions a.small { text-decoration: none; line-height: 1.9; }
/* A page-level action that opens a modal rather than a form sitting on the page — used rarely
   enough (adding a person) that it shouldn't cost permanent page real estate. */
.page-actions { margin-bottom: 18px; }
button.danger:hover { border-color: var(--accent); color: var(--accent); }

a.chip { text-decoration: none; display: inline-flex; gap: 6px; align-items: baseline; }
.chip .yrs { font-family: var(--mono); font-size: calc(11px * var(--font-scale)); color: var(--ink-3); }

/* pedigree: nested lists, indented by generation */
.pedigree, .pedigree ul { list-style: none; margin: 0; padding: 0; }
.pedigree ul { margin-left: 22px; border-left: 1px solid var(--rule); padding-left: 14px; }
.pedigree li { margin: 5px 0; }

table.kv { width: auto; margin: 10px 0; }
table.kv th { padding-right: 16px; white-space: nowrap; }

.doclinks a { color: var(--accent-2); }
.err { color: var(--accent); }
.lead { flex-wrap: wrap; }
.lead-snip { flex-basis: 100%; }

/* consent prompt — a decision, not an error */
.consent {
  border: 1px solid var(--rule); border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 7%, transparent);
  border-radius: 6px; padding: 14px; margin-top: 12px;
}
.consent .actions { margin-top: 12px; }
.consent-state { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 12px; }
.consent-state button.small { margin-left: 6px; }

/* search plan */
.plan { border-left: 3px solid var(--accent-2); padding: 10px 14px; margin: 14px 0;
  background: color-mix(in srgb, var(--accent-2) 6%, transparent); border-radius: 0 6px 6px 0; }
.plan-why { margin: 0; font-size: calc(14px * var(--font-scale)); }
.sb-title { margin: 18px 0 8px; font: 600 calc(12px * var(--font-scale)) var(--ui); text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3); }
.searchblock { border: 1px solid var(--rule); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.searchblock.nil { opacity: .6; }
.sb-head { display: flex; gap: 10px; align-items: baseline; }
.sb-head b { font-family: var(--sans); }
.variants { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule); }
.variants .chips, .variants a.chip { margin-right: 6px; }
.variants code { font-family: var(--mono); font-size: calc(12px * var(--font-scale)); background: var(--paper);
  padding: 1px 5px; border-radius: 3px; }

/* free-text web search */
.websearch { margin-top: 10px; }
.ws-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.ws-row .ws-q { flex: 1 1 260px; margin-bottom: 0; }
.ws-row .ws-country {
  border: 1px solid var(--rule); border-radius: 6px; background: var(--paper);
  color: var(--ink); font: inherit; padding: 0 10px;
}
.ws-presets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.ws-presets .meta { margin-right: 2px; }
.ws-out { margin-top: 12px; }
.ws-meta { font-family: var(--mono); font-size: calc(12px * var(--font-scale)); }
.ws-hit { flex-direction: column; align-items: flex-start; gap: 2px; cursor: default; }
.ws-hit .name { color: var(--accent-2); text-decoration: none; }
.ws-hit .name:hover { text-decoration: underline; }
.ws-url { font-family: var(--mono); font-size: calc(11px * var(--font-scale)); word-break: break-all; }
.ws-snip { font-size: calc(13px * var(--font-scale)); }

.ws-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.ws-group-label { font: 600 calc(11px * var(--font-scale)) var(--ui); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); min-width: 92px; }

/* ── A: lineage columns ─────────────────────────────────────────────────── */
.lineage-wrap { overflow-x: auto; padding-bottom: 6px; }
.lineage { display: flex; gap: 42px; align-items: center; min-width: min-content; padding: 6px 0; }
.gen { display: flex; flex-direction: column; gap: 10px; justify-content: center; position: relative; }
.gen::after { content: ""; position: absolute; right: -21px; top: 14px; bottom: 14px;
  width: 1px; background: var(--rule); }
.gen:last-child::after { display: none; }
.gen-label { font: 600 calc(10px * var(--font-scale)) var(--ui); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 2px; white-space: nowrap; }

.pc { display: inline-flex; flex-direction: column; gap: 1px; padding: 7px 11px;
  border-radius: 7px; border: 1px solid var(--rule); background: var(--paper);
  cursor: pointer; text-align: left; font: inherit; color: inherit; min-width: 136px;
  text-decoration: none; transition: border-color .12s, transform .12s; }
.pc:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.pc .nm { font: 600 calc(13px * var(--font-scale)) var(--sans); line-height: 1.25; }
.pc .yr { font-family: var(--mono); font-size: calc(10.5px * var(--font-scale)); color: var(--ink-3);
  font-variant-numeric: tabular-nums; }
.pc.me { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.pc.me .yr { color: color-mix(in srgb, var(--paper-2) 70%, transparent); }
.pc.ghost { border-style: dashed; color: var(--ink-3); background: transparent; }
.pc.infant { border-left: 3px solid var(--accent); }
.pc.add { border-style: dashed; color: var(--ink-3); justify-content: center;
  align-items: center; min-height: 48px; font-size: calc(12px * var(--font-scale)); }
.pc.add:hover { color: var(--accent); border-color: var(--accent); }

/* ── C: family group ────────────────────────────────────────────────────── */
.couple { display: flex; gap: 10px; align-items: center; justify-content: center;
  flex-wrap: wrap; margin-bottom: 4px; }
.couple .amp { color: var(--ink-3); font-family: var(--sans); }
.drop { height: 18px; border-left: 1px solid var(--rule); width: 1px; margin: 0 auto; }
.kids { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  border-top: 1px solid var(--rule); padding-top: 14px; }
.kidwrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.kid-tick { font-family: var(--mono); font-size: calc(9.5px * var(--font-scale)); color: var(--accent); }
.infant-note { text-align: center; color: var(--accent); margin-top: 14px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: calc(12px * var(--font-scale)); color: var(--ink-3);
  margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--rule); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 22px; border-top: 2px solid var(--rule); display: inline-block; }
.sw.dash { border-top-style: dashed; }
.sw.sol { border-color: var(--accent-2); }
.sw.inf { border-top: 3px solid var(--accent); }

/* ── D: checks ──────────────────────────────────────────────────────────── */
.issue { align-items: baseline; }
.issue.impossible { border-left: 3px solid var(--accent); padding-left: 10px; }
.issue.doubtful { border-left: 3px solid var(--warn); padding-left: 10px; }
.tag.bad { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.issue a { color: var(--accent-2); text-decoration: none; }
.issue a:hover { text-decoration: underline; }

/* ── scrollable bidirectional tree ─────────────────────────────────────── */
.tree-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 12px 0 10px; }
.tree-controls a.small { text-decoration: none; }
.tree-controls a[aria-disabled="true"] { opacity: .4; pointer-events: none; }

.tree-pane {
  max-height: 62vh; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--paper);
}
.gen-row { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.gen-row:last-child { border-bottom: 0; }
.gen-row.focus { background: color-mix(in srgb, var(--accent-2) 7%, transparent); }
@media (max-width: 620px) { .gen-row { grid-template-columns: 1fr; gap: 6px; } }

.gen-side { display: flex; flex-direction: column; gap: 2px; }
.gen-count { font-family: var(--mono); font-size: calc(10.5px * var(--font-scale)); color: var(--ink-3); }

/* Each generation scrolls sideways on its own — only one axis can grow without bound, and
   generations must stay aligned with their labels. */
.gen-track { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin; }
.gen-track::-webkit-scrollbar { height: 7px; }
.gen-track::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.pc.stated { border-style: dashed; }
.pc.partner { border-color: var(--accent-2); }

/* A-Z picker */
.pick-group { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--rule); }
.pick-group:last-child { border-bottom: 0; }
.pick-letter { font: 600 calc(15px * var(--font-scale)) var(--sans); color: var(--ink-3); }

/* ── archive: record type and holding institution ──────────────────────── */
.rec-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.tag.rec { background: color-mix(in srgb, var(--accent-2) 16%, transparent); color: var(--accent-2);
  text-decoration: none; }
.tag.arc { background: var(--rule); color: var(--ink-2); text-decoration: none; }
a.tag:hover { filter: brightness(.94); }

.facet-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.facet-label { font: 600 calc(10px * var(--font-scale)) var(--ui); text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); min-width: 86px; }
.facet { display: inline-flex; gap: 6px; align-items: baseline; padding: 3px 10px;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--paper);
  color: var(--ink-2); text-decoration: none; font-size: calc(12.5px * var(--font-scale)); }
.facet:hover { border-color: var(--ink-3); color: var(--ink); }
.facet.on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.facet .n { font-family: var(--mono); font-size: calc(10.5px * var(--font-scale)); opacity: .65; }

/* archived images */
.scans { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.scanfig { margin: 0; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden;
  background: var(--paper); }
.scanfig img { display: block; width: 100%; height: auto; }
.scanfig figcaption { padding: 7px 10px; font-size: calc(11.5px * var(--font-scale)); color: var(--ink-3);
  border-top: 1px solid var(--rule); }
.scanfig figcaption a { color: var(--accent-2); }
.filebox { padding: 28px 12px; text-align: center; font-family: var(--mono); font-size: calc(12px * var(--font-scale));
  color: var(--ink-3); }
.scanslot { min-height: 108px; display: flex; align-items: center; justify-content: center;
  background: var(--paper); }
.scanslot img { display: block; width: 100%; height: auto; }
.scanload { font: inherit; font-size: calc(13px * var(--font-scale)); padding: 10px 16px; cursor: pointer;
  border: 1px dashed var(--rule); border-radius: 6px; background: none; color: var(--ink-2);
  display: flex; gap: 8px; align-items: baseline; }
.scanload:hover { border-color: var(--accent-2); color: var(--ink); }

/* ── auth: header area, login, account, family accounts ──────────────────── */
.auth-area { display: flex; align-items: center; font-size: calc(13px * var(--font-scale)); }
.role-tag {
  font: 500 calc(10px * var(--font-scale)) var(--ui); text-transform: uppercase; letter-spacing: .05em;
  background: var(--rule); color: var(--ink-2); padding: 1px 6px; border-radius: 3px;
}

/* user menu: avatar button + dropdown, replaces the old flat link row */
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px; background: none; border: 1px solid transparent;
  border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer; font: inherit; color: var(--ink);
  transition: background .12s, border-color .12s;
}
.user-btn:hover { background: var(--paper); border-color: var(--rule); }
.user-btn .chev { color: var(--ink-3); flex: 0 0 auto; }
.user-btn-name { font-size: calc(13.5px * var(--font-scale)); font-weight: 500; }
@media (max-width: 620px) { .user-btn-name { display: none; } }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  background: var(--ink); color: var(--paper-2);
  font: 600 calc(11.5px * var(--font-scale)) var(--ui); letter-spacing: .02em;
}
.avatar.lg { width: 38px; height: 38px; font-size: calc(14px * var(--font-scale)); }

.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30;
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.14); padding: 6px; min-width: 232px;
}
.user-dropdown[hidden] { display: none; }
.dd-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}
.dd-head > div { flex: 1; min-width: 0; }
.dd-name { font-weight: 600; font-size: calc(13.5px * var(--font-scale)); }
.dd-email { font-size: calc(12px * var(--font-scale)); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown a, .user-dropdown button.dd-logout {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 6px;
  color: var(--ink-2); text-decoration: none; font: inherit; font-size: calc(13.5px * var(--font-scale));
  background: none; border: 0; cursor: pointer;
}
.user-dropdown a:hover, .user-dropdown button.dd-logout:hover { background: var(--paper); color: var(--ink); }
.user-dropdown button.dd-logout {
  color: var(--accent); margin-top: 2px; border-top: 1px solid var(--rule);
  border-radius: 0 0 6px 6px; padding-top: 11px;
}

.signin-prompt {
  border: 1px dashed var(--rule); border-radius: 7px; padding: 14px; text-align: center;
}
.signin-prompt p { margin: 0 0 10px; color: var(--ink-2); }
a.primary-link {
  display: inline-block; background: var(--ink); color: var(--paper-2); text-decoration: none;
  padding: 7px 14px; border-radius: 6px; font-size: calc(13px * var(--font-scale));
}

.temp-pw {
  border-left: 3px solid var(--accent-2); background: color-mix(in srgb, var(--accent-2) 8%, transparent);
  padding: 12px 14px; border-radius: 0 7px 7px 0; margin-top: 10px;
}
.temp-pw .mono { font-family: var(--mono); font-size: calc(14px * var(--font-scale)); font-weight: 600; margin: 6px 0; }

#login-form, #pw-form { max-width: 360px; }
