:root {
  --site-header-height: 82px;
  --bg: #f4efe6;
  --bg-alt: #efe7d8;
  --surface: rgba(255, 252, 247, 0.9);
  --surface-strong: #fffdf9;
  --surface-quiet: #f7f1e7;
  --surface-dark: #21362d;
  --line: #d7ccb8;
  --line-strong: #c3b59c;
  --text: #1f261f;
  --muted: #5d645c;
  --brand-950: #17251f;
  --brand-900: #1f3229;
  --brand-800: #274134;
  --brand-700: #345241;
  --brand-600: #48715a;
  --brand-500: #648c74;
  --accent-700: #9e4d31;
  --accent-600: #b65d3c;
  --accent-100: #f8dfd4;
  --success-700: #366247;
  --success-100: #dceddf;
  --danger-700: #983a32;
  --danger-100: #f9ddda;
  --info-100: #e4efe9;
  --shadow-sm: 0 10px 30px rgba(30, 40, 31, 0.06);
  --shadow-md: 0 18px 48px rgba(26, 38, 30, 0.12);
  --shadow-lg: 0 32px 72px rgba(19, 28, 22, 0.18);
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 30px;
  --shell: min(1180px, calc(100vw - 32px));
  --heading-font: 'Outfit', 'Manrope', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(182, 93, 60, 0.08), transparent 34%),
    radial-gradient(circle at top right, rgba(72, 113, 90, 0.12), transparent 26%),
    linear-gradient(180deg, #f6f2ea 0%, #f1eadf 100%);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(23, 37, 31, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 37, 31, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent 70%);
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--brand-900);
  color: #fff;
  z-index: 100;
  text-decoration: none;
}

.skip-link:focus {
  top: 16px;
}

.shell {
  width: var(--shell);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(18px);
  background: rgba(246, 242, 234, 0.76);
  border-bottom: 1px solid rgba(195, 181, 156, 0.6);
}

.page-admin .site-header {
  backdrop-filter: none;
  background: rgba(246, 242, 234, 0.96);
}

.site-header-inner {
  min-height: var(--site-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-header-inner.has-center-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  min-width: 0;
}

.site-header-center {
  min-width: 0;
  justify-self: center;
  text-align: center;
}

.site-header-center-label {
  display: inline-block;
  max-width: min(40vw, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--brand-950);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 55%),
    linear-gradient(135deg, var(--brand-700), var(--brand-900));
  color: #fff;
  font-family: var(--heading-font);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 14px 28px rgba(31, 50, 41, 0.22);
}

.brand-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 0;
}

.brand-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--brand-950);
  white-space: nowrap;
}

.site-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
  justify-self: end;
}

.site-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--brand-950);
  background: rgba(255, 255, 255, 0.72);
  transform: translateY(-1px);
}

.site-nav a.is-active {
  color: var(--brand-950);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 12px 24px rgba(28, 40, 31, 0.08);
}

.page-shell {
  padding: 42px 0 72px;
}

.page-family .page-shell {
  padding-top: 22px;
  min-height: calc(100vh - 83px);
  display: flex;
  flex-direction: column;
}

.page-family-dashboard .page-shell,
.page-family-tree .page-shell {
  padding-top: 0;
}

body.page-family-tree {
  overflow: hidden;
}

.page-family-tree .page-shell {
  width: min(1680px, calc(100vw - 20px));
  height: calc(100vh - 83px);
  overflow: hidden;
  padding-bottom: 18px;
}

.page-admin-family.page-family-tree .page-shell {
  padding-top: 12px;
}

.page-modal-form .page-shell {
  min-height: calc(100vh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 24px;
  padding-bottom: 32px;
}

.page-hero,
.panel,
.stat-card,
.directory-card,
.empty-state,
.auth-panel {
  animation: rise-in 0.55s ease both;
}

.page-hero {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  padding: 36px 38px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.6), transparent 50%),
    linear-gradient(135deg, rgba(39, 65, 52, 0.95), rgba(31, 50, 41, 0.92));
  color: #fdf8f1;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
}

.page-hero::after {
  content: '';
  position: absolute;
  width: 320px;
  height: 320px;
  right: -90px;
  top: -120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 70%);
}

.page-hero.compact {
  padding: 28px 30px;
}

.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.92);
  border: 1px solid rgba(195, 181, 156, 0.72);
  box-shadow: var(--shadow-sm);
}

.page-toolbar h1 {
  margin: 0;
  font-family: var(--heading-font);
  font-size: clamp(1.6rem, 2.5vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--brand-950);
  line-height: 1.05;
}

.page-toolbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(253, 248, 241, 0.72);
}

.page-hero h1,
.section-title,
.panel h2,
.auth-panel h1 {
  margin: 0;
  font-family: var(--heading-font);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-hero h1 {
  max-width: 16ch;
  font-size: clamp(2.1rem, 3.8vw, 3.5rem);
  line-height: 1;
}

.page-hero p {
  max-width: 58ch;
  margin: 16px 0 0;
  color: rgba(253, 248, 241, 0.8);
  font-size: 0.96rem;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: min(360px, 100%);
}

.hero-kpi {
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.hero-kpi strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1;
  margin-bottom: 6px;
}

.hero-kpi span {
  display: block;
  font-size: 0.8rem;
  color: rgba(253, 248, 241, 0.75);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
  color: #fff8f2;
  box-shadow: 0 16px 30px rgba(158, 77, 49, 0.24);
}

.button-primary:hover,
.button-primary:focus-visible {
  box-shadow: 0 20px 34px rgba(158, 77, 49, 0.32);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--brand-950);
  border-color: rgba(195, 181, 156, 0.82);
  box-shadow: 0 10px 24px rgba(37, 47, 38, 0.08);
}

.button-secondary:hover,
.button-secondary:focus-visible {
  background: #fff;
}

.button-ghost {
  background: transparent;
  color: var(--brand-700);
  border-color: rgba(100, 140, 116, 0.26);
}

.button-danger {
  background: #fff;
  color: var(--danger-700);
  border-color: rgba(152, 58, 50, 0.18);
}

.button-sm {
  min-height: 40px;
  padding: 0 16px;
  font-size: 0.86rem;
}

.button-xs {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 26px;
}

.page-family .stats-grid {
  margin-top: 0;
}

.page-family .stats-grid,
.page-admin-family .stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.family-main {
  margin-top: 26px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.family-tabs {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-top: 0;
  margin-bottom: 24px;
  background: rgba(243, 238, 228, 0.82);
  border-bottom: 1px solid rgba(195, 181, 156, 0.68);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 20px rgba(26, 38, 30, 0.04);
}

.page-family-tree .family-tabs {
  margin-bottom: 12px;
}

.family-tabs-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
}

.family-tabs-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.family-tabs-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.family-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  appearance: none;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--muted);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  cursor: pointer;
}

.family-tab:hover,
.family-tab:focus-visible {
  color: var(--brand-950);
  background: rgba(255, 255, 255, 0.72);
}

.family-tab.is-active {
  color: var(--brand-950);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 20px rgba(28, 40, 31, 0.08);
}

.family-tab-action {
  white-space: nowrap;
}

.admin-shell {
  display: grid;
  gap: 18px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-toolbar h1 {
  margin: 0;
  font-family: var(--heading-font);
  font-size: clamp(1.55rem, 2.2vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--brand-950);
}

.admin-toolbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-summary-card {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 252, 247, 0.92);
  border: 1px solid rgba(195, 181, 156, 0.72);
  box-shadow: var(--shadow-sm);
}

.admin-summary-card strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--brand-950);
}

.admin-summary-card span {
  display: block;
  margin-top: 8px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.admin-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-layout > * {
  min-width: 0;
}

.admin-sticky {
  position: sticky;
  top: calc(var(--site-header-height) + 16px);
}

.admin-directory {
  display: grid;
  gap: 10px;
}

.admin-row {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 14px 16px 30px;
  border-radius: 20px;
  background: rgba(255, 252, 247, 0.94);
  border: 1px solid rgba(195, 181, 156, 0.72);
  box-shadow: var(--shadow-sm);
}

.admin-row-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.admin-row-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.admin-row-head {
  min-width: 0;
}

.admin-row-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--brand-950);
  line-height: 1.2;
}

.admin-row-meta {
  margin-top: 6px;
  display: flex;
  gap: 8px 12px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--muted);
}

.admin-cell {
  min-width: 0;
}

.admin-row-stats {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-self: start;
  flex-wrap: wrap;
}

.admin-cell-label {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 4px;
}

.admin-cell-value {
  display: block;
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--brand-900);
}

.admin-row-link {
  min-width: 0;
}

.admin-row-link .copy-field {
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-row-link .copy-field input {
  min-width: 0;
}

.admin-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modal-panel {
  width: min(720px, 100%);
  padding: 24px;
  border-radius: 26px;
  background: rgba(255, 252, 247, 0.96);
  border: 1px solid rgba(195, 181, 156, 0.76);
  box-shadow: var(--shadow-md);
}

.page-person-form .modal-panel {
  width: min(620px, 100%);
  padding: 18px;
  border-radius: 22px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head h1 {
  margin: 0;
  font-family: var(--heading-font);
  font-size: clamp(1.45rem, 2.4vw, 1.95rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--brand-950);
  line-height: 1.05;
}

.modal-copy {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-context {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface-quiet);
  border: 1px solid rgba(195, 181, 156, 0.56);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.modal-context strong {
  color: var(--brand-900);
}

.page-person-form .modal-head {
  margin-bottom: 14px;
}

.page-person-form .modal-copy {
  margin-top: 6px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.page-person-form .form-grid,
.page-person-form .form-stack,
.page-person-form .toggle-grid {
  gap: 12px;
}

.page-person-form .field-group {
  gap: 6px;
}

.page-person-form .field-group label,
.page-person-form .fieldset-label {
  font-size: 0.74rem;
}

.page-person-form .field-hint {
  font-size: 0.78rem;
  line-height: 1.4;
}

.page-person-form .field,
.page-person-form .field-file {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 0.82rem;
}

.page-person-form .field-file {
  padding-top: 10px;
  padding-bottom: 10px;
}

.page-person-form .button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
}

.page-person-form .button-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.76rem;
}

.page-person-form .media-picker {
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
}

.page-person-form .avatar-frame {
  width: 92px;
  height: 92px;
  border-radius: 20px;
}

.page-person-form .avatar-fallback {
  font-size: 1.5rem;
}

.page-person-form .toggle-card {
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
}

.page-person-form .toggle-card input {
  width: 18px;
  height: 18px;
}

.page-person-form .toggle-card span {
  font-size: 0.8rem;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-row-id {
  position: absolute;
  right: 16px;
  bottom: 10px;
  font-size: 0.62rem;
  color: var(--muted);
  opacity: 0.8;
  pointer-events: none;
}

.admin-shell .panel {
  padding: 18px;
  border-radius: 22px;
}

.admin-shell .section-header {
  margin-bottom: 14px;
}

.admin-shell .field,
.admin-shell .search-input,
.admin-shell .copy-field input {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 0.82rem;
}

.admin-shell .field-file {
  border-radius: 12px;
  font-size: 0.82rem;
}

.admin-shell .button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
}

.admin-shell .button-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.76rem;
}

.admin-shell .search-input {
  min-width: 220px;
}

.admin-shell .field-group {
  gap: 6px;
}

.admin-shell .field-group label {
  font-size: 0.74rem;
}

.admin-shell .field-hint {
  font-size: 0.78rem;
  line-height: 1.45;
}

.family-main > .panel,
.family-main > .empty-state {
  flex: 1;
  min-height: 0;
}

.family-main > .panel {
  display: flex;
  flex-direction: column;
}

.family-main > .panel .tree-shell {
  flex: 1;
  min-height: 0;
}

.stat-card {
  padding: 22px 22px 20px;
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.88);
  border: 1px solid rgba(195, 181, 156, 0.72);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.stat-value {
  display: block;
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 8px;
  font-weight: 800;
  color: var(--brand-950);
}

.stat-detail {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 22px;
  margin-top: 26px;
  align-items: start;
}

.two-up {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.panel {
  padding: 28px;
  border-radius: 28px;
  background: rgba(255, 252, 247, 0.9);
  border: 1px solid rgba(195, 181, 156, 0.72);
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  font-size: clamp(1.4rem, 2vw, 1.8rem);
  color: var(--brand-950);
  line-height: 1.08;
}

.panel h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--brand-900);
}

.panel p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.72;
}

.panel > p:first-of-type,
.panel > .section-copy {
  margin-top: 10px;
}

.panel-header,
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

.section-copy {
  max-width: 60ch;
}

.mini-grid {
  display: grid;
  gap: 12px;
}

.portal-actions {
  display: grid;
  gap: 12px;
}

.portal-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--surface-quiet);
  border: 1px solid rgba(195, 181, 156, 0.56);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.portal-link-card:hover,
.portal-link-card:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(100, 140, 116, 0.3);
}

.portal-link-card strong {
  display: block;
  color: var(--brand-900);
}

.portal-link-card span {
  display: block;
  margin-top: 6px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

.portal-link-arrow {
  margin-top: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--brand-700);
  align-self: center;
}

.mini-card {
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--surface-quiet);
  border: 1px solid rgba(195, 181, 156, 0.56);
}

.mini-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-900);
}

.mini-card p {
  margin: 0;
  font-size: 0.88rem;
}

.checklist {
  display: grid;
  gap: 12px;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-quiet);
  border: 1px solid rgba(195, 181, 156, 0.56);
}

.check-indicator {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: var(--brand-700);
  border: 1px solid rgba(100, 140, 116, 0.22);
  font-weight: 800;
}

.check-content strong {
  display: block;
  margin-bottom: 4px;
  color: var(--brand-900);
}

.check-content p {
  margin: 0;
  font-size: 0.88rem;
}

.callout,
.alert,
.banner {
  padding: 18px 20px;
  border-radius: 22px;
  border: 1px solid transparent;
}

.banner {
  margin-top: 24px;
}

.alert {
  background: #fff7f6;
  border-color: rgba(152, 58, 50, 0.22);
  color: var(--danger-700);
}

.alert-success,
.banner-success {
  background: rgba(220, 237, 223, 0.72);
  border-color: rgba(54, 98, 71, 0.18);
  color: var(--success-700);
}

.callout {
  background: rgba(228, 239, 233, 0.66);
  border-color: rgba(72, 113, 90, 0.14);
}

.alert-title {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
}

.meta-row,
.inline-meta {
  display: flex;
  align-items: center;
  gap: 10px 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.88rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(195, 181, 156, 0.6);
  color: var(--brand-700);
}

.chip-success {
  background: rgba(220, 237, 223, 0.88);
  color: var(--success-700);
  border-color: rgba(54, 98, 71, 0.14);
}

.chip-muted {
  color: var(--muted);
}

.chip-deceased {
  background: rgba(100, 108, 118, 0.16);
  color: #5f6770;
  border-color: rgba(100, 108, 118, 0.22);
}

.copy-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.copy-field input,
.copy-field code,
.search-input,
.field,
.field-file,
.textarea {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid rgba(195, 181, 156, 0.84);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.copy-field input,
.search-input,
.field,
.textarea {
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.copy-field input:focus,
.search-input:focus,
.field:focus,
.textarea:focus {
  border-color: rgba(72, 113, 90, 0.72);
  box-shadow: 0 0 0 4px rgba(100, 140, 116, 0.14);
}

.copy-field input {
  font-size: 0.88rem;
}

.search-input {
  min-width: 260px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-stack {
  display: grid;
  gap: 18px;
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-group label,
.fieldset-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--brand-900);
  letter-spacing: -0.01em;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

.field-file {
  padding: 12px 16px;
}

.media-picker {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border-radius: 22px;
  background: var(--surface-quiet);
  border: 1px solid rgba(195, 181, 156, 0.6);
}

.avatar-frame {
  width: 112px;
  height: 112px;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(72, 113, 90, 0.18), rgba(182, 93, 60, 0.16));
  border: 1px solid rgba(195, 181, 156, 0.64);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--heading-font);
  font-size: 2rem;
  color: var(--brand-900);
}

.toggle-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--surface-quiet);
  border: 1px solid rgba(195, 181, 156, 0.6);
}

.toggle-card input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand-700);
}

.toggle-card strong {
  display: block;
  color: var(--brand-900);
}

.toggle-card span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-state {
  padding: 38px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(247, 241, 231, 0.94));
  border: 1px solid rgba(195, 181, 156, 0.68);
  box-shadow: var(--shadow-sm);
}

.empty-state h2 {
  margin-bottom: 10px;
  font-size: clamp(1.7rem, 2.8vw, 2.3rem);
}

.empty-state p {
  max-width: 58ch;
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.step-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(195, 181, 156, 0.52);
}

.step-number {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 12px;
  background: rgba(72, 113, 90, 0.12);
  color: var(--brand-700);
  font-weight: 800;
}

.auth-layout {
  min-height: calc(100vh - 170px);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 420px);
  gap: 24px;
  align-items: stretch;
}

.auth-panel {
  position: relative;
  padding: 34px;
  border-radius: 32px;
  border: 1px solid rgba(195, 181, 156, 0.62);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.auth-panel--feature {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.14), transparent 28%),
    linear-gradient(135deg, rgba(39, 65, 52, 0.96), rgba(23, 37, 31, 0.96));
  color: #fdf9f2;
}

.auth-panel--feature p,
.auth-panel--feature li,
.auth-panel--feature .inline-meta {
  color: rgba(253, 249, 242, 0.78);
}

.auth-panel--feature .chip {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(253, 249, 242, 0.82);
  border-color: rgba(255, 255, 255, 0.12);
}

.auth-panel--access {
  background: rgba(255, 252, 247, 0.92);
}

.auth-panel h1 {
  font-size: clamp(2rem, 3.5vw, 3.1rem);
  line-height: 1;
}

.auth-list {
  display: grid;
  gap: 12px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.auth-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-list strong {
  display: block;
  color: #fff;
  margin-bottom: 4px;
}

.page-auth .page-shell {
  min-height: calc(100vh - 83px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-simple {
  width: 100%;
  display: flex;
  justify-content: center;
}

.auth-simple-card {
  width: min(720px, 100%);
  padding: 36px;
}

.auth-simple-card h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.7rem);
  line-height: 1.05;
  color: var(--brand-950);
}

.auth-simple-copy {
  max-width: 52ch;
  margin: 14px 0 0;
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.directory-card {
  padding: 24px;
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.94);
  border: 1px solid rgba(195, 181, 156, 0.72);
  box-shadow: var(--shadow-sm);
}

.directory-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.directory-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--brand-950);
  line-height: 1.15;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric-strip dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric-strip dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--brand-900);
}

.directory-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.inline-form {
  margin: 0;
}

.tree-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

.family-tree-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.family-tree-surface {
  flex: 1;
  min-height: 0;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.92);
  border: 1px solid rgba(195, 181, 156, 0.72);
  box-shadow: var(--shadow-sm);
}

.page-family-tree .banner {
  margin-top: 0;
  margin-bottom: 12px;
}

.family-tree-surface .tree-shell {
  height: 100%;
}

.tree-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.tree-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tree-zoom-label {
  min-width: 4ch;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.tree-wrap {
  position: relative;
  overflow: hidden;
  min-height: 520px;
  height: clamp(520px, 72vh, 820px);
  border-radius: 28px;
  border: 1px solid rgba(195, 181, 156, 0.72);
  background:
    radial-gradient(circle at top left, rgba(182, 93, 60, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(247, 241, 231, 0.95));
  cursor: grab;
  touch-action: none;
}

.page-family-tree .tree-wrap {
  flex: 1;
  min-height: 0;
  height: auto;
}

.tree-wrap.is-dragging {
  cursor: grabbing;
}

.tree-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.tree-canvas {
  width: max-content;
  padding: 36px 36px 48px;
}

.tree-level {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
}

.tree-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 22px;
}

.tree-item::before,
.tree-item::after {
  content: '';
  position: absolute;
  top: 0;
  width: 50%;
  border-top: 2px solid rgba(100, 140, 116, 0.48);
}

.tree-item::before {
  left: 0;
}

.tree-item::after {
  right: 0;
}

.tree-item:first-child::before,
.tree-item:last-child::after,
.tree-item:only-child::before,
.tree-item:only-child::after {
  display: none;
}

.tree-root > .tree-item {
  padding-top: 0;
}

.tree-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 28px;
}

.tree-node::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 28px;
  border-left: 2px solid rgba(100, 140, 116, 0.48);
}

.tree-root > .tree-item > .tree-node {
  padding-top: 0;
}

.tree-root > .tree-item > .tree-node::before {
  display: none;
}

.tree-children {
  position: relative;
  padding-top: 28px;
}

.tree-children::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 28px;
  border-left: 2px solid rgba(100, 140, 116, 0.48);
}

.tree-couple {
  display: flex;
  align-items: stretch;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(195, 181, 156, 0.78);
  box-shadow: var(--shadow-sm);
}

.tree-couple.has-partner .tree-person:first-child {
  border-right: 1px solid rgba(195, 181, 156, 0.72);
}

.tree-person {
  width: auto;
  min-width: 252px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tree-card-top {
  display: flex;
  gap: 12px;
  align-items: center;
}

.tree-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(72, 113, 90, 0.2), rgba(182, 93, 60, 0.18));
  border: 1px solid rgba(195, 181, 156, 0.68);
}

.tree-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tree-avatar .avatar-fallback {
  font-size: 1rem;
}

.tree-name {
  display: block;
  font-size: 0.95rem;
  line-height: 1.1;
  color: var(--brand-950);
  white-space: nowrap;
}

.tree-card-copy {
  min-height: 44px;
  display: flex;
  align-items: center;
}

.tree-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tree-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.tree-meta {
  display: grid;
  gap: 8px;
  min-height: 54px;
}

.tree-email {
  word-break: break-word;
  font-size: 0.85rem;
  color: var(--muted);
}

.tree-dates {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: pre;
}

.tree-age-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(72, 113, 90, 0.1);
  color: var(--brand-700);
  font-size: 0.68rem;
  line-height: 1;
  white-space: nowrap;
}

.tree-email-empty {
  visibility: hidden;
}

.tree-actions,
.tree-node-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tree-person-deceased,
.stack-person-deceased {
  background: rgba(245, 244, 241, 0.88);
  opacity: 0.72;
}

.tree-node-actions {
  justify-content: center;
  margin-top: 12px;
}

.tree-list {
  display: none;
  gap: 14px;
}

.stack-node {
  display: grid;
  gap: 14px;
}

.stack-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 252, 247, 0.96);
  border: 1px solid rgba(195, 181, 156, 0.72);
  box-shadow: var(--shadow-sm);
}

.stack-card + .stack-children {
  margin-left: 22px;
  padding-left: 18px;
  border-left: 2px solid rgba(100, 140, 116, 0.28);
}

.stack-couple {
  display: grid;
  gap: 12px;
}

.stack-person {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-quiet);
  border: 1px solid rgba(195, 181, 156, 0.56);
}

.stack-person-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stack-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-empty[hidden] {
  display: none;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: 'IBM Plex Mono', 'SFMono-Regular', monospace;
}

.subtle {
  color: var(--muted);
}

.divider {
  height: 1px;
  background: rgba(195, 181, 156, 0.62);
  margin: 6px 0;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .page-hero,
  .panel,
  .stat-card,
  .directory-card,
  .empty-state,
  .auth-panel {
    animation: none;
  }

  .button,
  .site-nav a {
    transition: none;
  }
}

@media (max-width: 1080px) {
  body.page-family-tree {
    overflow: auto;
  }

  .page-family-tree .page-shell {
    height: auto;
    overflow: visible;
  }

  .stats-grid,
  .metric-strip,
  .admin-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .directory-grid,
  .two-up,
  .content-grid,
  .auth-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .hero-kpis {
    min-width: 0;
  }

  .admin-sticky {
    position: static;
  }

  .admin-row {
    gap: 10px;
  }

  .admin-row-top {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-row-main {
    gap: 12px;
  }

  .admin-row-stats,
  .admin-row-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  :root {
    --site-header-height: 74px;
  }

  .site-header-inner {
    min-height: var(--site-header-height);
  }

  .page-shell {
    padding-top: 26px;
  }

  .page-family .page-shell {
    padding-top: 14px;
    min-height: calc(100vh - 75px);
  }

  .page-family-dashboard .page-shell,
  .page-family-tree .page-shell {
    padding-top: 0;
  }

  .page-family-tree .page-shell {
    padding-bottom: 24px;
  }

  .page-modal-form .page-shell {
    min-height: calc(100vh - 75px);
  }

  .page-hero {
    padding: 28px 24px;
  }

  .page-hero h1 {
    max-width: none;
    font-size: clamp(1.85rem, 8vw, 2.75rem);
  }

  .tree-wrap {
    display: none;
  }

  .tree-toolbar {
    display: none;
  }

  .tree-list {
    display: grid;
  }

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

@media (max-width: 720px) {
  :root {
    --shell: calc(100vw - 24px);
  }

  .site-header-inner,
  .site-header-right,
  .site-header-actions,
  .admin-toolbar,
  .page-toolbar,
  .page-hero,
  .panel-header,
  .section-header,
  .tree-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .site-header-inner.has-center-label {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .site-header-center,
  .site-header-right {
    justify-self: stretch;
    text-align: left;
  }

  .family-tabs {
    margin-bottom: 20px;
  }

  .family-tabs-inner,
  .family-tabs-nav,
  .family-tabs-actions {
    align-items: stretch;
    justify-content: flex-start;
  }

  .family-tabs-inner {
    flex-direction: column;
    padding: 10px 0;
  }

  .portal-link-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-title {
    white-space: normal;
  }

  .brand-copy {
    max-width: 220px;
  }

  .site-nav {
    width: 100%;
  }

  .site-nav a,
  .site-nav .inline-form,
  .site-nav .inline-form .button {
    width: 100%;
    justify-content: center;
  }

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

  .admin-summary,
  .hero-kpis,
  .form-grid,
  .copy-field,
  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .admin-row-id {
    position: static;
    justify-self: end;
  }

  .admin-row-stats {
    flex-wrap: wrap;
    gap: 12px;
  }

  .panel,
  .auth-panel,
  .empty-state {
    padding: 22px;
  }

  .modal-panel {
    padding: 20px;
  }

  .page-hero,
  .page-hero.compact {
    padding: 24px 20px;
  }

  .media-picker {
    grid-template-columns: 1fr;
  }

  .search-input {
    min-width: 0;
  }

  .admin-shell .search-input {
    min-width: 0;
  }
}
