/* ============================================================
   My Goodly Heritage — design system
   Material 3 structure (tonal surfaces, nav rail / bar, FAB, chips,
   filled text fields) with a heritage palette: paper, ink,
   terracotta, gold.
   ============================================================ */

:root {
  /* Palette — light: white pages, deep navy, cool grey panels, amber accent */
  --primary: #0f2a4a;            --on-primary: #ffffff;
  --primary-container: #dbe6f3;  --on-primary-container: #0b1e36;
  --secondary: #3b5578;          --on-secondary: #ffffff;
  --secondary-container: #e3ebf5;--on-secondary-container: #16273f;
  --tertiary: #b4760a;           --on-tertiary: #ffffff;
  --tertiary-container: #fdf0d5; --on-tertiary-container: #4a2e00;
  --error: #b3261e;              --on-error: #ffffff;
  --error-container: #fde7e5;    --on-error-container: #5c0d08;
  --success: #1e6b3f;            --success-container: #dcf3e4;

  --surface: #ffffff;
  --surface-dim: #e6e9ee;
  --surface-bright: #ffffff;
  --surface-lowest: #ffffff;
  --surface-low: #f5f7fa;
  --surface-mid: #eef1f5;
  --surface-high: #e6eaf0;
  --surface-highest: #dde2ea;
  --on-surface: #111827;
  --on-surface-variant: #4b5563;
  --outline: #8b95a5;
  --outline-variant: #e3e7ed;
  --inverse-surface: #1f2937;
  --inverse-on-surface: #f3f4f6;
  --scrim: rgba(15, 23, 42, .5);
  --hero: #0f2a4a;

  /* Branch colours */
  --b-general: #0f2a4a;
  --b-laseinde: #0e7c7b;
  --b-owoyemi: #2f5fb8;
  --b-olayemi: #c7861b;
  --b-arogundade: #b5432c;
  --b-durojaiye: #4f8a3d;

  /* Shape & motion */
  --r-xs: 4px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;
  --e1: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --e2: 0 2px 4px rgba(15,23,42,.06), 0 6px 16px rgba(15,23,42,.08);
  --e3: 0 8px 24px rgba(15,23,42,.14), 0 2px 6px rgba(15,23,42,.08);
  --ease: cubic-bezier(.2, 0, 0, 1);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --rail-w: 88px;
  --bar-h: 64px;
  --nav-h: 80px;
  color-scheme: light;
}

/* Dark: navy-black, never brown */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #9fc1ec; --on-primary: #0b1e36; --primary-container: #1d3a5f; --on-primary-container: #dbe6f3;
    --secondary: #b7c7dd; --on-secondary: #1e2f47; --secondary-container: #2d4160; --on-secondary-container: #e3ebf5;
    --tertiary: #f0c060; --on-tertiary: #3f2a00; --tertiary-container: #5c4100; --on-tertiary-container: #fdf0d5;
    --error: #ffb4ab; --on-error: #690005; --error-container: #93000a; --on-error-container: #ffdad6;
    --success: #8fd4a0; --success-container: #1d4a2c;
    --surface: #0b1220; --surface-dim: #0b1220; --surface-bright: #2a3650;
    --surface-lowest: #070c16; --surface-low: #111a2b; --surface-mid: #15203380; --surface-mid: #152033; --surface-high: #1c2840; --surface-highest: #24314c;
    --on-surface: #e5eaf2; --on-surface-variant: #b4bfd0; --outline: #7b879a; --outline-variant: #263349;
    --inverse-surface: #e5eaf2; --inverse-on-surface: #1f2937; --scrim: rgba(0,0,0,.6); --hero: #070c16;
    --b-general: #9fc1ec; --b-laseinde: #4fc1bf; --b-owoyemi: #7fa6ea; --b-olayemi: #e8a94a; --b-arogundade: #f0806a; --b-durojaiye: #8ec275;
    --e1: 0 1px 2px rgba(0,0,0,.4); --e2: 0 2px 6px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.35); --e3: 0 8px 24px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #9fc1ec; --on-primary: #0b1e36; --primary-container: #1d3a5f; --on-primary-container: #dbe6f3;
  --secondary: #b7c7dd; --on-secondary: #1e2f47; --secondary-container: #2d4160; --on-secondary-container: #e3ebf5;
  --tertiary: #f0c060; --on-tertiary: #3f2a00; --tertiary-container: #5c4100; --on-tertiary-container: #fdf0d5;
  --error: #ffb4ab; --on-error: #690005; --error-container: #93000a; --on-error-container: #ffdad6;
  --success: #8fd4a0; --success-container: #1d4a2c;
  --surface: #0b1220; --surface-dim: #0b1220; --surface-bright: #2a3650;
  --surface-lowest: #070c16; --surface-low: #111a2b; --surface-mid: #152033; --surface-high: #1c2840; --surface-highest: #24314c;
  --on-surface: #e5eaf2; --on-surface-variant: #b4bfd0; --outline: #7b879a; --outline-variant: #263349;
  --inverse-surface: #e5eaf2; --inverse-on-surface: #1f2937; --scrim: rgba(0,0,0,.6); --hero: #070c16;
  --b-general: #9fc1ec; --b-laseinde: #4fc1bf; --b-owoyemi: #7fa6ea; --b-olayemi: #e8a94a; --b-arogundade: #f0806a; --b-durojaiye: #8ec275;
  --e1: 0 1px 2px rgba(0,0,0,.4); --e2: 0 2px 6px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.35); --e3: 0 8px 24px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--surface); color: var(--on-surface);
  font-family: var(--sans); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--serif); font-weight: 500; line-height: 1.15; color: var(--on-surface); font-variation-settings: "opsz" 120; }
h1 { font-size: 34px; letter-spacing: -.01em; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
h4 { font-size: 17px; }
p { margin: 0 0 12px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--on-surface-variant); }
.small { font-size: 13px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--on-surface-variant); }
.serif { font-family: var(--serif); }
svg.ic { width: 24px; height: 24px; flex: 0 0 auto; fill: currentColor; }
svg.ic.sm { width: 18px; height: 18px; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; }
.rail {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail-w); background: var(--surface); border-right: 1px solid var(--outline-variant);
  display: flex; flex-direction: column; align-items: center; padding: 12px 0 16px; gap: 6px; z-index: 20;
}
.rail .brand { margin-bottom: 14px; }
.rail .brand img { width: 44px; height: 44px; border-radius: 50%; }
.rail .spacer { flex: 1; }
.navitem {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 6px 0;
  color: var(--on-surface-variant); font-size: 12px; font-weight: 500; text-decoration: none; border-radius: var(--r-lg);
}
.navitem:hover { text-decoration: none; color: var(--on-surface); }
.navitem .ind { width: 56px; height: 32px; border-radius: var(--r-full); display: grid; place-items: center; transition: background .2s var(--ease); position: relative; }
.navitem:hover .ind { background: var(--surface-high); }
.navitem[aria-current="page"] { color: var(--on-surface); }
.navitem[aria-current="page"] .ind { background: var(--primary); color: var(--on-primary); }
.navitem .badge-dot { position: absolute; top: 3px; right: 10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--error); color: var(--on-error); font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.navitem .avatar { width: 32px; height: 32px; }

.content { flex: 1; margin-left: var(--rail-w); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.topbar {
  height: var(--bar-h); display: flex; align-items: center; gap: 8px; padding: 0 16px 0 20px; position: sticky; top: 0; z-index: 15;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--outline-variant);
}
.topbar .title { font-family: var(--serif); font-size: 22px; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title small { font-family: var(--sans); font-size: 12.5px; color: var(--on-surface-variant); margin-left: 10px; font-weight: 400; }
.topbar .brand-mini { display: none; align-items: center; gap: 8px; }
.topbar .brand-mini img { width: 32px; height: 32px; border-radius: 50%; }
.page { flex: 1; padding: 8px 24px 40px; max-width: 1240px; width: 100%; margin: 0 auto; }
.page.full { max-width: none; padding: 0; display: flex; flex-direction: column; }

.bottomnav { display: none; }
.fab {
  position: fixed; right: 20px; bottom: 24px; z-index: 18; height: 56px; padding: 0 20px 0 16px; border-radius: var(--r-lg);
  background: var(--primary); color: var(--on-primary); box-shadow: var(--e3); display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14.5px; text-decoration: none; transition: transform .2s var(--ease), box-shadow .2s;
}
.fab:hover { text-decoration: none; box-shadow: var(--e3), 0 0 0 6px color-mix(in srgb, var(--primary) 10%, transparent); }
.fab:active { transform: scale(.97); }
body.sheet-open .fab { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 20px; border-radius: var(--r-full);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; transition: box-shadow .15s, background .15s, transform .1s; user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.filled { background: var(--primary); color: var(--on-primary); }
.btn.filled:hover { box-shadow: var(--e1); }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.tonal:hover { box-shadow: var(--e1); }
.btn.outlined { border: 1px solid var(--outline); color: var(--primary); }
.btn.outlined:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.btn.text { color: var(--primary); padding: 0 12px; }
.btn.text:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.btn.danger { background: var(--error-container); color: var(--on-error-container); }
.btn.success { background: var(--success-container); color: var(--on-surface); }
.btn.sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn[disabled], .btn.loading { opacity: .5; pointer-events: none; }
.btn .ic { width: 18px; height: 18px; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--on-surface-variant); flex: 0 0 auto; }
.iconbtn:hover { background: var(--surface-high); color: var(--on-surface); }
.iconbtn.filled { background: var(--surface-high); }

/* ---------- Cards & surfaces ---------- */
.card { background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--e1); }
.card.elevated { box-shadow: var(--e2); }
.card.outlined { background: transparent; border: 1px solid var(--outline-variant); }
.card.tonal { background: var(--surface-low); box-shadow: none; }
.card.hero { background: var(--primary); color: #fff; border: 0; }
.card.hero h1, .card.hero h2 { color: inherit; }
.card.gold { background: var(--tertiary-container); color: var(--on-tertiary-container); border-color: color-mix(in srgb, var(--tertiary) 35%, transparent); }
.card.gold h3 { color: inherit; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid.branches { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.divider { height: 1px; background: var(--outline-variant); margin: 8px 0; border: 0; }
.section { margin-top: 28px; }
.section > h2, .section > h3 { margin-bottom: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px 0 10px; border-radius: var(--r-sm);
  border: 1px solid var(--outline-variant); font-size: 13.5px; font-weight: 500; color: var(--on-surface-variant); background: transparent; white-space: nowrap;
}
.chip:hover { background: var(--surface-high); }
.chip i.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--outline)); flex: 0 0 auto; }
.chip[aria-pressed="true"], .chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip.assist { padding: 0 12px; }
.chip.assist .ic { width: 18px; height: 18px; }
.chiprow { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chiprow::-webkit-scrollbar { display: none; }
.chiprow .chip { flex: 0 0 auto; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500;
  background: var(--surface-high); color: var(--on-surface-variant);
}
.tag i.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--outline)); }
.tag.status-confirmed { background: var(--success-container); color: var(--on-surface); }
.tag.status-estimated { border: 1px dotted var(--outline); background: transparent; }
.tag.status-disputed { background: var(--error-container); color: var(--on-error-container); }
.tag.status-pending { opacity: .75; }
.tag.pending { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.tag.approved { background: var(--success-container); }
.tag.rejected { background: var(--error-container); color: var(--on-error-container); }
.tag.role { background: var(--secondary-container); color: var(--on-secondary-container); }
.tag.j12 { background: var(--tertiary-container); color: var(--on-tertiary-container); font-weight: 600; }

/* ---------- Avatar ---------- */
.avatar {
  width: 48px; height: 48px; border-radius: 50%; display: inline-grid; place-items: center; flex: 0 0 auto; overflow: hidden;
  background: color-mix(in srgb, var(--c, var(--outline)) 18%, var(--surface-lowest)); color: var(--c, var(--on-surface-variant));
  font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: .02em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; font-size: 36px; }
.avatar.xl { width: 128px; height: 128px; font-size: 46px; }
.avatar.sm { width: 36px; height: 36px; font-size: 14px; }

/* ---------- Person card (directory) ---------- */
.pcard {
  display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg);
  text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .1s;
}
.pcard:hover { border-color: var(--outline); box-shadow: var(--e2); text-decoration: none; }
.pcard:active { transform: scale(.99); }
.pcard .name { font-family: var(--serif); font-size: 17px; font-weight: 500; line-height: 1.2; }
.pcard .aka { font-style: italic; color: var(--on-surface-variant); font-size: 13px; }
.pcard .meta { font-size: 12.5px; color: var(--on-surface-variant); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pcard .body { min-width: 0; flex: 1; }
.pcard .go { color: var(--outline); }

/* ---------- Text fields (filled, M3) ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--on-surface-variant); }
.field .in {
  position: relative; display: flex; align-items: center; background: var(--surface-lowest); border-radius: var(--r-md); border: 1px solid var(--outline-variant);
  transition: border-color .15s, background .15s;
}
.field .in:focus-within { border-color: var(--primary); background: var(--surface-lowest); }
.field.error .in { border-color: var(--error); }
.field input, .field select, .field textarea {
  width: 100%; background: transparent; border: 0; outline: none; padding: 12px 14px; font-size: 16px; min-height: 48px; color: var(--on-surface);
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
.field select { appearance: none; padding-right: 40px; cursor: pointer; }
.field .in.select::after { content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--on-surface-variant); border-bottom: 2px solid var(--on-surface-variant); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.field .hint { font-size: 12px; color: var(--on-surface-variant); }
.field.error .hint { color: var(--error); }
.field.compact input { min-height: 44px; padding: 10px 14px; font-size: 15px; }
.formgrid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.formgrid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; cursor: pointer; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--outline); border-radius: var(--r-full); overflow: hidden; }
.seg button { height: 38px; padding: 0 16px; font-size: 13.5px; font-weight: 500; color: var(--on-surface-variant); border-right: 1px solid var(--outline); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }

/* Person picker */
.picker { position: relative; }
.picker .sel { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.picker .sel .chip { height: 30px; padding-right: 6px; }
.picker .sel .chip .x { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.picker .sel .chip .x:hover { background: var(--surface-highest); }
.picker .menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface-lowest); border-radius: var(--r-md); box-shadow: var(--e3);
  z-index: 30; max-height: 280px; overflow: auto; padding: 6px 0;
}
.picker .menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 14px; font-size: 14px; }
.picker .menu button:hover, .picker .menu button.active { background: var(--surface-high); }
.picker .menu .life { color: var(--on-surface-variant); font-size: 12px; margin-left: auto; white-space: nowrap; }
.picker .menu .empty { padding: 10px 14px; color: var(--on-surface-variant); font-size: 13.5px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--outline-variant); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 12px 16px; font-weight: 600; font-size: 14px; color: var(--on-surface-variant); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { background: var(--surface-high); border-radius: var(--r-full); padding: 1px 8px; font-size: 12px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list .item { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--outline-variant); min-height: 56px; }
.list .item:last-child { border-bottom: 0; }
.list .item .body { flex: 1; min-width: 0; }
.list .item .t { font-weight: 500; }
.list .item .s { font-size: 13px; color: var(--on-surface-variant); }
.list .item a.t:hover { text-decoration: underline; }

/* ---------- Facts ---------- */
.facts { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.fact { background: var(--surface-low); border: 1px solid var(--outline-variant); border-radius: var(--r-md); padding: 10px 12px; }
.fact .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--on-surface-variant); margin-bottom: 2px; font-weight: 600; }
.fact .v { font-size: 15px; }
.fact.wide { grid-column: 1 / -1; }

/* ---------- Profile ---------- */
.profile-head { display: flex; gap: 22px; align-items: flex-start; }
.profile-head .body { flex: 1; min-width: 0; }
.profile-head h1 { font-size: 32px; }
.profile-head .aka { font-style: italic; color: var(--on-surface-variant); font-size: 16px; margin-top: 2px; }
.profile-head .tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.profile-head .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.famgroups { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.famgroup .label { margin-bottom: 8px; }
.famgroup .people { display: flex; flex-direction: column; gap: 6px; }
.plink { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-md); color: inherit; text-decoration: none; }
.plink:hover { background: var(--surface-low); text-decoration: none; }
.plink .n { font-weight: 500; }
.plink .s { font-size: 12px; color: var(--on-surface-variant); }
.bio { font-size: 16px; line-height: 1.65; max-width: 72ch; }
.src { font-size: 13.5px; color: var(--on-surface-variant); line-height: 1.55; }

/* ---------- Timeline ---------- */
.tl { max-width: 820px; }
.decade { position: relative; padding-left: 86px; margin-bottom: 8px; }
.decade::before { content: ""; position: absolute; left: 62px; top: 0; bottom: 0; width: 2px; background: var(--outline-variant); }
.decade-label { position: absolute; left: 0; top: 2px; width: 50px; text-align: right; font-family: var(--serif); font-size: 16px; color: var(--on-surface-variant); font-weight: 500; }
.ev { position: relative; background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 10px; }
.ev::before { content: ""; position: absolute; left: -29px; top: 20px; width: 10px; height: 10px; border-radius: 50%; background: var(--outline); border: 2px solid var(--surface); }
.ev.june12 { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.ev.june12::before { background: var(--tertiary); width: 12px; height: 12px; left: -30px; top: 19px; }
.ev.june12 h3, .ev.june12 .sig, .ev.june12 p { color: inherit; }
.ev-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.ev-when { font-weight: 600; font-size: 13.5px; }
.ev h3 { font-size: 18px; margin: 2px 0 6px; }
.ev p { margin: 0 0 6px; font-size: 14.5px; color: var(--on-surface-variant); }
.ev .sig { font-size: 13.5px; color: var(--on-surface-variant); border-left: 3px solid var(--outline-variant); padding-left: 10px; margin-top: 8px; }
.ev .who { font-size: 13px; margin-top: 8px; }
.ev.compact { padding: 12px 14px; }
.ev.compact::before { display: none; }

/* life events on the timeline */
.ev.life { padding: 10px 14px; }
.ev.life .life-row { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.ev.life .life-row:hover { text-decoration: none; }
.ev.life .life-row:hover b { color: var(--primary); }
.ev.life .ev-top { margin-bottom: 1px; }
.ev.life .life-title { font-size: 15.5px; }

/* ---------- Tree ---------- */
.tree-wrap { position: relative; flex: 1; min-height: 0; }
.tree-toolbar { display: flex; gap: 10px; align-items: center; padding: 8px 20px 10px; flex-wrap: wrap; }
.tree-toolbar .search { flex: 1 1 220px; max-width: 360px; }
.tree-toolbar .legend { margin-left: auto; display: flex; gap: 14px; font-size: 12.5px; color: var(--on-surface-variant); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 22px; height: 12px; border-radius: 3px; border: 1.5px solid var(--outline); background: var(--surface-lowest); display: inline-block; }
.legend .sw.est { border-style: dotted; }
.legend .sw.dis { border-style: dashed; border-color: var(--error); }
#tree-svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; background: var(--surface-low); }
#tree-svg:active { cursor: grabbing; }
.link { fill: none; stroke: var(--outline-variant); stroke-width: 1.6; }
.link.dim { opacity: .15; }
.marriage { stroke: var(--outline-variant); stroke-width: 1.6; }
.tcard { cursor: pointer; }
.tcard rect.bg { fill: var(--surface-lowest); stroke: var(--outline-variant); stroke-width: 1.25; rx: 10; filter: drop-shadow(0 1px 2px rgba(15,23,42,.10)); }
.tcard.estimated rect.bg { stroke-dasharray: 2 3; stroke: var(--outline); }
.tcard.disputed rect.bg { stroke: var(--error); stroke-dasharray: 6 4; }
.tcard.pending { opacity: .55; }
.tcard rect.stripe { fill: var(--c); rx: 0; clip-path: inset(0 round 10px 0 0 10px); }
.tcard .ring { fill: none; stroke: var(--c); stroke-width: 2; }
.tcard .avatar-bg { fill: color-mix(in srgb, var(--c) 14%, var(--surface-lowest)); }
.tcard .initials { font-family: var(--serif); font-size: 15px; font-weight: 600; fill: var(--c); letter-spacing: .02em; }
.tcard .name { font-family: var(--serif); font-size: 13.5px; font-weight: 500; fill: var(--on-surface); }
.tcard .aka { font-size: 11px; fill: var(--on-surface-variant); font-style: italic; }
.tcard .dates { font-size: 11px; fill: var(--on-surface-variant); }
.tcard .flag { font-size: 9.5px; fill: var(--error); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.tcard:hover rect.bg { stroke: var(--on-surface); }
.tcard.selected rect.bg { stroke: var(--primary); stroke-width: 2.5; }
.tcard.dim { opacity: .15; }
.tcard.hit rect.bg { stroke: var(--tertiary); stroke-width: 2.5; }
.gen-label { font-size: 11px; fill: var(--on-surface-variant); letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.zoom-ctl { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 3; }
.zoom-ctl button { width: 44px; height: 44px; border-radius: var(--r-md); background: var(--surface-lowest); box-shadow: var(--e2); font-size: 20px; color: var(--on-surface-variant); display: grid; place-items: center; }
.zoom-ctl button:hover { color: var(--on-surface); }
.tree-hint { position: absolute; left: 16px; bottom: 16px; font-size: 12.5px; color: var(--on-surface-variant); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 4px 10px; border-radius: var(--r-sm); pointer-events: none; }

/* Peek sheet (tree) */
.sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(400px, 100%); background: var(--surface-lowest); box-shadow: var(--e3);
  transform: translateX(104%); transition: transform .25s var(--ease); z-index: 6; display: flex; flex-direction: column; border-radius: var(--r-lg) 0 0 var(--r-lg);
}
.sheet.open { transform: translateX(0); }
.sheet .bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 8px 18px; }
.sheet .body { overflow: auto; padding: 0 20px 28px; flex: 1; }
.sheet .handle { display: none; width: 36px; height: 4px; border-radius: 2px; background: var(--outline-variant); margin: 10px auto 2px; }

/* ---------- Admin / submissions ---------- */
.sub { background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); padding: 16px 18px; }
.sub .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.sub .head .t { font-weight: 600; font-size: 15.5px; }
.sub .diff { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 14px; margin: 10px 0; }
.sub .diff .k { color: var(--on-surface-variant); font-size: 12.5px; padding-top: 2px; }
.sub .diff .old { text-decoration: line-through; color: var(--on-surface-variant); opacity: .75; }
.sub .diff .new { color: var(--on-surface); }
.sub .diff .arrow { color: var(--outline); margin: 0 6px; }
.sub .foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.sub .foot .field { flex: 1 1 240px; }
.sub .foot .field input { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.sub .notes { font-size: 13.5px; background: var(--surface-mid); border-radius: var(--r-sm); padding: 8px 10px; margin-top: 10px; }

/* ---------- Dialog / snackbar / states ---------- */
.dialog-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--surface-high); border-radius: var(--r-xl); padding: 24px; width: min(480px, 100%); box-shadow: var(--e3); }
.dialog h3 { margin-bottom: 8px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.snackbar {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--inverse-surface); color: var(--inverse-on-surface);
  padding: 12px 18px; border-radius: var(--r-sm); font-size: 14px; box-shadow: var(--e3); z-index: 60; opacity: 0; transition: opacity .2s, transform .2s var(--ease); max-width: min(560px, calc(100% - 32px));
}
.snackbar.show { opacity: 1; transform: translate(-50%, 0); }
.snackbar.err { background: var(--error); color: var(--on-error); }
.state { padding: 48px 20px; text-align: center; color: var(--on-surface-variant); }
.state h2 { margin: 12px 0 6px; }
.spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--outline-variant); border-top-color: var(--primary); animation: spin .9s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 28px; text-align: center; color: var(--on-surface-variant); background: var(--surface-low); border-radius: var(--r-lg); }

/* ---------- Home ---------- */
.photo-hero {
  position: relative; margin: 0 -24px 24px; min-height: 420px; display: flex; align-items: flex-end; color: #fff; overflow: hidden; background: var(--hero);
}
.photo-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 12%; filter: saturate(.15) contrast(1.05); opacity: .85; }
.photo-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,42,74,.15) 0%, rgba(15,42,74,.55) 55%, rgba(11,30,54,.92) 100%); }
.photo-hero .inner { position: relative; z-index: 1; padding: 56px 32px 36px; max-width: 1240px; width: 100%; margin: 0 auto; }
.photo-hero .kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; background: var(--tertiary); color: #fff; padding: 6px 10px; border-radius: var(--r-xs); margin-bottom: 16px; }
.photo-hero h1 { color: #fff; font-size: 46px; max-width: 18ch; margin-bottom: 14px; text-shadow: 0 2px 12px rgba(0,0,0,.35); }
.photo-hero p { font-size: 17px; line-height: 1.6; max-width: 60ch; color: rgba(255,255,255,.9); }
.photo-hero .btn.filled { background: #fff; color: var(--primary); }
.photo-hero .btn.outlined { border-color: rgba(255,255,255,.7); color: #fff; }
.photo-hero .btn.outlined:hover { background: rgba(255,255,255,.12); }
.home-hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: stretch; }
.home-hero .kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 12px; opacity: .85; }
.home-hero h1 { font-size: 40px; margin-bottom: 12px; }
.home-hero p { font-size: 16.5px; line-height: 1.6; max-width: 56ch; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); padding: 16px; }
.stat .n { font-family: var(--serif); font-size: 36px; font-weight: 500; line-height: 1; }
.stat .l { font-size: 13px; color: var(--on-surface-variant); margin-top: 4px; }
.branchcard { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--r-lg); background: var(--surface-lowest); border: 1px solid var(--outline-variant); color: inherit; text-decoration: none; border-top: 5px solid var(--c); transition: box-shadow .15s; }
.branchcard:hover { box-shadow: var(--e2); text-decoration: none; }
.branchcard h3 { font-size: 20px; }
.branchcard .n { font-size: 13px; color: var(--on-surface-variant); }
.founders { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root { --rail-w: 0px; }
  .rail { display: none; }
  .content { margin-left: 0; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 8px 0 16px; }
  .topbar .brand-mini { display: inline-flex; }
  .topbar .title { font-size: 19px; }
  .topbar .title small { display: none; }
  .page { padding: 4px 16px 24px; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface-low); z-index: 20; box-shadow: 0 -1px 0 var(--outline-variant);
  }
  .bottomnav .navitem { flex: 1; padding: 10px 0 12px; gap: 4px; border-radius: 0; }
  .bottomnav .navitem .ind { width: 64px; height: 32px; }
  .bottomnav { background: var(--surface); }
  .fab { bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); right: 16px; }
  .snackbar { bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); }
  .home-hero { grid-template-columns: 1fr; }
  .home-hero h1 { font-size: 30px; }
  .photo-hero { margin: 0 -16px 20px; min-height: 360px; }
  .photo-hero img { object-position: center 8%; }
  .photo-hero .inner { padding: 40px 20px 28px; }
  .photo-hero h1 { font-size: 30px; }
  .photo-hero p { font-size: 15.5px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .profile-head { gap: 14px; }
  .profile-head h1 { font-size: 26px; }
  .avatar.xl { width: 84px; height: 84px; font-size: 32px; }
  .sheet { top: auto; height: 72%; width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; transform: translateY(104%); }
  .sheet.open { transform: translateY(0); }
  .sheet .handle { display: block; }
  .tree-toolbar { padding: 6px 12px 8px; }
  .tree-toolbar .legend { display: none; }
  .tree-hint { display: none; }
  .zoom-ctl { flex-direction: row; right: 12px; bottom: 12px; }
  .decade { padding-left: 64px; }
  .decade::before { left: 44px; }
  .decade-label { width: 36px; font-size: 13px; }
  .ev::before { left: -25px; }
  .ev.june12::before { left: -26px; }
  .sub .diff { grid-template-columns: 1fr; gap: 2px 0; }
  .sub .diff .k { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ============================================================
   Family Wall
   ============================================================ */
.wall { max-width: 640px; margin: 0 auto; }
.celebrations { margin-bottom: 16px; }
.celeb {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: var(--r-full); background: var(--surface-low);
  border: 1px solid var(--outline-variant); color: inherit; text-decoration: none; flex: 0 0 auto;
}
.celeb:hover { text-decoration: none; border-color: var(--outline); }
.celeb.today.birthday { background: var(--tertiary-container); color: var(--on-tertiary-container); border-color: transparent; }
.celeb.today.remembrance { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.celeb-name { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.celeb-when { font-size: 12px; opacity: .85; }

.composer .in { display: flex; background: var(--surface-low); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); }
.composer .in:focus-within { border-color: var(--primary); background: var(--surface-lowest); }
.composer textarea { width: 100%; min-height: 48px; max-height: 240px; border: 0; background: transparent; outline: 0; padding: 12px 14px; font: inherit; font-size: 16px; resize: none; color: var(--on-surface); }
.composer-preview { position: relative; margin-top: 10px; }
.composer-preview img { max-height: 260px; border-radius: var(--r-md); }
.composer-preview .iconbtn { position: absolute; top: 6px; left: 6px; background: var(--scrim); color: #fff; }

.feed { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.post { background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); padding: 16px 18px 10px; }
.post.flash { animation: flash 1.6s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--tertiary) 50%, transparent); } 100% { box-shadow: none; } }
.post.auto.birthday { border-color: color-mix(in srgb, var(--tertiary) 45%, var(--outline-variant)); background: linear-gradient(180deg, var(--tertiary-container) 0, var(--surface-lowest) 120px); }
.post.auto.remembrance { border-color: color-mix(in srgb, var(--primary) 35%, var(--outline-variant)); background: linear-gradient(180deg, var(--primary-container) 0, var(--surface-lowest) 120px); }
.post-head { display: flex; align-items: center; gap: 12px; }
.post-head .post-del { margin-left: auto; }
.post-who { font-weight: 600; font-size: 15px; }
.post-who a { color: inherit; }
.post-body { margin: 12px 0 4px; font-size: 15.5px; line-height: 1.55; overflow-wrap: anywhere; }
.post.auto .post-body { font-size: 16px; }
.post-photo { display: block; margin: 12px -18px 4px; background: var(--surface-low); }
.post-photo img { max-width: 100%; max-height: 520px; width: auto; height: auto; display: block; margin: 0 auto; }
.post-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 8px; border-top: 1px solid var(--outline-variant); padding-top: 6px; }
.post-actions .btn.text.sm { color: var(--on-surface-variant); }
.post-thread { margin-top: 4px; }
.thread-preview { margin-top: 6px; }

/* reactions */
.rx { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.rx-main { height: 34px; padding: 0 12px; border-radius: var(--r-full); font-size: 17px; display: inline-flex; align-items: center; gap: 6px; color: var(--on-surface-variant); }
.rx-main:hover { background: var(--surface-high); }
.rx-main.on { background: var(--primary-container); color: var(--on-primary-container); }
.rx-main .n { font-size: 13px; font-weight: 600; }
.rx-pick { position: absolute; left: 0; bottom: calc(100% + 4px); display: none; gap: 2px; background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-full); padding: 4px; box-shadow: var(--e3); z-index: 8; }
.rx:hover .rx-pick, .rx.open .rx-pick, .rx:focus-within .rx-pick { display: inline-flex; }
.rx-pick button { width: 38px; height: 38px; border-radius: 50%; font-size: 21px; display: grid; place-items: center; transition: transform .12s; }
.rx-pick button:hover { transform: scale(1.25); background: var(--surface-high); }
.rx-pick button.on { background: var(--primary-container); }
.rx-summary { font-size: 12.5px; color: var(--on-surface-variant); white-space: nowrap; }
.rx.sm .rx-main { height: 28px; padding: 0 9px; font-size: 14px; }
.rx.sm .rx-pick button { width: 32px; height: 32px; font-size: 18px; }

/* comments */
.thread { margin-top: 6px; }
.cmt { display: flex; gap: 10px; padding: 8px 0; align-items: flex-start; }
.cmt-body { flex: 1; min-width: 0; background: var(--surface-low); border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg); padding: 8px 12px; }
.cmt-head { display: flex; align-items: baseline; gap: 8px; }
.cmt-head b { font-size: 13.5px; }
.cmt-head b a { color: inherit; }
.cmt-del { margin-left: auto; color: var(--outline); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.cmt-del:hover { color: var(--error); background: var(--error-container); }
.cmt-text { font-size: 14.5px; line-height: 1.5; margin-top: 2px; overflow-wrap: anywhere; }
.cmt .rx { margin-top: 4px; }
.thread-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.thread-form .in { flex: 1; display: flex; background: var(--surface-low); border: 1px solid var(--outline-variant); border-radius: var(--r-xl); }
.thread-form textarea { width: 100%; border: 0; background: transparent; outline: 0; padding: 10px 14px; font: inherit; font-size: 15px; resize: none; color: var(--on-surface); max-height: 160px; }
.thread-form .iconbtn.filled { background: var(--primary); color: var(--on-primary); }

/* notifications */
.notif { text-decoration: none; color: inherit; }
.notif:hover { background: var(--surface-low); text-decoration: none; }
.notif.unread .t { font-weight: 600; }
.notif.unread::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: 0 0 8px; }
#bell .badge-dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--error); color: var(--on-error); font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }

@media (max-width: 900px) {
  .post { padding: 14px 14px 8px; border-radius: var(--r-md); }
  .post-photo { margin: 10px -14px 4px; }
  .rx-pick { left: -4px; }
}

/* ============================================================
   Galleries
   ============================================================ */
.album-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.album { display: block; color: inherit; text-decoration: none; background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); overflow: hidden; transition: box-shadow .15s; }
.album:hover { box-shadow: var(--e2); text-decoration: none; }
.album-cover { aspect-ratio: 4 / 3; background: var(--surface-low); }
.album-cover img { width: 100%; height: 100%; object-fit: cover; }
.album-empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--outline); }
.album-empty .ic { width: 36px; height: 36px; }
.album-body { padding: 12px 14px; }
.album-title { font-family: var(--serif); font-size: 17px; font-weight: 500; }
.photo-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-top: 16px; }
.photo-tile { position: relative; display: block; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: var(--r-sm); background: var(--surface-low); padding: 0; }
.photo-grid .photo-tile { aspect-ratio: 1 !important; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.photo-tile:hover img { transform: scale(1.03); }
.photo-meta { position: absolute; left: 6px; bottom: 6px; font-size: 11.5px; color: #fff; background: rgba(0,0,0,.55); padding: 2px 7px; border-radius: var(--r-full); }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.photo-strip .photo-tile { flex: 0 0 120px; width: 120px; height: 120px; }

.lightbox { position: fixed; inset: 0; z-index: 70; background: #0a0f18; display: grid; grid-template-columns: 1fr 380px; color: #fff; }
.lb-stage { position: relative; display: grid; place-items: center; padding: 20px; min-width: 0; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 40px); object-fit: contain; border-radius: var(--r-sm); }
.lb-close { position: absolute; top: 12px; left: 12px; color: #fff; background: rgba(255,255,255,.12); }
.lb-close:hover { background: rgba(255,255,255,.25); color: #fff; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; background: rgba(255,255,255,.12); width: 48px; height: 48px; }
.lb-nav:hover { background: rgba(255,255,255,.25); color: #fff; }
.lb-nav.prev { left: 12px; } .lb-nav.next { right: 12px; }
.lb-side { background: var(--surface); color: var(--on-surface); padding: 16px 18px; overflow: auto; }
.lb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lb-caption { font-size: 15px; line-height: 1.5; margin-top: 8px; }
.lb-thread { margin-top: 12px; }
@media (max-width: 900px) {
  .lightbox { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .lb-stage { padding: 8px; }
  .lb-stage img { max-height: 55vh; }
  .lb-side { max-height: 45vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .lb-nav { width: 40px; height: 40px; }
}

/* ============================================================
   Events
   ============================================================ */
.gcard { display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); color: inherit; text-decoration: none; transition: box-shadow .15s; }
.gcard:hover { box-shadow: var(--e2); text-decoration: none; }
.gcard.past { opacity: .75; }
.gdate { flex: 0 0 60px; text-align: center; background: var(--primary); color: var(--on-primary); border-radius: var(--r-md); padding: 6px 0; }
.gcard.past .gdate { background: var(--surface-high); color: var(--on-surface-variant); }
.gd-m { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.gd-d { font-family: var(--serif); font-size: 26px; line-height: 1.1; }
.gbody { flex: 1; min-width: 0; }
.gtitle { font-family: var(--serif); font-size: 18px; font-weight: 500; }
.gcover { width: 84px; height: 64px; object-fit: cover; border-radius: var(--r-sm); flex: 0 0 auto; }
.gevent { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.gevent-side { position: sticky; top: calc(var(--bar-h) + 12px); }
.gevent-cover { margin: 0 -24px 20px; max-height: 360px; overflow: hidden; background: var(--surface-low); }
.gevent-cover img { width: 100%; height: 100%; max-height: 360px; object-fit: cover; display: block; }
@media (max-width: 900px) {
  .gevent { grid-template-columns: 1fr; }
  .gevent-side { position: static; }
  .gevent-cover { margin: 0 -16px 16px; max-height: 220px; }
  .gcover { display: none; }
}

/* ============================================================
   More sheet (phones)
   ============================================================ */
.more-scrim { align-items: end; padding: 0; }
.more-panel { width: 100%; background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 8px 8px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--e3); }
.more-panel .handle { width: 36px; height: 4px; border-radius: 2px; background: var(--outline-variant); margin: 6px auto 10px; }
.more-item { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: var(--r-md); color: var(--on-surface); text-decoration: none; font-weight: 500; font-size: 16px; }
.more-item:hover, .more-item:active { background: var(--surface-low); text-decoration: none; }
.more-item .ic { color: var(--on-surface-variant); }
#more-btn.navitem { background: none; border: 0; }

/* ============================================================
   History
   ============================================================ */
.chapters { display: flex; flex-direction: column; gap: 12px; }
.chapter { display: flex; gap: 18px; align-items: center; padding: 16px 18px; background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); color: inherit; text-decoration: none; transition: box-shadow .15s; }
.chapter:hover { box-shadow: var(--e2); text-decoration: none; }
.chapter.draft { border-style: dashed; }
.chapter-num { flex: 0 0 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-size: 24px; background: var(--primary); color: var(--on-primary); }
.chapter-cover { flex: 0 0 96px; width: 96px; height: 72px; object-fit: cover; border-radius: var(--r-sm); }
.chapter-body { min-width: 0; }
.chapter-body h3 { font-size: 20px; margin: 2px 0 4px; }
.chapter-body p { margin: 0 0 4px; }
.reader { max-width: 760px; margin: 0 auto; }
.reader-cover { margin: 0 -24px 24px; max-height: 420px; overflow: hidden; }
.reader-cover img { width: 100%; max-height: 420px; object-fit: cover; display: block; }
.reader-head h1 { font-size: 36px; margin: 6px 0 10px; }
.reader-summary { font-size: 18px; color: var(--on-surface-variant); line-height: 1.5; }
.prose { font-size: 17.5px; line-height: 1.75; margin-top: 24px; }
.prose p { margin: 0 0 1.1em; }
.prose h2, .prose h3, .prose h4 { margin: 1.6em 0 .5em; }
.prose h2 { font-size: 26px; } .prose h3 { font-size: 21px; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.prose li { margin: .25em 0; }
.prose blockquote { margin: 1.2em 0; padding: .4em 1.2em; border-left: 4px solid var(--tertiary); background: var(--surface-low); font-family: var(--serif); font-size: 19px; border-radius: 0 var(--r-md) var(--r-md) 0; }
.prose hr { border: 0; border-top: 1px solid var(--outline-variant); margin: 2em 0; }
.prose figure { margin: 1.6em 0; }
.prose figure img, .prose p img { width: 100%; border-radius: var(--r-md); }
.prose figcaption { font-size: 13.5px; color: var(--on-surface-variant); margin-top: 8px; text-align: center; }
.reader-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--outline-variant); }
.reader-nav a { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
@media (max-width: 900px) {
  .reader-cover { margin: 0 -16px 16px; max-height: 260px; }
  .reader-head h1 { font-size: 28px; }
  .prose { font-size: 16.5px; }
  .chapter { gap: 12px; padding: 12px 14px; }
  .chapter-cover { flex-basis: 72px; width: 72px; height: 56px; }
}

/* ============================================================
   The front door (gate) — mygoodlyheritage.com and #/welcome
   ============================================================ */
body.gated .rail, body.gated .bottomnav, body.gated .fab, body.gated #topbar-back { display: none !important; }
body.gated .content { margin-left: 0; }
body.gated .page { padding: 0; max-width: none; }
.gate { min-height: calc(100dvh - var(--bar-h)); display: grid; grid-template-rows: auto 1fr; justify-items: center; align-content: start; padding: 28px 16px 48px; background:
  radial-gradient(900px 500px at 10% -10%, var(--primary-container) 0%, transparent 60%),
  radial-gradient(700px 400px at 100% 110%, var(--tertiary-container) 0%, transparent 60%), var(--surface-low); }
.gate.standalone { min-height: 100dvh; padding-top: 40px; }
.gate-card { width: 100%; max-width: 640px; background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-xl); padding: 28px 32px 32px; box-shadow: var(--e3); animation: gate-in .35s var(--ease); }
@keyframes gate-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.gate-top { display: flex; align-items: center; justify-content: space-between; margin: -8px -12px 14px; min-height: 40px; }
.gate-dots { display: flex; gap: 6px; }
.gate-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-highest); transition: all .25s var(--ease); }
.gate-dots i.done { background: var(--primary); opacity: .5; }
.gate-dots i.now { background: var(--tertiary); width: 22px; border-radius: 4px; }
.gate h1 { font-size: 40px; line-height: 1.05; margin: 10px 0 14px; }
.gate h2 { font-size: 28px; line-height: 1.15; margin: 0 0 8px; }
.gate h2 .hl { color: var(--tertiary); }
.gate p { line-height: 1.6; margin: 0 0 12px; font-size: 16px; }
.gate .kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--tertiary); margin-bottom: 8px; }
.gate-hero { text-align: center; padding: 8px 0 0; }
.gate-hero p { max-width: 52ch; margin-left: auto; margin-right: auto; }
.gate-logo { width: 160px; height: 160px; border-radius: 50%; display: block; margin: 0 auto 18px; box-shadow: var(--e2); }
@media (max-width: 640px) { .gate-logo { width: 128px; height: 128px; } }
.gate-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin-top: 22px; }
.gate .field { margin-top: 10px; }
.gate .field input { font-size: 18px; min-height: 56px; }
.gate-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }
.gate-opt { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 18px 14px; border: 1.5px solid var(--outline-variant); border-radius: var(--r-lg); background: var(--surface-lowest); transition: all .18s var(--ease); font: inherit; color: inherit; }
.gate-opt b { font-family: var(--serif); font-weight: 600; font-size: 17px; line-height: 1.2; }
.gate-opt:hover { border-color: var(--primary); background: var(--surface-low); }
.gate-opt.on { border-color: var(--primary); background: var(--primary-container); box-shadow: 0 0 0 2px var(--primary) inset; }
.gate-results { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.gate-result { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--r-md); text-align: left; font: inherit; color: inherit; }
.gate-result:hover { background: var(--surface-high); }
.gate-picked { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 14px; background: var(--success-container); border-radius: var(--r-md); }
.gate-picked .btn { margin-left: auto; }
.gate-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gate-chips .chip { height: 42px; font-size: 15px; }
.gate-q { margin-top: 22px; }
.gate-q-text { font-weight: 600; font-size: 16.5px; line-height: 1.4; }
.gate-summary { margin-top: 18px; padding: 14px 16px; background: var(--surface-low); border-radius: var(--r-md); }
.gate-summary p { font-size: 15px; margin: 6px 0 0; }
.gate-check { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; background: var(--success-container); color: var(--success); font-size: 36px; font-weight: 700; }
.gate-check.wait { background: var(--tertiary-container); color: var(--tertiary); }
.gate-quote { margin: 18px 0 8px; padding: 14px 18px; border-left: 4px solid var(--tertiary); background: var(--surface-low); font-family: var(--serif); font-size: 18px; line-height: 1.55; text-align: left; border-radius: 0 var(--r-md) var(--r-md) 0; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.gate-foot { text-align: center; font-size: 13px; color: var(--on-surface-variant); margin-top: 18px; align-self: end; }
@media (max-width: 640px) {
  .gate { padding: 12px 12px 32px; }
  .gate-card { padding: 20px 18px 24px; border-radius: var(--r-lg); }
  .gate h1 { font-size: 32px; } .gate h2 { font-size: 24px; }
  .gate-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gate-opt { padding: 14px 8px; } .gate-opt .avatar.lg { width: 64px; height: 64px; font-size: 24px; }
  .gate-actions .btn { flex: 1 1 auto; }
}

/* "Place this person" assistant on queue cards */
.sub .place { margin: 12px 0 4px; padding: 12px 14px; background: var(--primary-container); color: var(--on-primary-container); border-radius: var(--r-md); }
.sub .place .label { color: var(--primary); margin-bottom: 2px; }
.sub .place .radios { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.sub .place .radios label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; line-height: 1.35; }
.sub .place .radios input { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; flex: 0 0 auto; }
.sub .place .dup { margin: 8px 0 10px; padding: 10px 12px; background: var(--tertiary-container); color: var(--on-tertiary-container); border-radius: var(--r-sm); }
.sub .place .picker { background: var(--surface-lowest); }
.sub .place .field { margin-top: 8px; }
.role-select { height: 34px; padding: 0 28px 0 10px; border: 1px solid var(--outline-variant); border-radius: var(--r-full); background: var(--surface-lowest); color: var(--on-surface); font: inherit; font-size: 13px; font-weight: 500; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--on-surface-variant) 50%), linear-gradient(135deg, var(--on-surface-variant) 50%, transparent 50%); background-position: calc(100% - 14px) 14px, calc(100% - 10px) 14px; background-size: 4px 4px; background-repeat: no-repeat; cursor: pointer; }

/* Site footer (app) and credits (front door) */
.site-foot { border-top: 1px solid var(--outline-variant); background: var(--surface-low); color: var(--on-surface-variant); font-size: 13px; }
.site-foot-inner { max-width: 1240px; margin: 0 auto; padding: 18px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; }
.site-foot .brandline { display: inline-flex; align-items: center; gap: 10px; }
.site-foot .brandline img { width: 28px; height: 28px; border-radius: 50%; }
.credits { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; letter-spacing: .01em; }
.credits a { color: var(--primary); font-weight: 600; text-decoration: none; }
.credits a:hover { text-decoration: underline; }
.credits .sep { color: var(--outline); }
.gate-foot .credits { display: flex; justify-content: center; margin-top: 8px; }
body.gated .site-foot { display: none; }
@media (max-width: 640px) { .site-foot-inner { flex-direction: column; align-items: flex-start; padding: 16px; } }

/* ============================================================
   Member profiles
   ============================================================ */
.profile-cover { position: relative; height: 220px; background: var(--surface-mid); overflow: hidden; }
.profile-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-cover .cover-fallback { width: 100%; height: 100%; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 70%, var(--surface)) 0%, var(--primary) 100%); }
.profile-cover .cover-btn { position: absolute; right: 14px; bottom: 14px; cursor: pointer; }
.profile-head { display: flex; align-items: flex-end; gap: 18px; padding: 0 24px 18px; flex-wrap: wrap; }
.profile-avatar { position: relative; margin-top: -56px; flex: 0 0 auto; }
.profile-avatar .avatar.xl { width: 128px; height: 128px; border: 4px solid var(--surface-lowest); box-shadow: var(--e2); font-size: 44px; }
.profile-avatar .avatar-btn { position: absolute; right: 2px; bottom: 6px; width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; cursor: pointer; box-shadow: var(--e2); }
.profile-title { flex: 1; min-width: 200px; padding-top: 12px; }
.profile-title h1 { font-size: 30px; margin: 0 0 6px; }
.profile-title .chips { gap: 6px; }
.profile-title .tag { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.profile-head .row { padding-top: 12px; gap: 8px; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--outline-variant); }
.profile-stats > div { display: flex; flex-direction: column; align-items: center; padding: 12px 6px; gap: 2px; }
.profile-stats b { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1; }
.profile-stats span { font-size: 12px; color: var(--on-surface-variant); text-transform: uppercase; letter-spacing: .06em; }
.profile-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 1.6fr); gap: 16px; align-items: start; }
.prose-sm { line-height: 1.6; font-size: 15.5px; }
.facts { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.fact { display: flex; align-items: center; gap: 10px; color: var(--on-surface-variant); font-size: 14px; }
.fact .ic { color: var(--primary); flex: 0 0 auto; }
.list.compact .item { padding: 8px 2px; min-height: 48px; text-decoration: none; color: inherit; }
.photo-grid.small { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); margin-top: 12px; }
.photo-grid.small .ph { aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-mid); display: block; }
.photo-grid.small .ph img { width: 100%; height: 100%; object-fit: cover; }
.member-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.member-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 20px 14px 16px; background: var(--surface-lowest); border: 1px solid var(--outline-variant); border-radius: var(--r-lg); text-decoration: none; color: inherit; transition: box-shadow .15s var(--ease), transform .15s var(--ease); }
.member-card:hover { box-shadow: var(--e2); transform: translateY(-2px); text-decoration: none; }
.member-card .t { font-weight: 600; font-size: 16px; margin-top: 4px; }
.member-card .chips { justify-content: center; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 14.5px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.row.wrap { flex-wrap: wrap; gap: 12px; }
@media (max-width: 900px) {
  .profile-cover { height: 150px; }
  .profile-head { padding: 0 16px 16px; gap: 12px; }
  .profile-avatar { margin-top: -44px; }
  .profile-avatar .avatar.xl { width: 96px; height: 96px; font-size: 34px; }
  .profile-title h1 { font-size: 24px; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-stats b { font-size: 18px; }
  .member-grid { grid-template-columns: repeat(2, 1fr); }
}
.member-link { text-decoration: none; color: inherit; gap: 12px; }
.member-link:hover { text-decoration: none; box-shadow: var(--e1); }

/* relationship controls on person pages (admin) */
.plink { position: relative; }
.plink.has-tools { padding-right: 76px; }
.plink .rel-tools { display: inline-flex; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); gap: 2px; opacity: .6; }
.plink:hover .rel-tools, .plink:focus-within .rel-tools { opacity: 1; }
.plink .rel-tools .iconbtn { width: 32px; height: 32px; background: var(--surface-lowest); box-shadow: var(--e1); }
.plink .rel-tools .iconbtn .ic { width: 16px; height: 16px; }
.tag.ended { background: var(--error-container); color: var(--on-error-container); }
.famgroup .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--surface-high); font-size: 11px; text-align: center; margin-left: 4px; }
.famgroup.wide-group.collapsed .people > .plink:nth-child(n+9) { display: none; }
.famgroup.wide-group [data-expand] { margin-top: 4px; }

/* Family video meeting */
.meet-wrap { display: flex; flex-direction: column; height: calc(100dvh - var(--bar-h)); }
.meet-bar { display: flex; align-items: center; gap: 12px; padding: 6px 12px; border-bottom: 1px solid var(--outline-variant); background: var(--surface-low); flex-wrap: wrap; }
.meet-frame { flex: 1; min-height: 0; background: #000; position: relative; }
.meet-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.meet-frame .state { color: #fff; }
body.meeting .bottomnav, body.meeting .fab, body.meeting .site-foot { display: none !important; }
body.meeting .content { padding-bottom: 0; }
.meet-card h3 { display: inline-flex; align-items: center; gap: 6px; }
.gevent-list .tag.online, .tag.online { background: var(--success-container); color: var(--on-surface); }

/* Birth register */
.reg-list { display: flex; flex-direction: column; }
.reg-decade { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--primary); padding: 14px 4px 6px; border-bottom: 1px solid var(--outline-variant); margin-bottom: 4px; }
.reg-row { display: grid; grid-template-columns: 56px 36px 1fr auto; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--outline-variant); text-decoration: none; color: inherit; }
.reg-row:last-child { border-bottom: 0; }
.reg-row:hover { background: var(--surface-low); text-decoration: none; }
.reg-no { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--tertiary); text-align: right; }
.reg-name { display: flex; flex-direction: column; min-width: 0; }
.reg-name b { font-weight: 600; }
.reg-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.reg-meta .tag { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 640px) { .reg-row { grid-template-columns: 44px 32px 1fr; } .reg-meta { grid-column: 2 / -1; flex-direction: row; align-items: center; gap: 8px; margin-top: -2px; } .reg-no { font-size: 17px; } }
.dup-warn { margin-top: 6px; padding: 8px 12px; background: var(--tertiary-container); color: var(--on-tertiary-container); border-radius: var(--r-sm); font-size: 13px; line-height: 1.5; }
.dup-warn a { color: inherit; font-weight: 600; }
