/* =====================================================================
   Family Tree Portal — Design System
   ---------------------------------------------------------------------
   Direction: a private family archive/ledger, not a generic SaaS panel.
   Palette: deep forest green + antique brass on warm archival paper.
   Type: Fraunces (display, used with restraint) + Source Sans 3 (body)
         + IBM Plex Mono (dates, years, record data).
   Signature: the interlocking-rings mark — the app's one recurring
   motif, standing in for "two people, linked" throughout the UI.
   ===================================================================== */

:root {
  /* ---- Color tokens ---- */
  --ink:          #202A22;
  --ink-soft:     #3C4438;
  --muted:        #736C5E;
  --paper:        #F8F5EC;
  --card:         #FFFFFF;
  --line:         #E3DAC4;
  --line-soft:    #ECE5D3;

  --forest:       #2B5C4B;
  --forest-deep:  #1C3F33;
  --forest-tint:  #E4EEE9;

  --brass:        #AD7F35;
  --brass-deep:   #8C6527;
  --brass-tint:   #F3E7CC;

  --rose:         #A0473D;
  --rose-tint:    #F3E2DE;

  /* ---- Legacy aliases (kept so nothing that references the old
     token names breaks; new code should use the tokens above) ---- */
  --color-primary: var(--forest);
  --color-primary-dark: var(--forest-deep);
  --color-accent: var(--brass);
  --color-bg: var(--paper);
  --color-card: var(--card);
  --color-border: var(--line);
  --color-text: var(--ink);
  --color-muted: var(--muted);
  --color-danger: var(--rose);

  /* ---- Type ---- */
  --font-display: 'Fraunces', Georgia, 'Iowan Old Style', serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* ---- Shape & shadow ---- */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(32, 42, 34, 0.06);
  --shadow: 0 2px 12px rgba(32, 42, 34, 0.07);
  --shadow-lg: 0 12px 32px rgba(28, 63, 51, 0.12);
}

/* ---------------------------------------------------------
   Reset & base
--------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}
h1 { font-size: 2.1rem; font-weight: 600; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.08rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--forest-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
code {
  font-family: var(--font-mono);
  background: var(--forest-tint);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------
   Icon system (inline SVGs from includes/functions.php icon())
--------------------------------------------------------- */
.icon { display: inline-block; vertical-align: -0.2em; flex-shrink: 0; }

/* ---------------------------------------------------------
   Top bar / nav
--------------------------------------------------------- */
.topbar {
  background: var(--forest-deep);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
}
.brand {
  color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 1.2rem;
  display: inline-flex; align-items: center; gap: 9px; letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; opacity: .92; }
.brand-mark { display: inline-flex; color: var(--brass); }
.brand-mark .icon { stroke-width: 1.4; }

.mainnav { display: flex; gap: 22px; flex: 1; flex-wrap: wrap; }
.mainnav a {
  color: rgba(255,255,255,0.82); font-size: 0.93rem; font-weight: 500;
  padding-bottom: 3px; border-bottom: 2px solid transparent;
}
.mainnav a:hover { color: #fff; text-decoration: none; }
.mainnav a.active { color: #fff; font-weight: 600; border-bottom-color: var(--brass); }

.navuser { display: flex; align-items: center; gap: 14px; color: rgba(255,255,255,0.82); font-size: .88rem; }

/* ---------------------------------------------------------
   Page layout
--------------------------------------------------------- */
.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.page-full { max-width: none; padding: 0; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 26px; flex-wrap: wrap;
  padding-bottom: 18px; border-bottom: 1px solid var(--line);
}
.section-title { margin-top: 36px; }
.footer {
  text-align: center; color: var(--muted); padding: 36px 20px 44px;
  font-size: .84rem; border-top: 1px solid var(--line); margin-top: 20px;
}

/* ---------------------------------------------------------
   Buttons
--------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: var(--font-body); font-size: .92rem; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .14s ease, border-color .14s ease, transform .06s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--forest); color: #fff; border-color: var(--forest); }
.btn-primary:hover { background: var(--forest-deep); border-color: var(--forest-deep); }
.btn-secondary { background: var(--card); color: var(--forest-deep); border-color: var(--forest); }
.btn-secondary:hover { background: var(--forest-tint); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-danger { background: var(--card); color: var(--rose); border-color: var(--rose); }
.btn-danger:hover { background: var(--rose-tint); }
.btn-sm { padding: 6px 13px; font-size: .82rem; }
.btn-lg { padding: 13px 26px; font-size: 1rem; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------
   Cards / stats / dashboard
--------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-num { font-family: var(--font-display); font-size: 2.1rem; font-weight: 600; color: var(--forest-deep); }
.stat-label { color: var(--muted); font-size: .82rem; margin-top: 4px; letter-spacing: 0.01em; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.person-card {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px;
  color: var(--ink); box-shadow: var(--shadow-sm); transition: border-color .14s ease, box-shadow .14s ease;
}
.person-card:hover { border-color: var(--forest); box-shadow: var(--shadow); text-decoration: none; }
.person-name { font-weight: 600; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; color: #fff; flex-shrink: 0;
}
.avatar-male { background: var(--forest); }
.avatar-female { background: var(--brass-deep); }

/* ---------------------------------------------------------
   Forms
--------------------------------------------------------- */
.auth-wrap { display: flex; justify-content: center; padding-top: 24px; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 36px; max-width: 420px; width: 100%;
}
.auth-card h1 { font-size: 1.5rem; }

label { display: block; font-weight: 600; font-size: .87rem; margin-bottom: 16px; color: var(--ink-soft); }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; margin: 2px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=file], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: .95rem; margin-top: 4px; background: #fff; color: var(--ink);
  transition: border-color .14s ease;
}
input:hover, select:hover, textarea:hover { border-color: #C9BE9F; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: 1px; border-color: var(--brass); }
input[type=date] { font-family: var(--font-mono); font-size: .88rem; }

.checkbox-line { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.checkbox-line input { width: auto; margin: 0; accent-color: var(--forest); }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin-top: 6px; color: var(--ink-soft); }
.checkbox-inline input { width: auto; accent-color: var(--forest); }

fieldset {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 24px 8px;
  margin-bottom: 22px; background: var(--card);
}
legend {
  padding: 0 10px; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
  color: var(--forest-deep);
}
.form-row { margin-bottom: 6px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-row.three-col { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 700px) {
  .form-row.two-col, .form-row.three-col { grid-template-columns: 1fr; }
}
.form-actions { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.row-sep { border: none; border-top: 1px dashed var(--line); margin: 16px 0; }
.remove-row-btn { margin-top: -4px; }
.partner-status { align-self: start; }
.partner-row, .custom-field-row { margin-bottom: 2px; }
.person-form { max-width: 900px; }

.alert { padding: 13px 18px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: .9rem; }
.alert-error { background: var(--rose-tint); color: var(--rose); border: 1px solid #E4C5BF; }
.alert ul { margin: 4px 0 0 18px; padding: 0; }

.photo-preview { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; }
.photo-preview img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }

/* ---------------------------------------------------------
   Person picker (search dropdown)
--------------------------------------------------------- */
.person-picker { position: relative; }
.picker-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-top: 4px; max-height: 240px; overflow-y: auto; display: none;
  box-shadow: var(--shadow-lg);
}
.picker-results.open { display: block; }
.picker-item { padding: 9px 13px; cursor: pointer; font-weight: 400; font-size: .9rem; }
.picker-item:hover { background: var(--forest-tint); }
.picker-empty { padding: 9px 13px; color: var(--muted); font-size: .85rem; }

/* ---------------------------------------------------------
   Search bar / data table (archive)
--------------------------------------------------------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.search-bar input[type=search] {
  flex: 1; margin-top: 0; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-family: var(--font-body); font-size: .95rem;
}
.search-bar input[type=search]:focus { outline: 2px solid var(--brass); outline-offset: 1px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
.data-table th { background: var(--forest-tint); font-family: var(--font-body); }
.data-table th a { color: var(--forest-deep); font-weight: 700; font-size: .8rem; letter-spacing: .02em; text-transform: uppercase; }
.data-table th a:hover { text-decoration: none; color: var(--brass-deep); }
.data-table td:nth-child(4) { font-family: var(--font-mono); font-size: .84rem; }
.data-table tbody tr:hover { background: #FBF9F2; }
.row-actions a { margin-right: 12px; font-weight: 600; font-size: .85rem; }
.badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: .74rem; font-weight: 600; letter-spacing: .01em; }
.badge-ok { background: var(--forest-tint); color: var(--forest-deep); }
.badge-muted { background: var(--line-soft); color: var(--muted); }

/* ---------------------------------------------------------
   Person detail view
--------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px 26px; box-shadow: var(--shadow-sm); }
.detail-card h2 { font-size: 1.15rem; }
.detail-list { display: grid; grid-template-columns: 160px 1fr; row-gap: 9px; column-gap: 12px; margin: 12px 0 20px; }
.detail-list dt { color: var(--muted); font-size: .82rem; }
.detail-list dd { margin: 0; }
.rel-list { list-style: none; margin: 10px 0 20px; padding: 0; }
.rel-list li { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.rel-label { color: var(--muted); font-size: .8rem; margin-right: 6px; }

.profile-photo-wrap { text-align: center; margin-bottom: 20px; }
.profile-photo {
  width: 120px; height: 120px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--card); box-shadow: var(--shadow);
}
.avatar-xl { width: 84px; height: 84px; font-size: 2rem; }
.avatar-photo { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--line); }
.avatar-photo-lg { width: 64px; height: 64px; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }

/* =========================================================
   PUBLIC PAGES — Home / About
========================================================= */
.section-inner { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.section-inner.narrow { max-width: 760px; }
.section-inner.narrow.center { text-align: center; }

.hero {
  display: flex; align-items: center; gap: 48px; flex-wrap: wrap;
  padding: 72px 24px 60px; max-width: 1220px; margin: 0 auto;
}
.hero-inner { flex: 1 1 480px; min-width: 300px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--brass-deep); background: var(--brass-tint);
  font-family: var(--font-body); font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 6px 13px; border-radius: 20px; margin-bottom: 20px;
}
.hero h1 { font-size: 2.9rem; margin-bottom: 20px; }
.hero h1 .hl { color: var(--forest-deep); font-style: italic; }
.hero-sub { font-size: 1.1rem; color: var(--muted); max-width: 540px; margin-bottom: 28px; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 40px; }
.hero-stats { display: flex; gap: 38px; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font-family: var(--font-mono); font-size: 1.5rem; color: var(--forest-deep); font-weight: 500; }
.hero-stats span { color: var(--muted); font-size: .78rem; margin-top: 2px; }

.hero-art { flex: 1 1 320px; min-width: 240px; max-width: 380px; display: flex; justify-content: center; }
.hero-mark { color: var(--forest); opacity: 0.9; animation: mark-in 900ms ease-out; }
.hero-mark .icon circle { stroke-width: 1.1; }
.hero-mark svg { width: 100%; height: auto; max-width: 260px; }
@keyframes mark-in {
  from { opacity: 0; transform: scale(0.92) rotate(-4deg); }
  to { opacity: 0.9; transform: scale(1) rotate(0deg); }
}

.section { padding: 60px 0; }
.section-alt { background: var(--forest-tint); }
.section-heading { font-size: 1.85rem; text-align: center; margin-bottom: 8px; }
.section-sub { text-align: center; max-width: 560px; margin: 0 auto 40px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.feature-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px; box-shadow: var(--shadow-sm); transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.feature-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px; background: var(--forest-tint); color: var(--forest-deep);
  margin-bottom: 14px;
}
.feature-card h3 { margin-bottom: 8px; font-size: 1.05rem; }
.feature-card p { color: var(--muted); font-size: .92rem; margin: 0; }
.feature-card-link { display: block; color: var(--ink); }
.feature-card-link:hover { text-decoration: none; border-color: var(--forest); box-shadow: var(--shadow); transform: translateY(-2px); }

.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 26px; }
.step-card { text-align: center; }
.step-num {
  width: 40px; height: 40px; border-radius: 50%; background: var(--forest); color: #fff;
  font-family: var(--font-display); display: flex; align-items: center; justify-content: center;
  font-weight: 600; margin: 0 auto 14px;
}
.step-card h3 { margin-bottom: 8px; font-size: 1.02rem; }
.step-card p { color: var(--muted); font-size: .9rem; margin: 0; }

.cta-band { background: var(--forest-deep); color: #fff; padding: 48px 0; }
.cta-band h2 { color: #fff; margin-bottom: 4px; }
.cta-band .muted { color: #C8D9CE; }
.cta-band-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.page-hero { padding: 58px 0 20px; max-width: 1120px; margin: 0 auto; }
.about-list { padding-left: 22px; }
.about-list li { margin-bottom: 11px; }
.about-cta { display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .hero h1 { font-size: 2.1rem; }
}

/* =========================================================
   TREE VIEW — person-centered
========================================================= */
.tree-page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.tree-toolbar {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  flex-wrap: wrap; margin-bottom: 36px;
}
.tree-jump { width: 280px; max-width: 100%; }
.tree-jump .picker-input { margin-top: 0; }

.tree-canvas {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 48px 26px; overflow-x: auto;
}

.tree-row { display: flex; justify-content: center; align-items: flex-start; gap: 30px; flex-wrap: wrap; position: relative; }
.tree-row + .tree-row { margin-top: 48px; }

.tree-row-branch { padding-top: 32px; }
.tree-row-branch::before {
  content: ''; position: absolute; top: -32px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 32px; background: var(--line);
}
.tree-row-focusgroup { padding-top: 0; }
.tree-row-focusgroup.tree-row-branch { padding-top: 32px; }

.tree-family-unit { display: flex; align-items: center; gap: 0; flex-wrap: wrap; justify-content: center; }
.tree-union-line { width: 28px; height: 2px; background: var(--brass); align-self: center; }

.tree-node {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  width: 136px; padding: 16px 10px 13px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); position: relative; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tree-node:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--forest); text-decoration: none; }
.tree-node-focus { border-color: var(--forest); box-shadow: 0 0 0 3px var(--forest-tint); }
.tree-node-tag {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--brass); color: #fff; font-size: .64rem; font-weight: 700;
  padding: 2px 10px; border-radius: 10px; white-space: nowrap; text-transform: uppercase; letter-spacing: .04em;
}
.tree-node-avatar, .tree-node-avatar-img {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; color: #fff; margin-bottom: 9px; font-size: 1rem;
  object-fit: cover;
}
.tree-node-avatar.avatar-unknown { background: #8C8574; }
.tree-node-name { font-weight: 600; font-size: .86rem; line-height: 1.25; }
.tree-node-meta { font-family: var(--font-mono); color: var(--muted); font-size: .72rem; margin-top: 3px; }

.tree-legend { display: flex; gap: 12px; justify-content: center; margin-top: 32px; flex-wrap: wrap; }

.tree-row-grandparents .tree-node { opacity: 0.82; transform: scale(0.94); }
.tree-row-grandparents .tree-node:hover { opacity: 1; transform: scale(0.97) translateY(-2px); }

.empty-state { text-align: center; padding: 44px 20px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { margin-bottom: 22px; }

@media (max-width: 640px) {
  .tree-toolbar { flex-direction: column; }
  .tree-jump { width: 100%; }
}

/* =========================================================
   WHOLE FAMILY TREE — collapsible indented chart
========================================================= */
.ftree-canvas { padding: 32px 22px; }
.ftree-node { margin: 10px 0; }
.ftree-couple { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ftree-union { width: 22px; height: 2px; background: var(--brass); flex-shrink: 0; }

.ftree-chip {
  display: inline-flex; align-items: center; gap: 10px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 15px 8px 9px;
  color: var(--ink); box-shadow: var(--shadow-sm); position: relative;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.ftree-chip:hover { border-color: var(--forest); text-decoration: none; box-shadow: var(--shadow); }
.ftree-chip-avatar, .ftree-chip-avatar-img {
  width: 33px; height: 33px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; color: #fff; font-size: .85rem; flex-shrink: 0;
  object-fit: cover;
}
.ftree-chip-avatar.avatar-unknown { background: #8C8574; }
.ftree-chip-text { display: flex; flex-direction: column; line-height: 1.22; }
.ftree-chip-name { font-weight: 600; font-size: .88rem; }
.ftree-chip-meta { font-family: var(--font-mono); color: var(--muted); font-size: .72rem; }
.ftree-chip-tag {
  position: absolute; top: -9px; left: 10px; background: var(--brass); color: #fff;
  font-size: .6rem; font-weight: 700; padding: 1px 9px; border-radius: 8px; text-transform: uppercase; letter-spacing: .04em;
}

details.ftree-children {
  margin-left: 21px; margin-top: 9px; padding-left: 21px;
  border-left: 2px dashed var(--line);
}
details.ftree-children > summary {
  cursor: pointer; color: var(--forest-deep); font-weight: 600; font-size: .8rem;
  list-style: none; margin-bottom: 9px; user-select: none;
}
details.ftree-children > summary::-webkit-details-marker { display: none; }
details.ftree-children > summary::before { content: '▾ '; }
details.ftree-children:not([open]) > summary::before { content: '▸ '; }
.ftree-children-list { display: flex; flex-direction: column; gap: 4px; }

/* =========================================================
   FAMILIES — listing + per-family card
========================================================= */
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 20px; }
.family-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px 16px; text-align: center; box-shadow: var(--shadow-sm); color: var(--ink);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.family-card:hover { border-color: var(--forest); text-decoration: none; box-shadow: var(--shadow); }
.family-card-parents { display: flex; justify-content: center; align-items: center; gap: 4px; margin-bottom: 11px; }
.family-card-amp { color: var(--brass-deep); font-family: var(--font-display); font-style: italic; font-size: .95rem; margin: 0 3px; }
.family-card-names { font-weight: 700; margin-bottom: 4px; }
.family-card-names .muted { display: block; font-weight: 400; font-size: .8rem; }
.family-card-meta { color: var(--muted); font-size: .82rem; font-family: var(--font-mono); }

.family-view-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 38px 28px; max-width: 900px; margin: 0 auto;
}
.family-view-parents { display: flex; justify-content: center; align-items: center; gap: 28px; flex-wrap: wrap; margin-bottom: 20px; }
.family-view-person { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink); text-align: center; width: 160px; }
.family-view-person:hover { text-decoration: none; }
.family-view-person-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; margin-top: 5px; }
.family-view-union { display: flex; align-items: center; gap: 8px; }
.family-view-union .line { width: 26px; height: 2px; background: var(--brass); }
.family-view-union .label { font-size: .72rem; color: var(--brass-deep); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.family-view-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }

.family-view-children { border-top: 1px solid var(--line); padding-top: 24px; margin-top: 6px; }
.family-view-children h2 { text-align: center; font-size: 1.1rem; margin-bottom: 18px; }
.family-children-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.family-child-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 10px 13px; position: relative;
  color: var(--ink); background: #FBF9F2; transition: border-color .14s ease;
}
.family-child-card:hover { border-color: var(--forest); text-decoration: none; }
.family-child-name { font-weight: 600; font-size: .86rem; }

/* =========================================================
   DASHBOARD REMINDERS
========================================================= */
.reminders-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 22px; }
.reminder-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.reminder-card h2 { font-size: .98rem; margin-bottom: 13px; display: flex; align-items: center; gap: 8px; color: var(--forest-deep); }
.reminder-card h2 .icon { color: var(--brass); }
.reminder-list { list-style: none; margin: 0; padding: 0; }
.reminder-list li { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: .88rem; gap: 10px; }
.reminder-list li:last-child { border-bottom: none; }
.reminder-meta { font-family: var(--font-mono); color: var(--muted); font-size: .76rem; white-space: nowrap; }

/* =========================================================
   RELATIONSHIP CALCULATOR
========================================================= */
.relcalc-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 22px; }
.relcalc-result {
  background: var(--forest-tint); border: 1px solid #C9DED3; border-radius: var(--radius-lg);
  padding: 30px; text-align: center;
}
.relcalc-people { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: 1.1rem; }
.relcalc-name { font-family: var(--font-display); font-weight: 600; color: var(--forest-deep); }
.relcalc-arrow { color: var(--ink); }
.relcalc-arrow strong { color: var(--brass-deep); }
