/* ============================================================================
   Lineamy — Phase 1 theme
   Identity: deep ink-slate ground, restrained heritage gold, quiet verdigris.
   Display: Fraunces (editorial serif).  UI/body: Inter.
   ========================================================================== */

:root {
  /* Palette */
  --ink:        #18222e;   /* primary dark ground */
  --ink-2:      #1f2c3a;   /* raised dark surface */
  --ink-3:      #2a3a4c;   /* hairlines on dark */
  --paper:      #fbf8f2;   /* warm light ground */
  --paper-2:    #ffffff;   /* cards on light */
  --gold:       #b98a3c;   /* heritage accent (the star) */
  --gold-soft:  #d8b878;
  --sage:       #5e7c72;   /* quiet secondary */
  --sage-soft:  #88a298;
  --text:       #21303d;   /* body text on paper */
  --muted:      #6a7682;   /* secondary text */
  --line:       #e6ded0;   /* hairline on paper */
  --danger:     #a83a2f;
  --danger-bg:  #f7e7e4;
  --ok:         #3f6b54;
  --ok-bg:      #e6efe8;
  --warn-bg:    #f6efdd;

  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 1px 2px rgba(24,34,46,.06), 0 12px 32px -16px rgba(24,34,46,.28);
  --shadow-sm:  0 1px 2px rgba(24,34,46,.07), 0 4px 14px -8px rgba(24,34,46,.22);
  --maxw:       1140px;
  --font-ui:    'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 560;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 .5em;
  font-optical-sizing: auto;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ----- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: inherit; font-weight: 600; letter-spacing: .01em;
  padding: .72rem 1.3rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  text-decoration: none; line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); color: #2a1e08; }
.btn-primary:hover { background: var(--gold-soft); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--gold); color: var(--text); text-decoration: none; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: var(--ink-2); text-decoration: none; }
.btn-danger { background: transparent; color: var(--danger); border-color: #e3c9c4; }
.btn-danger:hover { background: var(--danger-bg); text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: .5rem .85rem; font-size: .86rem; }

/* ----- Site header ------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251,248,242,.86);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-display);
  font-size: 1.35rem; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 26px; height: 26px; flex: none; }
.nav { display: flex; align-items: center; gap: 1.4rem; }
.nav a.navlink { color: var(--text); font-weight: 500; font-size: .95rem; }
.nav a.navlink:hover { color: var(--gold); text-decoration: none; }

/* On dark hero pages the header can invert */
.site-header.on-dark { background: rgba(24,34,46,.7); border-bottom-color: var(--ink-3); }
.site-header.on-dark .brand { color: var(--paper); }
.site-header.on-dark .nav a.navlink { color: #cdd6df; }
.site-header.on-dark .nav a.navlink:hover { color: var(--gold-soft); }

/* ----- Hero -------------------------------------------------------------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 600px at 78% -10%, #24384a 0%, transparent 60%),
    linear-gradient(160deg, #1b2734 0%, #18222e 55%, #15202b 100%);
  background-color: var(--ink);
  color: var(--paper);
}
.hero .wrap { position: relative; z-index: 2; padding: 96px 24px 110px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; }
.eyebrow {
  display: inline-block; font-size: .78rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold-soft); font-weight: 600; margin-bottom: 1.1rem;
}
.hero h1 { font-size: clamp(2.5rem, 5.2vw, 4.1rem); color: var(--paper); margin-bottom: .55em; }
.hero h1 em { font-style: italic; color: var(--gold-soft); }
.hero p.lead { font-size: 1.15rem; color: #c5cfd9; max-width: 33ch; margin: 0 0 2rem; }
.hero-cta { display: flex; gap: .9rem; flex-wrap: wrap; }
.hero-meta { margin-top: 2.4rem; display: flex; gap: 2.2rem; color: #9fb0bd; font-size: .9rem; }
.hero-meta strong { display: block; font-family: var(--font-display); font-size: 1.5rem; color: var(--paper); font-weight: 560; }

/* Pedigree signature diagram (SVG strokes) */
.pedigree { width: 100%; height: auto; }
.pedigree .node-fill { fill: var(--ink-2); }
.pedigree .node-stroke { stroke: var(--gold); }
.pedigree .link { stroke: var(--sage-soft); stroke-opacity: .55; }
.pedigree .pulse { transform-box: fill-box; transform-origin: center; }

/* ----- Generic section --------------------------------------------------- */
.section { padding: 84px 0; }
.section.alt { background: linear-gradient(180deg, #fff 0%, var(--paper) 100%); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { max-width: 60ch; margin-bottom: 48px; }
.section-head .eyebrow { color: var(--gold); }
.section-head h2 { font-size: clamp(1.9rem, 3.4vw, 2.7rem); color: var(--ink); }
.section-head p { color: var(--muted); font-size: 1.08rem; margin: 0; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.feature {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px; box-shadow: var(--shadow-sm);
}
.feature .ficon { width: 40px; height: 40px; color: var(--gold); margin-bottom: 16px; }
.feature h3 { font-size: 1.3rem; color: var(--ink); }
.feature p { color: var(--muted); margin: 0; font-size: .98rem; }

/* steps */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; counter-reset: step; }
.step { position: relative; padding-top: 14px; }
.step .num { font-family: var(--font-display); font-size: 1rem; color: var(--gold);
  border: 1px solid var(--line); width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: 14px; background: #fff; }
.step h3 { font-size: 1.2rem; color: var(--ink); margin-bottom: .35em; }
.step p { color: var(--muted); margin: 0; font-size: .97rem; }

/* CTA band */
.cta-band { background: var(--ink); color: var(--paper); border-radius: var(--radius); padding: 56px; text-align: center; }
.cta-band h2 { color: var(--paper); font-size: clamp(1.8rem, 3vw, 2.4rem); }
.cta-band p { color: #c5cfd9; max-width: 48ch; margin: 0 auto 1.8rem; }

/* ----- Footer ------------------------------------------------------------ */
.site-footer { background: var(--ink); color: #9fb0bd; padding: 54px 0 40px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.site-footer .brand { color: var(--paper); margin-bottom: .6rem; }
.site-footer a { color: #c5cfd9; }
.site-footer a:hover { color: var(--gold-soft); }
.foot-col h4 { font-family: var(--font-ui); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-soft); margin-bottom: 1rem; }
.foot-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.foot-bottom { border-top: 1px solid var(--ink-3); margin-top: 36px; padding-top: 22px; font-size: .85rem; color: #7e8d99; }

/* ============================================================================
   Auth + account: quiet, disciplined surfaces
   ========================================================================== */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside {
  background: linear-gradient(165deg, #1d2a37, #16202b);
  color: var(--paper); padding: 56px 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-aside .brand { color: var(--paper); }
.auth-aside .aside-copy h2 { color: var(--paper); font-size: 2.2rem; max-width: 16ch; }
.auth-aside .aside-copy p { color: #b9c5cf; max-width: 34ch; }
.auth-aside .aside-quote { color: #9fb0bd; font-style: italic; border-left: 2px solid var(--gold); padding-left: 16px; font-family: var(--font-display); font-size: 1.05rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--paper); }
.auth-card { width: 100%; max-width: 460px; }
.auth-card.wide { max-width: 560px; }
.auth-card h1 { font-size: 2rem; color: var(--ink); margin-bottom: .2em; }
.auth-card .sub { color: var(--muted); margin: 0 0 2rem; }

/* Forms */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: .9rem; font-weight: 600; color: var(--ink); margin-bottom: .4rem; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: .35rem; }
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .72rem .9rem; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(185,138,60,.16);
}
.textarea { resize: vertical; min-height: 90px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.checkline { display: flex; align-items: center; gap: .55rem; font-size: .92rem; color: var(--text); }
.checkline input { width: 16px; height: 16px; accent-color: var(--gold); }
.form-foot { margin-top: 8px; }
.muted-link { color: var(--muted); font-size: .92rem; }
.divider-or { text-align: center; color: var(--muted); font-size: .85rem; margin: 1.5rem 0; position: relative; }
.error-text { color: var(--danger); font-size: .84rem; margin-top: .35rem; }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }

/* Flash messages */
.flash { padding: .85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem; font-size: .94rem; border: 1px solid transparent; }
.flash.error   { background: var(--danger-bg); color: var(--danger); border-color: #eccfca; }
.flash.success { background: var(--ok-bg); color: var(--ok); border-color: #cfe0d4; }
.flash.info    { background: var(--warn-bg); color: #7a5b1a; border-color: #e8d9b0; }

/* ----- Account shell ----------------------------------------------------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.app-side {
  background: var(--ink); color: #c5cfd9; padding: 26px 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.app-side .brand { color: var(--paper); padding: 0 10px 26px; }
.app-nav { display: grid; gap: 4px; }
.app-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .65rem .75rem; border-radius: var(--radius-sm);
  color: #c5cfd9; font-weight: 500; font-size: .95rem;
}
.app-nav a:hover { background: var(--ink-2); color: var(--paper); text-decoration: none; }
.app-nav a.active { background: var(--ink-2); color: var(--paper); box-shadow: inset 2px 0 0 var(--gold); }
.app-nav a svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.app-side .side-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--ink-3); }
.app-side .who { font-size: .85rem; color: #9fb0bd; padding: 0 10px 10px; }
.app-side .who strong { color: var(--paper); display: block; font-weight: 600; }

.app-main { padding: 40px 44px; background: var(--paper); }
.app-main .page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 30px; }
.app-main .page-head h1 { font-size: 2rem; color: var(--ink); margin: 0 0 .15em; }
.app-main .page-head p { color: var(--muted); margin: 0; }

.card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow-sm); margin-bottom: 22px;
}
.card h2 { font-size: 1.3rem; color: var(--ink); }
.card .card-sub { color: var(--muted); margin: -.3rem 0 1.2rem; font-size: .96rem; }

.badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600;
  padding: .25rem .6rem; border-radius: 999px; letter-spacing: .02em; }
.badge.on  { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: #eef0f2; color: var(--muted); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Tree list */
.tree-list { display: grid; gap: 14px; }
.tree-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: #fff; }
.tree-item:hover { border-color: var(--gold-soft); }
.tree-item .t-meta h3 { font-size: 1.15rem; color: var(--ink); margin: 0 0 .15em; }
.tree-item .t-meta p { color: var(--muted); margin: 0; font-size: .9rem; }
.tree-item .t-vis { font-size: .78rem; color: var(--muted); text-transform: capitalize; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ei { width: 46px; height: 46px; color: var(--sage-soft); margin: 0 auto 14px; }

/* 2FA enrol */
.enrol-grid { display: grid; grid-template-columns: 220px 1fr; gap: 30px; align-items: start; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; place-items: center; }
.qr-box img, .qr-box canvas, .qr-box svg { width: 190px; height: 190px; }
.secret-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f3efe6; border: 1px dashed var(--line);
  border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .95rem; letter-spacing: .06em; word-break: break-all; color: var(--ink); }
.code-input { letter-spacing: .5em; font-size: 1.4rem; text-align: center; font-family: ui-monospace, monospace; }
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; background: #f3efe6; border-radius: var(--radius-sm); padding: 18px 22px; margin: 14px 0; }
.backup-codes code { font-family: ui-monospace, monospace; font-size: 1rem; letter-spacing: .08em; color: var(--ink); }
.backup-codes code.used { text-decoration: line-through; color: var(--muted); }

/* password strength */
.pw-meter { height: 6px; border-radius: 999px; background: #eee5d4; overflow: hidden; margin-top: .5rem; }
.pw-meter > span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s ease, background .2s ease; }

/* ----- Responsive -------------------------------------------------------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-visual { order: -1; max-width: 460px; }
  .features, .steps { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .app { grid-template-columns: 1fr; }
  .app-side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
  .app-side .brand { padding: 0 8px 0 4px; }
  .app-side .side-foot, .app-side .who { display: none; }
  .app-nav { grid-auto-flow: column; gap: 4px; overflow-x: auto; }
  .app-main { padding: 28px 20px; }
  .enrol-grid { grid-template-columns: 1fr; }
  .qr-box { max-width: 220px; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .app-main .page-head { flex-direction: column; }
  .tree-item { flex-direction: column; align-items: flex-start; }
  .backup-codes { grid-template-columns: 1fr; }
  .cta-band, .auth-aside { padding: 32px 22px; }
}

/* Accessibility */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}


/* ============================================================================
   Phase 2 (rev) — Full-page family tree, person nodes, drawer & add-menu
   ========================================================================== */

body.tree-body { height: 100vh; overflow: hidden; display: flex; flex-direction: column; background: var(--paper); }

/* Top bar */
.tree-bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 9px 18px; background: var(--ink); border-bottom: 1px solid var(--ink-3);
  box-shadow: var(--shadow-sm); z-index: 30;
}
.tree-bar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tree-bar .brand { font-size: 1rem; gap: .4rem; }
.tree-bar .brand .mark { width: 24px; height: 24px; }
.tree-title { min-width: 0; }
.tree-title h1 { font-size: 1.1rem; margin: 0; color: var(--ink); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.tree-title p { margin: 0; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.tree-bar-right { display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.vis-toggle .select { padding: .38rem .55rem; font-size: .82rem; }
.zoom-controls { display: inline-flex; gap: 4px; }
.zoom-controls .btn { min-width: 34px; padding: .38rem .5rem; font-weight: 600; }

/* Canvas / viewport: scrolls in all directions */
.tree-canvas {
  flex: 1; position: relative; overflow: auto; cursor: grab; -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(circle at 1px 1px, rgba(24,34,46,.07) 1px, transparent 0) 0 0 / 24px 24px,
    var(--paper);
}
.tree-canvas.grabbing { cursor: grabbing; }
.tree-canvas.grabbing .pnode { pointer-events: none; }
.tree-stage { position: relative; transform-origin: 0 0; }
.tree-links { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.ft-link { fill: none; stroke: #b9c4cd; stroke-width: 1.7; }
.ft-link.marr { stroke: var(--gold); stroke-width: 2; }
.tree-nodes { position: absolute; inset: 0; }
.tree-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.ft-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; justify-items: center; color: var(--muted); text-align: center; }

/* Person node — evenly sized, absolutely positioned */
.pnode {
  position: absolute; box-sizing: border-box; background: var(--paper-2);
  border: 1px solid var(--line); border-top: 3px solid var(--muted); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); padding: 8px 12px 10px; display: flex; flex-direction: column; align-items: center;
  transition: box-shadow .12s ease, border-color .12s ease; cursor: pointer;
}
.pnode:hover { box-shadow: var(--shadow); border-color: var(--gold); }
.pnode.sex-male    { border-top-color: #6b8aa6; }
.pnode.sex-female  { border-top-color: #b07ea0; }
.pnode.sex-unknown { border-top-color: #c2c8cf; }
.pnode.is-living   { border-style: dashed; border-top-style: solid; border-top-color: var(--sage-soft); background: #f7f4ee; }

.pnode-top { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; position: relative; }
.pnode-icon { width: 34px; height: 34px; border-radius: 50%; background: #eef1f4; display: grid; place-items: center; color: var(--ink); flex: none; }
.pnode.sex-male .pnode-icon    { background: #e7eef4; color: #4d6a85; }
.pnode.sex-female .pnode-icon  { background: #f3e7ef; color: #8d5a78; }
.pnode-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pnode-add {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font-size: 1.05rem; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.pnode-add:hover { background: var(--gold); color: #2a1e08; border-color: var(--gold); }

.pnode-name { font-family: var(--font-display); font-weight: 560; color: var(--ink); font-size: .98rem; line-height: 1.15; text-align: center; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pnode-years { font-size: .8rem; color: var(--muted); margin-top: 3px; }

.pnode-info {
  position: absolute; left: 50%; bottom: -11px; transform: translateX(-50%);
  width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 1px solid var(--line);
  color: var(--sage); display: grid; place-items: center; cursor: pointer; padding: 0; box-shadow: var(--shadow-sm);
}
.pnode-info svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.pnode-info:hover { color: #fff; background: var(--sage); border-color: var(--sage); }

/* Expand/collapse arrows */
.pnode-arrow {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 26px; height: 20px; border-radius: 11px; background: var(--ink); border: none; color: #fff;
  cursor: pointer; display: grid; place-items: center; padding: 0; opacity: .82;
}
.pnode-arrow:hover { opacity: 1; background: var(--gold); color: #2a1e08; }
.pnode-arrow svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pnode-arrow.up   { top: -12px; }
.pnode-arrow.down { bottom: -12px; }
.pnode-arrow.down.is-collapsed { background: var(--gold); color: #2a1e08; opacity: 1; }

/* Add-relative popover */
.add-menu {
  position: fixed; z-index: 120; background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px; min-width: 160px; display: grid; gap: 2px;
}
.add-menu[hidden] { display: none; }
.add-menu button {
  text-align: left; background: none; border: none; font: inherit; color: var(--text);
  padding: .55rem .7rem; border-radius: 7px; cursor: pointer;
}
.add-menu button:hover { background: #f3efe6; color: var(--ink); }

/* Details drawer */
.detail-drawer { position: fixed; inset: 0; z-index: 110; pointer-events: none; }
.detail-drawer .drawer-scrim { position: absolute; inset: 0; background: rgba(24,34,46,.4); opacity: 0; transition: opacity .2s ease; }
.detail-drawer .drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: 400px; max-width: 92vw;
  background: var(--paper-2); box-shadow: -12px 0 40px -16px rgba(0,0,0,.4);
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.detail-drawer.open { pointer-events: auto; }
.detail-drawer.open .drawer-scrim { opacity: 1; }
.detail-drawer.open .drawer-panel { transform: translateX(0); }
.drawer-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 1.4rem; color: var(--ink); }
.drawer-meta { margin: .25rem 0 0; color: var(--muted); font-size: .88rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 22px; }
.dr-group { padding: 14px 0; border-bottom: 1px solid var(--line); }
.dr-group:last-child { border-bottom: none; }
.dr-group h4 { font-family: var(--font-ui); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin: 0 0 8px; }
.dr-row { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; font-size: .92rem; }
.dr-label { color: var(--muted); flex: none; }
.dr-val { color: var(--ink); text-align: right; }
.dr-empty { color: var(--muted); padding: 20px 0; }
.drawer-foot { flex: none; padding: 16px 22px; border-top: 1px solid var(--line); }
.drawer-foot .btn + .btn { margin-top: 10px; }
.drawer-foot:empty { display: none; }

/* Modal (carried from Phase 2) */
.modal-overlay { position: fixed; inset: 0; background: rgba(24,34,46,.55); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px; z-index: 130; }
.modal-overlay[hidden] { display: none; }
.modal-card { background: var(--paper-2); border-radius: var(--radius); width: 100%; max-width: 720px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); overflow: hidden; }
.modal-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.4rem; color: var(--ink); }
.modal-x { background: none; border: none; font-size: 1.8rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-x:hover { color: var(--ink); }
.modal-context { flex: none; margin: 0; padding: 12px 24px 0; color: var(--gold); font-size: .9rem; font-weight: 500; }
.modal-context:empty { display: none; }
.modal-body { overflow-y: auto; padding: 16px 24px 4px; }
.form-group { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.form-group:first-of-type { border-top: none; padding-top: 4px; margin-top: 4px; }
.form-group h3 { font-family: var(--font-ui); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin: 0 0 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .field.span-2 { grid-column: 1 / -1; }
.status-row { display: flex; gap: 22px; }
.child-options { display: grid; gap: 8px; }
.modal-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }

@media (max-width: 620px) {
  .form-grid { grid-template-columns: 1fr; }
  .tree-title h1, .tree-title p { max-width: 34vw; }
  .modal-card { max-height: 96vh; }
  .zoom-controls .btn { min-width: 30px; }
}

/* Tree top bar: stay usable on small screens */
@media (max-width: 760px) {
  .tree-bar { flex-wrap: wrap; gap: 8px 10px; }
  .tree-title p { display: none; }
  .tree-title h1 { max-width: 60vw; }
  .tree-bar-right { width: 100%; justify-content: flex-start; }
  .tree-tools, .zoom-controls { flex: 1 1 auto; }
}

/* ============================================================================
   Phase 2 (rev) — focus/pivot tree: free-pan canvas + larger two-line cards
   These rules come last so they override the earlier tree styles.
   ========================================================================== */
.tree-canvas { overflow: hidden; cursor: grab; touch-action: none; }
.tree-canvas.grabbing { cursor: grabbing; }
.tree-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }

.pnode {
  position: absolute; box-sizing: border-box; background: var(--paper-2);
  border: 1px solid var(--line); border-top: 3px solid var(--muted); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); padding: 8px 12px 22px; display: flex; flex-direction: column; align-items: center;
  cursor: pointer; transition: box-shadow .12s ease, border-color .12s ease;
}
.pnode:hover { box-shadow: var(--shadow); border-color: var(--gold-soft); }
.pnode.sex-male    { border-top-color: #6b8aa6; }
.pnode.sex-female  { border-top-color: #b07ea0; }
.pnode.sex-unknown { border-top-color: #c2c8cf; }
.pnode.is-living   { border-style: dashed; border-top-style: solid; border-top-color: var(--sage-soft); background: #f7f4ee; }
.pnode.is-focus    { border-color: var(--gold); border-top-color: var(--gold); box-shadow: 0 0 0 3px rgba(185,138,60,.22), var(--shadow); }

.pnode-top { width: 100%; display: flex; align-items: center; justify-content: space-between; height: 26px; }
.pnode-icon { width: 26px; height: 26px; color: var(--muted); display: inline-flex; }
.pnode-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pnode.sex-male .pnode-icon { color: #6b8aa6; } .pnode.sex-female .pnode-icon { color: #b07ea0; }
.pnode-add {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: #f3efe6;
  color: var(--ink); font-size: 1.05rem; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.pnode-add:hover { border-color: var(--gold); background: #fff; }

.pnode-name { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 100%; text-align: center; }
.pn-first { font-size: .9rem; color: var(--text); line-height: 1.16; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; }
.pn-last  { font-family: var(--font-display); font-weight: 600; font-size: 1.06rem; color: var(--ink); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pnode-years { font-size: .82rem; color: var(--muted); margin-top: 2px; }

.pnode-info {
  position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%);
  width: 22px; height: 22px; border: none; background: none; color: var(--sage); cursor: pointer; padding: 0; display: grid; place-items: center;
}
.pnode-info svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.pnode-info:hover { color: var(--gold); }

/* "more relatives this way" hint tabs, just outside the card */
.pnode-more { position: absolute; left: 50%; transform: translateX(-50%); width: 22px; height: 16px; color: var(--sage); pointer-events: none; opacity: .8; }
.pnode-more svg { width: 22px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pnode-more.up   { top: -16px; }
.pnode-more.down { bottom: -16px; }

.ft-link { fill: none; stroke: var(--sage); stroke-width: 1.7; stroke-opacity: .7; }
.ft-link.marr { stroke: var(--gold); stroke-opacity: .8; }

.tree-stage { padding: 0; min-width: 0; }

/* ============================================================================
   Phase 2 (rev3) — FamilySearch-style couple-pivot viewer
   Last in the file → overrides all earlier tree styles.
   ========================================================================== */
body.tree-body { background: #e9ebee; }
.tree-canvas { overflow: hidden; cursor: grab; touch-action: none; background: #e9ebee; }
.tree-canvas.grabbing { cursor: grabbing; }
.tree-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; padding: 0; min-width: 0; }
.tree-nodes { position: absolute; inset: 0; }
.ft-link { fill: none; stroke: #b7c2cb; stroke-width: 2; }
.ft-link.marr { stroke: #b7c2cb; }

/* ---- Card ---- */
.fcard {
  position: absolute; box-sizing: border-box; width: 160px; height: 158px;
  background: #fff; border: 1px solid #eef1f4; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(20,30,40,.08); padding: 14px 10px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; overflow: visible;
  transition: box-shadow .12s ease, border-color .12s ease;
}
.fcard::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px; border-radius: 8px 8px 0 0; background: #c2c8cf; }
.fcard.sex-male::before   { background: #4aa3c7; }
.fcard.sex-female::before { background: #d6457f; }
.fcard:hover { box-shadow: 0 4px 14px rgba(20,30,40,.22); border-color: #9fb1bd; }
.fcard.is-focus { border-color: #4aa3c7; box-shadow: 0 0 0 2px rgba(74,163,199,.5), 0 4px 14px rgba(20,30,40,.2); }
.fcard.is-living { background: #f6f8f5; }

.fcard-rel, .fcard-add {
  position: absolute; top: 7px; width: 20px; height: 20px; display: grid; place-items: center;
  color: #5aa9d6; background: none; border: none; cursor: pointer; padding: 0;
}
.fcard-rel { left: 8px; } .fcard-add { right: 8px; font-size: 1.15rem; line-height: 1; }
.fcard-rel svg { width: 17px; height: 17px; fill: currentColor; }
.fcard-add:hover, .fcard-rel:hover { color: #2f87ab; }

.fcard-av { width: 52px; height: 52px; border-radius: 50%; margin: 4px 0 6px; display: grid; place-items: center; background: #e3e7ea; }
.fcard.sex-male .fcard-av   { background: #cdebf7; }
.fcard.sex-female .fcard-av { background: #f7d7e6; }
.fcard-av svg { width: 52px; height: 52px; }
.fcard.sex-male .fcard-av svg   { color: #2f87ab; }
.fcard.sex-female .fcard-av svg { color: #c63f7b; }
.fcard-av svg { color: #8a98a3; }

.fcard-name { font-weight: 700; font-size: .86rem; color: #33424e; line-height: 1.2; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; }
.fcard-years { font-size: .76rem; color: #8d99a4; margin-top: 3px; text-align: center; }
.fcard-code { font-size: .66rem; letter-spacing: .06em; color: #b3bcc4; margin-top: 2px; text-transform: uppercase; }
.fcard-doc { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); width: 20px; height: 20px;
  border: none; background: none; color: #5aa9d6; cursor: pointer; padding: 0; display: grid; place-items: center; }
.fcard-doc svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.fcard-doc:hover { color: #2f87ab; }

/* ---- Chevrons around cards ---- */
.fchev { position: absolute; width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer;
  color: #9fb1bd; background: none; border: none; padding: 0; z-index: 3; }
.fchev svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.fchev:hover { color: #4aa3c7; }
.fchev.up    { top: -26px;   left: 50%; transform: translateX(-50%); }
.fchev.down  { bottom: -26px; left: 50%; transform: translateX(-50%); }
.fchev.left  { left: -26px;  top: 50%; transform: translateY(-50%); }
.fchev.right { right: -26px; top: 50%; transform: translateY(-50%); }

/* ---- Top-bar search ---- */
.tree-search { position: relative; }
.tree-search input { font: inherit; font-size: .9rem; padding: .42rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); width: 220px; background: #fff; }
.tree-search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(185,138,60,.15); }
.tree-search-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; z-index: 60; }
.tree-search-results button { display: block; width: 100%; text-align: left; background: none; border: none; padding: .55rem .8rem; cursor: pointer; font: inherit; }
.tree-search-results button:hover { background: #f3efe6; }
.tree-search-results .sr-name { color: var(--ink); font-weight: 600; font-size: .9rem; }
.tree-search-results .sr-meta { color: var(--muted); font-size: .78rem; }
.tree-search-results .sr-empty { padding: .7rem .8rem; color: var(--muted); font-size: .85rem; }

@media (max-width: 760px) { .tree-search input { width: 150px; } }

/* link-existing controls inside the person modal */
.link-results { margin-top: 8px; display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.link-result { text-align: left; background: #f3efe6; border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; cursor: pointer; font: inherit; }
.link-result:hover { border-color: var(--gold); background: #fff; }
.link-chosen { margin: 10px 0 0; padding: .55rem .7rem; background: var(--ok-bg); border: 1px solid #cfe0d4; border-radius: 6px; color: var(--ok); font-size: .9rem; }
#attachChildrenList .checkline, #childFamilyOptions .checkline { display: flex; gap: .5rem; align-items: center; padding: .25rem 0; }

/* half-sibling connectors (dashed, lighter) */
.ft-link.half { stroke: #c4ced5; stroke-dasharray: 4 5; }

/* ---- GEDCOM tools in the top bar ---- */
.tree-tools { display: flex; align-items: center; gap: 6px; }
.tree-tools .tool-file { cursor: pointer; }

/* ---- source citations in the details drawer ---- */
.dr-citations { margin-top: 18px; }
.cit-list { list-style: none; margin: 0 0 10px; padding: 0; }
.cit-list li { position: relative; padding: 8px 26px 8px 10px; border: 1px solid #e7e2d7; border-radius: 8px; background: #fbf9f4; margin-bottom: 7px; }
.cit-main { font-size: 13px; line-height: 1.45; color: #2c343d; }
.cit-title { font-weight: 600; }
.cit-detail { color: #5a6470; }
.cit-date { color: #8a93a0; }
.cit-url { display: inline-block; margin-top: 3px; font-size: 12px; color: #5e7c72; word-break: break-all; }
.cit-del { position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; line-height: 16px; padding: 0; border: 0; border-radius: 50%; background: #efe7d8; color: #9a6b2f; font-size: 14px; cursor: pointer; }
.cit-del:hover { background: #e3b9a0; color: #7a2d18; }
.cit-add { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cit-add input { width: 100%; padding: 7px 9px; border: 1px solid #d8d2c5; border-radius: 7px; font: inherit; font-size: 13px; background: #fff; }
.cit-add input:focus { outline: none; border-color: #b98a3c; box-shadow: 0 0 0 2px rgba(185,138,60,.18); }
.cit-add .btn { align-self: flex-start; }

/* ===== Member dashboard: people table, person view/edit ===== */
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.search-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.search-inline .input { min-width: 240px; }

.dtable { width: 100%; border-collapse: collapse; background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dtable th, .dtable td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: .9rem; vertical-align: top; }
.dtable thead th { background: #f4f1ea; font-weight: 600; color: #54606c; white-space: nowrap; }
.dtable tbody tr:last-child td { border-bottom: 0; }
.dtable tbody tr:hover { background: #faf8f3; }
.dtable .t-name { font-weight: 600; color: #27313c; }
.dtable .t-sub, .t-sub { color: #98a1ac; font-size: .8rem; }
.dtable .acts { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600; line-height: 1.5; }
.badge.living { background: #e4efe9; color: #3f6f5e; }
.badge.deceased { background: #eef1f4; color: #6b7682; }

.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 10px; flex-wrap: wrap; }
.pager .pg-count { color: var(--muted); font-size: .85rem; }
.pager .pg-links { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pager a, .pager .cur { padding: 6px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; text-decoration: none; color: #4a5560; }
.pager .cur { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager a:hover { border-color: var(--gold); color: var(--ink); }
.pager .pg-gap { padding: 6px 2px; color: var(--muted); }

/* person form */
.fset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 6px; margin: 0 0 16px; }
.fset legend { padding: 0 8px; font-weight: 600; color: var(--gold); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
.fgrid .field-wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .fgrid { grid-template-columns: 1fr; } }

/* person read-only detail */
.detail-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 0; }
.dl-row { display: contents; }
.dl-k { padding: 7px 0; color: #54606c; font-weight: 600; font-size: .85rem; }
.dl-v { padding: 7px 0; color: #232d37; font-size: .92rem; }
@media (max-width: 560px) { .dl { grid-template-columns: 1fr; } .dl-k { padding-bottom: 0; } }
.dupe-note { flex: 1; min-width: 240px; font-size: .85rem; color: var(--muted); background: #faf6ec; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }

/* ===== merge: selection bar, comparison table ===== */
.col-pick { width: 34px; text-align: center; }
.col-pick input { width: 16px; height: 16px; cursor: pointer; }
.merge-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 10px 14px; background: var(--ink); color: #eef2f6; border-radius: 10px; font-size: .88rem; }
.merge-bar strong { color: var(--gold-soft); }

.merge-table th:first-child, .merge-table td:first-child { color: #54606c; font-weight: 600; width: 150px; }
.merge-table .keep-opt { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-weight: 600; color: #27313c; }
.merge-table tr.is-diff td { background: #fbf3e6; }
.merge-table tr.rel-row td { font-size: .82rem; color: var(--muted); }

/* highlight the card currently in focus */
.fcard.is-focus { border-color: #b9c2cb !important; box-shadow: 0 0 0 3px rgba(150,162,173,.35), 0 6px 18px rgba(24,30,40,.12); z-index: 4; }

/* drawer: preserve entered spaces / line breaks in notes & history */
.dr-val.pre { white-space: pre-wrap; }
/* drawer: nested marriage / children rows under a spouse */
.dr-row.dr-sub .dr-label { padding-left: 12px; font-weight: 500; color: #98a1ac; }

/* share page: checkbox rows */
.chk { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; font-size: .92rem; color: #2c343d; cursor: pointer; }
.chk input { width: 16px; height: 16px; margin-top: 2px; }

/* drawer Family: space below parents and between marriages */
.dr-block { margin-bottom: 14px; }
.dr-block:last-child { margin-bottom: 0; }
.dr-marriage { padding-top: 12px; border-top: 1px solid #f1ece1; }

/* ===== alternative tree views ===== */
.view-switch { display: flex; align-items: center; gap: 6px; }
.view-switch .vs-label { font-size: .75rem; color: var(--muted); font-weight: 600; }
#viewSelect { padding: .4rem .6rem; }

/* positioned overlay elements used by several views */
.ft-extra { position: absolute; box-sizing: border-box; }

/* generation view labels */
.gen-label { font-size: .8rem; font-weight: 600; color: #6a7682; text-align: right; padding-right: 10px; border-right: 2px solid var(--line); }

/* timeline */
.tl-year { font-size: .72rem; color: #8a93a0; text-align: center; }
.tl-note { font-size: .95rem; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }

/* relationship path */
.rel-hint, .rel-banner { font-size: .92rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; color: #2c343d; text-align: center; box-shadow: 0 2px 8px rgba(20,30,40,.06); }
.rel-banner { background: #18222e; color: #eef2f6; border-color: #18222e; }
.rel-banner strong { color: var(--gold-soft); }

/* fan chart */
.fan-seg { stroke: #fff; stroke-width: 1.5; cursor: pointer; transition: opacity .12s; }
.fan-seg:hover { opacity: .82; }
.fan-label { fill: #20303a; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: Inter, sans-serif; font-weight: 600; }
.fan-label-light { fill: #fff; }

/* family group sheet */
.gs-sheet { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 22px 26px; box-shadow: 0 4px 18px rgba(20,30,40,.10); font-size: .92rem; }
.gs-sheet h2 { margin: 0 0 14px; font-size: 1.3rem; color: var(--ink); }
.gs-sheet h3 { margin: 18px 0 8px; font-size: 1rem; color: var(--gold); }
.gs-table { width: 100%; border-collapse: collapse; }
.gs-table th { text-align: left; vertical-align: top; width: 90px; padding: 8px 10px 8px 0; color: #54606c; font-weight: 600; border-bottom: 1px solid var(--line); }
.gs-table td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.gs-name { font-weight: 600; color: #27313c; }
.gs-kids { margin: 0; padding-left: 22px; }
.gs-kids li { padding: 3px 0; }
.gs-muted { color: #98a1ac; }

/* ===== dark tree header (matches the site's ink-slate brand chrome) ===== */
.tree-bar .tree-title h1 { color: #f1f4f7; }
.tree-bar .tree-title p { color: #9fb0bf; }
.tree-bar .brand .mark circle { stroke: #fbf8f2; }
.tree-bar .vs-label { color: #9fb0bf; }
.tree-bar .select,
.tree-bar #viewSelect { background: var(--ink-2); color: #eef2f6; border-color: rgba(255,255,255,.16); }
.tree-bar .select option { color: #18222e; background: #fff; }
.tree-bar .tree-search input {
  background: var(--ink-2); color: #eef2f6; border-color: rgba(255,255,255,.16);
}
.tree-bar .tree-search input::placeholder { color: #8a99a8; }
.tree-bar .btn-ghost {
  color: #dbe3ea; background: transparent; border-color: rgba(255,255,255,.18);
}
.tree-bar .btn-ghost:hover { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.32); color: #fff; }
.tree-bar .tool-file { color: #dbe3ea; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* timeline: compact boxes + decade gridlines */
.tl-card { width: 178px; height: 64px; padding: 7px 11px; justify-content: center; }
.tl-card .tl-name { width: 100%; font-size: .82rem; font-weight: 600; color: #232d38; text-align: center; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-card .tl-surname { width: 100%; font-size: .82rem; font-weight: 500; color: #36424e; text-align: center; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-card .tl-by { font-size: .7rem; color: #6a7682; text-align: center; margin-top: 2px; }
.tl-grid { stroke: #ccd5dd; stroke-width: 1; }
.tl-band { fill: #f1efe9; opacity: .6; }
.tl-grid-yr { fill: #8a93a0; font-size: 11px; text-anchor: middle; font-family: Inter, sans-serif; font-weight: 600; }

/* drawer marriage editing */
.dr-muted { color: #98a1ac; }
.dr-rel { color: #b08440; font-weight: 600; font-size: .85em; }
.dr-rel-sel { padding: 3px 8px; font-size: .85rem; min-width: 120px; }
.dr-marr-act { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }

/* ===== documents (drawer) ===== */
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.doc-item { display: flex; align-items: center; gap: 6px; }
.doc-open { flex: 1; display: flex; align-items: center; gap: 10px; text-align: left; background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; cursor: pointer; transition: border-color .12s, box-shadow .12s; min-width: 0; }
.doc-open:hover { border-color: #c4ccd3; box-shadow: 0 2px 8px rgba(20,30,40,.07); }
.doc-thumb { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 8px; overflow: hidden; background: #eef1f4; display: grid; place-items: center; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-ic svg { width: 24px; height: 24px; fill: none; stroke: #6f7c89; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.doc-ic.doc-pdf svg { stroke: #b5532e; }
.doc-ic.doc-word svg { stroke: #2a5699; }
.doc-meta { min-width: 0; display: flex; flex-direction: column; }
.doc-name { font-weight: 600; color: #27313c; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { font-size: .72rem; color: #8a93a0; }
.doc-del { flex: 0 0 auto; width: 26px; height: 26px; border: 1px solid var(--line); background: var(--paper); border-radius: 7px; color: #98a1ac; cursor: pointer; font-size: 1rem; line-height: 1; }
.doc-del:hover { color: #b5532e; border-color: #e3b9a9; }
.doc-add { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.doc-up-label { cursor: pointer; align-self: flex-start; }
.doc-hint { font-size: .72rem; color: #98a1ac; }
.doc-prog { font-size: .8rem; color: var(--gold); }

/* ===== document viewer (OpenSeadragon / PDF) ===== */
.doc-viewer { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: rgba(12,18,24,.92); }
.doc-viewer[hidden] { display: none; }
.doc-viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--ink); color: #eef2f6; }
.doc-viewer-title { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-viewer-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.doc-viewer-bar .btn-ghost { color: #dbe3ea; border-color: rgba(255,255,255,.22); background: transparent; }
.doc-viewer-bar .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.doc-viewer-body { flex: 1; min-height: 0; position: relative; display: flex; }
.doc-osd { flex: 1; min-height: 0; background: #0c1218; }
.doc-osd[hidden] { display: none; }
.doc-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.doc-frame[hidden] { display: none; }
.doc-msg { margin: auto; max-width: 460px; padding: 24px; color: #eef2f6; text-align: center; font-size: 1rem; }
.doc-msg[hidden] { display: none; }
.doc-msg a { color: var(--gold-soft); }

/* ===== onboarding tour ===== */
.page-head-actions { display: flex; gap: 10px; align-items: center; }
body.ob-lock { overflow: hidden; }
.ob-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(12,18,24,.62); backdrop-filter: blur(3px); }
.ob-overlay[hidden] { display: none; }
.ob-modal { position: relative; width: 100%; max-width: 720px; background: var(--paper, #faf8f3); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 70px rgba(12,18,24,.34); overflow: hidden; }
.ob-x { position: absolute; top: 12px; right: 14px; z-index: 2; width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(255,255,255,.7); color: #5a6671; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.ob-x:hover { background: #fff; color: #18222e; }
.ob-stage { position: relative; }
.ob-slide { display: none; }
.ob-slide.is-active { display: block; animation: obFade .25s ease; }
@keyframes obFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ob-art { background: linear-gradient(180deg,#eef1f4,#e3e8ee); padding: 26px 26px 20px; display: flex; justify-content: center; }
.ob-svg { width: 100%; max-width: 520px; height: auto; display: block; filter: drop-shadow(0 10px 24px rgba(20,30,40,.16)); }
.ob-text { padding: 20px 28px 6px; }
.ob-step { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold, #b98a3c); }
.ob-text h3 { margin: 6px 0 8px; font-family: Fraunces, Georgia, serif; font-size: 1.5rem; color: var(--ink, #18222e); }
.ob-body { margin: 0; color: #45525f; font-size: .98rem; line-height: 1.55; }
.ob-body strong { color: #2a3543; }
.ob-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 28px 22px; }
.ob-dots { display: flex; gap: 7px; }
.ob-dot { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: #cdd4db; cursor: pointer; transition: transform .12s, background .12s; }
.ob-dot.is-on { background: var(--gold, #b98a3c); transform: scale(1.35); }
.ob-nav { display: flex; gap: 8px; }
@media (max-width: 560px) {
  .ob-text h3 { font-size: 1.25rem; }
  .ob-art { padding: 18px 16px 14px; }
  .ob-text { padding: 16px 18px 4px; }
  .ob-foot { padding: 14px 18px 18px; flex-direction: column-reverse; align-items: stretch; }
  .ob-nav { justify-content: space-between; }
  .ob-dots { justify-content: center; }
}

/* ---- legal pages (privacy / terms) ---- */
.legal { padding: 56px 0 72px; background: #fbfaf7; }
.legal-wrap { max-width: 760px; margin: 0 auto; }
.legal-eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 700; color: #b98a3c; margin: 0 0 .4rem; }
.legal h1 { font-family: 'Fraunces', Georgia, serif; font-size: 2.1rem; line-height: 1.15; color: #1c2733; margin: 0 0 .35rem; }
.legal-updated { color: #7a8794; font-size: .9rem; margin: 0 0 2rem; }
.legal h2 { font-family: 'Fraunces', Georgia, serif; font-size: 1.28rem; color: #21303d; margin: 2.2rem 0 .6rem; padding-top: 1.1rem; border-top: 1px solid #ebe7df; }
.legal h3 { font-size: 1.02rem; color: #2a3744; margin: 1.3rem 0 .4rem; }
.legal p, .legal li { color: #3c4a57; line-height: 1.72; font-size: 1.005rem; }
.legal p { margin: 0 0 .9rem; }
.legal ul { margin: 0 0 1rem; padding-left: 1.25rem; }
.legal li { margin: .3rem 0; }
.legal a { color: #2f6f57; font-weight: 500; }
.legal a:hover { text-decoration: underline; }
.legal strong { color: #2a3744; }
.legal-contact { background: #fff; border: 1px solid #e7e3da; border-radius: 12px; padding: 1rem 1.1rem; line-height: 1.8; }
.legal-foot { margin-top: 2.4rem; padding-top: 1.2rem; border-top: 1px solid #ebe7df; font-weight: 600; }
@media (max-width: 640px){ .legal { padding: 36px 0 52px; } .legal h1 { font-size: 1.7rem; } }
