/* ============================================================
  public/css/style.css – Family Tree (redesigned)
  Clean, polished stylesheet.
  Fonts are loaded via <link rel="preload"> in the layout for
  non-render-blocking performance. Fallback system fonts below.
   ============================================================ */

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #0f766e;
  --color-primary-d: #115e59;
  --color-primary-l: #ecfdf5;
  --color-danger: #ef4444;
  --focus-bar-bg: #fffbeb;
  --focus-bar-border: #fcd34d;
  --focus-bar-text: #92400e;
  --focus-bar-btn-hover: #fef3c7;
  --toolbar-bg: rgba(232, 240, 235, .94);
  --toolbar-border: var(--border);
  --toolbar-shadow: 0 8px 24px rgba(2, 44, 34, .1);
  --table-row-hover: #dde9e3;
  --color-danger-d: #dc2626;
  --color-danger-l: #fef2f2;
  --color-warning: #d97706;
  --color-warning-d: #b45309;
  --color-info: #0891b2;
  --color-info-d: #0e7490;
  --color-success: #10b981;
  --color-primary-hover: #0d9488;
  --color-secondary: #6b7280;
  --color-secondary-d: #4b5563;
  --bg: #dbe6e0;
  --surface: #eff5f2;
  --surface-2: #e2ebe6;
  --border: #c3d2cb;
  --border-strong: #aebfb7;
  --text: #10221d;
  --text-muted: #4f6f64;
  --text-light: #94a3b8;
  --navbar-bg: #0a2a23;
  --navbar-text: #e7f7f2;
  --navbar-muted: #a7c7be;
  --theme-control-bg: rgba(255, 255, 255, .12);
  --theme-control-text: #ffffff;
  --badge-m-bg: #d1fae5;
  --badge-m-text: #166534;
  --badge-f-bg: #fce7f3;
  --badge-f-text: #9d174d;
  --badge-o-bg: #ede9fe;
  --badge-o-text: #5b21b6;
  --status-alive-bg: #d1fae5;
  --status-alive-text: #065f46;
  --status-deceased-bg: #f3f4f6;
  --status-deceased-text: #6b7280;
  --status-verified-bg: #dcfce7;
  --status-verified-text: #065f46;
  --status-estimated-bg: #ffedd5;
  --status-estimated-text: #9a3412;
  --status-founder-bg: #fffbeb;
  --status-founder-text: #92400e;
  --status-unverified-bg: #fee2e2;
  --status-unverified-text: #991b1b;
  --founder-row-bg: rgba(255, 223, 67, .16);
  --founder-row-cell-bg: rgba(255, 223, 67, .1);
  --founder-row-accent: #f59e0b;
  --accent-story: #4e8ae7;
  --accent-tech: #f0ad4e;
  --accent-deploy: #6f42c1;
  --accent-collab: #17a2b8;
  --accent-support: #f97316;
  --accent-privacy: #007bff;
  --timeline-line: var(--border);
  --timeline-dot-birth: #10b981;
  --timeline-dot-death: #94a3b8;
  --timeline-dot-custom: #6366f1;
  --timeline-badge-birth-bg: #d1fae5;
  --timeline-badge-birth-text: #065f46;
  --timeline-badge-death-bg: #f1f5f9;
  --timeline-badge-death-text: #475569;
  --timeline-badge-custom-bg: #e0e7ff;
  --timeline-badge-custom-text: #3730a3;
  --legend-dot-male: #60a5fa;
  --legend-dot-female: #f472b6;
  --legend-dot-other: #a78bfa;
  --body-bg: radial-gradient(960px 400px at 6% -12%, rgba(16, 185, 129, .06), transparent 64%), radial-gradient(720px 320px at 100% 0%, rgba(13, 148, 136, .05), transparent 62%), linear-gradient(180deg, #e4ede8 0%, #d6e1db 100%);
  --content-max-width: 1200px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(4, 33, 26, .07);
  --shadow: 0 1px 3px rgba(4, 33, 26, .12), 0 1px 2px rgba(4, 33, 26, .08);
  --shadow-md: 0 4px 12px rgba(4, 33, 26, .1), 0 2px 4px rgba(4, 33, 26, .06);
  --shadow-lg: 0 12px 28px rgba(4, 33, 26, .12), 0 4px 12px rgba(4, 33, 26, .06);
  --shadow-xl: 0 20px 40px rgba(4, 33, 26, .14), 0 8px 16px rgba(4, 33, 26, .06);
  --font: "Space Grotesk", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", "Space Grotesk", "Georgia", serif;
  --transition: .2s cubic-bezier(.4, 0, .2, 1);
  --transition-fast: .12s cubic-bezier(.4, 0, .2, 1);
}

/* Tell the browser which color scheme each theme uses so it
   does not try to auto-invert the page in OS dark mode. */
html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="dark"] {
  --color-primary: #2dd4bf;
  --color-primary-d: #0d9488;
  --color-primary-l: #042f2e;
  --focus-bar-bg: var(--surface);
  --focus-bar-border: #fbbf24;
  --focus-bar-text: #fbbf24;
  --focus-bar-btn-hover: #f59e0b;
  --toolbar-bg: var(--surface);
  --toolbar-border: #2f3836;
  --toolbar-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  --table-row-hover: rgba(45, 212, 191, .06);
  --color-danger: #f87171;
  --color-danger-d: #ef4444;
  --color-danger-l: #1c1017;
  --color-warning: #fbbf24;
  --color-warning-d: #f59e0b;
  --color-info: #22d3ee;
  --color-info-d: #06b6d4;
  --color-success: #34d399;
  --color-secondary: #9ca3af;
  --color-secondary-d: #6b7280;
  --bg: #0f1a15;
  --surface: #15231c;
  --surface-2: #1b2e25;
  --border: #24352c;
  --border-strong: #33483d;
  --text: #eaf4ee;
  --text-muted: #a3b8ad;
  --text-light: #889e93;
  --navbar-bg: #0c1712;
  --navbar-text: #eaf4ee;
  --navbar-muted: #a3b8ad;
  --theme-control-bg: rgba(255, 255, 255, .08);
  --theme-control-text: #eaf4ee;
  --badge-m-bg: #1a2e26;
  --badge-m-text: #5eead4;
  --badge-f-bg: #2a1f28;
  --badge-f-text: #f9a8d4;
  --badge-o-bg: #201f2e;
  --badge-o-text: #c4b5fd;
  --status-alive-bg: #0d3324;
  --status-alive-text: #5eead4;
  --status-deceased-bg: #1a1f22;
  --status-deceased-text: #a3b8ad;
  --status-verified-bg: #0d3324;
  --status-verified-text: #5eead4;
  --status-estimated-bg: #3d2008;
  --status-estimated-text: #fcd34d;
  --status-founder-bg: #3d2008;
  --status-founder-text: #fef9c3;
  --status-unverified-bg: #3d1018;
  --status-unverified-text: #fecaca;
  --founder-row-bg: rgba(251, 191, 36, .1);
  --founder-row-cell-bg: rgba(251, 191, 36, .08);
  --founder-row-accent: #fbbf24;
  --accent-story: #2dd4bf;
  --accent-tech: #fbbf24;
  --accent-deploy: #c084fc;
  --accent-collab: #34d399;
  --accent-support: #fb923c;
  --accent-privacy: #2dd4bf;
  --timeline-line: #33483d;
  --timeline-dot-birth: #2dd4bf;
  --timeline-dot-death: #6b7f74;
  --timeline-dot-custom: #a78bfa;
  --timeline-badge-birth-bg: rgba(45, 212, 191, .15);
  --timeline-badge-birth-text: #5eead4;
  --timeline-badge-death-bg: rgba(148, 163, 156, .15);
  --timeline-badge-death-text: #a3b8ad;
  --timeline-badge-custom-bg: rgba(167, 139, 250, .15);
  --timeline-badge-custom-text: #c4b5fd;
  --legend-dot-male: #5eead4;
  --legend-dot-female: #f9a8d4;
  --legend-dot-other: #c4b5fd;
  --body-bg: radial-gradient(1000px 420px at 6% -12%, rgba(45, 212, 191, .07), transparent 55%), radial-gradient(760px 360px at 100% 0%, rgba(13, 148, 136, .05), transparent 52%), linear-gradient(180deg, #0f1a15 0%, #0a120e 100%);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  font-family: var(--font) !important;
  background: var(--body-bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
  line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6,
.page-header h1 {
  font-family: var(--font-display);
  letter-spacing: -.01em;
  line-height: 1.25;
}

.icon-left {
  margin-right: .45rem;
  color: var(--color-primary);
}

.icon-inline {
  margin-right: .35rem;
  color: var(--text-muted);
  font-size: .95em;
}

.alert-icon {
  margin-right: .4rem;
  display: inline-flex;
  align-items: center;
}

body.nav-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    padding: .75rem 1rem;
  }

  .theme-toggle {
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.95rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
  }

  .theme-toggle:hover,
  .theme-toggle:focus-visible {
    background: var(--surface);
    outline: none;
  }

  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    width: min(280px, 85vw);
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 4.5rem 0.75rem 1rem;
    margin: 0;
    background: var(--navbar-bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 150;
    overflow-y: auto;
  }

  .nav-links.open {
    transform: translateX(0) !important;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-close-container {
    display: flex;
    justify-content: flex-end;
    padding-bottom: .5rem;
  }

  .nav-close {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--navbar-text);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
  }

  .nav-close:hover,
  .nav-close:focus {
    background: var(--surface-2);
    border-color: var(--border);
    outline: none;
  }

  .nav-links a {
    display: block;
    width: 100%;
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
  }

  .nav-backdrop {
    display: none;
    pointer-events: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    transition: opacity .25s ease;
    opacity: 0;
    z-index: 140;
  }

  .nav-backdrop.open {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .sub-nav {
    width: 100%;
    overflow-x: visible;
    background: transparent;
    border-bottom: none;
    padding: 0;
  }

  .sub-nav .sub-nav-links {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .container {
    padding: 0 1rem;
  }
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: rgba(13, 148, 136, .22);
  color: var(--text);
}

:focus-visible {
  outline: 3px solid rgba(13, 148, 136, .35);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -42px;
  left: 12px;
  z-index: 1200;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: .45rem .85rem;
  font-size: .82rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: top .15s ease;
}

.skip-link:focus-visible {
  top: 12px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Scrollbar for Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* ── NAVBAR ──────────────────────────────────────────────── */
.navbar {
  background: var(--navbar-bg);
  color: var(--navbar-text);
  border-bottom: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navbar-text);
  font-family: var(--font-display);
  letter-spacing: -.01em;
  transition: opacity var(--transition-fast);
}

.navbar-brand:hover {
  text-decoration: none;
  color: var(--navbar-text);
  opacity: .85;
}

.navbar-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

/* ── Sidebar Navigation (all screen sizes) ────────────────── */
.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  position: fixed;
  top: 0;
  left: 0;
  width: min(280px, 85vw);
  height: 100vh;
    padding: 0.5rem 0.75rem 1rem;
  margin: 0;
  background: var(--navbar-bg);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform .25s ease;
  z-index: 150;
  overflow-y: auto;
}

.nav-links.open {
  transform: translateX(0) !important;
}

.nav-links li {
  width: 100%;
}

.nav-links a {
  display: block;
  width: 100%;
  color: var(--navbar-muted);
  font-weight: 500;
  font-size: .875rem;
  padding: .65rem .85rem;
  border-radius: var(--radius);
  transition: all var(--transition-fast);
  letter-spacing: .01em;
}

.nav-links a:hover {
  color: var(--navbar-text);
  background: rgba(255, 255, 255, .1);
  text-decoration: none;
  transform: translateX(2px);
}

.nav-links a[aria-current="page"] {
  color: var(--navbar-text);
  background: rgba(110, 231, 183, .12);
  border: 1px solid rgba(167, 243, 208, .25);
  font-weight: 600;
}

.nav-links .btn {
  margin-left: .5rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .06);
  color: var(--navbar-text);
  font-size: .85rem;
  padding: .4rem .75rem;
  border-radius: 999px;
  cursor: pointer;
  margin-left: .5rem;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .4);
  outline: none;
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: .4rem;
  margin-left: .5rem;
  color: var(--navbar-text);
  font-size: 1.5rem;
  line-height: 1;
}

.nav-toggle i {
  width: 22px;
  text-align: center;
}

.nav-toggle.open i {
  content: '\f00d';
}

.nav-close-container {
  display: flex;
  justify-content: flex-end;
  padding-bottom: .5rem;
}

.nav-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--navbar-text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.nav-close:hover,
.nav-close:focus {
  background: var(--surface-2);
  border-color: var(--border);
  outline: none;
}

.sub-nav {
  display: none;
}

.sub-nav.hidden {
  display: none !important;
}

.sub-nav .sub-nav-links {
  list-style: none;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

.sub-nav .sub-nav-links li {
  flex: 0 0 auto;
  font-weight: 600;
  font-size: .85rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.sub-nav .sub-nav-links a {
  color: var(--navbar-text);
  text-decoration: none;
  border: 1px solid transparent;
  padding: .35rem .7rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.sub-nav .sub-nav-links a:hover,
.sub-nav .sub-nav-links a:focus {
  color: var(--text);
  background: rgba(255, 255, 255, .16);
}

.nav-links .mobile-admin-heading {
  margin: 0.35rem 0.2rem 0.15rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-strong);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Family List (uses main .card / .search-bar / .pagination) ── */

.family-list-stats {
  color: var(--text-muted);
  font-size: .85rem;
}

.family-card-meta {
  font-size: .78rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Family index cards (shared by /family-group index and /family-list) ── */
.fgs-index-grid { display: flex; flex-direction: column; gap: .5rem; }
.fgs-index-card {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition-fast);
}
.fgs-index-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.fgs-index-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--color-primary-l);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.fgs-index-body { flex: 1; min-width: 0; }
.fgs-index-title { font-weight: 600; font-size: .95rem; }
.fgs-index-meta { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }
.fgs-index-arrow { color: var(--text-muted); flex-shrink: 0; }

/* Family-list rows pair an index card with a quick "Family Tree" action */
.fgs-index-row { display: flex; align-items: stretch; gap: .4rem; }
.fgs-index-row .fgs-index-card { flex: 1; }
.fgs-index-tree-btn {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: 0 .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--color-info);
  text-decoration: none;
  font-size: .85rem;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.fgs-index-tree-btn:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.family-member-notes {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .1rem;
}

.role-tag {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.sub-nav .sub-nav-links a[aria-current="page"] {
  color: var(--color-primary-d);
  background: var(--color-primary-l);
}

.btn-link {
  color: var(--navbar-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1;
  font-size: .85rem;
  font-weight: 600;
  padding: .35rem .7rem;
  border-radius: var(--radius-sm);
}

.btn-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.15);
}

/* ── LAYOUT ──────────────────────────────────────────────── */
.container {
  max-width: var(--content-max-width);
  width: 100%;
  margin: 10px;
  padding: 0 1.5rem;
  flex: 1;
  overflow-x: hidden;
  min-height: calc(100vh - 180px);
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .section-grid {
    grid-template-columns: 1fr;
  }
}

.footer {
  text-align: center;
  padding: 1rem 1.5rem;
  color: var(--text-muted);
  font-size: .82rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}

.footer a {
  color: var(--color-primary);
  font-weight: 500;
}

.footer a:hover {
  text-decoration: underline;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border: none;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: .01em;
}

.btn:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary-hover), var(--color-primary));
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 118, 110, .3);
}

.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(15, 118, 110, .4);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, .25);
}

.btn-danger:hover {
  box-shadow: 0 4px 12px rgba(239, 68, 68, .35);
}

.btn-warning {
  background: var(--color-warning);
  color: #fff;
  box-shadow: 0 2px 6px rgba(245, 158, 11, .25);
}

.btn-info {
  background: var(--color-info);
  color: #fff;
}

.btn-success {
  background: var(--color-success);
  color: #fff;
  box-shadow: 0 2px 6px rgba(16, 185, 129, .25);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-outline-secondary {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border-strong);
  box-shadow: none;
}

.btn-outline-secondary:hover {
  background: var(--surface-2);
  border-color: var(--text-muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-outline-danger {
  background: transparent;
  color: var(--color-danger);
  border: 1.5px solid var(--color-danger);
  box-shadow: none;
}

.btn-outline-danger:hover {
  background: var(--color-danger-l);
  color: var(--color-danger-d);
  transform: translateY(-1px);
}

.btn-sm {
  padding: .35rem .8rem;
  font-size: .8125rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: .2rem .5rem;
  font-size: .75rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.btn-chip-remove {
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--color-danger);
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
  margin-left: auto;
}

.btn-chip-remove:hover {
  background: var(--color-danger-l);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, .35);
}

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  color: var(--text);
}

/* ── ADMIN BREADCRUMB ────────────────────────────────────── */
.admin-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.admin-breadcrumb a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.admin-breadcrumb a:hover { text-decoration: underline; }
.admin-breadcrumb__sep { opacity: 0.5; }
.admin-breadcrumb__current { font-weight: 600; color: var(--text); }

.header-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  overflow-x: hidden;
}

.header-action-inline {
  flex: 0 0 auto;
  white-space: nowrap;
}

.header-actions::-webkit-scrollbar {
  height: 6px;
}

.header-actions::-webkit-scrollbar-thumb {
  background: rgba(15, 39, 33, .35);
  border-radius: 999px;
}

/* ── CARD ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  animation: cardRise .4s cubic-bezier(.4, 0, .2, 1);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card-accent {
  border-left-width: 5px;
  border-left-style: solid;
}

.card-accent-story {
  border-left-color: var(--accent-story);
}

.card-accent-tech {
  border-left-color: var(--accent-tech);
}

.card-accent-deploy {
  border-left-color: var(--accent-deploy);
}

.card-accent-collab {
  border-left-color: var(--accent-collab);
}

.card-accent-support {
  border-left-color: var(--accent-support);
}

.card-accent-privacy {
  border-left-color: var(--accent-privacy);
}

@keyframes cardRise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0;
  margin-bottom: 1.1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.card h2 svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── AVATAR ──────────────────────────────────────────────── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8125rem;
  flex-shrink: 0;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.avatar[data-gender="M"] {
  background: #dbeafe;
  color: #1d4ed8;
}

.avatar[data-gender="F"] {
  background: #fce7f3;
  color: #9d174d;
}

.avatar[data-gender="Other"] {
  background: #ede9fe;
  color: #6d28d9;
}

.avatar-lg {
  width: 52px;
  height: 52px;
  font-size: 1.2rem;
  border-width: 3px;
}

img.avatar,
img.avatar-lg {
  object-fit: cover;
  display: block;
}

/* ── PHOTO GALLERY (for multi‑image support) ─────────────────────────── */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

.photo-gallery .photo-thumb {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(15, 118, 110, .08), rgba(255, 255, 255, .65));
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.photo-gallery .photo-thumb:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.photo-gallery img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  filter: saturate(1.02);
}

.page-header .photo-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  flex-basis: 100%;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: .15rem;
}

.page-header .photo-strip img {
  flex: 0 0 auto;
}

.photo-thumb .photo-caption {
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-remove-form {
  position: absolute;
  bottom: 6px;
  right: 6px;
  z-index: 2;
}

.photo-remove-form button {
  font-weight: bold;
  background: rgba(255, 255, 255, .9);
  color: var(--color-danger);
  border: none;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.photo-remove-form button:hover {
  background: var(--color-danger-l);
}

/* primary image indicator */
.photo-thumb.primary {
  outline: 2px solid var(--color-primary);
  box-shadow: 0 12px 22px -16px rgba(15, 118, 110, .75);
}

.photo-thumb .primary-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(15, 118, 110, .92);
  color: #ffffff;
  font-size: .62rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.photo-thumb .primary-form {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  opacity: 0;
  transition: opacity var(--transition), transform var(--transition);
}

.photo-primary-static {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-warning);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.photo-thumb:not(.primary):hover .primary-form,
.photo-thumb:not(.primary):focus-within .primary-form {
  opacity: 1;
  transform: translateY(-1px);
}

.photo-primary-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, .92);
  color: var(--color-warning);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), background var(--transition), color var(--transition);
}

.photo-primary-btn:hover,
.photo-primary-btn:focus-visible {
  background: var(--color-warning);
  color: #ffffff;
  transform: translateY(-1px);
  outline: none;
}

.photo-gallery-managed .photo-thumb {
  animation: photo-rise .35s ease both;
  animation-delay: calc(var(--stagger, 0) * 40ms);
}

.photo-gallery-managed img {
  height: 140px;
}

.photo-gallery-compact {
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
}

.photo-gallery-compact img {
  height: 90px;
}

.photo-thumb.selectable {
  border: 1px solid var(--border);
}

.photo-thumb.selectable.is-primary {
  outline: 2px solid var(--color-primary);
  box-shadow: 0 10px 18px -12px rgba(15, 118, 110, .6);
}

.photo-gallery-managed .photo-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, .05), rgba(0, 0, 0, .45));
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 0;
}

.photo-gallery-managed .photo-thumb:hover::after {
  opacity: 1;
}

.photo-gallery-managed .photo-link {
  position: relative;
  z-index: 1;
}

.photo-manager-header {
  align-items: flex-end;
  gap: 1rem;
}

.photo-manager-summary {
  margin-bottom: 1.5rem;
}

.photo-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.photo-summary-item {
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.photo-summary-label {
  font-size: .85rem;
  color: var(--text-muted);
}

.photo-summary-value {
  font-size: 1.35rem;
}

.photo-summary-note {
  font-size: .75rem;
  color: var(--text-muted);
}

.photo-dropzone {
  border: 1px dashed var(--border-strong);
  padding: 1rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(15, 118, 110, .08), rgba(248, 250, 252, .6));
}

.photo-upload-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.photo-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.photo-bulk-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.bulk-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
  color: var(--text-muted);
}

.photo-select {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: rgba(255, 255, 255, .9);
  color: var(--text);
  font-size: .7rem;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  z-index: 2;
  box-shadow: var(--shadow-sm);
}

.photo-select-input {
  width: 14px;
  height: 14px;
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 15, 13, .72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 1200;
}

.photo-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.photo-lightbox img {
  max-width: min(90vw, 900px);
  max-height: 75vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.photo-lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, .9);
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.photo-lightbox-caption {
  margin-top: 1rem;
  font-size: .95rem;
  color: #f1f5f9;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.gallery-header-badge {
  display: flex;
  align-items: center;
}

@keyframes photo-rise {
  from {
    opacity: 0;
    transform: translateY(6px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* show page avatar strip primary highlight */
.thumbnail.primary {
  box-shadow: 0 0 0 2px var(--color-primary);
}

/* photo link encourages click to enlarge */
.photo-link {
  display: block;
}

/* styled file input */
.file-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.file-input-wrapper input[type=file] {
  padding: .5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.file-input-wrapper .note {
  font-size: .875rem;
  color: var(--text-muted);
}

/* ── PERSON CHIP ─────────────────────────────────────────── */
.person-chip {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.person-chip--editable {
  flex-wrap: wrap;
  align-items: center;
  row-gap: .45rem;
}

.person-chip:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.person-chip-name {
  font-weight: 500;
  font-size: .9375rem;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-chip-name:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.person-chip-badge {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .15rem .5rem;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.rel-chip-edit-form {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-left: .25rem;
}

.rel-chip-edit-form select {
  min-width: 88px;
  font-size: .75rem;
  padding: .18rem .3rem;
}

.person-chip--editable .rel-chip-edit-form {
  margin-left: auto;
}

.rel-chip-edit-form .btn {
  padding: .22rem .5rem;
  font-size: .72rem;
}

@media (max-width: 700px) {
  .person-chip--editable .person-chip-name {
    flex: 1 1 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .person-chip--editable .rel-chip-edit-form {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .person-chip--editable .rel-chip-edit-form select {
    min-width: 150px;
    flex: 1 1 160px;
  }
}
.badge-father {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-mother {
  background: #fce7f3;
  color: #9d174d;
}

.badge-child {
  background: #d1fae5;
  color: #065f46;
}

.badge-sibling {
  background: #e0e7ff;
  color: #4338ca;
}

.badge-spouse {
  background: #fef3c7;
  color: #92400e;
}

/* ── RELATIONSHIP GROUPS ─────────────────────────────────── */
.rel-group {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.rel-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.rel-group-header {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .75rem;
}

.rel-group-header h3 {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}

.rel-group-header svg {
  color: var(--text-muted);
}

.rel-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .5rem;
}

.rel-history-list {
  list-style: none;
  display: grid;
  gap: .5rem;
}

.rel-history-item {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: .55rem .7rem;
}

.rel-history-main {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* Legacy badge classes */
.rel-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .1rem .45rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.rel-badge-father {
  background: #dbeafe;
  color: #1d4ed8;
}

.rel-badge-mother {
  background: #fce7f3;
  color: #9d174d;
}

.rel-badge-child {
  background: #d1fae5;
  color: #065f46;
}

/* ── TABLE ───────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.table th {
  background: var(--surface-2);
  text-align: left;
  padding: .75rem 1rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: .9rem;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--table-row-hover);
}

.clickable-row.founder,
.table tr.clickable-row.founder {
  background: var(--founder-row-bg);
  box-shadow: inset 4px 0 0 0 var(--founder-row-accent);
}

.founder-cell {
  background: var(--founder-row-cell-bg);
  font-weight: 600;
}

.table-person-cell {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.table-person-cell a {
  font-weight: 500;
  color: var(--text);
}

.table-person-cell a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.gender-tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 20px;
}

.gender-tag-m {
  background: var(--badge-m-bg);
  color: var(--badge-m-text);
}

.gender-tag-f {
  background: var(--badge-f-bg);
  color: var(--badge-f-text);
}

.gender-tag-o {
  background: var(--badge-o-bg);
  color: var(--badge-o-text);
}

.status-tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 20px;
}

.status-alive {
  background: var(--status-alive-bg);
  color: var(--status-alive-text);
}

.status-deceased {
  background: var(--status-deceased-bg);
  color: var(--status-deceased-text);
}

.status-verified {
  background: var(--status-verified-bg);
  color: var(--status-verified-text);
}

.status-estimated {
  background: var(--status-estimated-bg);
  color: var(--status-estimated-text);
}

.status-founder {
  background: var(--status-founder-bg);
  color: var(--status-founder-text);
  border: 1px solid var(--color-warning);
}

.status-unverified {
  background: var(--status-unverified-bg);
  color: var(--status-unverified-text);
}

/* ── FORMS ───────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 200px;
}

.form-group label {
  font-size: .8125rem;
  font-weight: 700;
  margin-bottom: .35rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-control {
  padding: .6rem .85rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
  background: var(--surface);
}

.form-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}

.feedback-tag {
  display: inline-flex;
  line-height: 1;
  padding: .14rem .5rem;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 700;
  background: var(--color-primary-l);
  color: var(--color-primary);
  border: 1px solid rgba(15, 118, 110, .25);
  margin-left: .5rem;
}

.feedback-form {
  padding: .2rem .1rem 0;
}

.feedback-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin-bottom: .8rem;
  box-shadow: var(--shadow-sm);
}

.feedback-item p {
  margin: .45rem 0 .55rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.feedback-item .meta {
  font-size: .74rem;
  color: var(--text-light);
  margin-left: .45rem;
}

.feedback-item small {
  display: inline-block;
  margin-top: .35rem;
  color: #526a63;
}

.feedback-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  min-width: 240px;
  padding: .75rem 1rem;
  border-radius: 12px;
  color: var(--surface);
  font-weight: 700;
  backdrop-filter: blur(6px);
  z-index: 1200;
  opacity: .97;
  display: inline-block;
  font-size: .9rem;
}

.toast-success {
  background: rgba(16, 185, 129, .95);
}

.toast-warning {
  background: rgba(217, 119, 6, .95);
}

.toast-danger {
  background: rgba(239, 68, 68, .95);
}

.feedback-float-btn {
  position: fixed;
  right: 1rem;
  bottom: 0.5rem;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .25rem .5rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(13, 148, 136, .6);
  text-decoration: none;
  font-weight: 700;
  font-size: .87rem;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.feedback-float-btn:hover,
.feedback-float-btn:focus-visible {
  background: var(--color-primary-d);
  box-shadow: 0 16px 24px rgba(6, 57, 49, .28);
}

@media (max-width: 768px) {
  .feedback-float-btn {
    bottom: 1rem;
    right: .9rem;
  }
}


/* Inline form compatibility */
.form-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
}

.form-inline .form-group {
  flex-direction: row;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.form-inline .form-group label {
  margin-bottom: 0;
  white-space: nowrap;
  text-transform: none;
  font-size: .875rem;
}

/* ── INFO GRID ───────────────────────────────────────────── */
/* Definition list used on person detail page. On wide screens we lay items
   out in two columns; on narrow screens this collapses to a single column
   via the media query further down. */
.info-grid {
  display: grid;
  grid-template-columns: repeat(2, max-content 1fr);
  column-gap: 2.5rem;
  row-gap: .6rem;
}

.info-grid dt {
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.info-grid dd {
  font-size: .9375rem;
  display: flex;
  align-items: center;
}

.info-icon {
  color: var(--text-muted);
  cursor: help;
  font-size: .85rem;
  margin-left: .35rem;
}

code.person-id {
  font-family: "SFMono-Regular", "Consolas", "Courier New", monospace;
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .1em;
  background: var(--color-primary-l);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: .2rem .55rem;
  color: var(--color-primary-d);
  user-select: all;
}

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  border-left-width: 4px;
  border-left-style: solid;
  line-height: 1.5;
}

.alert-warning {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}

.alert-danger {
  background: var(--color-danger-l);
  border-color: var(--color-danger);
  color: #991b1b;
}

.alert ul {
  margin-top: .5rem;
  padding-left: 1.25rem;
}

.alert li {
  margin-bottom: .25rem;
}

/* ── MISC HELPERS ────────────────────────────────────────── */
.text-muted {
  color: var(--text-muted);
}

.required {
  color: var(--color-danger);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  color: var(--text-muted);
  font-size: 1.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
  font-size: 1rem;
  font-weight: 500;
}

.error-page {
  text-align: center;
  padding: 5rem 1rem;
}

.error-page h1 {
  font-size: 2.25rem;
  margin-bottom: .75rem;
  font-weight: 800;
  letter-spacing: -.03em;
}

.error-message {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

/* ── SEARCH BAR ──────────────────────────────────────────── */
.search-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.search-bar:focus-within {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.search-bar-inner {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}

.search-icon {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: .5rem .75rem .5rem 2.2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-2);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .16);
  background: var(--surface);
}

.search-select {
  padding: .5rem .8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  flex: 0 0 auto;
}

.search-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .16);
}

.search-results-count {
  margin: .6rem 0 0;
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Advanced filter row */
.search-bar-advanced {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.2rem;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  flex: 1 1 180px;
  min-width: 150px;
}

.filter-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.filter-range {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.filter-range-sep {
  font-size: .8rem;
  color: var(--text-light);
}

.form-control-sm {
  padding: .35rem .55rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: .82rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-2);
  flex: 1;
  min-width: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control-sm:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .16);
  background: var(--surface);
}

.search-bar-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .45rem;
}

.search-advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: none;
  border: none;
  padding: .2rem 0;
  font-size: .78rem;
  font-family: var(--font);
  color: var(--color-primary);
  cursor: pointer;
  font-weight: 600;
  transition: color var(--transition);
}

.search-advanced-toggle:hover {
  color: var(--color-primary-hover);
}

/* ── EXPORT / SPECIAL BUTTONS ────────────────────────────── */
.export-group {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.export-label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.btn-export-excel {
  background: #16a34a;
  color: #fff;
  box-shadow: 0 1px 3px rgba(22, 163, 74, .30);
}

.btn-export-excel:hover {
  background: #15803d;
  filter: none;
}

.btn-export-json {
  background: #7c3aed;
  color: #fff;
  box-shadow: 0 1px 3px rgba(124, 58, 237, .30);
}

.btn-export-json:hover {
  background: #6d28d9;
  filter: none;
}

.btn-tree-api {
  background: #1f2b29;
  color: #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .20);
}

.btn-tree-api:hover {
  background: #2f433d;
  filter: none;
}

/* ── CONFIRMATION MODAL ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 20, 15, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(6px);
  animation: fadeIn .15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  animation: modalIn .25s cubic-bezier(.4, 0, .2, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(.94) translateY(-12px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -.01em;
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

.modal-detail {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.modal-row {
  display: flex;
  gap: .75rem;
  align-items: baseline;
}

.modal-row-label {
  min-width: 110px;
  flex-shrink: 0;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.modal-row-value {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.modal-row-warn {
  color: var(--color-danger);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ── RESPONSIVE – Tablet (≤ 768px) ──────────────────────── */
@media (max-width: 768px) {
  .container {
    margin: 1.25rem auto;
    padding: 0 1rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .navbar {
    flex-wrap: wrap;
    padding: .65rem 1rem;
  }

  /* Dashboard */
  .dash-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
  }

  .dash-header-actions {
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .75rem;
  }

  /* Charts */
  .chart-grid {
    grid-template-columns: 1fr;
  }

  /* Table horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }

  .clickable-row.founder,
  .table tr.clickable-row.founder {
    background: var(--founder-row-bg) !important;
    box-shadow: inset 4px 0 0 0 var(--founder-row-accent) !important;
  }

  .clickable-row.founder td,
  .table tr.clickable-row.founder td {
    background: var(--founder-row-cell-bg) !important;
    font-weight: 600 !important;
  }

  /* Search hero */
  .search-hero-inner {
    flex-wrap: wrap;
    gap: .5rem;
    padding: .5rem .75rem;
  }

  .search-hero-input {
    font-size: .95rem;
    min-width: 0;
  }

  /* Relationship finder path – vertical timeline */
  .rf-path {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 1rem 0 1rem 44px;
    position: relative;
    overflow-x: visible;
  }

  .rf-path::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 20px;
    bottom: 20px;
    width: 2px;
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--border-strong, #cbd5e1) 100%);
    border-radius: 2px;
  }

  .rf-path-node {
    flex-direction: row;
    align-items: center;
    text-align: left;
    max-width: none;
    min-width: 0;
    padding: .6rem .85rem;
    gap: .65rem;
  }

  /* Timeline dot on every node */
  .rf-path-node::before {
    content: '';
    position: absolute;
    left: -34px;
    width: 12px;
    height: 12px;
    background: var(--surface, #fff);
    border: 2.5px solid var(--color-primary);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
    z-index: 2;
  }

  /* Horizontal branch from dot to node card */
  .rf-path-node::after {
    content: '';
    position: absolute;
    left: -22px;
    top: 50%;
    width: 22px;
    height: 2px;
    background: var(--border, #e2e8f0);
    z-index: 1;
  }

  /* Start node – filled dot */
  .rf-path>.rf-path-node:first-child::before {
    background: var(--color-primary);
    width: 14px;
    height: 14px;
    left: -35px;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .15);
  }

  .rf-path>.rf-path-node:first-child::after {
    left: -21px;
    width: 21px;
  }

  /* End node – filled dot */
  .rf-path-step:last-child .rf-path-node::before {
    background: var(--color-primary);
    width: 14px;
    height: 14px;
    left: -35px;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .15);
  }

  .rf-path-step:last-child .rf-path-node::after {
    left: -21px;
    width: 21px;
  }

  .rf-node-name {
    max-width: none;
    font-size: .85rem;
  }

  .rf-path-step {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .rf-path-connector {
    flex-direction: row;
    align-items: center;
    padding: .35rem 0 .35rem 4px;
    gap: .5rem;
    min-width: 0;
  }

  .rf-path-connector::before {
    display: none;
  }

  .rf-arrow-line {
    display: none;
  }

  .rf-rel-label {
    font-size: .72rem;
    padding: .2rem .65rem;
  }

  /* Person show: header with avatar */
  .page-header>div[style*="display:flex"] {
    flex-wrap: wrap;
  }

  /* Search bar filters stack */
  .search-bar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-wrap {
    flex: 1 1 100%;
    min-width: 0;
  }

  .search-select {
    width: 100%;
  }

  .search-bar-advanced {
    flex-direction: column;
  }

  .filter-group {
    flex: 1 1 100%;
  }

  .header-actions {
    flex-wrap: wrap;
    overflow-x: hidden;
  }

  .header-action-inline {
    font-size: .78rem;
    padding: .45rem .7rem;
  }

  /* Relationship finder */
  .rf-selectors {
    grid-template-columns: 1fr;
  }

  /* Export buttons */
  .export-group {
    flex-wrap: wrap;
  }
}

/* ── RESPONSIVE – Mobile (≤ 640px) ──────────────────────── */
@media (max-width: 640px) {
  .container {
    margin: 1rem auto;
    padding: 0 .75rem;
  }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .6rem;
  }

  .page-header h1 {
    font-size: 1.3rem;
  }

  /* Forms */
  .form-row {
    flex-direction: column;
    gap: .75rem;
  }

  .form-group {
    min-width: 0;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  /* Add-relationship form */


  /* Table */
  .table {
    font-size: .82rem;
  }

  .table td,
  .table th {
    padding: .4rem .45rem;
  }

  /* Fixed header actions on narrowest mobiles */
  .header-actions {
    justify-content: flex-start;
  }

  .header-action-inline {
    flex: 1 1 100%;
    min-width: 0;
  }


  /* Cards */
  .card {
    padding: 1.15rem;
    margin-bottom: 1rem;
  }

  /* Relationship list */
  .rel-list {
    grid-template-columns: 1fr;
  }

  /* Dashboard */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
  }

  .stat-card {
    padding: .85rem;
    gap: .65rem;
  }

  .stat-value {
    font-size: 1.45rem;
  }

  .stat-label {
    font-size: .72rem;
  }

  .dash-two-col {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .quick-links {
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
  }

  /* Modal */
  .modal-box {
    max-width: 100%;
    border-radius: var(--radius-lg);
  }

  .modal-header {
    padding: 1rem 1.15rem;
  }

  .modal-body {
    padding: 1rem 1.15rem;
  }

  .modal-footer {
    flex-direction: column-reverse;
    padding: .85rem 1.15rem;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .modal-row {
    flex-direction: column;
    gap: .15rem;
  }

  .modal-row-label {
    min-width: unset;
  }

  /* Search hero */
  .search-hero-inner {
    padding: .5rem .75rem;
    border-radius: var(--radius-lg);
  }

  .search-hero-input {
    font-size: .95rem;
  }

  /* Pagination */
  .pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: .5rem;
  }

  .pagination-controls {
    justify-content: center;
  }

  /* Breadcrumb */
  .breadcrumb {
    font-size: .78rem;
  }

  /* Person chip */
  .person-chip {
    padding: .45rem .6rem;
    gap: .5rem;
  }

  /* Info grid */
  .info-grid {
    grid-template-columns: 1fr;
    gap: .5rem;
  }

  .info-grid dt {
    font-size: .72rem;
  }

  .info-grid dd {
    font-size: .875rem;
  }

  /* Kinship banner */
  .rf-kinship-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
    padding: .75rem 1rem;
  }

  .rf-kinship-text {
    font-size: .95rem;
  }

  /* Relationship finder path – tighter on small screens */
  .rf-path {
    padding-left: 38px;
  }

  .rf-path::before {
    left: 13px;
  }

  .rf-path-node::before {
    left: -29px;
    width: 10px;
    height: 10px;
  }

  .rf-path-node::after {
    left: -19px;
    width: 19px;
  }

  .rf-path>.rf-path-node:first-child::before {
    left: -30px;
    width: 12px;
    height: 12px;
  }

  .rf-path>.rf-path-node:first-child::after {
    left: -18px;
    width: 18px;
  }

  .rf-path-step:last-child .rf-path-node::before {
    left: -30px;
    width: 12px;
    height: 12px;
  }

  .rf-path-step:last-child .rf-path-node::after {
    left: -18px;
    width: 18px;
  }

  .rf-path-node .avatar-lg {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .rf-node-name {
    font-size: .8rem;
  }

  /* Search table: hide less vital columns */
  .table .hide-sm {
    display: none;
  }

  /* Person chip responsive */
  .person-chip-badge {
    font-size: .65rem;
    padding: .1rem .4rem;
  }
}

/* ── RESPONSIVE – Small phones (≤ 400px) ─────────────────── */
@media (max-width: 400px) {
  .container {
    padding: 0 .5rem;
  }

  .navbar {
    padding: .5rem .65rem;
  }

  .navbar-brand span {
    font-size: .95rem;
  }

  .navbar-logo {
    width: 28px;
    height: 28px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    flex-direction: row;
  }

  .page-header h1 {
    font-size: 1.15rem;
  }

  .btn {
    padding: .45rem .85rem;
    font-size: .82rem;
  }

  .btn-sm {
    padding: .3rem .65rem;
    font-size: .78rem;
  }

  .card {
    padding: .9rem;
    border-radius: var(--radius);
  }

  .table td,
  .table th {
    padding: .4rem .45rem;
    font-size: .78rem;
  }

  /* Hide less essential table columns on tiny screens */
  .table .hide-xs {
    display: none;
  }

  .table .hide-sm {
    display: none;
  }

  .quick-links {
    grid-template-columns: 1fr;
  }

  .quick-link {
    flex-direction: row;
    padding: .75rem;
    gap: .6rem;
  }

  .ql-icon {
    width: 32px;
    height: 32px;
    font-size: .95rem;
  }
}

/* ── ACTION DROPDOWN (3-dot menu for mobile) ────────────────── */
.action-dropdown {
  position: relative;
  display: inline-flex;
}

/* The 3-dot trigger – hidden on desktop */
.action-dot-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}

.action-dot-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* The dropdown panel */
.action-dropdown-menu {
  /* On desktop: just render inline as normal flex row */
  display: flex;
  gap: .4rem;
  align-items: center;
  flex-wrap: nowrap;
}

/* ── Mobile: show 3-dot, hide inline buttons ── */
@media (max-width: 768px) {
  .action-dot-btn {
    display: flex;
  }

  .action-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    flex-direction: column;
    align-items: stretch;
    min-width: 120px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .35rem;
    z-index: 50;
    gap: .2rem;
  }

  .action-dropdown-menu.open {
    display: flex;
  }

  .action-dropdown-menu .btn {
    width: 100%;
    justify-content: flex-start;
    font-size: .8rem;
    padding: .4rem .65rem;
  }
}

/* ── Icon action buttons ───────────────────────────── */
.action-icon,
.action-icon button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text);
  border: 1px solid transparent;
  background: transparent;
  padding: 0;
  margin: 0 2px;
  font-size: 0.85rem;
  cursor: pointer;
}

.action-icon:hover,
.action-icon button:hover {
  background: rgba(15, 118, 110, .1);
  color: var(--color-primary);
  border-color: rgba(15, 118, 110, .2);
}

.action-icon-danger,
.action-icon-danger:hover,
.action-icon-danger:focus {
  color: var(--color-danger);
  background: rgba(239, 68, 68, .1);
  border-color: rgba(239, 68, 68, .2);
}

.action-icon i {
  font-size: 0.95rem;
}

/* ── Add Relationship fields ───────────────────────── */
.rel-add-row {
  margin-bottom: 1.1rem;
}

.rel-add-label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

/* ── Relationship type chips (radio buttons styled as pills) ── */
.rel-type-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.rel-type-chip {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.rel-type-chip input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.rel-type-chip span {
  display: inline-flex;
  align-items: center;
  padding: .4rem .95rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 20px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  transition: border-color var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
  user-select: none;
}

.rel-type-chip:hover span {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-l);
}

.rel-type-chip.active span,
.rel-type-chip input:checked~span {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, .30);
}

/* ── Person search box ──────────────────────────────────────── */
.rel-person-search-wrap {
  position: relative;
  margin-bottom: .6rem;
}

.rel-search-icon {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.rel-person-search {
  width: 100%;
  padding: .55rem .75rem .55rem 2.2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface-2);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.rel-person-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
  background: var(--surface);
}

/* ── Scrollable person pick list ────────────────────────────── */
.rel-person-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rel-person-list::-webkit-scrollbar {
  width: 5px;
}

.rel-person-list::-webkit-scrollbar-track {
  background: transparent;
}

.rel-person-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.rel-person-option {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.rel-person-option:last-child {
  border-bottom: none;
}

.rel-person-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.rel-person-option:hover {
  background: var(--color-primary-l);
}

.rel-person-option.founder {
  background: var(--founder-row-cell-bg);
  border-left: 3px solid var(--founder-row-accent);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.32);
}

.rel-person-option.founder .rel-person-option-name::after {
  content: ' (Founder)';
  color: var(--status-founder-text);
  font-size: 0.75rem;
  margin-left: 0.35rem;
}

.rel-person-option.selected {
  background: var(--color-primary-l);
  border-left: 3px solid var(--color-primary);
}

.rel-person-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .75rem;
  flex-shrink: 0;
  text-transform: uppercase;
  background: #e6fffa;
  color: #0f4d2b;
  user-select: none;
}

.rel-person-avatar[data-gender="M"] {
  background: #dbeafe;
  color: #1d4ed8;
}

.rel-person-avatar[data-gender="F"] {
  background: #fce7f3;
  color: #9d174d;
}

.rel-person-avatar[data-gender="Other"] {
  background: #ede9fe;
  color: #6d28d9;
}

img.rel-person-avatar {
  object-fit: cover;
  display: block;
}

.rel-no-results {
  font-size: .875rem;
  color: var(--text-muted);
  padding: .75rem;
}

.rel-add-actions {
  display: flex;
  margin-top: 1.25rem;
}

/* ── Person picker – name + meta layout ─────────────────── */
.rel-person-option-info {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
  min-width: 0;
}

.rel-person-option-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.rel-person-option-name .rel-parent-label {
  font-weight: 400;
  color: var(--text-muted);
}

.person-parent-label {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

a.rel-person-option-name {
  text-decoration: none;
}

a.rel-person-option-name:hover {
  color: var(--color-primary);
}

.rel-person-option-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem;
  font-size: .72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.rel-person-meta-sep {
  color: var(--text-light);
  font-size: .7rem;
}

.rel-person-id {
  font-family: "SFMono-Regular", "Consolas", "Courier New", monospace;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .05rem .3rem;
  color: var(--text-muted);
}

/* ── BREADCRUMB ──────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.breadcrumb-item {
  color: var(--color-primary);
  text-decoration: none;
}

.breadcrumb-item:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--text-light);
}

.breadcrumb-current {
  color: var(--text-muted);
  font-weight: 600;
}

/* ── PAGINATION ──────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.5rem;
  padding: .75rem 0;
}

.pagination-info {
  font-size: .85rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
}

.pagination-current {
  pointer-events: none;
}

/* ── DASHBOARD ───────────────────────────────────────────── */
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.dash-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.dash-subtitle {
  font-size: .95rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.dash-header-actions {
  display: flex;
  gap: .5rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* Flat, compact statistics groups (no nested card chrome) */
.stat-groups {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-group-title {
  margin: 0 0 .6rem;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .6rem;
  margin-bottom: 0;
}

.stat-card-sm {
  padding: .6rem .75rem;
  gap: .6rem;
  box-shadow: none;
}

.stat-card-sm .stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: .95rem;
}

.stat-card-sm .stat-value {
  font-size: 1.25rem;
}

.stat-card-sm .stat-label {
  font-size: .72rem;
  margin-top: .1rem;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 1.2rem;
  line-height: 1;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  font-family: var(--font-display);
}

.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

.stat-icon-blue {
  color: #15803d;
  background: #d1fae5;
  border-color: #bbf7d0;
}

.stat-icon-green {
  color: #059669;
  background: #d1fae5;
  border-color: #a7f3d0;
}

.stat-icon-gray {
  color: #64748b;
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.stat-icon-pink {
  color: #db2777;
  background: #fce7f3;
  border-color: #fbcfe8;
}

.stat-icon-indigo {
  color: #4f46e5;
  background: #e0e7ff;
  border-color: #c7d2fe;
}

.stat-icon-rose {
  color: #e11d48;
  background: #ffe4e6;
  border-color: #fecdd3;
}

.stat-icon-purple {
  color: #7c3aed;
  background: #ede9fe;
  border-color: #ddd6fe;
}

.stat-icon-lightblue {
  color: #0284c7;
  background: #e0f2fe;
  border-color: #bae6fd;
}

.stat-icon-teal {
  color: #0f766e;
  background: #ccfbf1;
  border-color: #99f6e4;
}

.stat-icon-amber {
  color: #b45309;
  background: #fef3c7;
  border-color: #fde68a;
}

.stat-icon-orange {
  color: #c2410c;
  background: #ffedd5;
  border-color: #fed7aa;
}

.stat-icon-yellow {
  color: #a16207;
  background: #fef9c3;
  border-color: #fef08a;
}

.stat-icon-black {
  color: #0f172a;
  background: #e2e8f0;
  border-color: #cbd5e1;
}

.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
  .dash-two-col {
    grid-template-columns: 1fr;
  }
}

.card-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-section-header h2 {
  margin: 0;
}

.dash-person-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dash-person-list-scrollable {
  max-height: 360px;
  overflow-y: auto;
  padding-right: .3rem;
}

/* Multi-column layout for person lists on wider screens (saves vertical space) */
@media (min-width: 640px) {
  .dash-person-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    column-gap: 1rem;
    row-gap: 0;
    align-content: start;
  }
}

.dash-person-list-scrollable::-webkit-scrollbar {
  width: 8px;
}

.dash-person-list-scrollable::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
}

.birthday-badge {
  background: #fef3c7;
  color: #92400e;
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .75rem;
}

.quick-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1.1rem .5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.quick-link:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-l);
  color: var(--color-primary-d);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.quick-link:hover .ql-icon {
  border-color: var(--color-primary);
  background: var(--surface);
  color: var(--color-primary-d);
}

.ql-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1rem;
  color: var(--color-primary);
}

/* ── COLLAPSIBLE SECTION ─────────────────────────────────── */
.collapsible-section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  /* hide default marker */
  background: var(--surface);
  transition: background .15s;
}

.collapsible-header:hover {
  background: var(--color-primary-l, #f0f4ff);
}

.collapsible-header::-webkit-details-marker {
  display: none;
}

.collapsible-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.collapsible-chevron {
  font-size: 1.2rem;
  transition: transform .2s ease;
  color: var(--text-muted, #888);
}

details.collapsible-section[open]>.collapsible-header .collapsible-chevron {
  transform: rotate(90deg);
}

.collapsible-body {
  padding: 1.25rem;
}

/* Always-expanded statistics section (no details/summary) */
.statistics-section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.statistics-section > .section-heading {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
}

/* ── STATS ───────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.chart-grid-wide {
  grid-template-columns: 1fr;
}

.chart-card h2 {
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  max-height: 220px;
}

.chart-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  font-size: .8rem;
  margin-top: .75rem;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot-male {
  background: var(--legend-dot-male);
}

.legend-dot-female {
  background: var(--legend-dot-female);
}

.legend-dot-other {
  background: var(--legend-dot-other);
}

.surname-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  max-height: 190px;
  overflow-y: auto;
  padding-right: .25rem;
}

.surname-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .88rem;
}

.surname-name {
  min-width: 100px;
  font-weight: 600;
}

.surname-bar-wrap {
  flex: 1;
  background: var(--surface-2);
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
}

.surname-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  min-width: 4px;
}

.surname-count {
  min-width: 24px;
  text-align: right;
  color: var(--text-muted);
  font-weight: 700;
  font-size: .82rem;
}

.stat-highlight {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .88rem;
}

.timeline-person-list {
  margin: .35rem 0 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
  font-size: .82rem;
}

.timeline-person-list li {
  margin-bottom: .1rem;
}

/* ── SEARCH HERO ─────────────────────────────────────────── */
.search-hero {
  margin-bottom: 1.5rem;
}

.search-hero-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: .6rem 1rem;
  box-shadow: var(--shadow);
}

.search-hero-icon {
  color: var(--text-light);
  flex-shrink: 0;
}

.search-hero-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.05rem;
  background: transparent;
  color: var(--text);
}

/* ── RELATIONSHIP FINDER ─────────────────────────────────── */
.rf-selectors {
  display: grid;
  align-items: start;
}

.rf-selector {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.rf-label {
  font-weight: 700;
  font-size: .88rem;
  color: var(--text-muted);
}

.rf-arrow {
  font-size: 2rem;
  color: var(--text-light);
  align-self: center;
  text-align: center;
}

.rf-person-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.rf-selected-chip {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .75rem;
  background: var(--color-primary-l);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .9rem;
  color: var(--color-primary);
}

/* ── Relationship Path – Redesigned ──────────────────────── */
.rf-path {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 1.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.rf-path-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  text-align: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  min-width: 112px;
  max-width: 132px;
  transition: none;
  position: relative;
}

/* ── Desktop: sidebar open by default (15vw / 85vw split) ── */
@media (min-width: 769px) {
  body {
    display: grid;
    grid-template-columns: 15vw 1fr;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    overflow: hidden;
  }

  .navbar {
    grid-column: 1;
    grid-row: 1 / -1;
    position: relative;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: .75rem 0;
    width: 100%;
    height: 100%;
    border-right: 1px solid var(--border-strong);
    border-bottom: none;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .navbar-brand {
    padding: 0 .75rem 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .5rem;
  }

  .theme-toggle {
    margin: .5rem .75rem;
    align-self: center;
  }

  .nav-links {
    position: static;
    transform: none;
    width: 100%;
    height: auto;
    flex: 1;
    padding: .5rem .25rem;
    z-index: auto;
  }

  .nav-toggle {
    display: none;
  }

  .nav-close {
    display: none;
  }

  .nav-close-container {
    display: none;
  }

  .container {
    grid-column: 2;
    grid-row: 2;
    margin-left: 0 !important;
    max-width: none !important;
    padding: 0 1.5rem;
    overflow-y: auto;
  }

  footer {
    grid-column: 2;
    grid-row: 3;
  }
}

.rf-ft-card {
  min-width: 112px;
  max-width: 132px;
}

.rf-path>.rf-path-node:first-child .rf-ft-card,
.rf-path-step:last-child .rf-path-node .rf-ft-card {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, .2), 0 8px 20px rgba(4, 33, 26, .14);
}

.rf-node-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  max-width: 100px;
  word-break: break-word;
  line-height: 1.3;
}

.rf-node-name:hover {
  color: var(--color-primary);
}

.rf-path-step {
  display: flex;
  align-items: center;
  gap: 0;
}

.rf-path-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: 0 .4rem;
  position: relative;
  min-width: 56px;
}

.rf-path-connector::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-strong, #cbd5e1);
  z-index: 0;
}

.rf-rel-label {
  font-size: .65rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #166534;
  padding: .15rem .5rem;
  border-radius: 20px;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}

.rf-arrow-line {
  font-size: 1rem;
  color: var(--text-light);
  position: relative;
  z-index: 1;
  line-height: 1;
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── ALERT ───────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}

.alert-danger {
  background: var(--color-danger-l);
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.alert-success {
  background: var(--color-primary-l);
  border: 1px solid var(--color-primary);
  color: var(--color-primary-d);
}

.rel-gender-pill {
  margin-left: auto;
  flex-shrink: 0;
  align-self: center;
}

/* ── API Login Page ──────────────────────────────────────────── */
.api-login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem;
}

.api-login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .08);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.api-login-icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
}

.api-login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 .4rem;
}

.api-login-sub {
  font-size: .9rem;
  color: var(--text-muted, #64748b);
  margin-bottom: 1.5rem;
}

.api-login-form {
  text-align: left;
}

.btn-block {
  width: 100%;
  margin-top: .25rem;
}

/* ── FT CARD (person cards used in family tree and descendant chart) ───── */
.ft-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .66rem .76rem .56rem;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(4, 33, 26, .1), 0 1px 2px rgba(4, 33, 26, .08);
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: box-shadow .2s ease, border-color .2s ease, opacity .2s ease;
  min-width: 100px;
  max-width: 128px;
  text-align: center;
  position: relative;
  overflow: visible;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  /* Remove forced 3D composite to reduce rendering blur when browser zoom is used */
  transform: none;
  backface-visibility: visible;
  will-change: box-shadow, opacity;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.ft-card .ft-avatar,
.ft-card .ft-name,
.ft-card .ft-years {
  transform: none;
  backface-visibility: visible;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.ft-card:hover {
  box-shadow: 0 14px 32px rgba(4, 33, 26, .18), 0 2px 8px rgba(4, 33, 26, .1);
  border-color: var(--color-primary);
  color: var(--text);
  text-decoration: none;
  z-index: 10;
}

.ft-card.ft-male {
  border-top: 3px solid #16a34a;
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 32px);
  border-left-color: rgba(16, 163, 82, .15);
  border-right-color: rgba(16, 163, 82, .15);
}

.ft-card.ft-owner {
  border-color: #fbbf24 !important;
  border-top: 3px solid #f59e0b !important;

  background: linear-gradient(180deg,
      rgba(255, 248, 220, 0.6),
      rgba(253, 230, 138, 0.4)) !important;

  box-shadow:
    0 0 0 2px rgba(251, 191, 36, 0.7),
    0 0 12px rgba(251, 191, 36, 0.6),
    0 0 25px rgba(245, 158, 11, 0.5),
    0 8px 24px rgba(245, 158, 11, 0.35),
    inset 0 0 10px rgba(255, 215, 0, 0.3) !important;

  transform: translateY(-1px) !important;
}

.ft-card.ft-owner:hover {
  box-shadow:
    0 0 0 2px rgba(245, 158, 11, .6),
    0 10px 30px rgba(245, 158, 11, .32),
    0 0 48px rgba(245, 158, 11, .4) !important;
}

.ft-father-card-wrap.ft-owner-wrap {
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .25), 0 0 20px rgba(245, 158, 11, .2), 0 0 40px rgba(245, 158, 11, .35);
  border-radius: 14px;
  padding: .15rem;
}

.ft-owner-badge-below {
  display: inline-block;
  margin-top: 6px;
  color: #b45309;
  font-size: .67rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  background: linear-gradient(135deg, rgba(255, 244, 229, .95), rgba(254, 243, 199, .94));
  border: 1px solid #f59e0b;
  border-radius: 999px;
  padding: 3px 8px;
  box-shadow: 0 0 10px rgba(245, 158, 11, .25);
  white-space: nowrap;
}

.ft-card.ft-female {
  border-top: 3px solid #ec4899;
  background: linear-gradient(180deg, #fdf2f8 0%, #ffffff 32px);
  border-left-color: rgba(236, 72, 153, .15);
  border-right-color: rgba(236, 72, 153, .15);
}

.ft-card.ft-other {
  border-top: 3px solid #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 32px);
  border-left-color: rgba(245, 158, 11, .16);
  border-right-color: rgba(245, 158, 11, .16);
}

[data-theme="dark"] .ft-card.ft-male {
  background: radial-gradient(circle at top left, #14532d 0%, #111827 100%);
}

[data-theme="dark"] .ft-card.ft-female {
  background: radial-gradient(circle at top left, #9d174d 0%, #111827 100%);
}

[data-theme="dark"] .ft-card.ft-other {
  background: radial-gradient(circle at top left, #7c2d12 0%, #111827 100%);
}

[data-theme="dark"] .rf-kinship-banner {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.75);
}

[data-theme="dark"] .rf-kinship-rel {
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.18);
}

[data-theme="dark"] .rf-kinship-analysis {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.ft-card.ft-ghost {
  border: 1.5px dashed #cbd5e1;
  background: var(--surface-2);
  opacity: 1;
  cursor: default;
  box-shadow: none;
}

.ft-card.ft-ghost:hover {
  transform: none;
  box-shadow: none;
  border-color: #cbd5e1;
  z-index: auto;
}

.ft-card.ft-deceased {
  filter: saturate(.7);
}

.ft-card.ft-deceased:hover {
  filter: saturate(.85);
}

.ft-card.ft-repeat {
  border-style: dashed;
  opacity: .8;
}

/* Highlight states */
.ft-card.ft-highlighted {
  box-shadow: 0 0 0 3px var(--color-primary), 0 8px 24px rgba(15, 118, 110, .24);
  border-color: var(--color-primary);
  z-index: 5;
  transform: translateY(-2px) scale(1.04);
}

.ft-card.ft-ancestor {
  box-shadow: 0 0 0 3px #f59e0b, 0 4px 12px rgba(245, 158, 11, .18);
  border-color: #f59e0b;
  z-index: 4;
}

.ft-card.ft-descendant {
  box-shadow: 0 0 0 3px #10b981, 0 4px 12px rgba(16, 185, 129, .18);
  border-color: #10b981;
  z-index: 4;
}

.ft-card.ft-dimmed {
  opacity: .18;
  pointer-events: none;
  filter: grayscale(.6);
  transition: opacity .3s ease, filter .3s ease;
}

.ft-card.ft-search-match {
  box-shadow: 0 0 0 3px #0f766e, 0 4px 16px rgba(15, 118, 110, .22);
  border-color: #0f766e;
  z-index: 4;
  animation: ft-pulse 1.8s ease infinite;
}

@keyframes ft-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, .34), 0 4px 16px rgba(15, 118, 110, .22);
  }

  70% {
    box-shadow: 0 0 0 9px rgba(15, 118, 110, 0), 0 4px 16px rgba(15, 118, 110, .22);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0), 0 4px 16px rgba(15, 118, 110, .22);
  }
}

/* Avatar */
.ft-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .88rem;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
  transition: box-shadow .2s ease;
  will-change: box-shadow;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.ft-card:hover .ft-avatar {
  transform: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

.ft-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  transition: filter .2s ease;
  image-rendering: auto;
  -webkit-image-rendering: auto;
  image-rendering: auto;
  backface-visibility: visible;
  -webkit-transform: none;
  transform: none;
  will-change: opacity;
}

.ft-card:hover .ft-avatar img {
  filter: brightness(1.05);
}

.ft-male .ft-avatar {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #166534;
}

.ft-female .ft-avatar {
  background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
  color: #be185d;
}

.ft-other .ft-avatar {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #b45309;
}

.ft-ghost .ft-avatar {
  background: var(--surface-2);
  color: var(--text-light);
}

.ft-name {
  font-size: .73rem;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
  color: var(--text);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ft-years {
  font-size: .63rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

.ft-age-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: var(--surface);
  font-size: .58rem;
  font-weight: 800;
  border-radius: 99px;
  padding: 2px 6px;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(37, 99, 235, .35);
  border: 1.5px solid var(--surface);
}

.ft-deceased .ft-age-badge {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.75);
}

/* ── Relationship Finder – Kinship Banner ──────────────────────────────── */
.rf-kinship-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--primary-light, #ecfdf5);
  border: 1px solid var(--primary, #16a34a);
  border-radius: 10px;
  padding: .9rem 1.25rem;
  margin-bottom: 1rem;
}

.rf-kinship-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.rf-kinship-text {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .35rem;
  font-size: 1.05rem;
}

.rf-kinship-a,
.rf-kinship-b {
  font-weight: 700;
  color: var(--text, #1e293b);
}

.rf-kinship-rel {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary, #16a34a);
  background: var(--primary-bg, #d1fae5);
  padding: .1rem .55rem;
  border-radius: 6px;
}

.rf-kinship-analysis {
  margin-top: .5rem;
  padding: .75rem;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: .4rem;
  color: var(--text, #1e293b);
}

.rf-kinship-analysis h3 {
  margin-top: 0;
  font-size: 1rem;
}

.rf-kinship-of {
  color: var(--text-muted, #64748b);
  font-size: .9rem;
}

/* ── Nav Dropdown ──────────────────────────────────────────────────────── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  cursor: pointer;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  min-width: 180px;
  padding: .35rem 0;
  z-index: 1000;
  list-style: none;
  margin: 0;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu li {
  margin: 0;
}

.nav-dropdown-menu a {
  display: block;
  padding: .45rem 1rem;
  font-size: .85rem;
  color: var(--text, #1e293b);
  text-decoration: none;
  white-space: nowrap;
}

.nav-dropdown-menu a:hover {
  background: var(--surface-2, #f1f5f9);
}

/* ── Print-friendly Styles ─────────────────────────────────────────────── */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
  }

  .navbar,
  .footer,
  .nav-toggle,
  .btn,
  .no-print,
  #confirm-modal,
  .rf-form,
  .page-header p {
    display: none !important;
  }

  .container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  svg {
    max-width: 100% !important;
    height: auto !important;
  }

  .tree-toolbar {
    display: none !important;
  }

  h1,
  h2,
  h3 {
    page-break-after: avoid;
  }

  table {
    font-size: 9pt;
  }
}
/* Utility classes extracted from repeated inline styles */
.u-m-0 { margin: 0 !important; }
.u-mb-1 { margin-bottom: 1rem !important; }
.u-mt-0 { margin-top: 0 !important; }
.u-mt-05 { margin-top: .5rem !important; }
.u-mt-075 { margin-top: .75rem !important; }
.u-mt-1 { margin-top: 1rem !important; }
.u-mr-03 { margin-right: .3rem !important; }
.u-mr-035 { margin-right: .35rem !important; }
.u-mr-04 { margin-right: .4rem !important; }
.u-mr-05 { margin-right: .5rem !important; }
.u-fs-085 { font-size: .85rem !important; }
.u-text-danger { color: var(--color-danger) !important; }
.u-obj-cover { object-fit: cover !important; }
.u-round-full { border-radius: 50% !important; }
.u-avatar-40-round-cover { width: 40px !important; height: 40px !important; border-radius: 50% !important; object-fit: cover !important; }
.u-avatar-60-round-cover { width: 60px !important; height: 60px !important; border-radius: 50% !important; object-fit: cover !important; }
.u-va-text-bottom { vertical-align: text-bottom !important; }
.u-hidden { display: none !important; }
.u-stat-card-pad-center { text-align: center !important; padding: 1.25rem 1rem !important; }
.u-stat-value { font-size: 2rem !important; font-weight: 700 !important; color: var(--color-primary) !important; }
.u-table-compact { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.u-th-left-pad { text-align: left; padding: 0.5rem; }
.u-th-right-pad { text-align: right; padding: 0.5rem; }
.u-td-pad { padding: 0.5rem; }
.u-td-right-pad { padding: 0.5rem; text-align: right; }
.u-td-break-pad { padding: 0.5rem; word-break: break-all; }

/* Layout utilities (shared classes replacing repeated inline styles) */
.u-flex { display: flex !important; }
.u-inline-flex { display: inline-flex !important; }
.u-flex-center { display: flex !important; align-items: center !important; }
.u-flex-between { display: flex !important; align-items: center !important; justify-content: space-between !important; }
.u-flex-col { display: flex !important; flex-direction: column !important; }
.u-flex-wrap { flex-wrap: wrap !important; }
.u-items-center { align-items: center !important; }
.u-items-end { align-items: flex-end !important; }
.u-items-start { align-items: flex-start !important; }
.u-justify-between { justify-content: space-between !important; }
.u-justify-center { justify-content: center !important; }
.u-gap-03 { gap: .3rem !important; }
.u-gap-035 { gap: .35rem !important; }
.u-gap-04 { gap: .4rem !important; }
.u-gap-045 { gap: .45rem !important; }
.u-gap-05 { gap: .5rem !important; }
.u-gap-06 { gap: .6rem !important; }
.u-gap-075 { gap: .75rem !important; }
.u-gap-1 { gap: 1rem !important; }
.u-gap-125 { gap: 1.25rem !important; }
.u-gap-15 { gap: 1.5rem !important; }
.u-mb-0 { margin-bottom: 0 !important; }
.u-mb-05 { margin-bottom: .5rem !important; }
.u-mb-075 { margin-bottom: .75rem !important; }
.u-mb-125 { margin-bottom: 1.25rem !important; }
.u-mb-15 { margin-bottom: 1.5rem !important; }
.u-mt-035 { margin-top: .35rem !important; }
.u-mt-055 { margin-top: .55rem !important; }
.u-ml-05 { margin-left: .5rem !important; }
.u-p-05 { padding: .5rem !important; }
.u-p-075 { padding: .75rem !important; }
.u-p-1 { padding: 1rem !important; }
.u-p-125 { padding: 1.25rem !important; }
.u-p-15 { padding: 1.5rem !important; }
.u-text-center { text-align: center !important; }
.u-text-muted { color: var(--text-muted) !important; }

/* Shared page grids (replaces repeated inline grid styles) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.u-muted-note { margin: 0.5rem 0; color: var(--gray-color-ml); }
/* 
   FAMILY TREE  redesigned styles
    */

.ft-page-header,
.ft-toolbar,
.ft-stats-panel,
.ft-focus-bar,
.ft-legend,
.ft-side-panel,
.ft-zoom-indicator,
.ft-mobile-zoom {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

@keyframes ft-float-in {
  
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/*  PAGE HEADER  */
.ft-page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem; margin-bottom: .9rem;
  padding: .9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 10% 0%, rgba(16,185,129,.08), transparent 58%),
    radial-gradient(80% 120% at 100% 100%, rgba(15,118,110,.09), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}
.ft-page-header-left h1 {
  font-size: 1.6rem; font-weight: 800; color: var(--text); letter-spacing: -.025em;
  display: flex; align-items: center; gap: .5rem;
  line-height: 1.15;
}
.ft-page-header-left h1 .ft-tree-icon { font-size: 1.5rem; }
.ft-subtitle {
  color: var(--text-muted); font-size: .875rem; margin-top: .3rem;
  display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
}
.ft-subtitle-pill {
  display: inline-flex; align-items: center; gap: .25rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 99px; padding: .1rem .55rem; font-size: .75rem;
  color: var(--text-muted); font-weight: 500;
}
.ft-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/*  TOOLBAR  */
.ft-toolbar {
  display: flex; align-items: center; justify-content: space-evenly; flex-wrap: wrap; gap: .45rem;
  padding: .55rem .85rem;
  top: calc(4.2rem + env(safe-area-inset-top, 0px)); z-index: 40;
  background: var(--toolbar-bg); border: 1px solid var(--toolbar-border);
  border-radius: var(--radius); margin-bottom: .75rem;
  box-shadow: var(--toolbar-shadow);
  animation: ft-float-in .28s ease;
}
.ft-toolbar-secondary {
  margin-top: 0.4rem;
  top: calc(4.2rem + 3.4rem + env(safe-area-inset-top, 0px));
  z-index: 39;
}
.ft-toolbar-group { display: flex; align-items: center; gap: .35rem; }
.ft-toolbar-sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; margin: 0 .2rem; }
.ft-toolbar-label { font-size: .72rem; color: var(--text-muted); white-space: nowrap; font-weight: 500; }

.ft-filter-select {
  min-width: 116px;
  padding: .35rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .76rem;
  font-weight: 500;
  outline: none;
}
.ft-filter-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,.14);
  background: var(--surface);
}

/* Search */
.ft-search-wrap { position: relative; }
.ft-search-wrap input {
  padding: .35rem .7rem .35rem 2rem;
  border: 1px solid var(--border); border-radius: 99px;
  font-size: .8rem; background: var(--surface-2); color: var(--text);
  width: 250px; transition: border-color .15s, box-shadow .15s, width .25s;
  outline: none;
}
.ft-search-wrap input:focus {
  border-color: var(--color-primary); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12); width: 240px;
}
.ft-search-wrap input::placeholder { color: var(--text-light); }
.ft-search-icon {
  position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .8rem; pointer-events: none; line-height: 1;
}
.ft-search-count {
  position: absolute; right: .65rem; top: 50%; transform: translateY(-50%);
  font-size: .68rem; color: var(--color-primary); font-weight: 700; letter-spacing: .02em;
}

/* Zoom display */
.ft-zoom-val {
  font-size: .75rem; color: var(--text-muted); min-width: 38px;
  text-align: center; font-variant-numeric: tabular-nums; font-weight: 600;
}
/* Toolbar buttons */
.ft-tbtn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .3rem .65rem; border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text);
  transition: all .15s cubic-bezier(.4,0,.2,1);
  white-space: nowrap; line-height: 1.4;
}
.ft-tbtn:hover {
  background: var(--surface); border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 1px 4px rgba(37,99,235,.12);
}
.ft-tbtn:active { transform: scale(.95); }
.ft-tbtn:focus-visible {
  outline: 3px solid rgba(15,118,110,.25);
  outline-offset: 1px;
}
.ft-tbtn.active {
  background: var(--color-primary-l); border-color: var(--color-primary);
  color: var(--color-primary); box-shadow: 0 1px 4px rgba(37,99,235,.15);
}

/* Export menu */
.ft-export-menu { position: relative; }
.ft-export-panel {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 160;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 10px 24px rgba(0,0,0,.12);
  padding: .35rem; min-width: 180px; display: none;
}
.ft-export-panel.open { display: block; }

@media (max-width: 640px) {
  .ft-toolbar { overflow: visible !important; }
  .ft-export-panel {
    position: fixed;
    top: calc(62px + env(safe-area-inset-top, 0px));
    right: 8px;
    left: auto;
    min-width: 190px;
    max-width: calc(100% - 16px);
    box-shadow: 0 14px 32px rgba(0,0,0,.28);
  }
}
.ft-export-option {
  display: flex; align-items: center; gap: .45rem;
  width: 100%; padding: .4rem .55rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font-size: .78rem; color: var(--text); text-align: left;
}
.ft-export-option:hover {
  background: var(--surface-2); border-color: var(--border);
}
.ft-export-option {
  justify-content: space-between;
}
.ft-export-option-label {
  flex: 1 1 auto;
}
.ft-export-option-meta {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: .66rem;
  margin-left: .4rem;
  white-space: nowrap;
}

/*  STATS PANEL  */
.ft-stats-panel {
  display: none; flex-wrap: wrap; gap: .6rem;
  padding: .85rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: .75rem;
  box-shadow: var(--shadow-sm); animation: ft-fadein .2s ease;
}
.ft-stats-panel.visible { display: flex; }
.ft-stat-card {
  display: flex; align-items: center; gap: .65rem; flex: 1 1 160px;
  padding: .65rem .85rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 120px;
}
.ft-stat-icon { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.ft-stat-body { display: flex; flex-direction: column; }
.ft-stat-val { font-size: 1.35rem; font-weight: 800; color: var(--text); line-height: 1; }
.ft-stat-lbl { font-size: .7rem; color: var(--text-muted); margin-top: .15rem; }

/*  FOCUS BANNER  */
.ft-focus-bar {
  display: none; align-items: center; gap: .75rem;
  padding: .5rem 1rem; background: var(--focus-bar-bg); border: 1px solid var(--focus-bar-border);
  border-radius: var(--radius); margin-bottom: .75rem;
  font-size: .85rem; animation: ft-fadein .2s ease;
}
.ft-focus-bar.visible { display: flex; }
.ft-focus-icon { font-size: 1rem; }
.ft-focus-bar strong { color: var(--text); }
.ft-focus-bar .ft-clear-btn {
  margin-left: auto; padding: .2rem .7rem; border: 1px solid var(--focus-bar-border);
  border-radius: var(--radius-sm); background: transparent; color: var(--focus-bar-text);
  cursor: pointer; font-size: .78rem; font-weight: 600; transition: background .12s;
}
.ft-focus-bar .ft-clear-btn:hover { background: var(--focus-bar-btn-hover); }

/*  LEGEND  */
.ft-legend {
  display: flex; gap: .75rem; flex-wrap: wrap; align-items: center;
  font-size: .78rem; color: var(--text-muted); margin-bottom: .75rem;
  padding: .5rem .9rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.ft-legend-item { display: flex; align-items: center; gap: .35rem; font-weight: 500; }
.ft-legend-swatch {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.ft-legend-swatch.male   { background: linear-gradient(135deg, #dbeafe, #93c5fd); border: 2px solid #3b82f6; }
.ft-legend-swatch.female { background: linear-gradient(135deg, #fce7f3, #f9a8d4); border: 2px solid #ec4899; }
.ft-legend-swatch.other  { background: linear-gradient(135deg, #ede9fe, #c4b5fd); border: 2px solid #8b5cf6; }
.ft-legend-swatch.ghost  { background: #f1f5f9; border: 2px dashed #94a3b8; }
.ft-legend-hint {
  margin-left: auto; display: flex; align-items: center; gap: .5rem;
  color: var(--text-light); font-size: .72rem;
}
.ft-legend-hint kbd {
  display: inline-flex; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 .3rem; font-size: .68rem;
  font-family: inherit; color: var(--text-muted); line-height: 1.6;
}

/*  CANVAS OUTER  */
.ft-outer {
  overflow: hidden; position: relative;
  height: 75vh; min-height: 400px;
  background: linear-gradient(180deg, #f8fcfa 0%, var(--surface) 100%);
  background-image:
    radial-gradient(circle, rgba(191,210,202,.8) .6px, transparent .6px);
  background-size: 24px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 0 60px rgba(0,0,0,.015);
  cursor: grab; user-select: none;
  transition: box-shadow .2s ease;
  contain: layout style paint;
  max-width: 100%;
}
.ft-outer:hover {
  box-shadow: var(--shadow-lg), inset 0 0 60px rgba(0,0,0,.02);
}
.ft-outer:active { cursor: grabbing; }

/* Corner gradient fade for a polished canvas edge feel */
.ft-outer::before {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, var(--surface) 0%, transparent 40px),
    linear-gradient(0deg,   var(--surface) 0%, transparent 40px),
    linear-gradient(90deg,  var(--surface) 0%, transparent 40px),
    linear-gradient(270deg, var(--surface) 0%, transparent 40px);
  border-radius: var(--radius-lg);
}

.ft-outer::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
}

/*  CANVAS INNER  */
.ft-inner {
  display: inline-block; min-width: 100%; min-height: 100%;
  transform-origin: 0 0; will-change: transform;
  padding: 80px 120px 120px 120px;
}

/*  FOREST  */
.ft-forest {
  display: flex; flex-direction: row; flex-wrap: nowrap;
  gap: 64px; justify-content: flex-start; align-items: flex-start;
}

.ft-component {
  display: flex; flex-direction: row; align-items: flex-start;
  gap: 56px; position: relative;
}

.ft-component + .ft-component {
  margin-left: 4px; padding-left: 34px;
  border-left: 2px dashed var(--border);
}

/*  TREE NODE  */
.ft-node { display: flex; flex-direction: column; align-items: flex-start; position: relative; }

/*  FATHER COLUMN – the sole branching anchor; v-connector + children hang from father's centre  */
.ft-father-col {
  display: flex; flex-direction: column; align-items: center; position: relative;
}

/*  FATHER CARD WRAP – sized only to the father card so children centre under him, not the couple  */
.ft-father-card-wrap {
  position: relative; display: inline-flex; justify-content: center; align-items: flex-start;
}
/* Spouse clearance is handled by padding on ft-child-wrap + JS connector fixup */

/*  SPOUSE EXTENSION – floats to the father's right without contributing to layout width  */
.ft-spouse-ext {
  position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: row; align-items: center;
  pointer-events: auto; z-index: 2;
}

/* Marriage connector */
.ft-marriage-bar {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 44px; flex-shrink: 0; position: relative;
}
.ft-marriage-bar::before {
  content: ''; position: absolute; top: 50%; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #f9a8d4 15%, #ec4899 50%, #f9a8d4 85%, transparent);
  transform: translateY(-50%);
}
.ft-marriage-bar::after {
  content: '\2665';
  position: relative; z-index: 1;
  font-size: 11px; color: #ec4899; line-height: 1;
  background: var(--surface); padding: 1px 4px;
  border-radius: 50%; 
  filter: drop-shadow(0 1px 2px rgba(236,72,153,.25));
}


/*  V-CONNECTOR – drops straight down from the father card's centre  */
.ft-v-connector {
  width: 2px; height: 32px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--border-strong) 0%, var(--border) 60%, rgba(203,213,225,.4) 100%);
  border-radius: 1px;
}

/*  UNION SEPARATOR  */
.ft-union-sep {
  margin-top: .55rem; font-size: .65rem; color: #ec4899;
  border-top: 1px dashed #fce7f3; padding-top: .4rem;
  width: 100%; text-align: center; font-weight: 600;
}

/*  CHILDREN ROW – centred naturally under ft-father-col  */
.ft-children-row {
  display: flex; flex-direction: row; align-items: flex-start; gap: 0; position: relative;
}

.ft-branch-collapsed {
  margin-top: .35rem;
  display: flex;
  justify-content: center;
}

.ft-branch-actions {
  margin-top: .25rem;
  display: flex;
  justify-content: center;
}

.ft-branch-toggle {
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  padding: .22rem .55rem;
  cursor: pointer;
  transition: all .14s ease;
}

.ft-branch-toggle:hover {
  background: var(--surface);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.ft-branch-toggle-collapse {
  border-style: solid;
}

/*  CHILD WRAP – horizontal bar across siblings, vertical drop to each child  */
.ft-child-wrap {
  display: flex; flex-direction: column; align-items: center;
  position: relative; padding-top: 20px; padding-left: 10px; padding-right: 20px;
}
/* Extra right padding when child has a spouse so the absolute card doesn't overlap siblings */
.ft-child-wrap:has(.has-spouse) { padding-right: 150px; }
/* Horizontal connector bar spanning siblings */
.ft-child-wrap::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--border-strong);
  border-radius: 1px;
}
/* Clip left half on first child so bar starts at drop point (--drop-x set by JS) */
.ft-child-wrap:first-child::before { left: var(--drop-x, 50%); }
/* Clip right half on last child so bar ends at drop point */
.ft-child-wrap:last-child::before  { right: calc(100% - var(--drop-x, 50%)); }
/* Single child: draw a short horizontal stub when child center is offset from parent drop */
.ft-child-wrap:only-child::before  {
  left: min(50%, var(--drop-x, 50%));
  right: calc(100% - max(50%, var(--drop-x, 50%)));
}
/* Vertical drop from bar down to the child card – position set by JS via --drop-x */
.ft-child-wrap::after {
  content: ''; position: absolute; top: 0; left: var(--drop-x, 50%); height: 32px;
  width: 2px;
  background: linear-gradient(180deg, var(--border-strong), rgba(203,213,225,.4));
  border-radius: 1px;
}

/*  GENERATION LABELS  */
.ft-gen-labels { position: absolute; left: 0; top: 0; bottom: 0; width: 58px; pointer-events: none; z-index: 10; }
.ft-gen-label {
  position: absolute; left: 6px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-radius: 99px; padding: 3px 10px;
  font-size: .64rem; font-weight: 700; color: var(--color-primary);
  white-space: nowrap; transform: translateY(-50%);
  box-shadow: 0 1px 4px rgba(37,99,235,.1);
  backdrop-filter: blur(4px);
}

/*  SIDE PANEL  */
.ft-side-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: 250px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-left: 1px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  box-shadow: -8px 0 28px rgba(0,0,0,.08);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
  z-index: 20; pointer-events: none;
}
.ft-side-panel.open { transform: translateX(0); pointer-events: all; }
.ft-side-backdrop {
  position: absolute; inset: 0; z-index: 19;
  background: rgba(2, 29, 22, .35);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.ft-side-backdrop.open {
  opacity: 1; pointer-events: all;
}
.ft-side-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2); border-radius: 0 var(--radius-lg) 0 0;
}
.ft-side-panel-title { font-size: .78rem; font-weight: 700; color: var(--text); }
.ft-side-close {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: 1rem; line-height: 1; padding: .1rem .3rem; border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.ft-side-close:hover { background: var(--border); color: var(--text); }
.ft-side-panel-body { padding: .85rem 1rem; flex: 1; overflow-y: auto; font-size: .8rem; }
.ft-side-avatar-row {
  display: flex; flex-direction: column; align-items: center;
  gap: .5rem; margin-bottom: .85rem; padding-bottom: .85rem;
  border-bottom: 1px solid var(--border);
}
.ft-side-avatar {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800; box-shadow: var(--shadow);
}
.ft-side-avatar.male   { background: #dbeafe; color: #1d4ed8; }
.ft-side-avatar.female { background: #fce7f3; color: #be185d; }
.ft-side-avatar.other  { background: #ede9fe; color: #6d28d9; }
.ft-side-name { font-size: .95rem; font-weight: 800; text-align: center; color: var(--text); }
.ft-side-gender-pill {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .7rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px;
}
.ft-side-gender-pill.male   { background: #dbeafe; color: #1d4ed8; }
.ft-side-gender-pill.female { background: #fce7f3; color: #be185d; }
.ft-side-gender-pill.other  { background: #ede9fe; color: #6d28d9; }
.ft-side-row {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .3rem 0; border-bottom: 1px solid var(--border);
}
.ft-side-row:last-child { border-bottom: none; }
.ft-side-row-label {
  font-size: .7rem; color: var(--text-muted); min-width: 72px; flex-shrink: 0;
  font-weight: 600; padding-top: .05rem;
}
.ft-side-row-val { font-size: .78rem; color: var(--text); word-break: break-word; }
.ft-side-panel-footer { padding: .75rem 1rem; border-top: 1px solid var(--border); }
.ft-side-panel-footer a {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  width: 100%; padding: .45rem; border-radius: var(--radius-sm);
  background: var(--color-primary); color: #fff; font-size: .8rem; font-weight: 600;
  text-decoration: none; transition: background .12s;
}
.ft-side-panel-footer a:hover { background: var(--color-primary-d); text-decoration: none; }



/*  ZOOM HUD  */
.ft-zoom-indicator {
  position: absolute; bottom: 14px; left: 14px; z-index: 15;
  display: flex; align-items: center; gap: .35rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  padding: .35rem .7rem; font-size: .72rem; color: var(--text-muted); font-weight: 600;
  opacity: .85; transition: opacity .2s ease;
  backdrop-filter: blur(8px);
}
.ft-zoom-indicator:hover { opacity: 1; }

/*  EMPTY  */
.ft-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 5rem 2rem; color: var(--text-muted); text-align: center; gap: .75rem;
}
.ft-empty-icon { font-size: 3rem; opacity: .4; }
.ft-empty h2 { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.ft-empty p  { font-size: .9rem; }
.ft-build-status-meta { font-size: .82rem; color: var(--text-muted); margin-top: -.2rem; }
.ft-empty a  { color: var(--color-primary); font-weight: 600; }

.ft-card.ft-highlighted {
  border: 2px solid #2563eb;
  background: linear-gradient(180deg, rgba(37,99,235,.08), rgba(37,99,235,.02));
  box-shadow: 0 0 0 3px rgba(37,99,235,.22), 0 8px 20px rgba(15,118,110,.22);
  transform: scale(1.05);
  z-index: 10;
}

.ft-card.ft-focused, .ft-card.ft-ancestor { border-color: #9333ea; }
.ft-card.ft-descendant { border-color: #059669; }
.ft-card.ft-dimmed { opacity: .35; }

.ft-card.ft-focused {
  background: linear-gradient(180deg, rgba(147,51,234,.12), rgba(147,51,234,.03));
  box-shadow: 0 0 0 3px rgba(147,51,234,.24), 0 6px 16px rgba(99,102,241,.16);
}

.ft-card.ft-founder {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245,158,11,.35), 0 8px 21px rgba(245,158,11,.22);
  background: linear-gradient(180deg, rgba(245,158,11,.18), rgba(253,230,138,.08));
}

.ft-card.ft-founder .ft-avatar {
  box-shadow: 0 0 0 2px rgba(245,158,11,.45), inset 0 1px 2px rgba(0,0,0,.15);
}

.ft-card.ft-filtered-out {
  opacity: .16;
  filter: grayscale(.75);
  pointer-events: none;
  box-shadow: none;
}

.ft-verify-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 0px;
  display: inline-flex;
  align-items: end;
  justify-content: center;
  border-radius: 999px;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  text-transform: none;
}
.ft-verify-badge i {
  display: block;
  font-size: .8rem;
  line-height: 1;
}
.ft-verify-verified {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}
.ft-verify-estimated {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}
.ft-verify-unverified {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

/*  TOAST  */
.ft-toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); color: #fff;
  padding: .6rem 1.5rem;
  border-radius: 99px; font-size: .85rem; z-index: 3000;
  box-shadow: 0 8px 28px rgba(0,0,0,.35); white-space: nowrap;
  backdrop-filter: blur(8px);
  animation: ft-toast-in .3s cubic-bezier(.4,0,.2,1), ft-toast-out .35s ease 2.2s forwards;
}
@keyframes ft-toast-in  { from { opacity:0; transform:translateX(-50%) translateY(12px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
@keyframes ft-toast-out { from { opacity:1; } to { opacity:0; transform:translateX(-50%) translateY(8px); } }

/* Export progress */
.ft-export-progress {
  position: fixed; inset: 0; z-index: 3500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 29, 22, .45);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.ft-export-progress.visible { opacity: 1; pointer-events: all; }
.ft-export-progress-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.2rem; min-width: 260px;
  box-shadow: 0 10px 28px rgba(0,0,0,.2);
}
.ft-export-progress-title { font-size: .9rem; font-weight: 700; color: var(--text); }
.ft-export-progress-sub { font-size: .72rem; color: var(--text-muted); margin-top: .2rem; }
.ft-export-progress-bar {
  margin-top: .7rem; height: 8px; background: var(--surface-2);
  border-radius: 99px; overflow: hidden; border: 1px solid var(--border);
}
.ft-export-progress-fill {
  height: 100%; width: 0%; background: var(--color-primary);
  transition: width .12s ease;
}
.ft-export-progress-count {
  margin-top: .35rem; font-size: .7rem; color: var(--text-light); text-align: right;
}
.ft-export-progress-bytes {
  margin-top: .15rem; font-size: .68rem; color: var(--text-muted); text-align: right;
}
.ft-export-progress-size {
  margin-top: .15rem; font-size: .68rem; color: var(--text-muted); text-align: right;
}

/*  ANIMATIONS  */
@keyframes ft-fadein { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }

/* Mobile floating zoom FAB */
.ft-mobile-zoom {
  display: none; position: absolute; z-index: 16;
  bottom: 14px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: .25rem .35rem; gap: .2rem;
  align-items: center; backdrop-filter: blur(8px);
}
.ft-mobile-zoom .ft-tbtn {
  min-width: 38px; min-height: 38px;
  justify-content: center; border-radius: 50%; padding: 0;
  font-size: .85rem;
}
.ft-mobile-zoom .ft-zoom-val { font-size: .7rem; min-width: 34px; }

/* Side-panel drag handle for mobile bottom-sheet */
.ft-side-drag-handle {
  display: none; width: 36px; height: 4px; border-radius: 99px;
  background: var(--border-strong); margin: .5rem auto .15rem;
  flex-shrink: 0; opacity: .55;
}

/*  RESPONSIVE – Tablet (≤ 768px)  */
@media (max-width: 768px) {
  .ft-page-header { flex-direction: column; gap: .6rem; margin-bottom: .85rem; }
  .ft-actions { width: 100%; justify-content: flex-start; }

  .ft-toolbar {
    gap: .35rem; padding: .45rem .6rem;
    top: calc(5rem + env(safe-area-inset-top, 0px));
    justify-content: space-around; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ft-toolbar::-webkit-scrollbar { display: none; }
  .ft-toolbar-sep { display: none; }
  .ft-search-wrap input { width: 250px; }

  .ft-legend { gap: .5rem; padding: .4rem .65rem; font-size: .72rem; }
  .ft-legend-hint { display: none; }

  .ft-outer {
    height: 65vh; min-height: 350px;
    touch-action: none; overscroll-behavior: contain;
    -webkit-tap-highlight-color: transparent;
  }
  .ft-inner { padding: 60px 40px 80px 40px; }
  .ft-forest { gap: 38px; }
  .ft-component { gap: 34px; }
  .ft-component + .ft-component { padding-left: 22px; }

  .ft-side-panel { width: 240px; }

  .ft-stats-panel { gap: .45rem; padding: .65rem; }
  .ft-stat-card { flex: 1 1 140px; min-width: 100px; padding: .5rem .65rem; }
  .ft-stat-val { font-size: 1.1rem; }

  .ft-focus-bar { font-size: .8rem; gap: .5rem; padding: .4rem .75rem; flex-wrap: wrap; }

  /* Ensure all touch targets ≥ 44px for accessibility */
  .ft-tbtn { min-height: 40px; min-width: 40px; justify-content: center; }
  .ft-side-close { min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; }
}

/*  RESPONSIVE – Mobile (≤ 640px)  */
@media (max-width: 640px) {
  .ft-page-header-left h1 { font-size: 1.25rem; }
  .ft-page-header-left h1 .ft-tree-icon { font-size: 1.15rem; }
  .ft-subtitle { font-size: .75rem; gap: .25rem; }
  .ft-subtitle-pill { font-size: .68rem; padding: .05rem .4rem; }
  .ft-actions { flex-wrap: wrap; gap: .35rem; }
  .ft-actions .btn {
    flex: 1 1 auto; text-align: center; min-width: 0;
    min-height: 42px; font-size: .8rem;
  }

  /* Toolbar – horizontally scrollable with larger touch targets */
  .ft-toolbar {
    position: static;
    left: 0;
    right: 0;
    top: calc(5.25rem + env(safe-area-inset-top, 0px));
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: .35rem .45rem;
    gap: .25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }
  .ft-toolbar::-webkit-scrollbar { display: none; }
  .ft-tbtn {
    padding: .35rem .55rem; font-size: .72rem;
    min-height: 40px; min-width: 40px;
    justify-content: center; flex-shrink: 0;
  }
  .ft-search-wrap input {
    width: 250px; font-size: .78rem;
    min-height: 40px; padding-top: .4rem; padding-bottom: .4rem;
  }
  .ft-filter-select { min-width: 96px; min-height: 40px; font-size: .72rem; }
  .ft-zoom-val { font-size: .7rem; min-width: 32px; }

  /* Hide desktop zoom controls in old toolbar mode, now using two toolbars for mobile */
  /* .ft-toolbar .ft-toolbar-group:nth-child(3) { display: none; } */
  .ft-mobile-zoom { display: flex; }

  .ft-legend {
    flex-wrap: wrap; gap: .35rem; padding: .3rem .45rem;
    font-size: .68rem; margin-bottom: .5rem;
  }
  .ft-legend-swatch { width: 10px; height: 10px; }

  /* Canvas – maximize viewport usage with dvh fallback */
  .ft-outer {
    height: calc(100vh - 200px);
    height: calc(100dvh - 200px);
    min-height: 280px;
    border-radius: var(--radius);
    touch-action: none;
    overscroll-behavior: contain;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
  }
  .ft-side-backdrop.open { opacity: .55; }
  .ft-outer::before { border-radius: var(--radius); }
  .ft-outer:hover { box-shadow: var(--shadow-md), inset 0 0 60px rgba(0,0,0,.015); }
  .ft-inner { padding: 36px 20px 56px 20px; }
  .ft-forest { gap: 30px; }
  .ft-component { gap: 28px; }
  .ft-component + .ft-component { padding-left: 12px; }

  /* Compact person cards */
  .ft-card {
    box-sizing: border-box;
    flex: 0 0 auto;
    min-width: 92px; max-width: 92px;
    width: 92px;
    padding: .45rem .5rem .35rem;
    gap: .25rem;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    backface-visibility: hidden;
    transform: translateZ(0);
  }
  .ft-card:hover { transform: translateZ(0); box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04); }
  .ft-card:active { transform: translateZ(0); }
  .ft-card.ft-highlighted {
    border: 2px solid #2563eb;
    background: linear-gradient(180deg, rgba(37,99,235,.08), rgba(37,99,235,.02));
    box-shadow: 0 0 0 3px rgba(37,99,235,.22), 0 8px 20px rgba(15,118,110,.22);
    transform: none;
    z-index: 10;
  }
  .ft-card.ft-highlighted {
    border: 2px solid #2563eb;
    background: linear-gradient(180deg, rgba(37,99,235,.08), rgba(37,99,235,.02));
    box-shadow: 0 0 0 3px rgba(37,99,235,.22), 0 8px 20px rgba(15,118,110,.22);
    transform: scale(1.05);
    z-index: 10;
  }
  .ft-card.ft-ancestor { border-color: #9333ea; }
  .ft-card.ft-descendant { border-color: #059669; }
  .ft-card.ft-dimmed { opacity: .35; }
  .ft-avatar { width: 34px; height: 34px; font-size: .72rem; }
  .ft-card:hover .ft-avatar { transform: none; }
  .ft-name { font-size: .64rem; max-width: 86px; }
  .ft-years { font-size: .54rem; }
  .ft-age-badge { font-size: .5rem; padding: 1px 4px; top: -6px; right: -6px; }
  .ft-verify-badge { min-width: 16px; height: 16px; font-size: .5rem; top: -6px; left: -6px; padding: 0 5px; }

  .ft-marriage-bar { width: 20px; height: 32px; }
  .ft-marriage-bar::after { font-size: 9px; }

  .ft-v-connector { height: 20px; }
  .ft-child-wrap { padding-top: 20px; padding-left: 10px; padding-right: 10px; }
  .ft-child-wrap:has(.has-spouse) { padding-right: 120px; }
  .ft-child-wrap::after { height: 20px; }

  .ft-gen-labels { display: none; }

  /* Side panel as bottom sheet */
  .ft-side-panel {
    width: 100%; height: 52%; top: auto; bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: none; border-top: 1px solid var(--border);
    transform: translateY(100%);
    box-shadow: 0 -6px 24px rgba(0,0,0,.15);
    transition: transform .28s cubic-bezier(.32,.72,.0,1);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .ft-side-panel.open { transform: translateY(0); }
  .ft-side-panel-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .ft-side-drag-handle { display: block; }
  .ft-side-close {
    min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
  }
  .ft-side-panel-footer a {
    min-height: 44px; font-size: .85rem;
  }

  .ft-zoom-indicator { display: none; }

  .ft-stats-panel { flex-direction: column; gap: .35rem; padding: .5rem; }
  .ft-stat-card { flex: 1 1 100%; padding: .45rem .6rem; }
  .ft-stat-val { font-size: 1rem; }
  .ft-stat-lbl { font-size: .65rem; }

  .ft-focus-bar {
    font-size: .78rem; flex-direction: row; align-items: center;
    gap: .4rem; padding: .35rem .65rem;
  }
  .ft-focus-bar .ft-clear-btn { min-height: 36px; padding: .25rem .65rem; }

  .ft-empty { padding: 2.5rem 1rem; }
  .ft-empty-icon { font-size: 2.2rem; }
  .ft-empty h2 { font-size: 1rem; }
  .ft-empty p { font-size: .82rem; }

  .ft-toast {
    bottom: 1rem; font-size: .8rem; padding: .5rem 1.2rem;
    padding-bottom: calc(.5rem + env(safe-area-inset-bottom, 0));
  }
}

/*  RESPONSIVE – Small phones (≤ 400px)  */
@media (max-width: 400px) {
  .ft-page-header-left h1 { font-size: 1.05rem; }
  .ft-page-header { gap: .4rem; margin-bottom: .6rem; }
  .ft-subtitle-pill { font-size: .62rem; }
  .ft-actions .btn { font-size: .75rem; padding: .3rem .5rem; min-height: 40px; }

  .ft-toolbar { gap: .2rem; padding: .3rem .35rem; }
  .ft-tbtn { padding: .25rem .35rem; font-size: .66rem; min-height: 38px; min-width: 38px; }
  .ft-search-wrap input { width: 250px; min-height: 38px; font-size: .72rem; }

  .ft-legend { display: none; }

  .ft-card {
    box-sizing: border-box;
    flex: 0 0 auto;
    min-width: 78px; max-width: 78px;
    width: 78px;
    padding: .3rem .35rem .25rem; gap: .2rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    backface-visibility: hidden;
    transform: translateZ(0);
  }
  .ft-avatar { width: 26px; height: 26px; font-size: .58rem; }
  .ft-name { font-size: .54rem; max-width: 70px; }
  .ft-years { font-size: .48rem; }
  .ft-age-badge { font-size: .46rem; padding: 1px 3px; top: -5px; right: -5px; }
  .ft-verify-badge { min-width: 14px; height: 14px; font-size: .46rem; top: -5px; left: -5px; padding: 0 4px; }
  .ft-forest { gap: 20px; }
  .ft-component { gap: 16px; }

  .ft-outer {
    height: calc(100vh - 180px);
    height: calc(100dvh - 180px);
    min-height: 240px;
  }
  .ft-outer::before { display: none; }
  .ft-inner { padding: 20px 10px 32px 10px; }
  .ft-forest { gap: 16px; }
  .ft-component { gap: 12px; }
  .ft-component + .ft-component {
    padding-left: 8px;
    border-left-width: 1px;
  }

  .ft-child-wrap { padding-left: 6px; padding-right: 6px; padding-top: 18px; }
  .ft-child-wrap:has(.has-spouse) { padding-right: 90px; }
  .ft-child-wrap::after { height: 18px; }
  .ft-v-connector { height: 18px; }
  .ft-marriage-bar { width: 16px; height: 28px; }
  .ft-marriage-bar::after { font-size: 7px; }

  .ft-mobile-zoom { bottom: 10px; padding: .2rem .3rem; }
  .ft-mobile-zoom .ft-tbtn { min-width: 34px; min-height: 34px; font-size: .78rem; }

  .ft-side-panel { height: 58%; }
  .ft-side-avatar { width: 48px; height: 48px; font-size: 1.1rem; }
  .ft-side-name { font-size: .85rem; }

  .ft-focus-bar { font-size: .7rem; padding: .3rem .5rem; }

  .ft-toast { font-size: .75rem; padding: .4rem 1rem; }
}

/*  PRINT  */
@media print {
  .ft-toolbar,.ft-focus-bar,.ft-page-header .ft-actions,.ft-legend,
  nav,footer,.btn,.ft-side-panel,.ft-zoom-indicator { display:none !important; }
  .ft-outer { overflow:visible !important; height:auto !important; border:none !important; background:white !important; }
  .ft-inner { transform:none !important; }
  body      { background:white !important; }
  .ft-stats-panel { page-break-after:always; }
}

/* ════════════════════════════════════════════════════════════
   PAGE-LEVEL STYLES
   Consolidated from the <style> blocks that used to live inside
   individual page templates. All page styles now share this one
   stylesheet and common class names so the whole site matches.
   ════════════════════════════════════════════════════════════ */

/* ── TIMELINE ──────────────────────────────────────────── */
.timeline-wrap {
  position: relative;
  padding-left: 2.75rem;
}
.timeline-wrap::before {
  content: '';
  position: absolute;
  left: 1.05rem;
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, rgba(15, 118, 110, .15), var(--timeline-line), rgba(15, 118, 110, .08));
}
.timeline-scroll-sentinel { height: 1px; }
.tl-year-group { margin-bottom: 2.5rem; }
.tl-year-label {
  position: sticky;
  top: calc(4.25rem + env(safe-area-inset-top, 0px));
  z-index: 5;
  left: -2.75rem;
  display: inline-block;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-d));
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  padding: .25rem .7rem;
  border-radius: 20px;
  margin-bottom: .75rem;
  letter-spacing: .04em;
  box-shadow: 0 6px 14px rgba(15, 118, 110, .28);
}
.tl-events { display: flex; flex-direction: column; gap: .75rem; }
.tl-event {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  position: relative;
}
.tl-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: .25rem;
  position: absolute;
  left: -34px;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .08);
}
.tl-event-birth .tl-dot  { background: var(--timeline-dot-birth); }
.tl-event-death .tl-dot  { background: var(--timeline-dot-death); }
.tl-event-story .tl-dot,
.tl-event-milestone .tl-dot,
.tl-event-education .tl-dot,
.tl-event-work .tl-dot,
.tl-event-marriage .tl-dot,
.tl-event-migration .tl-dot,
.tl-event-other .tl-dot {
  background: var(--timeline-dot-custom);
}

.tl-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.1rem;
  flex: 1;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.tl-content:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.tl-event-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.tl-age { font-size: .72rem; color: var(--text-muted); margin-left: auto; }
.tl-person-meta { margin-left:.5rem; color: var(--text-muted); font-size: 14px; }
.tl-badge { font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 20px; }
.tl-badge i { margin-right: .3rem; }
.tl-badge-birth { background: var(--timeline-badge-birth-bg); color: var(--timeline-badge-birth-text); }
.tl-badge-death { background: var(--timeline-badge-death-bg); color: var(--timeline-badge-death-text); }
.tl-badge-generic { background: var(--timeline-badge-custom-bg); color: var(--timeline-badge-custom-text); }
.tl-date { font-size: .78rem; color: var(--text-muted); }
.tl-person { display: flex; align-items: center; gap: .6rem; }
.tl-person-name { font-weight: 600; color: var(--text); text-decoration: none; font-size: .9rem; }
.tl-person-name:hover { color: var(--color-primary); }

.tl-toolbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

.tl-toolbar.float {
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  z-index: 1200;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .45rem .6rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

[data-theme="dark"] .tl-toolbar.float {
  background: rgba(25, 42, 15, 0.9);
  border-color: var(--border-strong);
}

.tl-tool {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .82rem;
}

.tl-tool input,
.tl-tool select {
  border: none;
  background: transparent;
  color: inherit;
  font-size: .82rem;
  outline: none;
}

.tl-tool input::placeholder {
  color: var(--text-light);
}

.tl-count {
  font-size: .78rem;
  color: var(--text-muted);
  padding-left: .25rem;
}

.tl-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.tl-fab:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.timeline-wrap.has-float-toolbar {
  padding-bottom: 4.75rem;
}

@media (max-width: 720px) {
  .timeline-wrap {
    padding-left: 2.1rem;
  }

  .timeline-wrap::before {
    left: .8rem;
  }

  .tl-dot {
    left: -28px;
  }

  .tl-content {
    padding: .65rem .9rem;
  }

  .tl-toolbar.float {
    width: min(94vw, 560px);
    max-width: calc(100vw - 1rem);
    border-radius: 18px;
    padding: .45rem .55rem;
    justify-content: center;
    gap: .45rem;
  }

  .tl-tool {
    flex: 1 1 100%;
    min-width: 0;
    justify-content: center;
  }

  .tl-tool input,
  .tl-tool select {
    min-width: 0;
    width: 100%;
    text-align: center;
  }

  .tl-fab {
    width: 32px;
    height: 32px;
  }

  .tl-count {
    flex: 1 1 100%;
    text-align: center;
    padding-left: 0;
  }
}

/* Keep the feedback FAB clear of the floating timeline toolbar */
@media (max-width: 768px) {
  body:has(.timeline-wrap) .feedback-float-btn {
    bottom: 3rem;
    right: calc(33%);
    z-index: 1200;
  }
}

.timeline-loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin: 1rem auto;
  padding: .85rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .95rem;
  max-width: 420px;
}

.timeline-loading-indicator[hidden] {
  display: none !important;
}

.timeline-spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid rgba(15, 118, 110, .15);
  border-top-color: var(--color-primary-d);
  animation: timeline-spinner 0.8s linear infinite;
}

@keyframes timeline-spinner {
  to { transform: rotate(360deg); }
}

/* ── DESCENDANT TREE ───────────────────────────────────── */
.desc-page { margin: 0 -1rem; }
.desc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: 0 1rem;
  margin-bottom: .75rem;
}
.desc-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.desc-toolbar {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  padding: .5rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 1rem .75rem;
}
.desc-canvas {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 1rem;
  background: var(--surface);
  overflow: hidden;
  height: calc(100vh - 220px);
  min-height: 400px;
}
.desc-canvas svg { width: 100%; height: 100%; }
.desc-node { cursor: pointer; }
.desc-link { fill: none; stroke: #94a3b8; stroke-width: 2px; }
.desc-link.extra-link { stroke-dasharray: 4 4; opacity: .8; }
.desc-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  font-size: .8rem;
  max-width: 240px;
  z-index: 10;
}
.desc-tooltip.visible { opacity: 1; }
.desc-tooltip .tt-name { font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
.desc-tooltip .tt-row { color: var(--text-muted); }
.desc-empty { text-align: center; padding: 3rem; color: var(--text-muted); }
.desc-info { font-size: .78rem; color: var(--text-muted); padding: 0 1rem; margin-top: .5rem; }
.desc-root-wrap { position: relative; display: inline-flex; align-items: center; gap: .4rem; }
.desc-root-input {
  padding: .3rem .5rem;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 250px;
}
.desc-root-list {
  position: absolute;
  top: 100%;
  left: 0;
  width: 300px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: none;
  margin-top: 2px;
}
.desc-root-list.open { display: block; }
.desc-root-list .rel-person-option { font-size: .8rem; }
.desc-root-list .rel-person-avatar { width: 24px; height: 24px; font-size: .6rem; }
.desc-root-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .5rem;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 600;
  background: var(--color-primary-l);
  color: var(--color-primary-d);
  border: 1px solid var(--color-primary);
}
.desc-root-chip .chip-x { cursor: pointer; margin-left: .2rem; font-weight: 700; opacity: .7; }
.desc-root-chip .chip-x:hover { opacity: 1; }
@media print {
  .desc-toolbar, .desc-header, .navbar, .footer, .desc-info { display: none !important; }
  .desc-canvas { height: auto !important; border: none !important; margin: 0 !important; }
}

/* ── FAMILY GROUP SHEETS ───────────────────────────────── */
.fgs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.fgs-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: .5rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--color-primary);
}
.fgs-marriage, .fgs-divorce {
  font-size: .9rem;
  margin-bottom: .25rem;
}
.fgs-label { font-weight: 600; color: var(--text-muted); }
.fgs-divorce .fgs-label { color: var(--color-danger); }
.fgs-spouses {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}
.fgs-spouse-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.fgs-spouse-card h3 {
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .75rem;
}
.fgs-person { display: flex; gap: .75rem; align-items: flex-start; }
.fgs-person-avatar img, .fgs-person-avatar .avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.fgs-person-name { font-weight: 700; font-size: 1.05rem; color: var(--color-primary); text-decoration: none; }
.fgs-person-name:hover { text-decoration: underline; }
.fgs-person-info { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }
.fgs-notes { font-size: .8rem; color: var(--text-muted); margin-top: .35rem; font-style: italic; max-width: 320px; }
.fgs-children-section { margin-top: 1.5rem; }
.fgs-children-section h3 { font-size: 1rem; margin-bottom: .75rem; color: var(--text); }

@media print {
  .navbar, .footer, .sub-nav, .page-header .header-actions, .fgs-index-arrow { display: none !important; }
  .fgs-card { border: none; box-shadow: none; padding: 0; }
  .container { max-width: 100%; padding: 0; }
  body { background: white; }
}
@media (max-width: 600px) {
  .fgs-spouses { grid-template-columns: 1fr; }
}