:root {
  --paper: #f4eee1;
  --paper-deep: #ece3d0;
  --card: #faf6ec;
  --ink: #1e3229;
  --ink-soft: #47594f;
  --gold: #a8853c;
  --gold-bright: #c9a45c;
  --hairline: rgba(30, 50, 41, 0.18);
  --danger: #8c3b2e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; } /* author display rules (e.g. flex labels) must not defeat the hidden attribute */

body {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.1rem;
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(201, 164, 92, 0.08), transparent 55%),
    var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .brand { font-family: "Fraunces", serif; }
h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; margin: 1.4rem 0 0.6rem; color: var(--ink); }
h3 { font-size: 1.05rem; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); margin: 1rem 0 0.3rem; }
a { color: var(--ink); text-decoration-color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--gold); }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--hairline);
}
.brand { font-size: 1.25rem; font-weight: 600; text-decoration: none; letter-spacing: 0.02em; }
.brand em { font-style: italic; font-weight: 300; color: var(--gold); }
.site-header nav { display: flex; gap: 1.1rem; align-items: baseline; flex-wrap: wrap; }
.site-header nav a, .site-header nav .linklike { font-size: 0.95rem; letter-spacing: 0.05em; white-space: nowrap; }
@media (max-width: 480px) {
  .site-header { padding-top: 0.8rem; padding-bottom: 0.8rem; }
  .site-header nav { gap: 0.7rem 0.9rem; }
  .site-header nav a, .site-header nav .linklike { font-size: 0.88rem; letter-spacing: 0.03em; }
}

.page {
  flex: 1;
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.6rem clamp(1rem, 4vw, 2rem) 3rem;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-top: 1px solid var(--hairline);
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.site-footer a { color: var(--ink-soft); }

.page-head { margin-bottom: 1.2rem; }
.page-head h1 { margin-bottom: 0.2rem; }

.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1.4rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 1px 3px rgba(30, 50, 41, 0.06);
}
.card.narrow { max-width: 26rem; margin: 2.5rem auto; }
.center { text-align: center; }

.muted { color: var(--ink-soft); }
.error { color: var(--danger); font-weight: 600; margin: 0.6rem 0; }
.small-note { font-size: 0.85rem; letter-spacing: 0; text-transform: none; }
.tag {
  font-size: 0.7rem;
  font-family: "Fraunces", serif;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  border: 1px solid var(--gold-bright);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
}

/* forms */
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; }
label small { font-weight: 400; }
label.check { flex-direction: row; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
input, select, textarea {
  font-family: inherit;
  font-size: 1.05rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: #fffdf7;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold-bright);
  outline-offset: 1px;
}
input[type="checkbox"] { width: auto; }
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.9rem;
}

.btn {
  display: inline-block;
  font-family: "Fraunces", serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  text-decoration: none;
  align-self: flex-start;
}
.btn:hover { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: transparent; color: var(--danger); }

.inline-form { display: inline; }
.linklike {
  background: none;
  border: none;
  font: inherit;
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
}
.linklike.danger { color: var(--danger); }

/* people list */
.search-form { display: flex; gap: 0.5rem; margin-top: 0.8rem; flex-wrap: wrap; }
.search-form input { flex: 1; min-width: 12rem; }
.person-list { list-style: none; }
.person-list li { border-bottom: 1px solid var(--hairline); }
.person-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0.3rem;
  text-decoration: none;
  flex-wrap: wrap;
}
.person-row:hover { background: rgba(201, 164, 92, 0.09); }
.person-name { font-weight: 600; font-size: 1.15rem; }
.person-meta { color: var(--ink-soft); font-size: 0.95rem; font-style: italic; }

/* person page */
.person-head { border-bottom: 1px solid var(--hairline); padding-bottom: 0.9rem; margin-bottom: 0.9rem; }
.lifespan { font-style: italic; color: var(--ink-soft); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 0.8rem 0; }
.facts dt { font-family: "Fraunces", serif; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); }
.bio { margin: 1rem 0; line-height: 1.7; }
.relation-group ul { list-style: none; }
.relation-group li { padding: 0.25rem 0; }

/* dashboard */
.stat-row { display: flex; gap: 0.9rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.stat {
  flex: 1;
  min-width: 7rem;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 0.9rem;
  text-align: center;
}
.stat strong { display: block; font-family: "Fraunces", serif; font-size: 1.9rem; }
.stat span { color: var(--ink-soft); font-size: 0.9rem; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.activity { list-style: none; }
.activity li { padding: 0.3rem 0; border-bottom: 1px solid var(--hairline); }
.activity .muted { font-size: 0.85rem; margin-right: 0.5rem; }

.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }

/* families overview */
.center-head { text-align: center; max-width: 34rem; margin: 0 auto 1.4rem; }
.family-field {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.6rem;
  padding: 1rem 0 2rem;
}
.family-medallion {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 0.15rem;
  border: 1.5px solid var(--ink-soft);
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 5px rgba(168, 133, 60, 0.45);
  text-decoration: none;
  padding: 1rem;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.family-medallion:hover { transform: translateY(-3px); border-color: var(--gold); }
.family-medallion.sm { width: 9.5rem; height: 9.5rem; }
.family-medallion.md { width: 12rem; height: 12rem; }
.family-medallion.lg { width: 15rem; height: 15rem; }
.fam-name { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.15rem; line-height: 1.15; }
.family-medallion.lg .fam-name { font-size: 1.45rem; }
.fam-meta { font-size: 0.85rem; font-style: italic; color: var(--ink-soft); }
.fam-jamat {
  font-family: "Fraunces", serif;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

/* tree info-bar editor actions */
.tree-info { flex-wrap: wrap; }
.tree-info-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.anchor-note {
  border: 1px solid var(--gold-bright);
  background: rgba(201, 164, 92, 0.12);
  border-radius: 3px;
  padding: 0.5rem 0.8rem;
}

/* auth + moderation */
.google-btn { display: block; text-align: center; width: 100%; }
.or-rule {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 1.1rem 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-style: italic;
}
.or-rule::before, .or-rule::after { content: ""; flex: 1; border-top: 1px solid var(--hairline); }
.tag.pending { color: var(--ink-soft); border-color: var(--ink-soft); }
.tag.approved { color: #2f6b46; border-color: #2f6b46; }
.tag.rejected { color: var(--danger); border-color: var(--danger); }
a.stat { text-decoration: none; }
.stat.attention { border-color: var(--gold); background: rgba(201, 164, 92, 0.14); }
.attention-card { border-color: var(--gold); background: rgba(201, 164, 92, 0.1); }
.success-card { border-color: #2f6b46; background: rgba(47, 107, 70, 0.08); }
.member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0.3rem;
  flex-wrap: wrap;
}
.facts s { text-decoration-color: var(--danger); }

/* family tree page */
.page:has(.tree-chart) { max-width: 80rem; }
.tree-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.tree-controls select { width: auto; min-width: 14rem; }
.tree-chart {
  width: 100%;
  height: 72vh;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: var(--paper-deep);
  overflow: hidden;
}
.tree-chart svg { background: transparent !important; }

/* theme the family-chart library to the heritage palette */
.tree-chart.f3 {
  --male-color: #35594b;        /* deep green */
  --female-color: #9a6244;      /* warm terracotta */
  --genderless-color: #7d7a6e;
  --background-color: transparent;
  --text-color: #f7f2e7;
  font-family: "Cormorant Garamond", Georgia, serif;
}
.tree-chart.f3 .card-inner { border-radius: 3px; }
.tree-chart.f3 .link { stroke: rgba(168, 133, 60, 0.65) !important; }
.tree-chart.f3 .card-main-outline { stroke: var(--gold-bright); }
.tree-info {
  position: sticky;
  z-index: 10; /* above the chart library's absolute card layer (z-index 2) */
  bottom: 0.8rem;
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--gold-bright);
  border-radius: 4px;
  padding: 0.6rem 1rem;
  box-shadow: 0 2px 8px rgba(30, 50, 41, 0.12);
}
#treeInfoName { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.1rem; }
.tree-hint { margin-top: 0.6rem; text-align: center; }
.add-relation { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.8rem; }
.add-relation select { width: auto; flex: 1; min-width: 10rem; }
.danger-zone { border-color: rgba(140, 59, 46, 0.4); }

@media (max-width: 640px) {
  .tree-chart { height: 62vh; }
}

/* ---- lineage view (vertical, phone-first) ---- */
.page:has(.lineage) { max-width: 64rem; padding-bottom: 5.5rem; }
.lineage { display: flex; flex-direction: column; gap: 1rem; }
.lin-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.8rem; flex-wrap: wrap; }
.lin-eyebrow { font-family: "Fraunces", serif; font-size: clamp(1.5rem, 5vw, 2.1rem); font-weight: 600; line-height: 1.1; }
.lin-sub { font-size: 0.95rem; font-style: italic; margin-top: 0.15rem; }
.lin-switch select { width: auto; max-width: 14rem; font-size: 0.95rem; padding: 0.4rem 0.6rem; }

.lin-label, .lin-sublabel {
  font-family: "Fraunces", serif;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.lin-sublabel { margin: 1.1rem 0 0.4rem; }
.lin-pill {
  font-family: "Fraunces", serif;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  white-space: nowrap;
}
.lin-pill.dark { background: var(--ink); }
.lin-tag {
  display: inline-block;
  margin-left: 0.4rem;
  font-family: "Fraunces", serif;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(30, 50, 41, 0.08);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  vertical-align: middle;
}
.lin-lock { margin-left: 0.4rem; font-size: 0.8rem; color: var(--gold); font-style: italic; }

/* migration strip */
.lin-route {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  overflow-x: auto;
}
.lin-route::before {
  content: "";
  position: absolute;
  left: 1.6rem; right: 1.6rem; top: 50%;
  border-top: 1px dashed rgba(201, 164, 92, 0.6);
}
.lin-stop { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 4.5rem; font-size: 0.8rem; line-height: 1.2; text-align: center; }
.lin-stop:first-child { align-items: flex-start; text-align: left; }
.lin-stop:last-child { align-items: flex-end; text-align: right; }
.lin-place { background: var(--ink); padding: 0 0.3rem; position: relative; z-index: 1; }
.lin-stop b { color: var(--gold-bright); font-family: "Fraunces", serif; font-weight: 600; background: var(--ink); padding: 0 0.3rem; position: relative; z-index: 1; }

/* columns: single on phones, two on desktop */
.lin-columns { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }
.lin-columns > * { min-width: 0; } /* let the scrolling branch strip shrink instead of widening the page */
@media (min-width: 860px) {
  .lin-columns { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 2.4rem; align-items: start; }
  .lin-spine { position: sticky; top: 1rem; }
}

/* the spine */
.lin-spine-head, .lin-kin-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; margin-bottom: 0.5rem; }
.lin-rail { list-style: none; position: relative; padding-left: 0; }
.lin-rail::before {
  content: "";
  position: absolute;
  left: 1.45rem; top: 1.2rem; bottom: 1.6rem;
  border-left: 1.5px solid rgba(168, 133, 60, 0.55);
}
.lin-row { position: relative; padding: 0.15rem 0; }
.lin-row.focus { margin-top: 0.3rem; }
.lin-row.focus .lin-person {
  background: var(--card);
  border: 1px solid var(--gold-bright);
  box-shadow: 0 6px 18px rgba(30, 50, 41, 0.10);
  padding: 0.7rem 0.6rem 0.7rem 0.45rem;
}
.lin-row.focus .lin-name { font-size: 1.35rem; }
@media (max-width: 480px) { .lin-row.focus .lin-pill { display: none; } }
.lin-rail .lin-person { padding-left: 0.4rem; }

.lin-person {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.4rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.2s ease;
}
a.lin-person:hover, a.lin-person:focus-visible { background: rgba(201, 164, 92, 0.13); color: var(--ink); }
.lin-seal {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  border: 2.5px solid var(--paper);
  box-shadow: 0 0 0 1px rgba(30, 50, 41, 0.35);
  color: var(--paper);
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}
.lin-seal.lg { width: 3.4rem; height: 3.4rem; font-size: 1.05rem; box-shadow: 0 0 0 1.5px var(--gold); }
.lin-seal.sm { width: 2.1rem; height: 2.1rem; font-size: 0.9rem; }
.lin-seal.xs { width: 1.45rem; height: 1.45rem; font-size: 0.55rem; border-width: 1.5px; }
.lin-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lin-name { font-family: "Fraunces", serif; font-weight: 500; font-size: 1.08rem; line-height: 1.2; overflow-wrap: anywhere; }
.lin-meta { font-size: 0.88rem; color: var(--ink-soft); font-style: italic; line-height: 1.35; }
.lin-meta a { color: var(--ink-soft); }
.lin-partner {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: -0.15rem 0 0.15rem 3.55rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-decoration: none;
}
.lin-partner:hover { color: var(--gold); }
.lin-arrow { color: var(--gold); font-size: 1.1rem; padding-right: 0.3rem; }
.lin-edit { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; padding-left: 0.4rem; }

/* kin lists */
.lin-list { list-style: none; }
.lin-list li + li { border-top: 1px solid var(--hairline); }
.lin-list.nested { margin-left: 1.05rem; border-left: 1px solid var(--hairline); padding-left: 0.5rem; margin-top: 0.3rem; }
.lin-fold { margin-top: 0.8rem; border: 1px solid var(--hairline); border-radius: 12px; background: var(--card); }
.lin-fold summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
}
.lin-fold summary::-webkit-details-marker { display: none; }
.lin-chevron { color: var(--gold); font-size: 1.4rem; transition: transform 0.2s ease; }
.lin-fold[open] .lin-chevron { transform: rotate(90deg); }
.lin-fold[open] summary { border-bottom: 1px solid var(--hairline); }
.lin-fold .lin-list.nested { margin: 0.3rem 0.5rem 0.5rem 1.5rem; }
.lin-empty { padding: 0.6rem 0.4rem; font-style: italic; }

/* branch cards: married-in families */
.lin-branches { display: flex; gap: 0.6rem; overflow-x: auto; padding: 0.2rem 0 0.6rem; scroll-snap-type: x proximity; }
.lin-branch {
  flex: 0 0 11.5rem;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.lin-branch:hover { border-color: var(--gold); transform: translateY(-2px); color: var(--ink); }
.lin-branch-bar { height: 3px; width: 2.4rem; border-radius: 999px; margin-bottom: 0.35rem; }
.lin-branch-count { font-family: "Fraunces", serif; font-size: 1.4rem; font-weight: 600; line-height: 1; }
.lin-branch-name { font-family: "Fraunces", serif; font-size: 0.95rem; font-weight: 500; }
.lin-branch-label { font-size: 0.82rem; color: var(--ink-soft); font-style: italic; line-height: 1.25; }
.lin-branch-via { margin-top: 0.3rem; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); font-family: "Fraunces", serif; }
@media (min-width: 860px) { .lin-branches { flex-wrap: wrap; } .lin-branch { flex-basis: calc(50% - 0.3rem); } }

/* sticky bottom bar */
.lin-foot {
  position: sticky;
  bottom: 0.7rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 14px;
  padding: 0.4rem;
  box-shadow: 0 10px 24px rgba(30, 50, 41, 0.28);
}
.lin-foot-btn, .lin-foot-main {
  font-family: "Fraunces", serif;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--paper);
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lin-foot-btn { flex: 0 1 auto; min-width: 5.5rem; text-align: center; }
.lin-foot-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--paper); }
.lin-foot-btn.disabled { opacity: 0.35; }
.lin-foot-main { flex: 1; text-align: center; background: var(--paper); color: var(--ink); font-weight: 600; }
.lin-foot-main:hover { background: var(--gold-bright); color: var(--ink); }
@media (min-width: 860px) { .lin-foot { position: static; max-width: 32rem; margin: 0.4rem auto 0; } .page:has(.lineage) { padding-bottom: 3rem; } }
