/* ============================================================
   public/css/style.css – Family Tree (redesigned)
   Clean, polished stylesheet with no external dependencies.
   ============================================================ */

/* 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(255, 255, 255, .86);
  --toolbar-border: var(--border);
  --toolbar-shadow: 0 8px 24px rgba(2, 44, 34, .1);
  --table-row-hover: #f0f7ff;
  --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: #f2f7f4;
  --surface: #ffffff;
  --surface-2: #f7fbf9;
  --border: #dbe8e2;
  --border-strong: #bfd2ca;
  --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: #dbeafe;
  --badge-m-text: #1e40af;
  --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(1000px 420px at 6% -12%, rgba(16, 185, 129, .16), transparent 60%), radial-gradient(760px 360px at 100% 0%, rgba(13, 148, 136, .14), transparent 58%), linear-gradient(180deg, #f8fcfa 0%, #edf4f1 100%);
  --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 6px 10px -2px rgba(4, 33, 26, .14), 0 2px 4px -2px rgba(4, 33, 26, .08);
  --shadow-lg: 0 14px 24px -6px rgba(4, 33, 26, .18), 0 6px 12px -4px rgba(4, 33, 26, .08);
  --font: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: var(--font);
  --transition: .15s ease;
}

/* 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: #38bdf8;
  --color-primary-d: #22d3ee;
  --color-primary-l: #0f172a;
  --focus-bar-bg: #1f2937;
  --focus-bar-border: #fbbf24;
  --focus-bar-text: #f59e0b;
  --focus-bar-btn-hover: #fbbf24;
  --toolbar-bg: rgba(16, 24, 39, .78);
  --toolbar-border: #334155;
  --toolbar-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  --table-row-hover: rgba(255, 255, 255, 0.08);
  --color-danger: #ff2e2e;
  --color-danger-d: #ff3c3c;
  --color-danger-l: #111827;
  --color-warning: #fbbf24;
  --color-warning-d: #f59e0b;
  --color-info: #38bdf8;
  --color-info-d: #0ea5e9;
  --color-success: #22c55e;
  --color-secondary: #a1a1aa;
  --color-secondary-d: #7c7c84;
  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #334155;
  --border-strong: #475569;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-light: #cbd5e1;
  --navbar-bg: #111827;
  --navbar-text: #e2e8f0;
  --navbar-muted: #94a3b8;
  --theme-control-bg: rgba(255, 255, 255, .12);
  --theme-control-text: #e2e8f0;
  --badge-m-bg: #1e293b;
  --badge-m-text: #38bdf8;
  --badge-f-bg: #1f2937;
  --badge-f-text: #f9a8d4;
  --badge-o-bg: #111827;
  --badge-o-text: #fef3c7;
  --status-alive-bg: #134e4a;
  --status-alive-text: #a7f3d0;
  --status-deceased-bg: #0f172a;
  --status-deceased-text: #94a3b8;
  --status-verified-bg: #064e3b;
  --status-verified-text: #a7f3d0;
  --status-estimated-bg: #78350f;
  --status-estimated-text: #fcd34d;
  --status-founder-bg: #78350f;
  --status-founder-text: #fef9c3;
  --status-unverified-bg: #641220;
  --status-unverified-text: #fecaca;
  --founder-row-bg: rgba(251, 191, 36, .16);
  --founder-row-cell-bg: rgba(251, 191, 36, .12);
  --founder-row-accent: #fbbf24;
  --accent-story: #60a5fa;
  --accent-tech: #fbbf24;
  --accent-deploy: #c084fc;
  --accent-collab: #22d3ee;
  --accent-support: #fb923c;
  --accent-privacy: #38bdf8;
  --timeline-line: #475569;
  --timeline-dot-birth: #34d399;
  --timeline-dot-death: #cbd5f5;
  --timeline-dot-custom: #c084fc;
  --timeline-badge-birth-bg: rgba(16, 185, 129, .2);
  --timeline-badge-birth-text: #a7f3d0;
  --timeline-badge-death-bg: rgba(148, 163, 184, .2);
  --timeline-badge-death-text: #e2e8f0;
  --timeline-badge-custom-bg: rgba(129, 140, 248, .24);
  --timeline-badge-custom-text: #e0e7ff;
  --legend-dot-male: #38bdf8;
  --legend-dot-female: #f9a8d4;
  --legend-dot-other: #c4b5fd;
  --body-bg: radial-gradient(1000px 420px at 6% -12%, rgba(14, 165, 233, .1), transparent 60%), radial-gradient(760px 360px at 100% 0%, rgba(56, 189, 248, .1), transparent 58%), linear-gradient(180deg, #0f172a 0%, #0b1220 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;
}

body.nav-open {
  overflow: hidden;
}

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

  .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;
  }

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

  .nav-toggle {
    display: inline-flex;
  }

  .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);
  }

  .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;
}

/* ── 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;
}

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

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

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

.nav-links {
  list-style: none;
  display: flex;
  gap: .25rem;
  align-items: center;
}

.nav-links a {
  color: var(--navbar-muted);
  font-weight: 600;
  font-size: .9rem;
  padding: .4rem .75rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.nav-links a:hover {
  color: var(--navbar-text);
  background: rgba(255, 255, 255, .14);
  text-decoration: none;
}

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

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

.theme-toggle {
  border: 1px solid rgba(255, 255, 255, .4);
  background: rgba(0, 0, 0, .1);
  color: var(--navbar-text);
  font-size: .9rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  cursor: pointer;
  margin-left: .5rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: rgba(255, 255, 255, .2);
  outline: none;
}

.nav-toggle {
  display: none;
  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 {
  display: none;
}

@media (max-width: 768px) {
  .nav-close {
    display: block;
  }
}

.sub-nav {
  background: var(--navbar-bg);
  padding: .7rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow-x: auto;
}

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

.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-page-header {
  margin-bottom: 1rem;
}

.family-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: .75rem;
  border-radius: var(--radius);
}

.family-list-search-form {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  width: 100%;
  max-width: 680px;
}

.family-list-search-form label {
  font-weight: 600;
  color: var(--text);
}

.family-list-search-form input {
  min-width: 180px;
  flex: 1;
  padding: .45rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.family-list-stats {
  margin-bottom: .8rem;
  color: var(--text-muted);
  font-size: .9rem;
}

.family-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  overflow: hidden;
}

.family-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  background: var(--surface-2);
}

.family-card-header h2 {
  font-size: 1rem;
  margin: 0;
}

.family-card-header small {
  display: block;
  margin-top: .2rem;
  color: var(--text-muted);
}

.family-card-actions {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.family-card .table-wrap {
  padding: 0 .7rem 1rem;
}

.family-card table {
  width: 100%;
  border-collapse: collapse;
}

.family-card table th,
.family-card table td {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}

.family-card table th {
  text-align: left;
  background: var(--surface-2);
}

@media (max-width: 768px) {
  .family-card table th,
  .family-card table td {
    font-size: .8rem;
    padding: .45rem .4rem;
  }
}

.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: 1320px;
  width: 100%;
  margin: 2.4rem auto 2rem;
  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;
  }

  .table td.actions {
    min-height: 77px;
  }
}

.footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--text-light);
  font-size: .8125rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  backdrop-filter: blur(8px);
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter var(--transition), transform var(--transition), box-shadow var(--transition), background var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn:active {
  filter: brightness(.96);
  transform: translateY(1px);
}

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

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  box-shadow: 0 1px 3px rgba(239, 68, 68, .30);
}

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

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

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

.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);
  filter: none;
}

.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: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: .3rem;
  border-radius: var(--radius-sm);
  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);
}

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

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

.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);
  backdrop-filter: blur(6px);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  animation: cardRise .35s ease;
}

.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.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.1rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
  letter-spacing: -.01em;
}

.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: var(--surface-2);
  transition: transform var(--transition), box-shadow var(--transition);
}

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

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

.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;
  top: 4px;
  right: 4px;
}

.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);
}

.photo-thumb .primary-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--color-primary);
  color: var(--surface);
  font-size: .65rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.photo-thumb .primary-form {
  position: absolute;
  bottom: 4px;
  left: 4px;
}

.photo-thumb .primary-form button {
  font-size: .7rem;
  padding: 2px 6px;
}

/* 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: .625rem;
  padding: .55rem .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.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;
}

.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;
}

/* 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: .7rem 1rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: .4rem .45rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: .9375rem;
}

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

.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 td.actions {
  vertical-align: middle;
  height: 100%;
  min-height: 54px;
  /* stabilize action cell height to match other cells */
}

.table .actions {
  display: flex;
  gap: .4rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-height: 100%;
}

.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: .55rem .8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: .9375rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.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 #bfdbfe;
  border-radius: var(--radius-sm);
  padding: .2rem .55rem;
  color: var(--color-primary-d);
  user-select: all;
}

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

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

.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 {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--text-muted);
}

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

.empty-state p {
  margin-bottom: 1.25rem;
  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: .875rem 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.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: #1e293b;
  color: #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .20);
}

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

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

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

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  animation: modalIn .18s cubic-bezier(.25, .8, .25, 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);
}

/* ── HAMBURGER TOGGLE (hidden on desktop) ────────────────── */
.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: .5rem;
  z-index: 110;
  flex-direction: column;
  gap: 4px;
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2.5px;
  background: var(--navbar-text);
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
}

/* Animate to X when open */
.nav-toggle.open .nav-toggle-bar:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}

.nav-toggle.open .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open .nav-toggle-bar:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

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

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

  /* Navbar: hamburger + slide-down menu */
  .nav-toggle {
    display: flex;
  }

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

  .nav-links {
    display: none;
    flex-direction: column;
    max-width: 220px !important;
    gap: 0;
    padding: .5rem 0 .25rem;
    order: 3;
    /* push below brand + toggle */
  }

  .nav-links.open {
    display: flex;
  }

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

  .nav-links a {
    display: block;
    padding: .65rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .95rem;
  }

  .nav-links .btn {
    margin-left: 0;
    margin-top: .35rem;
    text-align: center;
  }

  /* 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;
  }

  .table .actions {
    gap: .25rem;
  }

  /* 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 {
    font-size: 1.3rem;
  }
}

/* ── 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: #e2e8f0;
  color: #475569;
  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: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  font-size: 1.6rem;
  line-height: 1;
}

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

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

.stat-icon-blue {
  filter: none;
}

.stat-icon-green {
  filter: none;
}

.stat-icon-gray {
  filter: none;
}

.stat-icon-pink {
  filter: none;
}

.stat-icon-indigo {
  filter: none;
}

.stat-icon-rose {
  filter: none;
}

.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;
}

.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: .4rem;
  padding: 1rem .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.quick-link:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-l);
  color: var(--color-primary);
}

.ql-icon {
  font-size: 1.6rem;
}

/* ── 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;
}

/* ── 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: 260px;
}

.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: .5rem;
}

.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;
}

/* ── 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: .75rem .6rem .65rem;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 88px;
  max-width: 120px;
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
}

.rf-path>.rf-path-node:first-child {
  border-color: var(--color-primary);
  border-width: 2px;
}

.rf-path-node:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .08);
}

.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, #ede9fe, #e0e7ff);
  color: #6d28d9;
  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;
}

/* Last step destination gets a primary border too */
.rf-path-step:last-child .rf-path-node {
  border-color: var(--color-primary);
  border-width: 2px;
}

/* ── 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;
}

.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 #3b82f6;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 32px);
  border-left-color: rgba(59, 130, 246, .15);
  border-right-color: rgba(59, 130, 246, .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, #1e3a8a 0%, #0f172a 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(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.75);
}

[data-theme="dark"] .rf-kinship-rel {
  color: #bfdbfe;
  background: rgba(147, 197, 253, 0.2);
}

[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: #1d4ed8;
}

.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, #3b82f6 0%, #2563eb 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, #eff6ff);
  border: 1px solid var(--primary, #3b82f6);
  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, #3b82f6);
  background: var(--primary-bg, #dbeafe);
  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;
  }
}