/* ==========================================================================
   Family-Tree — design system
   Elegant heritage: parchment, ink, gold leaf, archival serif display.
   ========================================================================== */

:root {
  /* palette — heritage (light) */
  --parchment:   #f7f2e8;
  --parchment-2: #fdfaf4;
  --paper:       #fffdf8;
  --ink:         #24201a;
  --ink-2:       #4a4238;
  --ink-3:       #5e5648;
  --ink-4:       #786e5e;
  --line:        #e3d9c6;
  --line-ink:    #7d6c4a;   /* chart connection lines: dark enough to follow over the sky */
  --union-ink:   #8a6524;   /* the marriage curve, a deeper gold for the same reason */
  --line-2:      #efe7d8;
  --gold:        #b08d4f;
  --gold-2:      #cdae74;
  --gold-soft:   #f3e9d5;
  --sage:        #6a7f6b;
  --sage-soft:   #e7eee6;
  --claret:      #8f4f4f;
  --claret-soft: #f6e8e6;
  --azure:       #4c6b8a;
  --azure-soft:  #e6edf4;

  --bg:        var(--parchment);
  --surface:   var(--paper);
  --surface-2: var(--parchment-2);
  --border:    var(--line);
  --text:      var(--ink);
  --text-2:    var(--ink-2);
  --text-3:    var(--ink-3);
  --text-4:    var(--ink-4);
  --accent:    var(--gold);
  --accent-soft: var(--gold-soft);

  --male:      #4c6b8a;
  --female:    #9a5f78;
  --neutral:   #7c7263;

  /* The backdrop: a bright sky fading into parchment, with foliage at the
     edges. Kept faint on purpose — it should be noticed on arrival and then
     forgotten, never competing with a name on a card. */
  /* The home banner and the sign-in panel. They were painted dark whatever the
     theme, which read as a piece of the night left behind in daylight. */
  --hero-bg-1:  #fffdf8;
  --hero-bg-2:  #f3ead7;
  --hero-ink:   var(--ink);
  --hero-sub:   var(--ink-2);
  --hero-edge:  var(--line);
  --hero-faint: var(--ink-3);
  --hero-accent: #9a7433;              /* gold that still reads on cream */
  --hero-wash-1: rgba(205, 174, 116, .16);
  --hero-wash-2: rgba(106, 127, 107, .13);
  --hero-btn-bg:    rgba(36, 32, 26, .06);
  --hero-btn-edge:  rgba(36, 32, 26, .20);
  --hero-btn-hover: rgba(36, 32, 26, .11);

  --sky-high:  #2a7fd4;   /* overhead, where the blue is deepest */
  --sky-mid:   #6fb4ea;
  --sky-low:   #cbe6f8;   /* toward the horizon it pales */
  --cloud:     #ffffff;
  --cloud-a:   .62;
  --leaf-near: #4e8f37;   /* foliage in front, in full colour */
  --leaf-far:  #8fbf6a;   /* and further back, hazier */
  --leaf-a:    .92;
  --sky-a:     1;

  /* The sun is a warmth in the corner, not a disc to look at: a wide, soft
     glow with only the faintest core, so it lights the page without ever
     competing with anything written on it. */
  --orb-x:     82%;
  --orb-y:     14%;
  --orb-core:  rgba(255, 249, 226, .55);
  --orb-size:  90px;
  --orb-glow:  rgba(255, 232, 173, .38);
  --orb-halo:  460px;
  --star-a:    0;

  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow-1: 0 1px 2px rgba(60,45,20,.06), 0 2px 8px rgba(60,45,20,.05);
  --shadow-2: 0 2px 6px rgba(60,45,20,.07), 0 12px 32px rgba(60,45,20,.09);
  --shadow-3: 0 10px 24px rgba(60,45,20,.10), 0 32px 72px rgba(60,45,20,.16);

  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;

  --sidebar-w: 260px;
  --topbar-h: 66px;
  --ease: cubic-bezier(.2,.7,.3,1);
}

[data-theme="dusk"] {
  --bg:        #171410;
  --surface:   #1f1b16;
  --surface-2: #262119;
  --border:    #37301f;
  --line-ink:  #8d7f5f;
  --union-ink: #cfae6f;
  --text:      #f0e9dc;
  --text-2:    #cabfa9;
  --text-3:    #b7ac95;
  --text-4:    #9a8f79;
  --accent:    #d3b273;
  --accent-soft: #33291a;
  --gold-soft: #33291a;
  --sage-soft: #222a22;
  --claret-soft: #2e211f;
  --azure-soft: #1e262f;
  --male:      #7ba0c6;
  --female:    #c98fa8;
  --neutral:   #b1a48d;

  /* After dark the same scene, lit differently: a deep evening sky and foliage
     that has lost its colour to the light rather than gained a filter. */
  --hero-bg-1:  #322c21;
  --hero-bg-2:  #1a1712;
  --hero-ink:   #f4ecdc;
  --hero-sub:   #c9bfa9;
  --hero-edge:  #3a3225;
  --hero-faint: #8d8371;
  --hero-accent: #cdae74;
  --hero-wash-1: rgba(205, 174, 116, .22);
  --hero-wash-2: rgba(106, 127, 107, .2);
  --hero-btn-bg:    rgba(255, 255, 255, .09);
  --hero-btn-edge:  rgba(255, 255, 255, .18);
  --hero-btn-hover: rgba(255, 255, 255, .16);

  --sky-high:  #0b1c33;
  --sky-mid:   #16304f;
  --sky-low:   #22303a;
  --cloud:     #52698a;
  --cloud-a:   .30;
  /* Moonlight, not shadow. Near-black foliage disappeared entirely against a
     night sky; these are the greens a leaf actually shows under a moon. */
  --leaf-near: #4a7a52;
  --leaf-far:  #355b41;
  --leaf-a:    .82;
  --sky-a:     1;

  /* The moon is a real disc with a halo — the one thing in the scene that
     should be looked at. */
  --orb-x:     84%;
  --orb-y:     13%;
  --orb-core:  rgba(240, 244, 250, .95);
  --orb-size:  54px;
  --orb-glow:  rgba(186, 208, 236, .22);
  --orb-halo:  300px;
  --star-a:    .85;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 2px 6px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.45);
  --shadow-3: 0 12px 28px rgba(0,0,0,.5), 0 40px 80px rgba(0,0,0,.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
}
/* ---------------------------------------------------------------- backdrop
   Sky, cloud and leaves, in two fixed layers behind everything. Both are
   painted with gradients and a masked silhouette rather than a photograph:
   nothing to download, nothing to go stale, and every colour comes from the
   theme, so the scene turns to evening with the rest of the app. */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: var(--sky-a);
  background-image:
    /* cloud banks — several sizes, softest last, so they read as depth.
       They are listed first so they drift in front of the sun or moon. */
    radial-gradient(560px 170px at 18% 12%, color-mix(in srgb, var(--cloud) 92%, transparent), transparent 70%),
    radial-gradient(360px 118px at 27% 18%, color-mix(in srgb, var(--cloud) 80%, transparent), transparent 68%),
    radial-gradient(300px 96px at 11% 20%, color-mix(in srgb, var(--cloud) 70%, transparent), transparent 68%),
    radial-gradient(640px 190px at 72% 8%, color-mix(in srgb, var(--cloud) 88%, transparent), transparent 70%),
    radial-gradient(420px 128px at 62% 16%, color-mix(in srgb, var(--cloud) 74%, transparent), transparent 68%),
    radial-gradient(340px 104px at 88% 19%, color-mix(in srgb, var(--cloud) 66%, transparent), transparent 68%),
    radial-gradient(520px 150px at 44% 44%, color-mix(in srgb, var(--cloud) 46%, transparent), transparent 72%),
    radial-gradient(380px 116px at 82% 56%, color-mix(in srgb, var(--cloud) 38%, transparent), transparent 72%),
    /* the sun or the moon: a core, and the light around it */
    radial-gradient(circle var(--orb-size) at var(--orb-x) var(--orb-y),
      var(--orb-core), transparent 100%),
    radial-gradient(circle var(--orb-halo) at var(--orb-x) var(--orb-y),
      var(--orb-glow), transparent 70%),
    /* stars, which daylight simply turns off */
    radial-gradient(1.6px 1.6px at 12% 9%, rgba(255,255,255,var(--star-a)), transparent 100%),
    radial-gradient(1.4px 1.4px at 23% 22%, rgba(255,255,255,calc(var(--star-a) * .7)), transparent 100%),
    radial-gradient(1.8px 1.8px at 37% 7%, rgba(255,255,255,var(--star-a)), transparent 100%),
    radial-gradient(1.2px 1.2px at 49% 18%, rgba(255,255,255,calc(var(--star-a) * .6)), transparent 100%),
    radial-gradient(1.7px 1.7px at 61% 5%, rgba(255,255,255,calc(var(--star-a) * .9)), transparent 100%),
    radial-gradient(1.3px 1.3px at 68% 26%, rgba(255,255,255,calc(var(--star-a) * .6)), transparent 100%),
    radial-gradient(1.9px 1.9px at 91% 11%, rgba(255,255,255,var(--star-a)), transparent 100%),
    radial-gradient(1.4px 1.4px at 96% 31%, rgba(255,255,255,calc(var(--star-a) * .7)), transparent 100%),
    radial-gradient(1.5px 1.5px at 7% 34%, rgba(255,255,255,calc(var(--star-a) * .5)), transparent 100%),
    radial-gradient(1.3px 1.3px at 44% 37%, rgba(255,255,255,calc(var(--star-a) * .45)), transparent 100%),
    /* and the sky itself, all the way down */
    linear-gradient(to bottom,
      var(--sky-high) 0%,
      var(--sky-mid) 38%,
      var(--sky-low) 74%,
      color-mix(in srgb, var(--sky-low) 55%, var(--bg)) 100%);
}
/* Foliage in the four corners, tinted by the theme through a mask. The two
   overhead boughs are the nearer, fuller ones; the two at the foot sit further
   back and paler, so the page has a front and a distance rather than a border. */
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: var(--leaf-a);
  background-image:
    linear-gradient(var(--leaf-near), var(--leaf-near)),
    linear-gradient(var(--leaf-near), var(--leaf-near)),
    linear-gradient(var(--leaf-far), var(--leaf-far)),
    linear-gradient(var(--leaf-far), var(--leaf-far));
  background-repeat: no-repeat;
  -webkit-mask-image:
    url('/img/leaves-top.svg'), url('/img/leaves-top-right.svg'),
    url('/img/leaves.svg'), url('/img/leaves-right.svg');
  mask-image:
    url('/img/leaves-top.svg'), url('/img/leaves-top-right.svg'),
    url('/img/leaves.svg'), url('/img/leaves-right.svg');
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  /* each drawing already grows from its own corner, so it simply hangs there */
  -webkit-mask-position:
    left -20px top -18px, right -20px top -18px,
    left -20px bottom -18px, right -20px bottom -18px;
  mask-position:
    left -20px top -18px, right -20px top -18px,
    left -20px bottom -18px, right -20px bottom -18px;
  -webkit-mask-size: 40vw auto, 36vw auto, 30vw auto, 26vw auto;
  mask-size: 40vw auto, 36vw auto, 30vw auto, 26vw auto;
  background-size: 40vw 100%, 36vw 100%, 30vw 100%, 26vw 100%;
  background-position:
    left -20px top -18px, right -20px top -18px,
    left -20px bottom -18px, right -20px bottom -18px;
}
@media (max-width: 900px) {
  body::after {
    -webkit-mask-size: 66vw auto, 60vw auto, 50vw auto, 44vw auto;
    mask-size: 66vw auto, 60vw auto, 50vw auto, 44vw auto;
    background-size: 66vw 100%, 60vw 100%, 50vw 100%, 44vw 100%;
  }
}
@media (prefers-reduced-motion: no-preference) {
  body::before, body::after { transition: opacity .4s var(--ease); }
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: .1px; margin: 0; line-height: 1.2; }
h1 { font-size: 2.35rem; }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.22rem; }
h4 { font-size: 1.02rem; font-family: var(--sans); font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ---------------------------------------------------------------- boot */
.app-loading { display: grid; place-items: center; min-height: 100vh; }
.boot { text-align: center; color: var(--accent); animation: fadeUp .6s var(--ease); }
.boot-mark { width: 58px; height: 58px; fill: currentColor; animation: pulse 1.8s ease-in-out infinite; }
.boot p { font-family: var(--serif); font-size: 1.5rem; letter-spacing: .18em; text-transform: uppercase; margin-top: .6rem; color: var(--text-2); }
@keyframes pulse { 0%,100% { opacity: .45; transform: scale(.97) } 50% { opacity: 1; transform: scale(1) } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

/* =====================================================================
   AUTH
   ===================================================================== */
.auth {
  position: relative; z-index: 1; min-height: 100vh;
  display: grid; grid-template-columns: 1.05fr .95fr;
}
.auth-art {
  position: relative; overflow: hidden; padding: 4rem 4.5rem;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(160deg, var(--hero-bg-1), var(--hero-bg-2) 70%);
  color: var(--hero-ink);
}
.auth-art::after {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(600px 400px at 80% 20%, var(--hero-wash-1), transparent 65%),
    radial-gradient(500px 500px at 10% 90%, var(--hero-wash-2), transparent 60%);
}
.auth-art > * { position: relative; z-index: 1; }
.auth-art .brand { display: flex; align-items: center; gap: .7rem; font-family: var(--serif); font-size: 1.35rem; letter-spacing: .12em; text-transform: uppercase; }
.auth-art .brand svg { width: 34px; height: 34px; fill: var(--hero-accent); }
.auth-art h1 { font-size: clamp(2.4rem, 4vw, 3.6rem); max-width: 12ch; margin: 2rem 0 1rem; }
.auth-art h1 em { font-style: italic; color: var(--hero-accent); }
.auth-art .lede { max-width: 46ch; color: var(--hero-sub); font-size: 1.05rem; }
.auth-features { display: grid; gap: .7rem; margin-top: 2rem; max-width: 44ch; }
.auth-features div { display: flex; gap: .7rem; align-items: flex-start; color: var(--hero-sub); font-size: .92rem; }
.auth-features svg { width: 17px; height: 17px; flex: none; margin-top: .25rem; fill: var(--hero-accent); }
.auth-art footer { font-size: .8rem; color: var(--hero-faint); letter-spacing: .05em; }

.auth-panel { display: grid; place-items: center; padding: 3rem 2rem; background: var(--surface); }
.auth-card { width: min(410px, 100%); animation: fadeUp .5s var(--ease); }
.auth-card h2 { font-size: 2rem; margin-bottom: .35rem; }
.auth-card .sub { color: var(--text-3); margin-bottom: 1.8rem; }
.auth-switch { margin-top: 1.4rem; font-size: .9rem; color: var(--text-3); text-align: center; }
.auth-switch button { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; }
.auth-divider { display: flex; align-items: center; gap: 1rem; margin: 1.6rem 0; color: var(--text-3); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

@media (max-width: 940px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 2.5rem 1.75rem; }
  .auth-art h1 { font-size: 2.1rem; margin: 1.2rem 0 .6rem; }
  .auth-features { display: none; }
}

/* =====================================================================
   SHELL
   ===================================================================== */
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; background: transparent; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 1.15rem .85rem 2rem;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--surface) 82%, transparent),
    color-mix(in srgb, var(--surface-2) 78%, transparent));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 1.1rem;
}
.sidebar .brand {
  display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem 0;
  font-family: var(--serif); font-size: 1.16rem; letter-spacing: .13em; text-transform: uppercase; color: var(--text);
}
.sidebar .brand svg { width: 27px; height: 27px; fill: var(--accent); }

.tree-switch {
  width: 100%; display: flex; align-items: center; gap: .6rem; text-align: left;
  padding: .6rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; transition: .18s var(--ease);
}
.tree-switch:hover { border-color: var(--accent); background: var(--accent-soft); }
.tree-switch .tw-icon { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
/* A few faces from the tree, overlapped like photographs in an album. */
.tree-switch .tw-faces { display: flex; flex: none; align-items: center; }
.tree-switch .tw-faces > * { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: var(--shadow-1); }
.tree-switch .tw-faces > * + * { margin-left: -10px; }
.tree-switch:hover .tw-faces > * + * { margin-left: -5px; }
.tree-switch .tw-faces > * { transition: margin-left .18s var(--ease); }
.tree-switch .tw-icon svg { width: 16px; height: 16px; fill: currentColor; }
/* A family name is never abbreviated: it wraps onto a second line instead. */
.tree-switch .tw-name { font-weight: 600; font-size: .87rem; line-height: 1.25; overflow-wrap: anywhere; }
.tree-switch .tw-meta { font-size: .74rem; color: var(--text-3); }
.tree-switch .tw-caret { margin-left: auto; color: var(--text-3); }

/* the running build, quietly under the wordmark */
.brand-build {
  margin: -.55rem 0 .5rem 2.05rem; font-size: .64rem; letter-spacing: .04em;
  color: var(--text-4); font-variant-numeric: tabular-nums; user-select: text;
}

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group-label {
  font-size: .68rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-3); padding: 1rem .8rem .35rem; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .53rem .8rem;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: .885rem; font-weight: 500;
  transition: .15s var(--ease); position: relative;
}
.nav a svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
[data-theme="dusk"] .nav a:hover { background: rgba(255,255,255,.04); }
.nav a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav a.active svg { opacity: 1; color: var(--accent); }
.nav a.active::before { content: ''; position: absolute; left: -.85rem; top: 20%; bottom: 20%; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .badge { margin-left: auto; }

.sidebar-foot { margin-top: auto; display: grid; gap: .5rem; padding-top: 1rem; }
.user-chip {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: var(--radius-sm);
  cursor: pointer; transition: .15s var(--ease); border: 1px solid transparent;
}
.user-chip:hover { border-color: var(--border); background: var(--surface); }
.user-chip .name { font-size: .84rem; font-weight: 600; line-height: 1.2; }
.user-chip .mail { font-size: .72rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 1rem; padding: 0 1.6rem;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar .crumb { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.topbar .crumb small { display: block; font-family: var(--sans); font-size: .72rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.topbar .spacer { flex: 1; }
.searchbox {
  display: flex; align-items: center; gap: .55rem; width: min(360px, 34vw);
  padding: .48rem .8rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-3); cursor: pointer; transition: .18s var(--ease);
}
.searchbox:hover { border-color: var(--accent); color: var(--text-2); }
.searchbox svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.searchbox .kbd { margin-left: auto; }
.kbd {
  font-family: var(--mono); font-size: .68rem; padding: .12rem .38rem; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3);
}
.view { padding: 1.9rem 1.9rem 5rem; max-width: 1500px; width: 100%; animation: fadeIn .25s var(--ease); }
.view.wide { max-width: none; }
.view.flush { padding: 0; }

@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 90; width: 280px; transform: translateX(-102%);
    transition: transform .28s var(--ease); box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: none; }
  .view { padding: 1.2rem 1rem 4rem; }
  .topbar { padding: 0 1rem; }
  .searchbox { width: auto; }
  .searchbox span:not(.kbd) { display: none; }
}
.menu-btn { display: none; }
@media (max-width: 1024px) { .menu-btn { display: inline-flex; } }
.scrim { position: fixed; inset: 0; background: rgba(20,16,10,.45); z-index: 80; animation: fadeIn .2s; }

/* =====================================================================
   PRIMITIVES
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .55rem 1.05rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: .17s var(--ease); white-space: nowrap; text-decoration: none;
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-color: var(--gold); color: #fff; box-shadow: var(--shadow-1); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn.danger { color: var(--claret); }
.btn.danger:hover { background: var(--claret-soft); border-color: var(--claret); }
.btn.sm { padding: .34rem .72rem; font-size: .8rem; }
.btn.icon { padding: .5rem; border-radius: 50%; }
.btn.icon.sm { padding: .32rem; }
.btn.block { width: 100%; }
.btn.lg { padding: .75rem 1.5rem; font-size: .95rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.card.pad { padding: 1.25rem 1.35rem; }
.card-head {
  display: flex; align-items: center; gap: .75rem; padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { flex: 1; }
.card-head .sub { font-size: .8rem; color: var(--text-3); }
.card-body { padding: 1.15rem 1.35rem; }
.card-body.tight { padding: .5rem .6rem; }

.grid { display: grid; gap: 1.15rem; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 1.15rem; }
.muted { color: var(--text-3); }
.tiny { font-size: .78rem; }
.small { font-size: .86rem; }
.serif { font-family: var(--serif); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }

.page-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 2.1rem; }
.page-head .lede { color: var(--text-3); max-width: 60ch; margin: .25rem 0 0; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem;
  border-radius: 999px; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge.gold { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.sage { background: var(--sage-soft); color: var(--sage); border-color: transparent; }
.badge.claret { background: var(--claret-soft); color: var(--claret); border-color: transparent; }
.badge.azure { background: var(--azure-soft); color: var(--azure); border-color: transparent; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: .8rem; cursor: pointer;
  transition: .15s var(--ease);
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }

.field { display: grid; gap: .3rem; margin-bottom: .9rem; }
.field > label { font-size: .78rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.field .hint { font-size: .75rem; color: var(--text-3); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: .58rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); transition: .16s var(--ease);
}
[data-theme="dusk"] input, [data-theme="dusk"] select, [data-theme="dusk"] textarea { background: var(--surface-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 82px; line-height: 1.55; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5L6 8.5L10 4.5' stroke='%237c7263' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 620px) { .field-row { grid-template-columns: 1fr; } }
.switch { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-size: .875rem; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; transition: .2s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: left; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); font-weight: 600; padding: .6rem .8rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.table td { padding: .62rem .8rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
[data-theme="dusk"] .table td { border-bottom-color: var(--border); }
.table tbody tr { transition: background .14s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.clickable { cursor: pointer; }

.empty { text-align: center; padding: 3.5rem 1.5rem; color: var(--text-3); }
.empty svg { width: 46px; height: 46px; fill: none; stroke: currentColor; stroke-width: 1.3; opacity: .5; margin-bottom: .8rem; }
.empty h3 { font-family: var(--serif); color: var(--text-2); margin-bottom: .35rem; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* avatars */
.avatar {
  border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
  display: grid; place-items: center; font-family: var(--serif); font-weight: 600; color: var(--text-3);
  overflow: hidden;
}
.avatar.sq { border-radius: var(--radius-sm); }
.avatar.male   { box-shadow: 0 0 0 1px var(--male); }
.avatar.female { box-shadow: 0 0 0 1px var(--female); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* =====================================================================
   TOASTS · MODALS · PALETTE
   ===================================================================== */
/* ------------------------------------------------- phonetic typing popup */
.translit-box {
  position: fixed; z-index: 320; min-width: 190px; max-width: 340px; padding: .3rem;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--shadow-3); animation: fadeUp .14s var(--ease);
}
.translit-opt {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: inherit;
  padding: .38rem .6rem; border: 0; background: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 1.12rem; line-height: 1.5; color: var(--text);
}
.translit-opt.on, .translit-opt:hover { background: var(--accent-soft); }
.translit-num {
  margin-inline-start: auto; font-size: .66rem; font-family: var(--mono);
  color: var(--text-3); border: 1px solid var(--border); border-radius: 4px; padding: 0 .28rem;
}
.translit-hint {
  font-size: .68rem; color: var(--text-3); padding: .35rem .6rem .2rem;
  border-top: 1px solid var(--border); margin-top: .25rem;
}

/* ------------------------------------------------------ right-to-left ---- */
[dir="rtl"] .nav a.active::before { left: auto; right: -.85rem; border-radius: 3px 0 0 3px; }
[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--border); }
[dir="rtl"] .fact { grid-template-columns: 150px 1fr auto; }
[dir="rtl"] .timeline { padding-left: 0; padding-right: 2.2rem; }
[dir="rtl"] .timeline::before { left: auto; right: .62rem; }
[dir="rtl"] .tl-item::before { left: auto; right: -1.93rem; }
[dir="rtl"] .bar-row .n { text-align: left; }
[dir="rtl"] .toasts { right: auto; left: 1.4rem; }
[dir="rtl"] .add-close { right: auto; left: 1rem; top: 4.6rem; }
[dir="rtl"] .node::before { left: auto; right: 0; border-radius: 0 12px 12px 0; }
[dir="rtl"] .node-edit { right: auto; left: 6px; }
@media (max-width: 1024px) {
  [dir="rtl"] .sidebar { transform: translateX(102%); }
  [dir="rtl"] .sidebar.open { transform: none; }
}
/* charts stay left-to-right: a family tree is not a sentence */
.tree-stage, .tree-canvas, .fan-wrap, .add-layer { direction: ltr; }
/* scripts that need a little more room to breathe */
[data-lang="ta"], [data-lang="ml"], [data-lang="te"], [data-lang="kn"] { --serif: 'Cormorant Garamond', Georgia, serif; }
[data-lang="ta"] body, [data-lang="ml"] body, [data-lang="te"] body, [data-lang="kn"] body { line-height: 1.75; }
/* …but a chart card is a fixed height, so its three lines keep their own
   spacing rather than inheriting the page's generous one. */
.node .nn, .node .nd, .node .np { line-height: 1.38; }
/* Tamil, Malayalam, Telugu and Kannada hang marks below the line; a shade more
   room stops the place name being shaved off at the bottom. */
[data-lang="ta"] .node .nn, [data-lang="ml"] .node .nn,
[data-lang="te"] .node .nn, [data-lang="kn"] .node .nn { line-height: 1.42; }
[data-lang="ar"] .node .nn, [data-lang="ur"] .node .nn { line-height: 1.5; }
[data-lang="ar"] body, [data-lang="ur"] body { line-height: 1.9; }
[data-lang="ur"] { font-family: 'Noto Nastaliq Urdu', var(--sans); }

.toasts { position: fixed; bottom: 1.4rem; right: 1.4rem; z-index: 300; display: grid; gap: .6rem; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: .7rem; padding: .8rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2); font-size: .875rem;
  animation: toastIn .3s var(--ease);
}
.toast.ok { border-left-color: var(--sage); }
.toast.err { border-left-color: var(--claret); }
.toast .x { margin-left: auto; cursor: pointer; color: var(--text-3); background: none; border: 0; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px) } to { opacity: 1; transform: none } }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(28,22,12,.45);
  backdrop-filter: blur(3px); display: grid; place-items: center; padding: 1.5rem;
  animation: fadeIn .18s;
}
.modal {
  /* deliberately short: the essentials sit above the fold, the rest is a scroll away */
  width: min(680px, 100%); max-height: 74vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3); animation: modalIn .26s var(--ease); overflow: hidden;
}
.modal.wide { width: min(1000px, 100%); }
.modal.narrow { width: min(440px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.985) } to { opacity: 1; transform: none } }
.modal header { display: flex; align-items: center; gap: .8rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); }
.modal header h3 { flex: 1; }
/* Soft shadows at the edges appear only while there is more to scroll to,
   so it is always obvious that Death, Life and Notes are waiting below. */
.modal .body {
  padding: 1.3rem 1.4rem; overflow: auto; overscroll-behavior: contain;
  background:
    linear-gradient(var(--surface) 30%, transparent) top    / 100% 26px no-repeat local,
    linear-gradient(transparent, var(--surface) 70%) bottom / 100% 26px no-repeat local,
    radial-gradient(farthest-side at 50% 0,   rgba(60,45,20,.16), transparent) top    / 100% 11px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(60,45,20,.16), transparent) bottom / 100% 11px no-repeat scroll;
}
[data-theme="dusk"] .modal .body {
  background:
    linear-gradient(var(--surface) 30%, transparent) top    / 100% 26px no-repeat local,
    linear-gradient(transparent, var(--surface) 70%) bottom / 100% 26px no-repeat local,
    radial-gradient(farthest-side at 50% 0,   rgba(0,0,0,.5), transparent) top    / 100% 11px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.5), transparent) bottom / 100% 11px no-repeat scroll;
}
.modal footer { display: flex; gap: .6rem; justify-content: flex-end; padding: 1rem 1.4rem; border-top: 1px solid var(--border); background: var(--surface-2); }

.palette-backdrop { position: fixed; inset: 0; z-index: 250; background: rgba(28,22,12,.4); backdrop-filter: blur(3px); display: flex; justify-content: center; padding-top: 12vh; animation: fadeIn .15s; }
.palette { width: min(620px, 92vw); height: fit-content; max-height: 66vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); overflow: hidden; animation: modalIn .2s var(--ease); }
.palette input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 1rem 1.2rem; font-size: 1.05rem; background: transparent; }
.palette input:focus { box-shadow: none; border-color: var(--border); }
.palette .results { overflow: auto; padding: .4rem; }
.palette .res {
  display: flex; align-items: center; gap: .75rem; padding: .55rem .8rem; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .9rem;
}
.palette .res.sel, .palette .res:hover { background: var(--accent-soft); }
.palette .res .k { margin-left: auto; font-size: .7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .1em; }
.palette .group { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); padding: .7rem .8rem .3rem; font-weight: 600; }

.dropdown {
  position: fixed; z-index: 150; min-width: 220px; padding: .35rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-3); animation: fadeUp .16s var(--ease);
}
.dropdown .dd-body { overflow-y: auto; overscroll-behavior: contain; }
.dropdown button, .dropdown a {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
  padding: .5rem .7rem; border: 0; background: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .875rem; color: inherit;
}
.dropdown button:hover, .dropdown a:hover { background: var(--accent-soft); }
.dropdown hr { border: 0; border-top: 1px solid var(--border); margin: .35rem .2rem; }
.dropdown svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; opacity: .75; }
.dropdown .group {
  font-size: .66rem; letter-spacing: .15em; text-transform: uppercase; font-weight: 700;
  color: var(--text-3); padding: .55rem .6rem .3rem;
}
.dropdown .dd-body > .group:first-child { padding-top: .25rem; }
/* little arrow pointing back at whatever opened the menu */
.dd-arrow {
  position: absolute; width: 11px; height: 11px; top: -6px; z-index: 1;
  background: var(--surface); border-left: 1px solid var(--border); border-top: 1px solid var(--border);
  transform: rotate(45deg); border-radius: 2px 0 0 0; transition: opacity .12s;
}
.dropdown.flipped .dd-arrow { top: auto; bottom: -6px; transform: rotate(225deg); }

/* ghost cards for "add a relative" — a silhouette waiting to be filled in */
.dropdown.ghost-menu { min-width: 250px; padding: .45rem; }
.ghost-item {
  gap: .65rem !important; padding: .4rem .55rem !important; margin-bottom: 3px;
  border: 1px solid var(--border) !important; border-radius: 11px !important;
  background: var(--surface) !important; font-weight: 600 !important;
  transition: .16s var(--ease);
}
.ghost-item:hover { border-color: var(--accent) !important; background: var(--accent-soft) !important; transform: translateX(2px); }
.ghost-av {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-3);
  border: 1px dashed var(--border);
}
.ghost-av svg { opacity: 1; }
.ghost-item.m .ghost-av { border-color: var(--male); color: var(--male); }
.ghost-item.f .ghost-av { border-color: var(--female); color: var(--female); }
.ghost-item.x .ghost-av { border-color: var(--accent); color: var(--accent); }
.ghost-item.m:hover { border-color: var(--male) !important; }
.ghost-item.f:hover { border-color: var(--female) !important; }

/* =====================================================================
   DASHBOARD
   ===================================================================== */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius-lg);
  padding: 2.3rem 2.4rem; margin-bottom: 1.5rem; color: var(--hero-ink);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--hero-bg-1) 94%, transparent) 0%,
    color-mix(in srgb, var(--hero-bg-2) 92%, transparent) 100%);
  border: 1px solid var(--hero-edge);
  box-shadow: var(--shadow-2);
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(700px 340px at 88% 10%, rgba(205,174,116,.28), transparent 62%),
              radial-gradient(500px 320px at 6% 110%, rgba(106,127,107,.22), transparent 60%);
}
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.hero h1 { font-size: clamp(1.9rem, 3.4vw, 2.9rem); margin: .5rem 0 .5rem; }
.hero p { color: var(--hero-sub); max-width: 58ch; margin: 0; }
.hero .hero-actions { margin-top: 1.5rem; display: flex; gap: .6rem; flex-wrap: wrap; }
/* The banner's own buttons. They used to be white-on-transparent, which only
   works on a dark panel — on the daylight one they all but vanished. Both the
   tint and the ink now come from the theme. */
.hero .btn {
  background: var(--hero-btn-bg); border-color: var(--hero-btn-edge); color: var(--hero-ink);
}
.hero .btn:hover { background: var(--hero-btn-hover); border-color: var(--hero-accent); }
.hero .btn.primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-color: transparent; color: #241f16;
}

.stat {
  padding: 1.15rem 1.3rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1); position: relative; overflow: hidden;
  transition: .2s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.stat .k { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.stat .v { font-family: var(--serif); font-size: 2.2rem; font-weight: 600; line-height: 1.1; margin-top: .25rem; }
.stat .d { font-size: .78rem; color: var(--text-3); }
.stat .spark { position: absolute; right: 0; bottom: 0; opacity: .16; width: 90px; height: 46px; }

.list-row {
  display: flex; align-items: center; gap: .8rem; padding: .65rem .8rem; border-radius: var(--radius-sm);
  transition: .14s var(--ease); cursor: pointer;
}
.list-row:hover { background: var(--surface-2); }
.list-row .t { font-weight: 600; font-size: .89rem; line-height: 1.3; }
.list-row .s { font-size: .78rem; color: var(--text-3); }
.list-row .r { margin-left: auto; text-align: right; font-size: .78rem; color: var(--text-3); white-space: nowrap; }

.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }

/* =====================================================================
   PERSON CARDS & TREE CHART
   ===================================================================== */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 1rem; }
.person-card {
  display: flex; gap: .85rem; align-items: center; padding: .85rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: .18s var(--ease); box-shadow: var(--shadow-1); position: relative;
}
.person-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-2); }
.person-card .nm { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; line-height: 1.2; }
.person-card .dt { font-size: .78rem; color: var(--text-3); }
.person-card .oc { font-size: .74rem; color: var(--text-3); font-style: italic; }
.person-card .fav { position: absolute; top: .5rem; right: .6rem; color: var(--gold); }

.tree-stage {
  position: relative; height: calc(100vh - var(--topbar-h)); overflow: hidden;
  /* the dotted paper keeps its texture but lets the sky through behind it */
  background:
    radial-gradient(circle at 1px 1px,
      color-mix(in srgb, var(--border) 55%, transparent) 1px, transparent 0) 0 0 / 26px 26px,
    color-mix(in srgb, var(--bg) 46%, transparent);
  cursor: grab; touch-action: none;
}
.tree-stage.grabbing { cursor: grabbing; }
/* above .tree-dim, so the lit card and the ghost cards are never veiled */
/* `will-change: transform` promotes the canvas to its own layer, which the
   browser rasterises once and then stretches — so scaling it turns every letter
   to mush. The hint is only worn while a pan or zoom is actually in flight; the
   moment it settles the layer is given up and the text is drawn again crisply at
   the new size. */
.tree-canvas { position: absolute; top: 0; left: 0; z-index: 1; transform-origin: 0 0; }
.tree-canvas.moving { will-change: transform; }
.tree-toolbar {
  position: absolute; top: 1rem; left: 1rem; right: 1rem; z-index: 20;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; pointer-events: none;
}
.tree-toolbar > * { pointer-events: auto; }
.toolbar-group {
  display: flex; align-items: center; gap: .2rem; padding: .25rem;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow-1);
}
.toolbar-group .btn { border: 0; background: transparent; }
.toolbar-group .btn.on { background: var(--accent-soft); color: var(--accent); }
.tree-legend {
  position: absolute; bottom: 1rem; left: 1rem; z-index: 20; display: flex; gap: .9rem;
  padding: .5rem .9rem; font-size: .74rem; color: var(--text-3);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid var(--border); border-radius: 999px;
}
.tree-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }

.node {
  position: absolute;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-1); cursor: pointer; transition: box-shadow .18s, border-color .18s, transform .18s;
  overflow: visible;
}
.node-body {
  display: flex; align-items: center; gap: .65rem; padding: .5rem .8rem;
  height: 100%; overflow: hidden; border-radius: 12px;
}
.node:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-1px); z-index: 5; }
.node.root { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-2); }
.node.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.node::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--neutral); border-radius: 12px 0 0 12px;
}

/* hover affordances: edit pencil, add-relative bubble, branch toggle */
.node-btn {
  position: absolute; z-index: 6; display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-3); cursor: pointer; opacity: 0;
  transition: opacity .16s var(--ease), color .16s, border-color .16s, background .16s, transform .16s;
}
.node:hover .node-btn, .node-btn:focus-visible { opacity: 1; }
.node-edit { right: 6px; bottom: 5px; width: 22px; height: 22px; }
.node-edit:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.node-add { width: 26px; height: 26px; box-shadow: var(--shadow-1); }
/* A curved tongue drawn out of the bottom of the card, the way a branch grows
   out of a trunk. Always visible, so adding family never has to be discovered. */
.node-add.below {
  /* under the portrait, where the eye already is — not the middle of the card */
  left: 32px; bottom: -21px; transform: translateX(-50%);
  width: 46px; height: 22px; opacity: 1;
  border-radius: 0 0 23px 23px / 0 0 22px 22px;
  border-top: none; border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  /* The tongue starts as the card and warms into gold as it hangs away from it,
     so at rest it reads as part of the card growing downwards rather than a
     control stuck underneath. Hovering fills it in properly. */
  background: linear-gradient(to bottom,
    var(--surface) 0%,
    color-mix(in srgb, var(--accent-soft) 88%, var(--surface)) 55%,
    color-mix(in srgb, var(--accent) 34%, var(--accent-soft)) 100%);
  color: color-mix(in srgb, var(--accent) 78%, var(--text-2));
  box-shadow: 0 7px 12px -8px rgba(60, 45, 20, .45);
  align-items: center; padding-bottom: 2px;
  transition: background .18s var(--ease), color .16s, border-color .16s, transform .16s;
}
.node-add.side  { right: -13px; top: 50%; transform: translateY(-50%); }
.node-add:hover {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.node-add.below:hover { background: linear-gradient(to bottom, var(--accent-2, var(--accent)), var(--accent)); }
.node-add.below:hover { transform: translateX(-50%) translateY(2px); }
[dir="rtl"] .node-add.below { left: auto; right: 32px; transform: translateX(50%); }
[dir="rtl"] .node-add.below:hover { transform: translateX(50%) translateY(2px); }
.node-add.side:hover  { transform: translateY(-50%) scale(1.14); }

/* Two small wings above a card: click to walk into that person's own branch. */
/* Two small wings resting on the top edge of a card. Anchored to the edge
   itself rather than nudged with a negative offset, so there is no doubt which
   side they belong to — and always in view, so they can be aimed at without the
   pointer having to stay on the card. */
.node-wings {
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; align-items: center; padding: 4px 6px;
  background: none; border: none; cursor: pointer; opacity: .62; z-index: 8;
  transition: opacity .16s var(--ease);
}
.node:hover .node-wings, .node-wings:hover, .node-wings:focus-visible { opacity: 1; }
.node-wings i {
  display: block; width: 18px; height: 9px; border-radius: 999px;
  background: var(--line-ink);
  transition: background .16s, transform .16s var(--ease), box-shadow .16s;
}
.node-wings:hover i { background: var(--accent); box-shadow: 0 1px 5px var(--accent-soft); }
.node-wings:hover i:first-child { transform: translateX(-2px); }
.node-wings:hover i:last-child  { transform: translateX(2px); }

/* ---- a dashed card standing where a missing relative would go */
.node-ghost {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .34rem; padding: 0 .4rem; z-index: 2;
  margin: 0; text-align: center; -webkit-appearance: none; appearance: none;
  background: transparent; border: 2px dashed var(--line-ink); border-radius: 12px;
  color: var(--text-3); font: inherit; font-size: .84rem; font-weight: 600;
  cursor: pointer; box-shadow: none;
  transition: border-color .16s var(--ease), color .16s var(--ease), background .16s var(--ease);
}
.node-ghost::before { content: none; }
.node-ghost .ng-plus {
  display: grid; place-items: center; width: 24px; height: 24px; flex: none;
  border-radius: 50%; border: 2px dashed currentColor;
}
.node-ghost .ng-label { font-size: .8rem; }
.node-ghost .ng-label {
  /* a short word in most languages, but it may fold rather than be cut off */
  line-height: 1.2; text-align: center; overflow-wrap: anywhere; max-width: 100%;
}
.node-ghost:hover {
  border-color: var(--accent); color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}
.tree-links path.ghost { stroke: var(--line-ink); stroke-width: 1.6; stroke-dasharray: 4 5; opacity: .6; }

/* A birthday within the next two months earns a badge on the card. */
.node-cake {
  position: absolute; top: -12px; right: -11px; width: 27px; height: 27px;
  display: grid; place-items: center; border-radius: 50%; z-index: 7;
  background: var(--claret-soft); color: var(--claret);
  border: 1px solid color-mix(in srgb, var(--claret) 35%, transparent);
  box-shadow: var(--shadow-1);
}
.node-cake.today { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Shared hover bubble for the chart's small controls. */
/* A tooltip needs its host to be a positioning context — but plenty of hosts
   already are, and an attribute selector outranks nothing: declared here, after
   the components, `[data-tip]` quietly turned every card and badge that carries
   a tooltip from `absolute` into `relative`, so they fell back into document
   flow and stacked one below another. `:where()` carries no specificity at all,
   so any component rule wins no matter where it is written. */
:where([data-tip]) { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  padding: .45rem .7rem; border-radius: 11px; white-space: pre; text-align: center;
  font-family: var(--sans); font-size: .76rem; font-weight: 500; line-height: 1.4;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-2);
  z-index: 40; pointer-events: none;
}

.node-toggle {
  position: absolute; z-index: 6; height: 22px; min-width: 22px; padding: 0 .4rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .1rem;
  border-radius: 999px; border: 1px solid var(--accent); background: var(--accent-soft);
  color: var(--accent); font-size: .7rem; font-weight: 700; font-variant-numeric: tabular-nums;
  cursor: pointer; box-shadow: var(--shadow-1);
  transition: background .16s, color .16s, transform .16s, opacity .16s;
}
/* The top edge carries everything that is *about* the card — how many relatives
   are hidden, the way into this person's branch, a birthday coming up — reading
   left to right above the portrait, the wings, then the badge. The bottom edge
   is left to the one thing that changes the tree: the + . */
.node-toggle.right, .node-toggle.below {
  left: 30px; top: -11px; right: auto; bottom: auto; transform: translateX(-50%);
}
.node-toggle:hover { background: var(--accent); color: #fff; }
.node-toggle.right:hover, .node-toggle.below:hover { transform: translateX(-50%) scale(1.1); }
[dir="rtl"] .node-toggle.right, [dir="rtl"] .node-toggle.below {
  left: auto; right: 30px; transform: translateX(50%);
}
[dir="rtl"] .node-toggle.right:hover, [dir="rtl"] .node-toggle.below:hover { transform: translateX(50%) scale(1.1); }
/* the "hide this branch" variant stays quiet until the card is hovered */
.node-toggle.collapse { opacity: 0; background: var(--surface); border-color: var(--border); color: var(--text-3); }
.node:hover .node-toggle.collapse { opacity: 1; }
.node-toggle.collapse:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.node.m::before { background: var(--male); }
.node.f::before { background: var(--female); }
.node .nn { font-family: var(--serif); font-size: 1.04rem; font-weight: 700; letter-spacing: .1px; color: var(--text); line-height: 1.3; padding-top: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .nd { font-size: .76rem; font-weight: 500; line-height: 1.4; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .np { font-size: .72rem; font-weight: 500; line-height: 1.4; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node.ghost { border-style: dashed; opacity: .8; justify-content: center; color: var(--text-3); font-size: .8rem; }
.node.ghost:hover { opacity: 1; color: var(--accent); }


/* a quiet note when an edit will be filed under a language rather than replace
   what was originally typed */
.lang-note {
  display: flex; flex-direction: column; gap: .15rem; margin-bottom: 1rem;
  padding: .6rem .8rem; border-radius: var(--radius-sm);
  background: var(--accent-soft); border: 1px solid var(--border);
  font-size: .8rem; color: var(--text-2);
}
.lang-note strong { color: var(--accent); font-size: .84rem; }

/* ---- dates: a calendar beside the field, never instead of it -------------- */
.field.has-picker { position: relative; }
.field.has-picker input { padding-right: 2.4rem; }
.date-pick {
  position: absolute; right: .5rem; top: 2.05rem; width: 28px; height: 28px;
  display: grid; place-items: center; padding: 0; cursor: pointer;
  background: none; border: none; border-radius: 8px; color: var(--text-3);
  transition: color .15s var(--ease), background .15s var(--ease);
}
.date-pick:hover { color: var(--accent); background: var(--accent-soft); }
[dir="rtl"] .date-pick { right: auto; left: .5rem; }
[dir="rtl"] .field.has-picker input { padding-right: .75rem; padding-left: 2.4rem; }
/* how the typed date was understood — reassurance, not an error */
.date-reads { font-size: .72rem; color: var(--text-3); margin-top: .28rem; min-height: 1em; }
.date-reads.unclear { color: var(--claret); }

.date-pop {
  position: fixed; z-index: 300; width: 260px; padding: .6rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-3);
  animation: fadeIn .12s var(--ease);
}
.dp-head { display: flex; align-items: center; gap: .3rem; margin-bottom: .4rem; }
.dp-nav {
  width: 28px; height: 28px; flex: none; border-radius: 8px; cursor: pointer;
  background: none; border: 1px solid transparent; color: var(--text-2); font-size: 1rem;
}
.dp-nav:hover { border-color: var(--border); background: var(--surface-2); }
.dp-title {
  flex: 1; text-align: center; font-family: var(--serif); font-size: 1rem; font-weight: 600;
  background: none; border: none; cursor: pointer; color: var(--text); border-radius: 8px; padding: .2rem;
}
.dp-title:hover { background: var(--accent-soft); color: var(--accent); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd { display: grid; place-items: center; height: 24px; font-size: .68rem; color: var(--text-4); }
.dp-day {
  height: 30px; border-radius: 8px; border: 1px solid transparent; background: none;
  cursor: pointer; font-size: .82rem; color: var(--text); font-variant-numeric: tabular-nums;
}
.dp-day:hover { background: var(--accent-soft); color: var(--accent); }
.dp-day.on { background: var(--accent); color: #fff; font-weight: 600; }
.dp-years { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.dp-year {
  height: 30px; border-radius: 8px; border: 1px solid transparent; background: none;
  cursor: pointer; font-size: .8rem; color: var(--text); font-variant-numeric: tabular-nums;
}
.dp-year:hover { background: var(--accent-soft); color: var(--accent); }
.dp-year.on { background: var(--accent); color: #fff; font-weight: 600; }
.dp-foot { display: flex; gap: .4rem; margin-top: .5rem; }
.dp-foot .btn { flex: 1; justify-content: center; }

/* ---- resting on a card lights that person's direct line, and only that line */
.tree-stage.lineage .node { opacity: .32; transition: opacity .16s var(--ease); }
.tree-stage.lineage .node.lit { opacity: 1; }
.tree-stage.lineage .node.lit { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-2); }
.tree-stage.lineage .node.hot { box-shadow: 0 0 0 3px var(--accent), var(--shadow-2); z-index: 6; }
.tree-links path { transition: stroke .16s var(--ease), fill .16s var(--ease), stroke-width .16s var(--ease), opacity .16s var(--ease); }
.tree-stage.lineage .tree-links path { opacity: .22; }
.tree-stage.lineage .tree-links path.lit { opacity: 1; stroke: var(--accent); stroke-width: 3.2; }
/* add mode has its own dimming; the two must not fight */
.tree-stage.adding .node.lit, .tree-stage.adding .node.hot { box-shadow: none; }

/* ---- "add a relative" mode: dim the tree, float ghost cards round one card */
.tree-dim {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: rgba(18, 14, 9, .58); opacity: 0; transition: opacity .22s var(--ease);
}
.tree-stage.adding .tree-dim { opacity: 1; }
.tree-stage.adding .node { opacity: .2; pointer-events: none; transition: opacity .22s var(--ease); }
.tree-stage.adding .node .node-btn,
.tree-stage.adding .node .node-toggle { display: none; }
.tree-stage.adding .node.add-focus {
  opacity: 1; z-index: 8;
  box-shadow: 0 0 0 3px var(--accent), 0 12px 38px rgba(0, 0, 0, .5);
}
.tree-stage.adding .tree-links { opacity: .18; }
.add-layer { position: absolute; inset: 0; z-index: 9; }

.ghost-card {
  position: absolute; width: 200px; min-height: 56px; box-sizing: border-box;
  display: flex; align-items: center; gap: .65rem; padding: .5rem .7rem;
  background: var(--surface); border: 2px solid var(--border); border-radius: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease);
  animation: ghostIn .26s var(--ease) backwards;
}
.ghost-card:hover { transform: translateY(-3px) scale(1.035); box-shadow: 0 16px 42px rgba(0, 0, 0, .45); }
.ghost-card.m { border-color: var(--male); }
.ghost-card.f { border-color: var(--female); }
.ghost-card.x { border-color: var(--accent); }
.gc-av {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: 1px dashed var(--border); color: var(--text-3);
}
.ghost-card.m .gc-av { color: var(--male); border-color: var(--male); }
.ghost-card.f .gc-av { color: var(--female); border-color: var(--female); }
.ghost-card.x .gc-av { color: var(--accent); border-color: var(--accent); }
.gc-t { font-weight: 700; font-size: .88rem; line-height: 1.25; }
.gc-s { font-size: .72rem; color: var(--text-3); line-height: 1.25; }
@keyframes ghostIn { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: none; } }

/* sits clear of the chart toolbar above it */
.add-close {
  position: absolute; top: 4.6rem; right: 1rem; z-index: 30;
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem 1rem; border-radius: 999px; font-weight: 600; font-size: .875rem;
  border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .12);
  color: #f4ede1; cursor: pointer; backdrop-filter: blur(8px); transition: .16s var(--ease);
}
.add-close:hover { background: rgba(255, 255, 255, .24); }
.add-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.tree-links { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.tree-links path { fill: none; stroke: var(--line-ink); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
/* a wide invisible twin of each line, purely to be pointed at */
.tree-links path.hit { stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.tree-stage.lineage .tree-links path.hit { opacity: 1; }
.tree-links path.hl { stroke: var(--accent); stroke-width: 2.4; }
.tree-links path.union { stroke: var(--union-ink); stroke-width: 2.8; stroke-dasharray: 0; stroke-linecap: round; }
/* the small dot where the joint meets each card */

.fan-wrap { display: grid; place-items: center; padding: 1rem; }
/* the fan hangs on a stage like the tree, so it pans and zooms the same way */
.fan-stage { display: block; padding: 0; cursor: grab; }
.fan-stage.grabbing { cursor: grabbing; }
.fan-stage .tree-canvas { display: block; }
/* An unknown ancestor: a dashed wedge that offers to be filled. It stays quiet
   until approached, then warms up like the dashed cards on the tree do. */
.fan-gap { transition: fill-opacity .18s var(--ease), stroke-width .18s var(--ease); }
.fan-gap:hover { fill: var(--accent-soft); fill-opacity: 1; stroke-width: 2.2; }
.fan-gap-label { transition: fill-opacity .18s var(--ease); }
.fan svg text { font-family: var(--serif); }
.fan path { transition: filter .15s; cursor: pointer; }
.fan path:hover { filter: brightness(1.08); }

/* =====================================================================
   PERSON PROFILE
   ===================================================================== */
.profile-hero {
  display: flex; gap: 1.6rem; align-items: flex-end; padding: 1.9rem 2rem 1.5rem;
  border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-1); position: relative; overflow: hidden; margin-bottom: 1.3rem;
}
.profile-hero::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 108px;
  background: linear-gradient(120deg, var(--accent-soft), var(--sage-soft));
}
.profile-hero > * { position: relative; }
.profile-hero .avatar { width: 118px; height: 118px; font-size: 2.2rem; border-width: 4px; }
.profile-hero h1 { font-size: 2.15rem; }
.profile-hero .meta { display: flex; gap: 1rem; flex-wrap: wrap; color: var(--text-3); font-size: .87rem; margin-top: .35rem; }
.profile-hero .meta span { display: inline-flex; align-items: center; gap: .35rem; }
.profile-hero .acts { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; align-self: flex-start; padding-top: .4rem; }
@media (max-width: 720px) { .profile-hero { flex-direction: column; align-items: flex-start; } .profile-hero .acts { margin-left: 0; } }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.3rem; overflow-x: auto; }
.tabs button {
  padding: .65rem .95rem; border: 0; background: none; cursor: pointer; font-size: .88rem; font-weight: 600;
  color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: .15s;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.facts { display: grid; gap: .1rem; }
.fact { display: grid; grid-template-columns: 150px 1fr auto; gap: .8rem; padding: .6rem .5rem; border-radius: var(--radius-sm); align-items: baseline; }
.fact:hover { background: var(--surface-2); }
.fact .lbl { font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.fact .val { font-size: .93rem; }
.fact .val .pl { color: var(--text-3); font-size: .82rem; display: block; }
.fact .tools { opacity: 0; transition: .15s; }
.fact:hover .tools { opacity: 1; }
@media (max-width: 620px) { .fact { grid-template-columns: 1fr; } }

.timeline { position: relative; padding-left: 2.2rem; }
.timeline::before { content: ''; position: absolute; left: .62rem; top: .5rem; bottom: .5rem; width: 2px; background: linear-gradient(180deg, var(--accent), var(--border)); border-radius: 2px; }
.tl-item { position: relative; padding: .55rem 0 1.1rem; }
.tl-item::before {
  content: ''; position: absolute; left: -1.93rem; top: .95rem; width: 11px; height: 11px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
}
.tl-item.world::before { border-color: var(--text-4); }
.tl-item.world { opacity: .72; }
.tl-year { font-family: var(--serif); font-size: 1.22rem; font-weight: 600; color: var(--accent); }
.tl-title { font-weight: 600; font-size: .93rem; }
.tl-sub { font-size: .8rem; color: var(--text-3); }
.tl-age { font-size: .72rem; color: var(--text-3); }

.rel-block { display: grid; gap: .5rem; }
.rel-people { display: flex; gap: .6rem; flex-wrap: wrap; }
.mini {
  display: flex; align-items: center; gap: .55rem; padding: .4rem .75rem .4rem .4rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  cursor: pointer; transition: .15s var(--ease); font-size: .85rem;
}
.mini:hover { border-color: var(--accent); background: var(--accent-soft); }
.mini .avatar { width: 30px; height: 30px; font-size: .75rem; }
.mini .yr { color: var(--text-3); font-size: .76rem; }

/* photos */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.tile {
  position: relative; aspect-ratio: 4/3; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  box-shadow: var(--shadow-1); transition: .2s var(--ease);
}
.tile:hover { transform: translateY(-3px) scale(1.008); box-shadow: var(--shadow-2); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .cap {
  position: absolute; inset: auto 0 0; padding: 1.6rem .8rem .6rem; color: #fff; font-size: .8rem;
  background: linear-gradient(transparent, rgba(20,16,10,.82)); opacity: 0; transition: .2s;
}
.tile:hover .cap { opacity: 1; }
.tile .pin { position: absolute; top: .5rem; right: .5rem; }

.lightbox { position: fixed; inset: 0; z-index: 260; background: rgba(16,13,9,.94); display: grid; grid-template-rows: auto 1fr auto; animation: fadeIn .2s; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; display: block; }
.lightbox .lb-stage { position: relative; display: grid; place-items: center; padding: 1rem; min-height: 0; }
.lightbox .lb-bar { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.4rem; color: #e9e0cd; }
.lightbox .lb-bar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #e9e0cd; }
.face-tag { position: absolute; border: 2px solid var(--gold-2); border-radius: 6px; box-shadow: 0 0 0 9999px rgba(0,0,0,.0); }
.face-tag span { position: absolute; bottom: -1.7rem; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: .74rem; background: var(--gold); color: #23200f; padding: .1rem .5rem; border-radius: 999px; }

/* charts */
.donut-legend { display: grid; gap: .45rem; }
.donut-legend .li { display: flex; align-items: center; gap: .55rem; font-size: .85rem; }
.donut-legend i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.donut-legend .pc { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-3); }
.bars { display: grid; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: minmax(120px, max-content) 1fr 46px; gap: .7rem; align-items: center; font-size: .82rem; }
.bar { height: 9px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.bar-row .n { text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }
.histogram { display: flex; align-items: flex-end; gap: 3px; height: 130px; }
.histogram .hb { flex: 1; background: linear-gradient(180deg, var(--gold-2), var(--gold)); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; transition: .15s; }
.histogram .hb:hover { filter: brightness(1.1); }
.histogram .hb span { position: absolute; bottom: -1.35rem; left: 50%; transform: translateX(-50%) rotate(-45deg); font-size: .62rem; color: var(--text-3); white-space: nowrap; }

/* match / merge */
.match-card { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; }
@media (max-width: 720px) { .match-card { grid-template-columns: 1fr; } }
.score-ring { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; font-weight: 700; font-size: .95rem; flex: none; }
.merge-row { display: grid; grid-template-columns: 130px 1fr 1fr; gap: .6rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--line-2); font-size: .85rem; }
.merge-opt { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: .14s; }
.merge-opt:hover { border-color: var(--accent); }
.merge-opt.on { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

/* issues */
.issue { display: flex; gap: .8rem; padding: .75rem .9rem; border-radius: var(--radius-sm); border-left: 3px solid var(--border); background: var(--surface-2); align-items: flex-start; }
.issue.error { border-left-color: var(--claret); }
.issue.warning { border-left-color: var(--gold); }
.issue.info { border-left-color: var(--azure); }
.issue .t { font-weight: 600; font-size: .87rem; }
.issue .s { font-size: .79rem; color: var(--text-3); }

/* research board */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem; }
.board-col h4 { display: flex; align-items: center; gap: .5rem; padding: .2rem .4rem .6rem; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .8rem; margin-bottom: .5rem; cursor: pointer; transition: .15s var(--ease); }
.task-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.task-card .tt { font-weight: 600; font-size: .86rem; }
.task-card .td { font-size: .78rem; color: var(--text-3); }

/* print */
@media print {
  .sidebar, .topbar, .tree-toolbar, .toasts, .btn, .tabs { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body, .view { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .view { padding: 0; }
  a { color: #000; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }

/* utility animation for lists */
.stagger > * { animation: fadeUp .4s var(--ease) backwards; }
.stagger > *:nth-child(1) { animation-delay: .02s } .stagger > *:nth-child(2) { animation-delay: .05s }
.stagger > *:nth-child(3) { animation-delay: .08s } .stagger > *:nth-child(4) { animation-delay: .11s }
.stagger > *:nth-child(5) { animation-delay: .14s } .stagger > *:nth-child(6) { animation-delay: .17s }
.stagger > *:nth-child(7) { animation-delay: .2s }  .stagger > *:nth-child(8) { animation-delay: .23s }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   Conversations
   A room for the living, alongside the record of everyone else. Two columns
   on a desk, one at a time on a phone. Bubbles carry their own writing
   direction, so a Tamil line and an Arabic one can sit in the same thread and
   each still read the way it was written.
   ========================================================================== */
.view.chat-view { padding: 0; max-width: none; height: calc(100vh - var(--topbar-h)); }
.chat {
  display: grid; grid-template-columns: minmax(260px, 330px) 1fr;
  height: 100%; background: var(--surface); border-top: 1px solid var(--border);
}

/* ------------------------------------------------------- the conversations */
.chat-list {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--border); background: var(--surface-2);
}
.chat-list-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .85rem 1rem .6rem;
}
.chat-list-head strong { font-family: var(--serif); font-size: 1.12rem; }
.chat-search-wrap {
  display: flex; align-items: center; gap: .5rem; margin: 0 .8rem .6rem;
  padding: .4rem .7rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-3);
}
.chat-search {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font: inherit; font-size: .88rem; color: var(--text);
}
.chat-list-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 .5rem .8rem; }
.chat-list-body .pad { padding: 1.2rem .8rem; }

.chat-row {
  display: flex; align-items: center; gap: .7rem; width: 100%; text-align: start;
  padding: .55rem .6rem; border: 0; border-radius: var(--radius-sm);
  background: none; cursor: pointer; color: inherit; font: inherit;
  transition: background .16s var(--ease);
}
.chat-row:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.chat-row.on { background: var(--accent-soft); }
.chat-row-text { flex: 1; min-width: 0; }
.chat-row-top { display: flex; align-items: baseline; gap: .5rem; }
.chat-row-name {
  flex: 1; min-width: 0; font-weight: 600; font-size: .92rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-row-when { font-size: .7rem; color: var(--text-4); white-space: nowrap; }
.chat-row-last {
  font-size: .82rem; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-badge {
  min-width: 20px; padding: 0 .4rem; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: .7rem; font-weight: 700; line-height: 20px; text-align: center;
}
.chat-face {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  flex: none; color: #fff;
}
.chat-face.family { background: linear-gradient(150deg, var(--gold-2), var(--gold)); }
.chat-face.self { background: linear-gradient(150deg, var(--sage), #55684f); }

/* ------------------------------------------------------------- the thread */
.chat-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: .75rem; padding: .7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}
.chat-head-text { min-width: 0; }
.chat-head-name {
  font-family: var(--serif); font-size: 1.05rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-head-sub { font-size: .76rem; color: var(--text-3); }
.chat-head .spacer { flex: 1; }
.chat-back { display: none; }

.chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1.1rem .4rem;
  display: flex; flex-direction: column; gap: .18rem;
  scroll-behavior: smooth;
}
.chat-earlier { align-self: center; margin-bottom: .6rem; }

.chat-day { display: flex; align-items: center; justify-content: center; margin: .9rem 0 .5rem; }
.chat-day span {
  padding: .18rem .7rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .7rem; font-weight: 600; letter-spacing: .04em; color: var(--text-3);
}

/* ------------------------------------------------------------- one message */
.chat-msg { display: flex; align-items: flex-end; gap: .5rem; max-width: min(74%, 620px); }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.grouped { margin-inline-start: 38px; }
.chat-msg.mine.grouped { margin-inline-start: 0; margin-inline-end: 0; }
.chat-msg > .avatar { flex: none; align-self: flex-end; }

.chat-bubble {
  position: relative; min-width: 0;
  padding: .5rem .72rem .42rem; border-radius: 15px;
  background: var(--surface-2); border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}
.chat-msg:not(.grouped) .chat-bubble { border-start-start-radius: 5px; }
.chat-msg.mine .chat-bubble {
  background: color-mix(in srgb, var(--accent-soft) 85%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
}
.chat-msg.mine:not(.grouped) .chat-bubble {
  border-start-start-radius: 15px; border-start-end-radius: 5px;
}
.chat-author { font-size: .74rem; font-weight: 700; color: var(--accent); margin-bottom: .12rem; }
.chat-body {
  font-size: .935rem; line-height: 1.5; color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat-gone { font-size: .88rem; color: var(--text-4); }
.chat-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: .35rem;
  margin-top: .12rem; font-size: .66rem; color: var(--text-4);
}
.chat-quote {
  display: block; margin-bottom: .35rem; padding: .3rem .55rem;
  border-inline-start: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: color-mix(in srgb, var(--accent-soft) 60%, transparent);
  font-size: .8rem;
}
.chat-quote .who { display: block; font-weight: 700; color: var(--accent); }
.chat-quote .what { display: block; color: var(--text-3); }

.chat-photo { display: block; margin: .3rem 0; }
.chat-photo img { max-width: 320px; max-height: 320px; border-radius: var(--radius-sm); display: block; }
.chat-audio { display: block; margin: .3rem 0; max-width: 280px; height: 38px; }
.chat-file {
  display: flex; align-items: center; gap: .5rem; margin: .3rem 0; padding: .45rem .6rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: .84rem; text-decoration: none;
}
.chat-file small { color: var(--text-4); }

.chat-reacts { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.chat-react {
  display: inline-flex; align-items: center; gap: .2rem;
  padding: .08rem .4rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-size: .75rem; cursor: pointer; color: var(--text-2);
}
.chat-react.mine { border-color: var(--accent); background: var(--accent-soft); }

/* Actions appear on approach and take no space until then. */
.chat-tools {
  position: absolute; inset-block-end: calc(100% - 6px); inset-inline-end: 0;
  display: flex; align-items: center; gap: .1rem; padding: .15rem .25rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transform: translateY(4px);
  transition: opacity .14s var(--ease), transform .14s var(--ease);
  z-index: 3;
}
.chat-msg:hover .chat-tools, .chat-bubble:focus-within .chat-tools {
  opacity: 1; pointer-events: auto; transform: none;
}
.chat-msg.mine .chat-tools { inset-inline-end: auto; inset-inline-start: 0; }
.chat-quick { display: flex; gap: .05rem; padding-inline-end: .2rem; border-inline-end: 1px solid var(--border); }
.chat-quick-e {
  border: 0; background: none; cursor: pointer; font-size: .95rem;
  padding: .1rem .18rem; border-radius: 50%; line-height: 1;
}
.chat-quick-e:hover { background: var(--accent-soft); transform: scale(1.25); }

/* ----------------------------------------------------------- typing, reply */
.chat-typing { min-height: 1.1rem; padding: 0 1.2rem; font-size: .76rem; color: var(--text-3); font-style: italic; }
.chat-reply-bar {
  display: none; align-items: center; gap: .6rem; padding: .5rem 1.1rem;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.chat-reply-bar.on { display: flex; }
.chat-reply-text { flex: 1; min-width: 0; font-size: .8rem; }
.chat-reply-text strong { display: block; color: var(--accent); }
.chat-reply-text span {
  display: block; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* -------------------------------------------------------------- composer */
.chat-composer {
  display: flex; align-items: flex-end; gap: .35rem; padding: .6rem .8rem .8rem;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.chat-input {
  flex: 1; min-width: 0; resize: none; max-height: 160px;
  padding: .55rem .85rem; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .93rem;
  line-height: 1.45; outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.chat-lang {
  align-self: center; padding: .1rem .45rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .7rem; font-weight: 700; white-space: nowrap;
}
.chat-send { flex: none; }
/* Something is being recorded — said with a pulse rather than a word, because
   it has to be visible from the corner of an eye. */
.btn.recording { color: var(--claret); background: var(--claret-soft); animation: chatPulse 1.1s ease-in-out infinite; }
@keyframes chatPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.chat-pick { display: flex; flex-direction: column; gap: .3rem; max-height: 50vh; overflow-y: auto; }
.chat-pick-row {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; cursor: pointer; text-align: start; font: inherit; color: inherit;
}
.chat-pick-row:hover { background: var(--surface-2); }
.chat-pick-row.on { border-color: var(--accent); background: var(--accent-soft); }
.chat-pick-row small { color: var(--text-4); font-size: .74rem; }
.chat-pins { display: flex; flex-direction: column; gap: .6rem; }
.chat-pin { padding: .5rem .7rem; border-inline-start: 3px solid var(--accent); background: var(--surface-2); }
.chat-pin strong { display: block; font-size: .78rem; color: var(--accent); }
.empty.small { padding: 2.2rem 1rem; }

/* One column on a phone: the list, then the thread on top of it. */
@media (max-width: 820px) {
  .chat { grid-template-columns: 1fr; }
  .chat-thread { display: none; }
  .chat.threading .chat-list { display: none; }
  .chat.threading .chat-thread { display: flex; }
  .chat-back { display: inline-flex; }
  .chat-msg { max-width: 88%; }
}

/* ==========================================================================
   Places
   A field that knows the places this family already names, and a map to say
   where one of them actually is. The pin does not move — the world moves under
   it, which is one gesture instead of two and works the same with a finger.
   ========================================================================== */
.place-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 190px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); padding: 4px;
}
.place-row {
  display: flex; align-items: center; gap: .5rem; width: 100%; text-align: start;
  padding: .38rem .5rem; border: 1px solid transparent; border-radius: 7px;
  background: none; cursor: pointer; font: inherit; color: var(--text);
}
.place-row:hover { background: var(--surface-2); }
.place-row.on { border-color: var(--accent); background: var(--accent-soft); }
.place-row > svg { flex: none; color: var(--text-4); }
.place-row.on > svg, .place-row:hover > svg { color: var(--accent); }
.place-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-count { font-size: .72rem; color: var(--text-4); white-space: nowrap; }
.place-maprow { display: flex; gap: .5rem; margin: .2rem 0 .4rem; flex-wrap: wrap; }
.place-map { margin-top: .6rem; }

/* The little slippy map. It is `smap`, not `sm`, and must stay that way: `sm` is
   the size modifier worn by dozens of buttons as class="btn sm", so a bare `.sm`
   rule reaches every one of them. When this was `.sm`, its 320px height and grey
   fill were painted over each button in the app — the chart toolbar became a row
   of tall ovals lying across the family. Component classes stay out of the
   modifiers' namespace. */
.smap {
  position: relative; height: 320px; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: grab; touch-action: none;
  user-select: none;
}
.smap.dragging { cursor: grabbing; }
.sm-tiles { position: absolute; inset: 0; }
.sm-tile { position: absolute; width: 256px; height: 256px; pointer-events: none; }
/* No tiles arrived. Say so with the shape of the thing rather than a blank box,
   and leave the coordinates working — a place is its numbers, not its picture. */
.sm-dark::after {
  content: attr(data-offline); position: absolute; inset: 0;
  display: grid; place-items: center; padding: 1rem; text-align: center;
  font-size: .82rem; color: var(--text-3);
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, var(--border) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, var(--border) 39px 40px),
    var(--surface-2);
}
.sm-cross {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%);
  color: var(--claret); pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
}
.sm-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.sm-z {
  width: 30px; height: 30px; padding: 0; display: grid; place-items: center;
  font-size: 1.05rem; line-height: 1; background: var(--surface); opacity: .94;
}
.sm-credit {
  position: absolute; right: 0; bottom: 0; padding: 1px 6px;
  font-size: .64rem; color: var(--text-3);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-start-start-radius: 6px; pointer-events: none;
}

/* ==========================================================================
   Lately
   A page for somebody who opened the app with nothing particular in mind.
   A column of what happened, and beside it what is about to.
   ========================================================================== */
.feed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.4rem; align-items: start; }
.feed-side { display: flex; flex-direction: column; gap: 1.1rem; position: sticky; top: calc(var(--topbar-h) + 1.2rem); }
.feed-stream { display: flex; flex-direction: column; }

.feed-day { display: flex; align-items: center; gap: .8rem; margin: 1.2rem 0 .5rem; }
.feed-day:first-child { margin-top: 0; }
.feed-day span {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-4); white-space: nowrap;
}
.feed-day::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Each entry hangs off a single line running down the page, so a day reads as
   one thread of events rather than a stack of unrelated boxes. */
.feed-item { position: relative; display: flex; gap: .85rem; padding: 0 0 1.15rem; }
.feed-item::before {
  content: ''; position: absolute; inset-inline-start: 15px; top: 32px; bottom: 0;
  width: 2px; background: var(--border);
}
.feed-item:last-child::before { display: none; }
.feed-mark {
  flex: none; width: 32px; height: 32px; border-radius: 50%; z-index: 1;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3);
}
.feed-mark.gold { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.feed-mark.sage { background: var(--sage-soft, var(--surface-2)); border-color: var(--sage); color: var(--sage); }
.feed-mark.claret { background: var(--claret-soft); border-color: var(--claret); color: var(--claret); }
.feed-body { flex: 1; min-width: 0; padding-top: .28rem; }
.feed-said { font-size: .94rem; line-height: 1.45; color: var(--text); }
.feed-when { font-size: .73rem; color: var(--text-4); margin-top: .12rem; }

.feed-faces { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.feed-face {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .18rem .55rem .18rem .18rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer; font: inherit; font-size: .8rem; color: var(--text);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.feed-face:hover { border-color: var(--accent); background: var(--accent-soft); }
.feed-face > span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.feed-shots { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.feed-shot {
  width: 78px; height: 78px; padding: 0; overflow: hidden; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.feed-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feed-shot:hover { border-color: var(--accent); }

@media (max-width: 980px) {
  .feed-grid { grid-template-columns: 1fr; }
  .feed-side { position: static; }
}

/* ---------------------------------------------------------------- kinship
   The answer to "may they marry?". It carries a colour because the family
   will read the colour before they read the words, and it must not be the
   same colour whatever the tree says. */
.kin-card { border-left: 3px solid var(--border); }
.kin-card.kin-ok    { border-left-color: var(--sage); }
.kin-card.kin-warn  { border-left-color: var(--accent); }
.kin-card.kin-bad   { border-left-color: var(--claret); }
.kin-verdict { font-size: 1.7rem; }
.kin-ok    .kin-verdict { color: var(--sage); }
.kin-warn  .kin-verdict { color: var(--accent); }
.kin-bad   .kin-verdict { color: var(--claret); }
.kin-muted .kin-verdict { color: var(--text-3); }

/* Each reckoning on its own line, kept apart on purpose: gothram, paternal
   line and the Act's own test disagree with one another often enough that
   running them together would be dishonest. */
.kin-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .1rem 1.4rem; border-top: 1px solid var(--border); padding-top: .9rem;
}
.kin-row { display: flex; gap: .8rem; align-items: baseline; padding: .34rem 0; }
.kin-label { flex: 0 0 8.5rem; text-transform: uppercase; letter-spacing: .08em; }

/* ------------------------------------------------------------- marriage */
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; }
.mat-card { margin: 0; }
.mat-line { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.mat-line:last-child { border-bottom: 0; }

@media (max-width: 700px) {
  .kin-grid { grid-template-columns: 1fr; }
  .kin-label { flex-basis: 7rem; }
}

/* --------------------------------------------------------------- welcome */
/* Shown once, to somebody who has just arrived. It borrows the hero's warmth
   deliberately: it stands where the hero would, and dismissing it puts the
   hero back, so the page never looks as though something is missing. */
.wel {
  position: relative;
  background: linear-gradient(145deg, var(--hero-bg-1), var(--hero-bg-2));
  border-color: var(--accent-soft);
}
.wel-x {
  position: absolute; inset-inline-end: .55rem; top: .55rem;
  width: 1.9rem; height: 1.9rem; display: grid; place-items: center;
  border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--text-4);
}
.wel-x:hover { background: var(--surface-2); color: var(--text); }
.wel-title { margin: .15rem 0 .4rem; font-size: clamp(1.5rem, 3.4vw, 2.1rem); }
.wel-lede { margin: 0 0 1rem; max-width: 62ch; color: var(--text-2); line-height: 1.6; }

.wel-me {
  display: flex; align-items: center; gap: .9rem;
  padding: .75rem .9rem; margin-bottom: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.wel-face { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.wel-face:hover { box-shadow: 0 0 0 3px var(--accent-soft); }
.wel-name { font-size: 1.15rem; font-weight: 600; line-height: 1.25; }
.wel-near { display: flex; gap: .3rem; margin-top: .4rem; flex-wrap: wrap; }
.wel-mini { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; opacity: .85; }
.wel-mini:hover { opacity: 1; box-shadow: 0 0 0 2px var(--accent-soft); }

.wel-acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.wel-act {
  display: flex; align-items: flex-start; gap: .6rem; text-align: start;
  padding: .7rem .8rem; cursor: pointer; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .15s, transform .15s;
}
.wel-act:hover { border-color: var(--accent); transform: translateY(-1px); }
.wel-ic { color: var(--accent); flex: none; margin-top: .1rem; }
.wel-act-t { display: block; font-weight: 600; line-height: 1.3; }
.wel-privacy { display: flex; align-items: center; gap: .35rem; margin: 1rem 0 .6rem; }

@media (max-width: 760px) {
  .wel-acts { grid-template-columns: 1fr; }
}
