/* ============================================================
   باغ جوزا — Family Archive
   Design concept: an illuminated Persian garden ledger.
   Parchment ground, indigo ink, gold leaf, madder-red marriage
   knots, sage-green descent. Branches drawn as garden vines,
   not office-chart boxes.
   ============================================================ */

:root {
  --ink: #241d16;
  --indigo: #1c3144;
  --indigo-deep: #142430;
  --parchment: #f3e9d2;
  --parchment-dim: #ece0c4;
  --parchment-deep: #e4d6b2;
  --gold: #b8862f;
  --gold-bright: #d4a24a;
  --madder: #8c3a34;
  --sage: #5b7a54;
  --sage-deep: #43593e;
  --line-soft: rgba(36, 29, 22, 0.16);

  --font-display: "Lalezar", "Vazirmatn", sans-serif;
  --font-body: "Vazirmatn", "Tahoma", sans-serif;

  --radius: 14px;
  --shadow-card: 0 2px 0 rgba(36,29,22,0.06), 0 10px 24px -14px rgba(36,29,22,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  direction: rtl;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background-image:
    radial-gradient(circle at 15% 8%, rgba(184,134,47,0.08), transparent 40%),
    radial-gradient(circle at 85% 92%, rgba(91,122,84,0.08), transparent 45%);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
}

::selection { background: var(--gold-bright); color: var(--ink); }

*:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------- layout shell ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, var(--indigo) 0%, var(--indigo-deep) 100%);
  color: var(--parchment);
  border-bottom: 3px solid var(--gold);
}

.site-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.5px;
  color: var(--parchment);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.brand small {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--gold-bright);
  font-weight: 500;
}

.header-search {
  flex: 1;
  position: relative;
  max-width: 420px;
}

.header-search input {
  width: 100%;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(243,233,210,0.25);
  background: rgba(243,233,210,0.08);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 14px;
}

.header-search input::placeholder { color: rgba(243,233,210,0.55); }
.header-search input:focus { background: rgba(243,233,210,0.14); }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

/* ---------------- hero ---------------- */

.hero {
  position: relative;
  text-align: center;
  padding: 56px 20px 40px;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(180deg, var(--indigo) 0%, var(--indigo-deep) 100%);
  color: var(--parchment);
  margin-bottom: 22px;
}

.hero__pattern {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  pointer-events: none;
}

.hero__content { position: relative; }

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 8vw, 68px);
  margin: 0 0 6px;
  color: var(--parchment);
  text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

.hero p.tagline {
  margin: 0 0 26px;
  color: var(--gold-bright);
  font-size: 16px;
}

.hero-search {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.hero-search input {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  border-radius: 999px;
  border: none;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  box-shadow: var(--shadow-card);
}

.hero-search input:focus { box-shadow: 0 0 0 3px var(--gold-bright); }

.stat-strip {
  display: flex;
  justify-content: center;
  gap: 34px;
  margin-top: 26px;
  flex-wrap: wrap;
}

.stat-strip .stat {
  text-align: center;
}

.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--gold-bright);
}

.stat span {
  font-size: 12px;
  color: rgba(243,233,210,0.75);
}

/* ---------------- search dropdown ---------------- */

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  background: var(--parchment);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  max-height: 340px;
  overflow-y: auto;
  z-index: 60;
  text-align: right;
  display: none;
}

.search-results.open { display: block; }

.search-results a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  color: var(--ink);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover, .search-results a:focus-visible { background: var(--parchment-deep); }
.search-results .fam { color: var(--madder); font-size: 12px; }
.search-results .empty { padding: 16px; color: #7a7263; font-size: 13px; text-align: center; }

/* ---------------- section headers ---------------- */

.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 34px 0 14px;
  color: var(--indigo);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .leaf { color: var(--sage); }

/* ---------------- alphabet chips ---------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: var(--parchment-dim);
  font-size: 14px;
  color: var(--indigo);
}

.chip:hover { border-color: var(--gold); }
.chip.active { background: var(--indigo); color: var(--parchment); border-color: var(--indigo); }

/* ---------------- family grid ---------------- */

.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.add-person-row {
  text-align: center;
  margin-top: 22px;
}

.family-card {
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.family-card:hover, .family-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
  border-color: var(--gold);
}

.family-card .name {
  font-size: 17px;
  font-weight: 600;
  color: var(--indigo);
  margin-bottom: 4px;
}

.family-card .count {
  font-size: 13px;
  color: var(--madder);
}

.family-card .count b { font-family: var(--font-body); }

/* ---------------- breadcrumb ---------------- */

.breadcrumb {
  font-size: 13px;
  color: #6b6354;
  margin-bottom: 18px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--indigo); }
.breadcrumb a:hover { color: var(--gold); text-decoration: underline; }

/* ---------------- family member list ---------------- */

.member-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}

.member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--parchment-dim);
}

.member-row:nth-child(even) { background: var(--parchment); }
.member-row:hover { background: var(--parchment-deep); }

.member-row .who { display: flex; align-items: center; gap: 10px; }
.member-row .gender-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block;
}
.gender-dot.g1 { background: var(--indigo); }
.gender-dot.g2 { background: var(--madder); }
.gender-dot.g0 { background: #a8a08c; }

.member-row .dates { font-size: 12px; color: #7a7263; }

/* ---------------- person page ---------------- */

.person-card {
  background: linear-gradient(180deg, var(--parchment-dim), var(--parchment));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.person-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 6px;
}

.person-card.g1::before { background: var(--indigo); }
.person-card.g2::before { background: var(--madder); }
.person-card.g0::before { background: #a8a08c; }

.person-card h2 {
  font-family: var(--font-display);
  font-size: 34px;
  margin: 0 0 4px;
  color: var(--indigo);
}

.person-card .family-tag {
  display: inline-block;
  font-size: 13px;
  color: var(--madder);
  background: rgba(140,58,52,0.08);
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.person-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-bottom: 12px;
  font-size: 14px;
}

.person-meta div b {
  display: block;
  font-size: 11px;
  color: #7a7263;
  font-weight: 500;
  margin-bottom: 2px;
}

.person-desc {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-soft);
  font-size: 14px;
  line-height: 2;
  color: #45392a;
}

/* ---------------- ego tree (signature element) ---------------- */

.tree-wrap {
  margin-top: 30px;
  position: relative;
}

.tree-scroll {
  overflow-x: auto;
  padding: 10px 4px 26px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
}

.tree {
  position: relative;
  min-width: 640px;
  width: max-content;
  margin: 0 auto;
}

.tree-row {
  display: flex;
  justify-content: center;
  gap: 22px;
  position: relative;
  z-index: 2;
  margin: 0 0 46px;
}

.tree-row.center-row { margin-bottom: 46px; }
.tree-row:last-child { margin-bottom: 4px; }

.tree-row-label {
  text-align: center;
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 10px;
  font-weight: 700;
}

.branch-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.node {
  background: var(--parchment);
  border: 1.5px solid var(--line-soft);
  border-radius: 11px;
  padding: 10px 14px;
  min-width: 130px;
  max-width: 170px;
  text-align: center;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(36,29,22,0.10);
  position: relative;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.node:hover, .node:focus-visible {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 6px 14px rgba(36,29,22,0.18);
}

.node .leaf-bullet {
  position: absolute;
  top: -9px;
  right: 50%;
  transform: translateX(50%);
  font-size: 12px;
}

.node .n-name { font-weight: 600; color: var(--indigo); }
.node .n-years { font-size: 11px; color: #7a7263; margin-top: 2px; }

.node.center {
  background: var(--indigo);
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(184,134,47,0.25), var(--shadow-card);
}
.node.center .n-name { color: var(--parchment); }
.node.center .n-years { color: var(--gold-bright); }

.node.ghost {
  opacity: 0.55;
  border-style: dashed;
}

.node.placeholder {
  opacity: 0.65;
  border-style: dashed;
  font-size: 12px;
  color: #7a7263;
}

.spouse-pair {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spouse-knot {
  color: var(--madder);
  font-size: 15px;
}

.more-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--sage-deep);
  border-bottom: 1px dotted var(--sage-deep);
}
.more-link:hover { color: var(--gold); border-color: var(--gold); }

.children-more {
  min-width: auto;
  padding: 8px 12px;
}

.tree-legend {
  display: flex;
  gap: 18px;
  justify-content: center;
  font-size: 12px;
  color: #6b6354;
  margin-top: 4px;
  flex-wrap: wrap;
}
.tree-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tree-legend i { width: 16px; height: 2px; display: inline-block; }
.tree-legend i.up { background: var(--indigo); }
.tree-legend i.down { background: var(--sage); }
.tree-legend i.marry { background: var(--madder); }

/* ---------------- empty / not found ---------------- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #6b6354;
}
.empty-state h2 { font-family: var(--font-display); color: var(--indigo); font-size: 28px; }

/* ---------------- footer ---------------- */

.site-footer {
  text-align: center;
  font-size: 12px;
  color: #8a8272;
  padding: 30px 20px 50px;
}

.legal-footer {
  text-align: center;
  padding: 18px 20px 40px;
  border-top: 1px solid var(--line-soft);
  margin-top: -10px;
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.legal-footer a {
  font-size: 12.5px;
  color: #8a8272;
  letter-spacing: 0.3px;
}

.legal-footer a:hover { color: var(--gold); text-decoration: underline; }

.header-guide-link {
  color: var(--gold-bright);
  font-size: 13px;
  flex-shrink: 0;
  white-space: nowrap;
}
.header-guide-link:hover { text-decoration: underline; }

/* ---------------- impressum page ---------------- */

.impressum-card {
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 28px 30px;
  box-shadow: var(--shadow-card);
}

.impressum-image {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 0 auto 22px;
}

/* ---------------- guide / راهنما ---------------- */

.guide-card {
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 28px 30px 34px;
  box-shadow: var(--shadow-card);
}

.guide-image {
  display: block;
  width: 100%;
  max-width: 560px;
  border-radius: 12px;
  height: auto;
  margin: 0 auto 20px;
}

.guide-title {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--indigo);
  text-align: center;
  margin: 0 0 10px;
}

.guide-intro {
  text-align: center;
  font-size: 14.5px;
  color: #4a4030;
  line-height: 1.9;
  max-width: 640px;
  margin: 0 auto 30px;
}

.guide-section {
  max-width: 700px;
  margin: 0 auto 26px;
  padding-top: 20px;
  border-top: 1px dashed var(--line-soft);
}
.guide-section:first-of-type { border-top: none; padding-top: 0; }

.guide-section h3 {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--gold);
  margin: 0 0 10px;
}

.guide-section p {
  font-size: 14px;
  line-height: 1.95;
  color: #3a3024;
  margin: 0 0 10px;
}

.guide-section ul {
  margin: 0 0 10px;
  padding-inline-start: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-section li {
  font-size: 14px;
  line-height: 1.85;
  color: #3a3024;
}

.impressum-tribute {
  font-size: 15px;
  line-height: 2.1;
  color: #3a3024;
  margin: 0 0 14px;
}

.impressum-tribute--closing {
  font-style: italic;
  color: var(--indigo);
}

.impressum-tribute--solo {
  text-align: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  font-style: normal;
  margin: 6px 0 2px;
}

.impressum-signature {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--gold);
  margin: 4px 0 0;
}

.impressum-divider {
  border: none;
  border-top: 1px dashed var(--line-soft);
  margin: 28px 0;
}

.impressum-legal {
  font-size: 14px;
  line-height: 1.9;
  color: #3a3024;
}

.impressum-legal a { color: var(--madder); }
.impressum-legal a:hover { text-decoration: underline; }

/* ---------------- responsive ---------------- */

@media (max-width: 640px) {
  .site-header__inner { flex-wrap: wrap; }
  .brand { font-size: 21px; }
  .header-search { order: 3; max-width: none; flex-basis: 100%; }
  .hero { padding: 40px 14px 30px; }
  .person-card { padding: 20px; }
  .person-card h2 { font-size: 26px; }
  .stat-strip { gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   backend-powered additions: auth, editing, moderation
   ============================================================ */

/* ---------------- auth area (header) ---------------- */

.auth-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--parchment);
}

.auth-link {
  color: var(--gold-bright);
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
}
.auth-link:hover { text-decoration: underline; }

.auth-name { color: var(--parchment); font-weight: 600; }

.role-badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.role-admin { background: var(--gold); color: var(--indigo-deep); }
.role-editor { background: var(--sage); color: #fff; }
.role-pending { background: rgba(243,233,210,0.2); color: var(--parchment); }

/* ---------------- auth pages (login/register) ---------------- */

.auth-card {
  max-width: 420px;
  margin: 20px auto;
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 28px 30px;
  box-shadow: var(--shadow-card);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #4a4030; }
.auth-form input {
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--parchment);
  font-family: var(--font-body);
  font-size: 14px;
}
.auth-form input:focus { border-color: var(--gold); }

.auth-switch { margin-top: 16px; font-size: 13px; text-align: center; color: #6b6354; }
.auth-switch a { color: var(--madder); }

.register-success {
  text-align: center;
  padding: 10px 0;
}

.register-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sage);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.register-success h2 {
  font-family: var(--font-display);
  color: var(--indigo);
  font-size: 24px;
  margin: 0 0 12px;
}

.register-success p {
  font-size: 14px;
  line-height: 1.8;
  color: #4a4030;
  margin: 0 0 10px;
}

.register-success .btn-primary {
  display: inline-block;
  margin-top: 12px;
  text-decoration: none;
}

.form-msg { font-size: 13px; color: var(--sage-deep); min-height: 18px; }
.form-msg.error { color: var(--madder); }

.btn-primary {
  background: var(--indigo);
  color: var(--parchment);
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
}
.btn-primary:hover { background: var(--indigo-deep); }

.btn-secondary {
  background: transparent;
  color: var(--indigo);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--gold); }

/* ---------------- person edit ---------------- */

.person-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.edit-toggle {
  background: none;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12.5px;
  color: var(--indigo);
  cursor: pointer;
  font-family: var(--font-body);
}
.edit-toggle:hover { border-color: var(--gold); }

.deceased-tag {
  font-size: 0.6em;
  font-family: var(--font-body);
  color: #8a8272;
  font-style: italic;
}

.edit-form {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.edit-form label, .edit-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: #4a4030;
}

.edit-form input, .edit-form select, .edit-form textarea {
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--parchment);
  font-family: var(--font-body);
  font-size: 13.5px;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}
.checkbox-label input { width: auto; }

.edit-actions { display: flex; gap: 10px; }

/* ---------------- tree link affordances ---------------- */

.node.placeholder {
  cursor: default;
}
.node.placeholder[data-link-for] {
  cursor: pointer;
  opacity: 0.95;
  border-color: var(--sage-deep);
  border-width: 1.5px;
  background: rgba(91,122,84,0.06);
}
.node.placeholder[data-link-for]:hover {
  border-color: var(--gold);
  opacity: 1;
  background: rgba(184,134,47,0.10);
}
.add-hint {
  display: block;
  font-size: 10px;
  color: var(--sage-deep);
  margin-top: 3px;
}

.spouse-add {
  cursor: pointer;
  border: 1px dashed var(--sage-deep);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sage-deep);
  font-size: 15px;
}
.spouse-add:hover { background: var(--sage); color: #fff; border-color: var(--sage); }

.node-spouse-wrap {
  position: relative;
  display: inline-flex;
}

.remove-spouse-btn {
  position: absolute;
  top: -8px;
  inset-inline-end: -8px;
  z-index: 5;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--madder);
  background: var(--parchment);
  color: var(--madder);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.remove-spouse-btn:hover { background: var(--madder); color: #fff; }

/* ---------------- modal link picker ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--parchment);
  border-radius: var(--radius);
  padding: 24px 26px;
  max-width: 460px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

.modal-card h3 {
  font-family: var(--font-display);
  color: var(--indigo);
  margin: 0 0 6px;
  font-size: 22px;
}

.modal-hint { font-size: 13px; color: #6b6354; margin: 0 0 14px; }

/* ---------------- relationship finder ---------------- */

.kinship-picker-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.kinship-picker {
  position: relative;
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kinship-picker label {
  display: block;
  font-size: 12px;
  color: var(--indigo);
  font-weight: 600;
  margin-bottom: 6px;
}

.kinship-picker input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--parchment);
  font-family: var(--font-body);
  font-size: 14px;
  box-sizing: border-box;
}

.kinship-picker .link-picker-results {
  position: absolute;
  z-index: 15;
  left: 16px;
  right: 16px;
  top: 100%;
  margin-top: 4px;
  background: var(--parchment);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  max-height: 240px;
  overflow-y: auto;
}

.kinship-chosen {
  margin-top: 10px;
  font-size: 13px;
  color: #4a4030;
  min-height: 18px;
}
.kinship-chosen .fam { color: var(--madder); font-size: 12px; }

.kinship-no-result {
  padding: 20px;
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.9;
  color: #4a4030;
}

.kinship-label {
  text-align: center;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--indigo);
  background: var(--parchment-dim);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 24px;
}

.kinship-tree {
  position: relative;
  min-width: 480px;
  padding: 10px 20px 20px;
}

.tree-row.single-row {
  display: flex;
  justify-content: center;
  margin-bottom: 46px;
  position: relative;
  z-index: 2;
}

.kinship-branches {
  display: flex;
  justify-content: space-around;
  gap: 40px;
  position: relative;
  z-index: 2;
}

.kinship-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 46px;
}

@media (max-width: 640px) {
  .kinship-picker-row { grid-template-columns: 1fr; }
}

.second-parent-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #4a4030;
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.second-parent-picker select {
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--parchment);
  font-family: var(--font-body);
  font-size: 13px;
}

.modal-card input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 10px;
}

.link-picker-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.link-picker-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 8px 10px;
  border: none;
  background: var(--parchment-dim);
  border-radius: 8px;
  font-size: 13.5px;
  text-align: right;
  cursor: pointer;
  font-family: var(--font-body);
  width: 100%;
}
.link-picker-item:hover { background: var(--parchment-deep); }
.link-picker-item .fam { color: var(--madder); font-size: 12px; }
.link-picker-item .lp-main { display: flex; justify-content: space-between; gap: 8px; }
.link-picker-item .lp-details { font-size: 11.5px; color: #6b6354; }

.dup-warning {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(140,58,52,0.07);
  border: 1px solid rgba(140,58,52,0.25);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dup-warning-title {
  font-size: 12.5px;
  color: var(--madder);
  margin-bottom: 2px;
}

/* ---------------- admin dashboard ---------------- */

.admin-subtitle {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--indigo);
  margin: 26px 0 10px;
}

.suggest-summary {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.suggest-stat {
  flex: 1;
  min-width: 180px;
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
}
.suggest-stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  margin-bottom: 4px;
}
.suggest-stat span { font-size: 12.5px; color: #6b6354; }
.suggest-stat--ok { border-color: var(--sage-deep); }
.suggest-stat--ok b { color: var(--sage-deep); }
.suggest-stat--warn { border-color: var(--gold); }
.suggest-stat--warn b { color: var(--gold); }

.suggest-apply-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--parchment-dim);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13.5px;
}

.admin-row-actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn-approve, .btn-reject {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--font-body);
}
.btn-approve { background: var(--sage); color: #fff; }
.btn-approve:hover { background: var(--sage-deep); }
.btn-reject { background: transparent; color: var(--madder); border: 1px solid var(--madder); }
.btn-reject:hover { background: var(--madder); color: #fff; }

.admin-empty, .admin-loading { font-size: 13px; color: #8a8272; padding: 8px 2px; }

.danger-zone {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed rgba(140,58,52,0.35);
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-danger {
  background: transparent;
  color: var(--madder);
  border: 1px solid var(--madder);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--font-body);
}
.btn-danger:hover { background: var(--madder); color: #fff; }

@media (max-width: 640px) {
  .auth-area { order: 4; margin-inline-start: auto; }
}

/* ---------------- admin data table ---------------- */

.admin-nav-row {
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.table-search-input {
  width: 100%;
  max-width: 420px;
  padding: 9px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--parchment-dim);
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 16px;
  display: block;
}
.table-search-input:focus { border-color: var(--gold); }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--parchment-dim);
}

.admin-data-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12.5px;
}

.admin-data-table th {
  text-align: right;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--indigo);
  font-size: 12px;
  padding: 10px 8px;
  border-bottom: 2px solid var(--gold);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--parchment-dim);
}

.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { color: var(--gold); }

.table-filter-row th {
  position: sticky;
  top: 34px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line-soft);
}

.table-filter-input {
  width: 100%;
  min-width: 70px;
  padding: 4px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--parchment);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 400;
  color: #4a4030;
}
.table-filter-input:focus { border-color: var(--gold); }

.admin-data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.admin-data-table td {
  padding: 4px 5px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  overflow: hidden;
}

.admin-data-table tr:last-child td { border-bottom: none; }
.admin-data-table tr:hover { background: var(--parchment-deep); }

.cell-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: #3a3024;
}
.cell-input:hover { border-color: var(--line-soft); background: var(--parchment); }
.cell-input:focus { border-color: var(--gold); background: var(--parchment); }
input.cell-input[type="checkbox"] { width: auto; min-width: 0; margin: 0; }

.cell-textarea {
  resize: vertical;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  line-height: 1.4;
  font-size: 12px;
}

.cell-parent-wrap { position: relative; min-width: 0; }
.cell-parent-input { min-width: 0; }

.parent-suggest {
  position: absolute;
  z-index: 20;
  top: calc(100% + 2px);
  right: 0;
  left: 0;
  min-width: 220px;
  background: var(--parchment);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  max-height: 220px;
  overflow-y: auto;
}

.parent-suggest-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: none;
  font-size: 12.5px;
  text-align: right;
  cursor: pointer;
  font-family: var(--font-body);
  color: #3a3024;
}
.parent-suggest-item:hover { background: var(--parchment-deep); }
.parent-suggest-item .fam { color: var(--madder); font-size: 11px; }
.parent-suggest-empty { padding: 8px 10px; font-size: 12px; color: #8a8272; }

.cell-link { color: var(--madder); font-size: 12.5px; white-space: nowrap; }
.cell-link:hover { text-decoration: underline; }
.cell-empty { color: #a8a08c; }

.cell-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.cell-open-link { color: var(--indigo); font-size: 15px; }
.cell-open-link:hover { color: var(--gold); }

.cell-saved { font-size: 13px; min-width: 14px; display: inline-block; color: #8a8272; }
.cell-saved--ok { color: var(--sage-deep); }
.cell-saved--error { color: var(--madder); }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.table-page-info { font-size: 13px; color: #6b6354; }

/* Below this width, the table becomes a stack of labeled cards —
   the standard responsive-table pattern, so iPhone users get a
   thumb-friendly list instead of a horizontally-scrolling grid. */
@media (max-width: 700px) {
  .table-scroll { overflow-x: visible; border: none; background: none; }
  .admin-data-table thead { display: none; }
  .admin-data-table, .admin-data-table tbody, .admin-data-table tr, .admin-data-table td {
    display: block;
    width: 100%;
  }
  .admin-data-table tr {
    background: var(--parchment-dim);
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
  }
  .admin-data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 2px;
    border-bottom: 1px dashed var(--line-soft);
  }
  .admin-data-table tr td:last-child { border-bottom: none; }
  .admin-data-table td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--indigo);
    font-size: 11px;
    flex-shrink: 0;
  }
  .admin-data-table td[data-label=""]::before { content: none; }
  .cell-input { text-align: left; }
  .cell-actions { justify-content: flex-end; }
}

/* ---------------- photos ---------------- */

.person-card-titlewrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.person-portrait {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  flex-shrink: 0;
}

.leaf-bullet--photo {
  position: absolute;
  top: -14px;
  right: 50%;
  transform: translateX(50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--gold);
  background: var(--parchment);
}

.photo-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.photo-upload-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.admin-photo-preview {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  margin-top: 6px;
}
