/* Shajra-e-Nasab design language — see docs/design/product-psychology.md
   Warm ivory ground, deep forest ink, gold reserved for reverence. */
:root {
  --bg: #f8f5ee;
  --surface: #fffdf8;
  --surface-2: #f3efe4;
  --ink: #23261f;
  --muted: #75766a;
  --line: #e6e1d1;
  --brand: #1d4d40;
  --brand-deep: #143a30;
  --brand-soft: #e2ece6;
  --gold: #b98f3e;
  --gold-soft: #f2e8d2;
  --danger: #a63a3f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(35, 38, 31, 0.05), 0 6px 20px rgba(35, 38, 31, 0.06);
  --shadow-2: 0 6px 16px rgba(35, 38, 31, 0.08), 0 20px 48px rgba(35, 38, 31, 0.12);
  --sans: 'Manrope', system-ui, sans-serif;
  --display: 'Fraunces', Georgia, serif;
  --urdu: 'Noto Nastaliq Urdu', serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
[dir='rtl'] body, [dir='rtl'] input, [dir='rtl'] textarea, [dir='rtl'] button, [dir='rtl'] select {
  font-family: var(--urdu);
}
[dir='rtl'] { line-height: 1.95; }
.urdu { font-family: var(--urdu); }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-deep); }

/* ---------- Header ---------- */
header.site {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
header.site .brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
header.site .brand:hover { color: var(--ink); }
header.site .brand .mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(140deg, var(--brand), #2c6b57);
  color: var(--gold-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  box-shadow: 0 3px 10px rgba(29, 77, 64, 0.3);
}
header.site .brand .urdu { font-size: 1rem; color: var(--gold); font-weight: 400; }
header.site nav { display: flex; gap: 0.3rem; align-items: center; margin-inline-start: auto; flex-wrap: wrap; }
header.site nav a {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
}
header.site nav a:hover { background: var(--surface-2); color: var(--ink); }
header.site nav a.active { background: var(--brand-soft); color: var(--brand-deep); }
header.site nav a.nav-cta { background: var(--brand); color: #fdfbf5; padding: 0.38rem 1.1rem; box-shadow: 0 2px 6px rgba(29, 77, 64, 0.28); }
header.site nav a.nav-cta:hover { background: var(--brand-deep); color: #fdfbf5; }

/* ---------- Layout ---------- */
main { max-width: 1020px; margin: 0 auto; padding: 2.2rem 1.4rem 4rem; }
main.wide { max-width: none; padding: 0; }

h1 { font-family: var(--display); font-size: 1.85rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin-bottom: 0.4rem; }
h2 { font-family: var(--display); font-size: 1.25rem; font-weight: 600; margin: 2rem 0 0.9rem; }
[dir='rtl'] h1, [dir='rtl'] h2 { line-height: 1.9; letter-spacing: 0; }
.ornament { display: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 1.3rem 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.card h3 a { color: var(--ink); font-family: var(--display); font-size: 1.1rem; }
.card h3 a:hover { color: var(--brand-deep); }
.card .meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

/* ---------- Forms ---------- */
form.stack { display: flex; flex-direction: column; gap: 0.95rem; max-width: 430px; }
label {
  font-size: 0.74rem; font-weight: 700; color: var(--muted);
  display: block; margin-bottom: 0.3rem;
  letter-spacing: 0.07em; text-transform: uppercase;
}
[dir='rtl'] label { letter-spacing: 0; text-transform: none; font-size: 0.85rem; }
input[type='text'], input[type='email'], input[type='password'], textarea, select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.96rem;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { min-height: 8.5rem; resize: vertical; }
select:not([multiple]) {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2375766a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-inline-end: 2.4rem;
}
[dir='rtl'] select:not([multiple]) { background-position: left 0.85rem center; }
select[multiple] { padding: 0.35rem; }
select[multiple] option { padding: 0.35rem 0.6rem; border-radius: 7px; }
input[type='file'] {
  width: 100%;
  padding: 0.9rem;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
}
input[type='file']:hover { border-color: var(--brand); }
input[type='file']::file-selector-button {
  background: var(--brand-soft); color: var(--brand-deep);
  border: none; border-radius: 999px;
  padding: 0.35rem 0.95rem; margin-inline-end: 0.8rem;
  font-family: inherit; font-size: 0.84rem; font-weight: 700; cursor: pointer;
}
.hint { font-size: 0.79rem; color: var(--muted); }
.meta { color: var(--muted); font-size: 0.9rem; }
.btn-block { width: 100%; }
.inline-form { display: inline; }
.field-row { display: flex; gap: 0.8rem; }
.field-row > div { flex: 1; }
.form-actions { display: flex; gap: 0.6rem; }
.field-hint { margin-top: 0.3rem; }
.hint-spaced { margin-top: 1rem; }
.back-row { margin-top: 1.8rem; }
.empty-note { font-style: italic; }
h2 + .meta { margin-top: -0.5rem; margin-bottom: 0.8rem; }
::selection { background: var(--gold-soft); color: var(--ink); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--brand);
  color: #fdfbf5;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.35rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(29, 77, 64, 0.28);
}
button:hover, .btn:hover { background: var(--brand-deep); color: #fdfbf5; transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }
.btn-quiet { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); border-color: #d3cdba; }
.btn-small { padding: 0.32rem 0.85rem; font-size: 0.82rem; }
.btn-danger { background: var(--danger); box-shadow: none; }
.btn-danger:hover { background: #8a2e33; }
button.busy, button:disabled { opacity: 0.55; pointer-events: none; }

.error {
  background: #f9e9e9;
  border: 1px solid #e7c5c6;
  border-radius: var(--radius-sm);
  color: var(--danger);
  padding: 0.65rem 0.95rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ---------- Landing ---------- */
.landing { text-align: center; padding-top: 4rem; }
.landing .urdu-title {
  font-family: var(--urdu);
  font-size: 3.4rem;
  line-height: 2;
  color: var(--brand-deep);
}
.landing h1 { font-size: 2.5rem; letter-spacing: -0.02em; }
.landing p.intro { max-width: 560px; margin: 1.2rem auto; font-size: 1.08rem; color: var(--muted); }
.landing .actions { display: flex; gap: 0.8rem; justify-content: center; margin-top: 2rem; }
.landing .actions .btn { padding: 0.75rem 1.9rem; font-size: 1rem; }
.hero-rule {
  width: 72px; height: 3px; margin: 3rem auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 2px;
}
header.site .brand .mark svg { width: 22px; height: 22px; }
.onboarding-mark svg { width: 34px; height: 34px; }
.hero-mark {
  width: 76px; height: 76px; margin: 0 auto 1.4rem;
  border-radius: 22px;
  background: linear-gradient(140deg, var(--brand), #2c6b57);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 34px rgba(29, 77, 64, 0.35);
}
.hero-mark svg { width: 52px; height: 52px; }

.preview-wrap {
  max-width: 620px;
  margin: 3.2rem auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-2);
  padding: 1.4rem 1.2rem 0.9rem;
  background-image: radial-gradient(circle, #e6e0cd 1px, transparent 1px);
  background-size: 22px 22px;
}
.preview { width: 100%; height: auto; display: block; }
.pv-card { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; filter: drop-shadow(0 2px 5px rgba(35, 38, 31, 0.1)); }
.pv-line { stroke: #c9c3ae; stroke-width: 1.6; }
.pv-marriage { stroke: var(--gold); stroke-width: 1.4; stroke-dasharray: 1 5; stroke-linecap: round; }
.pv-year { fill: var(--gold); font-family: var(--sans); font-size: 10.5px; font-weight: 700; }
.pv-av { stroke: rgba(35, 38, 31, 0.1); stroke-width: 1; }
.pv-m { fill: #e2eaf2; }
.pv-f { fill: #f4e6ea; }
.pv-init { fill: var(--brand-deep); font-family: var(--display); font-weight: 600; font-size: 13px; }
.pv-name { fill: var(--ink); font-family: var(--sans); font-weight: 700; font-size: 12.5px; }
.pv-urdu { fill: var(--brand); font-family: var(--urdu); font-size: 11px; }
.pv-dates { fill: var(--muted); font-family: var(--sans); font-size: 10.5px; }

.how-title { text-align: center; margin-top: 3.4rem; font-size: 1.4rem; }
.steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; max-width: 860px; margin: 1.4rem auto 0; text-align: start;
}
.step {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem 1.5rem; box-shadow: var(--shadow-1);
}
.step-num {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold-soft); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 600; font-size: 1rem;
  margin-bottom: 0.8rem;
}
.step h3 { font-family: var(--display); font-size: 1.02rem; margin-bottom: 0.3rem; }
.step p { color: var(--muted); font-size: 0.88rem; }

.life-story { line-height: 1.75; max-width: 640px; }
.person-bio { margin-top: 1rem; max-width: 640px; }
.profile-main { flex: 1; min-width: 260px; }
.profile-edit-cta { margin-top: 0.8rem; }
.role-form { display: flex; gap: 0.4rem; }
.feature-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; max-width: 860px; margin: 3.5rem auto 0; text-align: start;
}
.feature {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem 1.5rem; box-shadow: var(--shadow-1);
}
.feature .glyph {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-bottom: 0.8rem;
}
.feature h3 { font-family: var(--display); font-size: 1.02rem; margin-bottom: 0.3rem; }
.feature p { color: var(--muted); font-size: 0.88rem; }
[dir='rtl'] .feature-row { text-align: start; }

/* ---------- Tables ---------- */
table.plain { border-collapse: collapse; width: 100%; margin-top: 0.8rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-1); }
table.plain th, table.plain td { text-align: start; padding: 0.65rem 0.95rem; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
table.plain th { color: var(--muted); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-2); }
[dir='rtl'] table.plain th { text-transform: none; letter-spacing: 0; font-size: 0.85rem; }
table.plain tr:last-child td { border-bottom: none; }

/* ---------- Pills & profile ---------- */
.pill {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand-deep);
  border-radius: 999px;
  padding: 0.18rem 0.75rem;
  font-size: 0.83rem;
  font-weight: 600;
  margin: 0.1rem;
}
a.pill:hover { background: #d2e2d9; }
.pill-managed { display: inline-flex; align-items: center; gap: 0.35rem; padding-inline-end: 0.25rem; }
.pill-x {
  background: rgba(166, 58, 63, 0.12); color: var(--danger); box-shadow: none;
  border-radius: 50%; width: 18px; height: 18px; padding: 0; font-size: 0.8rem;
  line-height: 1; font-weight: 700;
}
.pill-x:hover { background: var(--danger); color: #fff; transform: none; }

.profile-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 1.7rem 1.9rem;
  margin-top: 1.4rem;
  background-image: radial-gradient(circle at 100% 0%, rgba(185, 143, 62, 0.06), transparent 55%);
}
.profile-urdu { font-size: 1.45rem; color: var(--brand); line-height: 2; }
.profile-span { font-size: 0.98rem; }
.deceased-mark { color: var(--gold); font-weight: 700; font-size: 0.88rem; }
.profile-head { display: flex; gap: 1.6rem; align-items: flex-start; flex-wrap: wrap; }
.profile-photo {
  width: 132px; height: 132px; object-fit: cover; border-radius: 50%;
  border: 3px solid var(--surface); box-shadow: var(--shadow-2); background: var(--brand-soft);
}
.profile-photo.placeholder { display: flex; align-items: center; justify-content: center; font-size: 2.4rem; color: var(--gold); }
.relative-links { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; align-items: baseline; }

.rel-groups { display: flex; flex-direction: column; gap: 0.55rem; }
.rel-group { display: flex; gap: 0.8rem; align-items: baseline; flex-wrap: wrap; }
.rel-group-label {
  font-size: 0.7rem; font-weight: 800; color: var(--gold);
  text-transform: uppercase; letter-spacing: 0.09em;
  min-width: 5.2rem;
}
[dir='rtl'] .rel-group-label { text-transform: none; letter-spacing: 0; font-size: 0.85rem; }

.quick-add-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.6rem 1rem;
  align-items: start;
}
.quick-add-row details.quick-add { margin-top: 0; }

.back-link { font-weight: 700; font-size: 0.92rem; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 1.4rem 1.6rem;
  max-width: 640px;
}
form.stack.form-card { max-width: 640px; }

.page-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 1.2rem;
}
.page-empty .empty-glyph { font-size: 2rem; color: var(--gold); margin-bottom: 0.4rem; }
.page-empty p { color: var(--muted); max-width: 440px; margin: 0 auto; font-size: 0.95rem; }

.story-date { color: var(--gold); font-weight: 700; font-size: 0.92rem; margin-top: 0.2rem; }

.invite-card { margin: 0.8rem 0; }
.invite-card:hover { transform: none; box-shadow: var(--shadow-1); }
.invite-link {
  display: block; word-break: break-all;
  font-size: 0.84rem; color: var(--brand-deep);
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem; margin-bottom: 0.6rem;
}
.invite-actions { display: flex; gap: 0.5rem; margin-top: 0.7rem; align-items: center; }
.invite-new { display: flex; gap: 0.6rem; margin-top: 1rem; max-width: 430px; }
.invite-new select { flex: 1; width: auto; }
.invite-new button { flex: none; }

details.quick-add { margin-top: 0.6rem; }
details.quick-add summary { cursor: pointer; color: var(--brand-deep); font-size: 0.9rem; font-weight: 700; list-style: none; }
details.quick-add summary::before { content: '+ '; }
details.quick-add[open] { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.95rem 1.15rem; box-shadow: var(--shadow-1); }
details.quick-add form { margin-top: 0.6rem; }

.danger-zone { margin-top: 1.8rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.btn-text-danger { color: var(--danger); border-color: #e7c5c6; }
.btn-text-danger:hover { background: #f9e9e9; color: var(--danger); }
.confirm-text { font-size: 0.88rem; color: var(--muted); margin-bottom: 0.6rem; }

/* ---------- Stories ---------- */
.story h1 { font-size: 1.6rem; }
.story .body { font-size: 1.02rem; line-height: 1.75; margin-top: 1.2rem; max-width: 680px; }
.story .relative-links { margin-top: 0.5rem; }
.story .body p { margin-bottom: 0.9rem; max-width: 64ch; }
.story-images { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 0.9rem; }
.story-images img { max-width: 220px; border-radius: var(--radius-sm); box-shadow: var(--shadow-1); }
.story-list { list-style: none; margin-top: 1rem; display: flex; flex-direction: column; gap: 0.7rem; }
.story-item {
  display: flex; gap: 1rem; align-items: baseline;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.95rem 1.2rem; box-shadow: var(--shadow-1);
  transition: box-shadow 0.2s, transform 0.2s;
}
.story-item:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.story-item .year {
  font-family: var(--display); font-weight: 600; color: var(--gold);
  min-width: 3.2rem; font-size: 0.95rem;
}
.story-item a { font-family: var(--display); font-size: 1.05rem; color: var(--ink); }
.story-item a:hover { color: var(--brand-deep); }

footer.site {
  text-align: center; color: var(--muted); font-size: 0.82rem;
  padding: 2rem 1.4rem 1.8rem;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0.15rem; align-items: center;
}
footer.site .footer-star { color: var(--gold); font-size: 0.9rem; }
footer.site .footer-name { font-family: var(--display); color: var(--ink); font-size: 0.85rem; opacity: 0.75; }
footer.site .footer-name .urdu { color: var(--gold); }

.problem-page { display: flex; justify-content: center; padding-top: 3.5rem; }
.problem-page .error { margin-top: 0.4rem; }
.problem-actions { display: flex; justify-content: center; gap: 0.8rem; margin-top: 1.4rem; }

.invite-urdu-name { font-size: 1.4rem; color: var(--brand); line-height: 2; }
.invite-cta { display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.4rem; flex-wrap: wrap; }
.onboarding-card .error { text-align: start; }

/* ---------- Family masthead ---------- */
.family-nav {
  display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap;
  padding: 0.6rem 1.4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.family-nav strong {
  font-family: var(--display); font-weight: 600; font-size: 1rem; margin-inline-end: 0.7rem;
  max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.family-nav a {
  color: var(--muted); font-size: 0.86rem; font-weight: 600;
  padding: 0.3rem 0.75rem; border-radius: 999px;
}
.family-nav a:hover { background: var(--surface-2); color: var(--ink); }
.family-nav a.active { background: var(--brand-soft); color: var(--brand-deep); }
.chronicle {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chronicle .sep { color: var(--gold); margin: 0 0.35rem; }

/* ---------- Tree ---------- */
.tree-shell { position: relative; height: calc(100vh - 110px); overflow: hidden; background: var(--bg); }
.tree-canvas {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, #ddd7c4 1px, transparent 1px);
  background-size: 26px 26px;
  cursor: grab;
  touch-action: none;
}
.tree-canvas.dragging { cursor: grabbing; }
.tree-canvas svg { width: 100%; height: 100%; display: block; direction: ltr; }

#tree-pan { transition: none; }
.node-g { cursor: pointer; }
.node-card {
  fill: var(--surface);
  stroke: var(--line);
  stroke-width: 1.2;
  filter: drop-shadow(0 3px 8px rgba(35, 38, 31, 0.1));
  transition: stroke 0.15s;
}
.node-g:hover .node-card { stroke: #c8c2ac; }
.node-g.selected .node-card { stroke: var(--brand); stroke-width: 2.2; filter: drop-shadow(0 6px 16px rgba(29, 77, 64, 0.26)); }
.node-g.deceased .node-card { fill: #fbf7ec; stroke: #e0d5b8; }
.node-avatar-ring { fill: var(--bg); }
.node-g.selected .node-avatar-ring { fill: var(--brand-soft); }
.node-g.deceased .node-avatar-ring { fill: var(--gold-soft); }
.node-avatar-bg { fill: var(--brand-soft); }
.node-g.male .node-avatar-bg { fill: #e2eaf2; }
.node-g.female .node-avatar-bg { fill: #f4e6ea; }
.node-initial { fill: var(--brand-deep); font-family: var(--display); font-weight: 600; font-size: 19px; }
.node-g.male .node-initial { fill: #2f5878; }
.node-g.female .node-initial { fill: #8c4560; }
.node-name { fill: var(--ink); font-family: var(--sans); font-weight: 700; font-size: 13.5px; }
.node-urdu { fill: var(--brand); font-family: var(--urdu); font-size: 12px; }
.node-dates { fill: var(--muted); font-family: var(--sans); font-size: 11px; }
.node-star { fill: var(--gold); font-size: 11px; }

.node-toggle { cursor: pointer; }
.node-toggle rect {
  fill: var(--surface);
  stroke: var(--line);
  stroke-width: 1.2;
  transition: stroke 0.15s, fill 0.15s;
}
.node-toggle:hover rect { stroke: var(--brand); }
.node-toggle.closed rect { fill: var(--brand-soft); stroke: var(--brand); }
.node-toggle text { fill: var(--muted); font-family: var(--sans); font-size: 11px; font-weight: 700; pointer-events: none; }
.node-toggle.closed text { fill: var(--brand-deep); }
.node-toggle .chev { font-size: 10px; }

.edge { stroke: #c9c3ae; stroke-width: 1.6; fill: none; }
.edge.spouse { stroke: var(--gold); stroke-width: 1.4; stroke-dasharray: 1 5; stroke-linecap: round; }
.edge.spouse.divorced { stroke: #ada896; stroke-dasharray: 5 4; }
.edge.sibling { stroke: #c2bda9; stroke-width: 1.4; stroke-dasharray: 3 3; }
.edge-label { fill: var(--gold); font-family: var(--sans); font-size: 10.5px; font-weight: 700; }
.edge-label.divorced { fill: #96917f; }

.node-actions { pointer-events: none; }
.node-action { pointer-events: auto; cursor: pointer; }
.node-action circle { fill: var(--brand); transition: fill 0.15s; filter: drop-shadow(0 2px 6px rgba(29, 77, 64, 0.4)); }
.node-action:hover circle { fill: var(--brand-deep); }
.node-action text { fill: #fdfbf5; font-size: 15px; font-weight: 700; font-family: var(--sans); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node-action.info circle { fill: var(--surface); stroke: var(--line); filter: drop-shadow(0 2px 5px rgba(35, 38, 31, 0.18)); }
.node-action.info text { fill: var(--ink); }

.tree-toolbar {
  position: absolute; top: 14px; inset-inline-start: 16px; z-index: 10;
  display: flex; gap: 0.55rem; align-items: center;
}
.jump-box { position: relative; }
.jump-box input {
  width: 250px;
  padding: 0.55rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: 0.88rem;
}
.jump-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  width: 290px;
  max-height: 320px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  z-index: 30;
}
.jump-results.open { display: block; }
.jump-results button {
  display: flex; width: 100%; text-align: start;
  background: transparent; color: var(--ink);
  border: none; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none;
  padding: 0.6rem 0.95rem;
  font-weight: 600; font-size: 0.9rem;
  gap: 0.5rem; align-items: baseline;
}
.jump-results button:last-child { border-bottom: none; }
.jump-results button:hover { background: var(--brand-soft); transform: none; }
.jump-results .sub { color: var(--muted); font-weight: 400; font-size: 0.8rem; }

.tree-zoom {
  position: absolute; bottom: 18px; inset-inline-end: 16px; z-index: 10;
  display: flex; flex-direction: column; gap: 6px;
}
.tree-zoom button {
  width: 38px; height: 38px; padding: 0; border-radius: 12px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  font-size: 1.05rem; box-shadow: var(--shadow-1);
}
.tree-zoom button:hover { background: var(--surface-2); transform: none; }

.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.6rem; text-align: center; padding: 2rem;
}
.empty-state .empty-glyph { font-size: 2.6rem; color: var(--gold); }
.empty-state h2 { font-family: var(--display); font-size: 1.4rem; margin: 0; }
.empty-state p { color: var(--muted); max-width: 430px; font-size: 0.96rem; }
.empty-state .big-add { font-size: 1rem; padding: 0.8rem 1.9rem; margin-top: 0.8rem; }

.tree-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 5;
  transition: opacity 0.25s;
}
.tree-loading.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(35, 38, 31, 0.4);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.18s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-2);
  width: min(460px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem); overflow: auto;
  padding: 1.5rem 1.6rem;
  transform: translateY(10px) scale(0.98); transition: transform 0.18s;
}
.modal-backdrop.open .modal { transform: none; }
.modal h3 { font-family: var(--display); font-size: 1.2rem; margin-bottom: 1rem; }
.modal .row { display: flex; gap: 0.7rem; }
.modal .row > div { flex: 1; }
.modal .row-spaced { margin-top: 0.7rem; }
.modal #link-search { margin-bottom: 0.7rem; }
.modal #link-marriage { margin-bottom: 0.7rem; }
.modal form { display: flex; flex-direction: column; gap: 0.85rem; }
.modal .modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 0.4rem; }

.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 1rem; }
.seg button {
  flex: 1; background: transparent; color: var(--muted); box-shadow: none;
  padding: 0.42rem 0.6rem; font-size: 0.85rem; border-radius: 999px;
}
.seg button:hover { transform: none; background: transparent; color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.link-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.link-list button {
  display: flex; width: 100%; text-align: start; background: transparent; color: var(--ink);
  border: none; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none;
  padding: 0.6rem 0.85rem; font-weight: 600; font-size: 0.9rem; gap: 0.5rem; align-items: baseline;
}
.link-list button:last-child { border-bottom: none; }
.link-list button:hover { background: var(--brand-soft); transform: none; }
.link-list .sub { color: var(--muted); font-weight: 400; font-size: 0.8rem; }

.more-details summary {
  cursor: pointer; color: var(--brand-deep); font-size: 0.85rem; font-weight: 700;
  list-style: none; user-select: none;
}
.more-details summary::before { content: '+ '; }
.more-details[open] summary::before { content: '− '; }

/* ---------- Drawer ---------- */
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; z-index: 80;
  width: min(410px, 92vw);
  background: var(--surface);
  box-shadow: -10px 0 44px rgba(35, 38, 31, 0.16);
  transform: translateX(105%);
  transition: transform 0.24s cubic-bezier(0.2, 0.7, 0.3, 1);
  display: flex; flex-direction: column;
}
[dir='rtl'] .drawer { transform: translateX(-105%); }
.drawer.open { transform: none; }
.drawer-head {
  padding: 1.2rem 1.4rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  display: flex; gap: 0.9rem; align-items: center;
}
.drawer-head .avatar {
  width: 58px; height: 58px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand-deep);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 600; font-size: 1.4rem;
  object-fit: cover; overflow: hidden;
  border: 2.5px solid var(--surface);
  box-shadow: var(--shadow-1);
}
.drawer-head img.avatar { display: block; }
.drawer-head-main { display: flex; gap: 0.9rem; align-items: center; flex: 1; min-width: 0; }
.drawer-head h3 { font-family: var(--display); font-weight: 600; font-size: 1.18rem; line-height: 1.3; }
.drawer-head .urdu-name { font-family: var(--urdu); color: var(--brand-deep); font-size: 1.05rem; }
.drawer-head .close {
  margin-inline-start: auto; background: transparent; color: var(--muted);
  box-shadow: none; padding: 0.3rem 0.55rem; font-size: 1.2rem; border-radius: 8px;
}
.drawer-head .close:hover { background: var(--surface-2); color: var(--ink); transform: none; }
.drawer-body { padding: 1.1rem 1.4rem 2rem; overflow: auto; flex: 1; }
.drawer-body .meta-row { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.35rem; }
.drawer-body .meta-row .star { color: var(--gold); }
.drawer-body h4 {
  font-family: var(--sans); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--gold); margin: 1.3rem 0 0.5rem;
  font-weight: 800;
}
[dir='rtl'] .drawer-body h4 { text-transform: none; letter-spacing: 0; font-size: 0.85rem; }
.drawer-body .bio { font-size: 0.94rem; white-space: pre-wrap; line-height: 1.7; }
.drawer-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1.2rem; }
.drawer form.stack { max-width: none; }

.spouse-row { margin-bottom: 0.5rem; }
.spouse-row-top { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.marriage-info { color: var(--muted); font-size: 0.82rem; }
.marriage-form { display: flex; gap: 0.45rem; margin-top: 0.5rem; align-items: center; }
.marriage-form input { flex: 1; min-width: 0; padding: 0.4rem 0.6rem; font-size: 0.85rem; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(90px);
  background: var(--brand-deep); color: #fdfbf5; padding: 0.65rem 1.3rem; border-radius: 999px;
  font-size: 0.88rem; font-weight: 600; z-index: 100;
  box-shadow: var(--shadow-2);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Auth & onboarding ---------- */
.auth { display: flex; justify-content: center; padding-top: 3.5rem; }

.auth-split {
  display: grid;
  grid-template-columns: minmax(340px, 460px) 1fr;
  min-height: calc(100vh - 60px);
}
.auth-side {
  background:
    radial-gradient(circle at 20% 15%, rgba(211, 171, 95, 0.14), transparent 45%),
    linear-gradient(155deg, var(--brand-deep), var(--brand) 55%, #256353);
  color: #f2ecd9;
  display: flex;
  align-items: center;
  padding: 3rem 2.6rem;
  position: relative;
  overflow: hidden;
}
.auth-side::after {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(242, 236, 217, 0.09) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}
.auth-side-inner { position: relative; z-index: 1; max-width: 320px; margin: 0 auto; }
.auth-side-mark {
  width: 64px; height: 64px; border-radius: 18px;
  background: rgba(242, 236, 217, 0.1);
  border: 1px solid rgba(211, 171, 95, 0.4);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1.4rem;
}
.auth-side-mark svg { width: 44px; height: 44px; }
.auth-wordmark { font-size: 2.1rem; line-height: 2; color: #e8c87d; }
.auth-hero { font-family: var(--display); font-size: 1.35rem; line-height: 1.4; margin-top: 0.4rem; }
[dir='rtl'] .auth-hero { line-height: 2; }
.auth-points { list-style: none; margin-top: 1.8rem; display: flex; flex-direction: column; gap: 0.55rem; }
.auth-points li { font-size: 0.92rem; color: rgba(242, 236, 217, 0.85); }
.auth-points li::before { content: '✦  '; color: #d3ab5f; }

.auth-form-col { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.4rem; }
.auth-split .auth-card { text-align: start; box-shadow: var(--shadow-1); animation: none; }
.auth-split .auth-card h1 { font-size: 1.5rem; }
.auth-sub { color: var(--muted); font-size: 0.92rem; margin-top: 0.15rem; }
.auth-switch { margin-top: 1.2rem; font-size: 0.9rem; color: var(--muted); }
.auth-switch a { font-weight: 700; }

.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 2.6rem; }
.pw-toggle {
  position: absolute; top: 50%; transform: translateY(-50%);
  inset-inline-end: 0.45rem;
  background: transparent; color: var(--muted); box-shadow: none;
  padding: 0.25rem 0.45rem; font-size: 0.95rem; border-radius: 8px;
}
.pw-toggle:hover { background: var(--surface-2); color: var(--ink); transform: translateY(-50%); }
.pw-toggle.on { color: var(--brand-deep); }

@media (max-width: 860px) {
  .auth-split { grid-template-columns: 1fr; min-height: 0; }
  .auth-side { padding: 1.6rem 1.4rem; }
  .auth-side-inner { max-width: none; display: flex; align-items: center; gap: 1rem; }
  .auth-side-mark { width: 46px; height: 46px; margin-bottom: 0; flex: none; border-radius: 13px; }
  .auth-side-mark svg { width: 32px; height: 32px; }
  .auth-wordmark { display: none; }
  .auth-hero { font-size: 1.05rem; margin-top: 0; }
  .auth-points { display: none; }
  .auth-form-col { padding: 1.8rem 1rem 2.6rem; }
}
.auth-card, .onboarding-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-2);
  padding: 2.3rem 2.5rem;
  width: min(432px, 100%);
  text-align: center;
}
.auth-card h1, .onboarding-card h1 { font-size: 1.5rem; margin-bottom: 0.3rem; }
.auth-card form.stack, .onboarding-card form.stack { text-align: start; max-width: none; margin-top: 1.2rem; }
.onboarding { display: flex; justify-content: center; padding-top: 3rem; }
.onboarding-card { width: min(480px, 100%); }
.onboarding-card .intro { color: var(--muted); font-size: 0.95rem; }
.onboarding-mark {
  width: 54px; height: 54px; margin: 0 auto 1rem;
  border-radius: 16px;
  background: linear-gradient(140deg, var(--brand), #2c6b57);
  color: var(--gold-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.65rem;
  box-shadow: 0 8px 22px rgba(29, 77, 64, 0.35);
}

/* ---------- Motion ---------- */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
a, button, .btn, input, select, textarea { transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.12s; }

@media (prefers-reduced-motion: no-preference) {
  main { animation: page-in 0.35s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
  main.wide { animation: none; }
  .auth-card, .onboarding-card { animation: card-pop 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
  .tree-anim .node-g { animation: node-in 0.35s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
  .tree-anim .edge, .tree-anim .edge-label { animation: fade-in 0.5s ease 0.15s both; }
  .landing .urdu-title { animation: fade-in 0.7s ease both; }
  .landing h1 { animation: page-in 0.55s ease 0.1s both; }
  .landing .intro, .landing .actions, .landing .hero-rule { animation: page-in 0.55s ease 0.22s both; }
  .feature-row .feature { animation: page-in 0.5s ease both; }
  .feature-row .feature:nth-child(2) { animation-delay: 0.08s; }
  .feature-row .feature:nth-child(3) { animation-delay: 0.16s; }
}
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes card-pop { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes node-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 640px) {
  header.site { padding: 0.7rem 1rem; }
  main { padding: 1.3rem 1rem 3rem; }
  .landing { padding-top: 2.2rem; }
  .landing h1 { font-size: 1.9rem; }
  .landing .urdu-title { font-size: 2.4rem; }
  .tree-shell { height: calc(100vh - 130px); }
  .jump-box input { width: 170px; }
  .chronicle { display: none; }
}
