/* SFA design system */
:root {
  --sfa-font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sfa-bg: #f4f6fb;
  --sfa-surface: #ffffff;
  --sfa-ink: #1a2332;
  --sfa-muted: #5c6b7f;
  --sfa-primary: #2f5bd8;
  --sfa-primary-dark: #1e3f9e;
  --sfa-accent: #0d9488;
  --sfa-warm: #d97706;
  --sfa-danger: #dc3545;
  --sfa-nav-bg: linear-gradient(135deg, #1a2f5c 0%, #243b6e 48%, #1e4d6b 100%);
  --sfa-radius: 14px;
  --sfa-shadow: 0 8px 30px rgba(26, 35, 50, 0.08);
  --sfa-stat-primary: #2f5bd8;
  --sfa-stat-teal: #0d9488;
  --sfa-stat-amber: #d97706;
  --sfa-stat-violet: #7c3aed;
  --sfa-stat-rose: #e11d48;
}

body.sfa-body {
  font-family: var(--sfa-font);
  background: var(--sfa-bg);
  color: var(--sfa-ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sfa-container {
  max-width: 1280px;
}

/* ---- App shell: left sidebar + main column ---- */

.sfa-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.sfa-sidebar {
  --bs-offcanvas-width: 280px;
  --bs-offcanvas-bg: transparent;
  background: var(--sfa-nav-bg);
  color: #fff;
  border: 0;
  overflow-y: auto;
}

@media (min-width: 992px) {
  .sfa-sidebar {
    width: 256px;
    flex: 0 0 256px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }
}

.sfa-sidebar-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 1.1rem 0.9rem;
}

.sfa-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.15rem 0.35rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 0.9rem;
}

.sfa-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.sfa-sidebar-heading {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(255, 255, 255, 0.45);
  padding: 0.9rem 0.6rem 0.3rem;
}

.sfa-sidebar-heading:first-child {
  padding-top: 0.1rem;
}

.sfa-side-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sfa-side-link i {
  width: 1.2rem;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.85;
}

.sfa-side-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.sfa-side-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.85);
}

.sfa-sidebar-user {
  margin-top: 1rem;
  padding: 0.85rem 0.6rem 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sfa-sidebar-user-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: rgba(255, 255, 255, 0.92);
}

.sfa-sidebar-user-row > i {
  font-size: 1.4rem;
}

.sfa-sidebar-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  font-size: 0.85rem;
}

.sfa-sidebar-user-meta .sfa-role-pill {
  margin-left: 0;
  align-self: flex-start;
  margin-top: 0.15rem;
}

.sfa-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Mobile top bar (sidebar collapses into an offcanvas) */
.sfa-topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--sfa-nav-bg);
  padding: 0.55rem 0.9rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.sfa-topbar-toggle {
  color: #fff;
  font-size: 1.35rem;
  padding: 0.1rem 0.4rem;
  border: 0;
  line-height: 1;
}

.sfa-topbar-toggle:hover,
.sfa-topbar-toggle:focus {
  color: #fff;
}

.sfa-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff !important;
  text-decoration: none;
}

.sfa-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 1rem;
}

.sfa-role-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sfa-btn-signout {
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
}

.sfa-btn-signout:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

.sfa-footer {
  margin-top: auto;
  border-top: 1px solid rgba(26, 35, 50, 0.08);
  background: rgba(255, 255, 255, 0.6);
}

.sfa-page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.sfa-page-title {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--sfa-ink);
}

.sfa-page-subtitle {
  color: var(--sfa-muted);
  font-size: 0.95rem;
}

.sfa-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sfa-card {
  background: var(--sfa-surface);
  border: 1px solid rgba(26, 35, 50, 0.07);
  border-radius: var(--sfa-radius);
  box-shadow: var(--sfa-shadow);
}

.sfa-card-header {
  background: transparent;
  border-bottom: 1px solid rgba(26, 35, 50, 0.06);
  font-weight: 600;
  padding: 0.85rem 1.1rem;
}

.sfa-stat-card {
  background: var(--sfa-surface);
  border-radius: var(--sfa-radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--sfa-shadow);
  border: 1px solid rgba(26, 35, 50, 0.06);
  border-left: 4px solid var(--tone, var(--sfa-stat-primary));
  height: 100%;
}

.sfa-stat-card--primary { --tone: var(--sfa-stat-primary); }
.sfa-stat-card--teal { --tone: var(--sfa-stat-teal); }
.sfa-stat-card--amber { --tone: var(--sfa-stat-amber); }
.sfa-stat-card--violet { --tone: var(--sfa-stat-violet); }
.sfa-stat-card--rose { --tone: var(--sfa-stat-rose); }

.sfa-stat-card-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sfa-muted);
  margin-bottom: 0.35rem;
}

.sfa-stat-card-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--sfa-ink);
}

.sfa-stat-card-hint {
  font-size: 0.8rem;
  color: var(--sfa-muted);
  margin-top: 0.35rem;
}

.sfa-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  background: rgba(26, 35, 50, 0.03);
}

.sfa-metric-row--success { background: rgba(13, 148, 136, 0.1); }
.sfa-metric-row--warning { background: rgba(217, 119, 6, 0.1); }
.sfa-metric-row--danger { background: rgba(225, 29, 72, 0.08); }
.sfa-metric-row--info { background: rgba(47, 91, 216, 0.08); }
.sfa-metric-row--teal { background: rgba(13, 148, 136, 0.1); }
.sfa-metric-row--muted { background: rgba(92, 107, 127, 0.08); }

.sfa-badge--active { background: #d1fae5 !important; color: #065f46 !important; }
.sfa-badge--divorced { background: #fef3c7 !important; color: #92400e !important; }
.sfa-badge--widowed { background: #e0e7ff !important; color: #3730a3 !important; }
.sfa-badge--separated { background: #fce7f3 !important; color: #9d174d !important; }
.sfa-badge--annulled { background: #f3f4f6 !important; color: #374151 !important; }
.sfa-badge--neutral { background: #f3f4f6 !important; color: #4b5563 !important; }
.sfa-badge--warning { background: #fef3c7 !important; color: #92400e !important; }
.sfa-badge--danger { background: #fee2e2 !important; color: #991b1b !important; }

.sfa-event-report {
  white-space: pre-wrap;
  line-height: 1.6;
}

.sfa-table-card .table {
  margin-bottom: 0;
}

.sfa-table-card .table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sfa-muted);
  background: #f8fafc;
  border-bottom-width: 1px;
}

.sfa-table-card .table tbody tr:hover {
  background: rgba(47, 91, 216, 0.04);
}

.sfa-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

/* Family photo library */
.sfa-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.sfa-library-thumb {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  /* Dark backdrop so photos of any shape display whole (no cropped heads). */
  background: #17203a;
}

.sfa-library-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.sfa-library-thumb:hover img {
  transform: scale(1.025);
}

.sfa-library-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.sfa-library-detail-image,
.sfa-library-edit-preview {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #101827;
}

.sfa-library-edit-preview {
  max-height: 420px;
  border-radius: 10px;
}

.sfa-member-picker {
  max-height: 430px;
  overflow-y: auto;
  border: 1px solid #d8dee9;
  border-radius: 10px;
  background: #fff;
}

.sfa-member-picker-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid #edf0f5;
  cursor: pointer;
}

.sfa-member-picker-row:last-child {
  border-bottom: 0;
}

.sfa-member-picker-row:hover {
  background: rgba(47, 91, 216, 0.05);
}

.sfa-member-picker-row[hidden] {
  display: none;
}

.sfa-photo-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  /* Dark backdrop so the whole photo fits without cropping people out. */
  background: #17203a;
}

.sfa-photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  display: block;
}

.sfa-photo-delete {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
}

.sfa-photo-delete .btn {
  line-height: 1;
  padding: 0.15rem 0.45rem;
  opacity: 0.85;
}

.sfa-attendance-row {
  transition: background 0.15s ease;
}

.sfa-attendance-row--present {
  background: rgba(13, 148, 136, 0.08);
  border-left: 3px solid var(--sfa-stat-teal);
}

.sfa-attendance-row--excused {
  background: rgba(217, 119, 6, 0.08);
  border-left: 3px solid var(--sfa-stat-amber);
}

.sfa-attendance-row--no_response {
  background: rgba(225, 29, 72, 0.06);
  border-left: 3px solid var(--sfa-stat-rose);
}

.sfa-attendance-row--unchecked {
  border-left: 3px solid transparent;
}

.sfa-attendance-controls {
  min-width: 220px;
}

.sfa-attendance-controls .btn.active {
  font-weight: 600;
}

.sfa-filter-bar {
  background: var(--sfa-surface);
  border: 1px solid rgba(26, 35, 50, 0.07);
  border-radius: var(--sfa-radius);
  box-shadow: var(--sfa-shadow);
  padding: 1rem 1.1rem;
}

.sfa-filter-bar-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(10rem, 16rem) auto;
  gap: 0.75rem 1rem;
  align-items: end;
}

.sfa-filter-field {
  min-width: 0;
}

.sfa-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

mark.sfa-search-hit,
.sfa-search-hit {
  background: #ffe066;
  color: inherit;
  padding: 0 0.15em;
  border-radius: 3px;
  font-weight: 600;
}

.sfa-clan-name-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
}

.sfa-clan-name-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  font-size: 0.92rem;
  line-height: 1.2;
}

.sfa-clan-name-chip--hot {
  background: #e8f1ff;
  border-color: #b8d4ff;
}

.sfa-clan-name-chip--unused {
  opacity: 0.72;
}

.sfa-clan-name-chip--unlisted {
  background: #fff8e6;
  border-color: #f0d58c;
}

.sfa-clan-name-count {
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--sfa-muted);
}

.sfa-clan-name-chip--hot .sfa-clan-name-count {
  color: var(--sfa-primary);
}

.sfa-clan-unlisted-item {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.sfa-clan-name-item {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  max-width: 100%;
}

.sfa-clan-name-shared {
  line-height: 1.2;
  padding-left: 0.35rem;
}

#sfa-clan-picker select#clan_id {
  min-height: 12rem;
}

@media (max-width: 767.98px) {
  .sfa-filter-bar-grid {
    grid-template-columns: 1fr;
  }
}

.sfa-log-viewer {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--sfa-radius);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  max-height: 70vh;
  overflow: auto;
  padding: 0.75rem 0;
}

.sfa-log-line {
  padding: 0.15rem 1rem;
  border-left: 3px solid transparent;
  white-space: pre-wrap;
  word-break: break-word;
}

.sfa-log-line:hover {
  background: rgba(255, 255, 255, 0.04);
}

.sfa-log-line--DEBUG { border-left-color: #64748b; color: #94a3b8; }
.sfa-log-line--INFO { border-left-color: #38bdf8; }
.sfa-log-line--WARNING { border-left-color: #fbbf24; color: #fde68a; }
.sfa-log-line--ERROR,
.sfa-log-line--CRITICAL { border-left-color: #f87171; color: #fecaca; background: rgba(248, 113, 113, 0.08); }
.sfa-log-line--RAW { color: #cbd5e1; }

.sfa-log-meta {
  color: #64748b;
  margin-right: 0.5rem;
}

.sfa-list-avatar {
  width: 40px;
  height: 40px;
  object-fit: cover;
  background: var(--bs-secondary-bg);
}

.sfa-list-avatar.sfa-list-avatar--placeholder {
  object-fit: contain;
  padding: 3px;
  background: var(--bs-tertiary-bg);
}

/* ---- People list: status row tints ---- */

/* Departed relatives: a gentle sepia "memory" tint so the living stand out. */
.sfa-row-deceased > td {
  background-color: #f3efe7;
  color: #7a7466;
}

.sfa-row-deceased > td:first-child {
  box-shadow: inset 3px 0 0 #c9bda3;
}

.sfa-row-deceased .sfa-list-avatar {
  filter: grayscale(1);
  opacity: 0.75;
}

/* Missing / lost: a faint amber tint. */
.sfa-row-lost > td {
  background-color: #fdf6e7;
}

.sfa-row-lost > td:first-child {
  box-shadow: inset 3px 0 0 #e2b93b;
}

.sfa-badge-deceased {
  background: #8a8073;
  color: #fff;
}

.sfa-marriage-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.sfa-person-cell-name {
  min-width: 0;
  line-height: 1.25;
}

.sfa-photo {
  max-height: 220px;
  object-fit: cover;
}

.img-fluid.sfa-photo-placeholder,
.sfa-photo.sfa-photo-placeholder {
  object-fit: contain;
  background: var(--bs-tertiary-bg);
  padding: 0.5rem;
  max-height: 220px;
}

.sfa-tree-wrap {
  overflow: hidden;
}

.sfa-network-canvas {
  width: 100%;
  height: 75vh;
  background-color: var(--bs-body-bg);
}

.sfa-readme {
  white-space: pre-wrap;
}

.sfa-drop-zone {
  cursor: pointer;
  background: var(--bs-body-bg);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sfa-drop-zone:hover,
.sfa-drop-zone:focus {
  outline: none;
  background: var(--bs-secondary-bg);
}

.sfa-pyramid-stack {
  padding-bottom: 2rem;
}

.sfa-pyramid-stack--flat .sfa-household {
  margin-bottom: 1.75rem;
}

.sfa-pyramid-tier {
  padding: 0.5rem 0 0.25rem;
}

.sfa-pyramid-gen-band {
  padding: 0.75rem 0.5rem 1.25rem;
  margin-bottom: 0.25rem;
}

.sfa-household {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1rem 1.15rem;
  border-radius: 16px;
  border: 1px solid rgba(var(--bs-primary-rgb), 0.12);
  background: linear-gradient(135deg, rgba(var(--bs-success-rgb), 0.07), rgba(var(--bs-primary-rgb), 0.04));
}

.sfa-household-patriarch {
  flex: 0 0 auto;
  width: 100%;
  text-align: center;
  padding-bottom: 0.65rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid rgba(var(--bs-primary-rgb), 0.14);
}

.sfa-household-patriarch .sfa-pyramid-face {
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.42);
}

.sfa-household-mini-label {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.sfa-household-branches {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  flex: 1 1 auto;
  width: 100%;
  align-items: flex-start;
  justify-content: center;
}

.sfa-household-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 96px;
  max-width: 130px;
}

.sfa-household-branch-spouse {
  text-align: center;
  width: 100%;
}

.sfa-household-branch-stem {
  width: 3px;
  min-height: 20px;
  margin: 0.15rem 0 0.35rem;
  flex: 0 0 auto;
  border-radius: 2px;
  background: linear-gradient(180deg, #198754 0%, var(--bs-primary) 100%);
  opacity: 0.65;
}

.sfa-household-branch-kids {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.sfa-household-unknown-mother-placeholder {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bs-secondary-bg);
}

.sfa-pyramid-card--compact .sfa-pyramid-face {
  width: 52px;
  height: 52px;
}

.sfa-pyramid-card--compact {
  width: 86px;
  padding: 0.28rem;
}

.sfa-pyramid-card--compact .sfa-pyramid-name {
  font-size: 0.66rem;
}

.sfa-pyramid-card--compact .sfa-pyramid-meta {
  font-size: 0.6rem;
}

.sfa-pyramid-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0 auto;
  padding: 0.75rem 0.5rem;
  background: linear-gradient(to bottom, transparent, rgba(var(--bs-primary-rgb), 0.04));
  border-radius: 14px;
  justify-content: center;
  align-items: flex-start;
  max-width: min(98vw, calc(280px + var(--pyr-z, 0) * 240px));
}

.sfa-pyramid-union {
  display: inline-flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.35rem 0.5rem 0.45rem;
  border-radius: 12px;
  background: rgba(var(--bs-success-rgb), 0.06);
  border: 1px solid rgba(25, 135, 84, 0.22);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sfa-pyramid-union-slot {
  min-width: 92px;
  text-align: center;
}

.sfa-pyramid-union-slot--patriline .sfa-pyramid-face {
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.35);
}

.sfa-pyramid-union-connector {
  align-self: stretch;
  width: 3px;
  min-height: 56px;
  margin-top: 0.5rem;
  border-radius: 2px;
  background: linear-gradient(180deg, #198754, var(--bs-primary));
  opacity: 0.6;
}

.sfa-pyramid-face {
  width: 64px;
  height: 64px;
  object-fit: cover;
  display: block;
  margin: 0 auto 0.35rem;
  background: var(--bs-secondary-bg);
}

.sfa-pyramid-face.sfa-pyramid-face--placeholder {
  object-fit: contain;
  padding: 3px;
  background: var(--bs-tertiary-bg);
}

.sfa-pyramid-card {
  display: inline-block;
  vertical-align: top;
  width: 92px;
  padding: 0.35rem;
  border-radius: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sfa-pyramid-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.sfa-pyramid-name {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
}

.sfa-pyramid-meta {
  font-size: 0.65rem;
  color: var(--bs-secondary-color);
}

.sfa-pyramid-badge {
  display: inline-block;
  font-size: 0.6rem;
  margin-top: 0.12rem;
}

.sfa-pyramid-step-line {
  width: 4px;
  height: 28px;
  margin: 0.15rem auto;
  border-radius: 2px;
  background: linear-gradient(180deg, #198754, var(--bs-info));
  opacity: 0.45;
}

/* Family layout option demos (/family-layout-options) */
.sfa-demo-strip-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sfa-demo-union {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(var(--bs-success-rgb), 0.25);
  background: var(--bs-body-bg);
}

.sfa-demo-couple {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
}

.sfa-demo-marriage-bar {
  font-size: 0.75rem;
  color: var(--bs-success);
  letter-spacing: -0.05em;
  user-select: none;
}

.sfa-demo-union-stem {
  width: 3px;
  height: 22px;
  margin: 0.35rem auto;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--bs-success), var(--bs-primary));
  opacity: 0.7;
}

.sfa-demo-union-children {
  text-align: center;
}

.sfa-demo-children-label {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  margin-bottom: 0.35rem;
}

.sfa-demo-children-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.sfa-demo-person {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 88px;
  max-width: 120px;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.sfa-demo-person:hover {
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
  color: inherit;
}

.sfa-demo-person--compact {
  min-width: 72px;
  max-width: 96px;
  padding: 0.35rem;
}

.sfa-demo-person--unknown {
  border-style: dashed;
  background: var(--bs-secondary-bg);
}

.sfa-demo-person-role {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
}

.sfa-demo-person-name {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

.sfa-demo-person-meta {
  font-size: 0.65rem;
  color: var(--bs-secondary-color);
}

.sfa-demo-gen-band {
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px dashed var(--bs-border-color);
  background: var(--bs-body-bg);
}

.sfa-demo-gen-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-primary);
  margin-bottom: 0.75rem;
}

.sfa-demo-ladder-household {
  padding: 0.75rem;
  border-radius: 10px;
  background: var(--bs-secondary-bg);
}

.sfa-demo-ladder-branch {
  text-align: center;
  min-width: 90px;
}

.sfa-demo-outline ul {
  margin: 0.35rem 0 0.35rem 1.25rem;
  padding: 0;
}

.sfa-demo-outline li {
  margin-bottom: 0.25rem;
}

/* Blood lineage trail on profiles */
.sfa-blood-trail {
  border: 1px solid rgba(26, 35, 50, 0.08);
  border-radius: var(--sfa-radius);
  background: linear-gradient(135deg, #f7f9fc 0%, #eef3fb 100%);
  padding: 0.85rem 1rem;
}

.sfa-blood-trail-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  font-size: 0.95rem;
  line-height: 1.45;
}

.sfa-blood-trail-self {
  font-weight: 700;
  color: var(--sfa-ink);
}

.sfa-blood-trail-arrow {
  color: var(--sfa-primary);
  font-weight: 700;
}

.sfa-blood-trail-rel {
  color: var(--sfa-muted);
  font-size: 0.82rem;
  text-transform: lowercase;
}

.sfa-blood-trail-link {
  font-weight: 600;
  text-decoration: none;
  color: var(--sfa-primary-dark);
}

.sfa-blood-trail-link:hover {
  text-decoration: underline;
}

.sfa-mother-tag {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 0.85rem;
}

.sfa-mother-tag a {
  color: inherit;
  font-weight: 600;
}

/* Settings: keep action buttons snug beside their fields (no full-row stretch) */
.sfa-settings-inline-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.sfa-settings-inline-row > .form-select {
  width: auto;
  max-width: min(100%, 36rem);
  flex: 0 1 auto;
}

.sfa-settings-inline-row > .form-select.sfa-settings-select-narrow {
  max-width: 12rem;
}

.sfa-settings-inline-row > .btn {
  flex: 0 0 auto;
  width: auto;
  white-space: nowrap;
}

.sfa-settings-inline-form > .form-text {
  margin-top: 0.35rem;
}

.sfa-withheld-label {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px dashed #94a3b8;
  color: #64748b;
  font-size: 0.8rem;
  font-style: italic;
  letter-spacing: 0.02em;
}

@media (max-width: 576px) {
  .sfa-blood-trail-flow {
    font-size: 0.88rem;
  }
}

/* Portrait lightbox */
img.sfa-portrait-zoom {
  cursor: zoom-in;
}

.sfa-portrait-modal .modal-body {
  background: #0d1117;
}

.sfa-portrait-modal-stage {
  position: relative;
  height: min(72vh, 640px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

.sfa-portrait-modal-stage.is-dragging {
  cursor: grabbing;
}

.sfa-portrait-modal-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.05s linear;
  pointer-events: none;
}
