:root {
  --ink: #14241c;
  --moss: #1a3329;
  --leaf: #2f6b4f;
  --leaf-bright: #3d8a64;
  --mist: #e8f0ea;
  --fog: #d3e2d8;
  --paper: #f4faf6;
  --gold: #c4a35a;
  --gold-soft: #e8d9a8;
  --rose: #8b4d57;
  --shadow: 0 18px 50px rgba(20, 36, 28, 0.18);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Outfit", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 138, 100, 0.22), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(196, 163, 90, 0.18), transparent 55%),
    linear-gradient(165deg, #f7fcf8 0%, #e7f1ea 45%, #dceae1 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(47, 107, 79, 0.06) 0 1px, transparent 1.5px),
    radial-gradient(circle at 80% 70%, rgba(47, 107, 79, 0.05) 0 1px, transparent 1.5px);
  background-size: 28px 28px;
  z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100vh; max-width: 100%; overflow-x: hidden; }

body.modal-open {
  overflow: hidden;
  touch-action: none;
}

.auth-page {
  position: relative;
  color: #f3f7f4;
  background:
    radial-gradient(1000px 560px at 50% -10%, rgba(196, 163, 90, 0.2), transparent 55%),
    radial-gradient(800px 480px at 100% 40%, rgba(61, 138, 100, 0.22), transparent 50%),
    linear-gradient(180deg, #0c1a14 0%, #142820 38%, #1a3329 72%, #10241c 100%);
  overflow-x: hidden;
}

body.is-auth {
  background: #0c1a14;
}

body.is-auth::before {
  opacity: 0.18;
}

.auth-landing {
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  display: grid;
  align-items: center;
  gap: clamp(24px, 4vw, 40px);
  padding: clamp(28px, 6vw, 56px) 20px 36px;
  position: relative;
}

.auth-landing::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(232, 217, 168, 0.16) 0 1px, transparent 1.6px),
    radial-gradient(circle at 82% 68%, rgba(232, 217, 168, 0.1) 0 1px, transparent 1.6px);
  background-size: 26px 26px;
}

.auth-glow {
  position: absolute;
  width: min(520px, 90vw);
  height: min(520px, 90vw);
  left: 50%;
  top: 6%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(196, 163, 90, 0.22), transparent 68%);
  pointer-events: none;
  animation: authPulse 7s ease-in-out infinite;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(2px);
  opacity: 0.45;
}

.auth-orb-a {
  width: 180px;
  height: 180px;
  right: 8%;
  top: 18%;
  background: radial-gradient(circle, rgba(61, 138, 100, 0.45), transparent 70%);
  animation: authFloat 9s ease-in-out infinite;
}

.auth-orb-b {
  width: 140px;
  height: 140px;
  left: 6%;
  bottom: 22%;
  background: radial-gradient(circle, rgba(196, 163, 90, 0.28), transparent 70%);
  animation: authFloat 11s ease-in-out infinite reverse;
}

@keyframes authPulse {
  0%, 100% { opacity: 0.55; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.9; transform: translateX(-50%) scale(1.06); }
}

@keyframes authFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@keyframes markIn {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: none; }
}

.auth-hero {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 36rem;
  margin: 0 auto;
  animation: rise 0.7s ease both;
}

.auth-mark {
  width: clamp(120px, 30vw, 176px);
  height: auto;
  border-radius: 28%;
  display: block;
  margin: 0 auto 8px;
  position: relative;
  z-index: 2;
  box-shadow:
    0 0 0 1px rgba(232, 217, 168, 0.2),
    0 24px 56px rgba(0, 0, 0, 0.4);
  animation: markIn 0.85s ease both;
}

.auth-tree-art {
  width: min(100%, 420px);
  height: auto;
  display: block;
  margin: 0 auto;
}

.auth-brand {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 12vw, 4.8rem);
  line-height: 0.92;
  margin: 18px 0 14px;
  letter-spacing: -0.03em;
  color: #f7f3e7;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.25);
}

.auth-tagline {
  margin: 0 0 12px;
  font-size: clamp(1.05rem, 3.4vw, 1.3rem);
  font-weight: 500;
  color: var(--gold-soft);
  line-height: 1.35;
}

.auth-pitch {
  margin: 0;
  color: rgba(232, 240, 234, 0.78);
  line-height: 1.55;
  font-size: 0.98rem;
}

.auth-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  margin: 0 auto;
  padding: 22px 20px 20px;
  border-radius: 22px;
  background: rgba(244, 250, 246, 0.96);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  animation: rise 0.75s ease 0.12s both;
}

.auth-panel .tabs {
  background: rgba(211, 226, 216, 0.9);
}

.auth-stats {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 12px;
  animation: rise 0.8s ease 0.15s both;
}

.auth-stats-head {
  text-align: center;
  margin-bottom: 22px;
}

.auth-stats-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  margin: 0 0 8px;
  color: #f7f3e7;
}

.auth-stats-head p {
  margin: 0;
  color: rgba(232, 240, 234, 0.7);
  font-size: 0.95rem;
}

.auth-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (min-width: 720px) {
  .auth-stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.auth-stat {
  text-align: center;
  padding: 18px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(232, 217, 168, 0.16);
}

.auth-stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  color: var(--gold-soft);
  line-height: 1;
  margin-bottom: 8px;
}

.auth-stat-label {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(232, 240, 234, 0.7);
  font-weight: 600;
}

.auth-chart {
  margin-top: 18px;
  padding: 14px 16px 16px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(232, 217, 168, 0.12);
}

.auth-chart-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: rgba(232, 240, 234, 0.75);
  margin-bottom: 10px;
}

.auth-chart-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.auth-chart-male {
  background: linear-gradient(90deg, #5b8fbf, #3d6f9a);
}

.auth-chart-female {
  background: linear-gradient(90deg, #c17a86, #8b4d57);
}

.auth-chart-empty {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: rgba(232, 240, 234, 0.5);
  text-align: center;
}

.auth-showcase {
  max-width: 1040px;
  margin: 28px auto 8px;
  padding: 12px 20px 28px;
  display: grid;
  gap: 24px;
  align-items: center;
  animation: rise 0.85s ease 0.2s both;
}

.auth-showcase-copy h2 {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4vw, 2rem);
  margin: 0 0 10px;
  color: #f7f3e7;
}

.auth-showcase-copy p {
  margin: 0;
  color: rgba(232, 240, 234, 0.75);
  line-height: 1.55;
  max-width: 36rem;
}

.auth-mosaic {
  position: relative;
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 12px 0;
}

.auth-mosaic .auth-tree-art {
  width: min(420px, 100%);
  opacity: 0.92;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.28));
}

.auth-features-rich {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 20px 48px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 700px) {
  .auth-features-rich {
    grid-template-columns: 1fr 1fr;
    gap: 18px 24px;
  }
}

.auth-feature {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 18px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(232, 217, 168, 0.14);
}

.auth-feature-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #e8d9a8;
  background: rgba(232, 217, 168, 0.08);
  border: 1px solid rgba(232, 217, 168, 0.2);
  flex-shrink: 0;
}

.auth-feature-icon svg {
  width: 30px;
  height: 30px;
}

.auth-feature-text {
  min-width: 0;
}

.auth-feature-text h3 {
  margin: 2px 0 8px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.25;
  color: #f7f3e7;
}

.auth-feature-text p {
  margin: 0;
  color: rgba(232, 240, 234, 0.75);
  line-height: 1.5;
  font-size: 0.94rem;
}

.auth-foot {
  text-align: center;
  padding: 8px 20px 36px;
  color: rgba(232, 240, 234, 0.45);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

@media (min-width: 900px) {
  .auth-landing {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: center;
    padding-inline: clamp(40px, 8vw, 96px);
    gap: 48px;
  }

  .auth-hero {
    text-align: left;
    margin: 0;
    max-width: 38rem;
  }

  .auth-mark {
    margin-left: 0;
  }

  .auth-panel {
    margin: 0;
    width: min(440px, 100%);
  }

  .auth-glow {
    left: 28%;
    top: 12%;
  }

  .auth-showcase {
    grid-template-columns: 1fr 1.05fr;
    gap: 40px;
    padding-block: 36px;
  }
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.2rem);
  line-height: 0.95;
  margin: 0 0 8px;
  color: var(--moss);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  flex: 0 0 auto;
  box-shadow: 0 8px 20px rgba(26, 51, 41, 0.22);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-sub {
  display: block;
  font-size: 0.34em;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--leaf);
  font-family: var(--font-body);
  font-weight: 600;
}

.brand-mini {
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--moss);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo-sm {
  width: 32px;
  height: 32px;
  border-radius: 28%;
  flex: 0 0 auto;
  object-fit: cover;
}

.tree-toolbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--fog);
  padding: 5px;
  border-radius: 999px;
  margin-bottom: 22px;
}

.tabs button {
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  color: #456353;
  cursor: pointer;
}

.tabs button.active {
  background: white;
  color: var(--moss);
  box-shadow: 0 4px 14px rgba(20, 36, 28, 0.08);
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #456353;
  margin: 0 0 6px;
}

input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(47, 107, 79, 0.2);
  background: white;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  margin-bottom: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(61, 138, 100, 0.35);
  border-color: var(--leaf-bright);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--leaf) 0%, var(--moss) 100%);
  color: white;
  box-shadow: 0 10px 24px rgba(26, 51, 41, 0.25);
}

.btn-primary:hover { box-shadow: 0 14px 28px rgba(26, 51, 41, 0.32); }

.btn-ghost {
  background: rgba(255,255,255,0.7);
  color: var(--moss);
  border: 1px solid rgba(47, 107, 79, 0.18);
}

.btn-danger {
  background: #f8e9eb;
  color: var(--rose);
}

.btn-gold {
  background: linear-gradient(135deg, #d4b56a, #b8943f);
  color: #1c1608;
}

.full { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.err {
  background: #fdecee;
  color: var(--rose);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}
.ok {
  background: #e6f5ec;
  color: var(--leaf);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(244, 250, 246, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(47, 107, 79, 0.12);
  box-shadow: 0 8px 24px rgba(20, 36, 28, 0.08);
}

.topbar-spacer {
  height: 64px;
}

.pull-refresh {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(26, 51, 41, 0.92);
  color: #f3f7f4;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.pull-refresh.ready {
  background: rgba(47, 107, 79, 0.95);
}

.pull-refresh.busy {
  background: rgba(196, 163, 90, 0.95);
  color: #14241c;
}

.brand-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
}

.brand-home:hover .brand-mini,
.brand-home:hover span {
  color: var(--leaf-bright);
}

.topbar .brand-mini {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--moss);
  margin: 0;
  line-height: 1;
}

.topbar-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
}

.topbar .user {
  font-size: 0.8rem;
  color: #456353;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(52vw, 280px);
}

.topbar .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.topbar .actions .btn {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 16px 80px;
}

.hero-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  animation: rise 0.5s ease both;
}

.hero-panel h2 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 5vw, 2.3rem);
  margin: 0;
  color: var(--moss);
}

.hero-panel p {
  margin: 0;
  color: #456353;
  max-width: 42ch;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(47, 107, 79, 0.12);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(20, 36, 28, 0.06);
}

.panel h3 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  color: var(--moss);
  font-size: 1.25rem;
}

.person-list {
  display: grid;
  gap: 6px;
}

.person-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 6px;
  align-items: center;
  padding: 4px 6px 4px 4px;
  border-radius: 12px;
  background: var(--paper);
  border: 1px solid rgba(47, 107, 79, 0.08);
  min-width: 0;
  position: relative;
}

.person-open {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 4px;
  margin: 0;
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
  color: inherit;
  font: inherit;
}

.person-open:hover {
  background: rgba(47, 107, 79, 0.06);
}

.person-open:focus-visible {
  outline: 2px solid rgba(61, 138, 100, 0.45);
  outline-offset: 1px;
}

.person-main {
  min-width: 0;
}

.avatar.xl {
  width: 96px;
  height: 96px;
  font-size: 1.6rem;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
}

.person-view {
  text-align: center;
  padding: 4px 2px 8px;
}

.person-view-name {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin: 0 0 8px;
  color: var(--moss);
}

.person-view .badge-row {
  justify-content: center;
}

.person-view-life {
  margin: 8px 0 14px;
  color: #567463;
  font-size: 0.92rem;
}

.person-view-facts {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(47, 107, 79, 0.05);
  text-align: left;
  display: grid;
  gap: 8px;
}

.person-view-facts > div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.person-view-facts dt {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 650;
  color: #678575;
}

.person-view-facts dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
  min-width: 0;
  word-break: break-word;
}

.person-view-facts dd .meta {
  color: #6a7a70;
  font-size: 0.85em;
}

.person-view-facts .fact-person-link,
.extra-spouse-list .fact-person-link {
  font-weight: 600;
}

.extra-spouse-list .meta .kin-link {
  font-size: inherit;
}

.extra-spouse-box {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(180, 90, 70, 0.12);
  border: 1px solid rgba(180, 90, 70, 0.28);
}

.extra-spouse-box .field-hint {
  margin: 0 0 8px;
}

.extra-spouse-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.extra-spouse-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.extra-spouse-list .meta {
  display: block;
  font-size: 0.75rem;
  color: #7a5a50;
  margin-top: 2px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
  width: auto;
  flex: 0 0 auto;
}

.kin-panel {
  margin: 14px 0 4px;
  padding: 12px 12px 4px;
  border-radius: 12px;
  background: rgba(47, 107, 79, 0.08);
  text-align: left;
  width: 100%;
  max-height: min(42vh, 360px);
  overflow: auto;
  box-sizing: border-box;
}

.kin-panel-empty {
  max-height: none;
}

.kin-panel h5 {
  margin: 0 0 2px;
  font-size: 0.88rem;
  color: #2f6b4f;
  position: sticky;
  top: 0;
  background: rgba(232, 242, 236, 0.96);
  padding: 2px 0 0;
  z-index: 1;
}

.kin-ego-hint {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: #5a7264;
  position: sticky;
  top: 1.4rem;
  background: rgba(232, 242, 236, 0.96);
  padding: 0 0 6px;
  z-index: 1;
}

.kin-list {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
  display: grid;
  gap: 8px;
}

.kin-list li {
  display: grid;
  grid-template-columns: minmax(7.5rem, 34%) minmax(0, 1fr);
  gap: 6px 10px;
  align-items: start;
  font-size: 0.84rem;
  line-height: 1.35;
}

.kin-list strong {
  color: #1a3329;
  font-weight: 650;
}

.kin-names {
  color: #4a6356;
  display: block;
  min-width: 0;
  line-height: 1.45;
  word-break: break-word;
}

.kin-link {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #1f5c40;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.kin-link:hover {
  color: #0f3a28;
}

.kin-link.is-active {
  color: #8a5a12;
  text-decoration: none;
  background: rgba(232, 217, 168, 0.45);
  border-radius: 4px;
  padding: 0 4px;
}

.kin-sep {
  color: #4a6356;
}

.person-view-actions {
  display: grid;
  gap: 8px;
}

.person-item .name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-item .meta {
  margin: 2px 0 0;
  font-size: 0.75rem;
  line-height: 1.25;
  color: #567463;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-badges {
  opacity: 0.85;
}

.avatar.sm {
  width: 40px;
  height: 40px;
  font-size: 0.78rem;
}

.person-tools {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.person-menu-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--moss);
  background: rgba(47, 107, 79, 0.06);
}

.person-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(47, 107, 79, 0.14);
  box-shadow: 0 12px 28px rgba(20, 36, 28, 0.16);
}

.person-menu .btn {
  width: 100%;
  justify-content: center;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.tree-brand-home {
  color: #f7f3e7;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  max-width: min(48vw, 260px);
}

.tree-brand-home span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(145deg, var(--fog), #c9dbd0);
  border: 2px solid white;
  box-shadow: 0 4px 12px rgba(20, 36, 28, 0.12);
}

.avatar.placeholder {
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  letter-spacing: -0.02em;
  line-height: 1;
}

.avatar.placeholder.initials-3 {
  font-size: 0.78rem;
  letter-spacing: -0.04em;
}

.avatar.xl.placeholder.initials-3 {
  font-size: 1.15rem;
}

.avatar.tiny.placeholder.initials-3,
.avatar.sm.placeholder.initials-3 {
  font-size: 0.55rem;
}

.avatar.placeholder.gender-male {
  background: linear-gradient(145deg, #5b9fd4, #2f6fad);
}

.avatar.placeholder.gender-female {
  background: linear-gradient(145deg, #e8a0b5, #c45d7a);
}

.avatar.placeholder.gender-unknown {
  background: linear-gradient(145deg, #9aaf9f, #6f8576);
  color: #f4faf6;
}

.avatar.has-photo {
  border: 2.5px solid #fff;
  box-shadow:
    0 0 0 2px rgba(196, 163, 90, 0.35),
    0 8px 18px rgba(0, 0, 0, 0.2);
}

.list-toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 200px) minmax(140px, 190px);
  gap: 10px;
  margin-bottom: 14px;
}

@media (max-width: 720px) {
  .list-toolbar { grid-template-columns: 1fr 1fr; }
  .list-toolbar input[type="search"] { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .list-toolbar { grid-template-columns: 1fr; }
  .list-toolbar input[type="search"] { grid-column: auto; }
}

.list-toolbar input[type="search"],
.list-toolbar select {
  margin-bottom: 0;
}

.people-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(47, 107, 79, 0.08);
}

.people-tab {
  flex: 1 1 0;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #3a5246;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
}

.people-tab.active {
  background: #fff;
  color: #1a3329;
  box-shadow: 0 2px 8px rgba(20, 40, 28, 0.1);
}

.people-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.45);
}

.avatar.tiny {
  width: 40px;
  height: 40px;
  font-size: 0.85rem;
}

.reminder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .reminder-grid { grid-template-columns: 1fr; }
}

.reminder-card {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(47, 107, 79, 0.12);
  border-radius: 16px;
  padding: 12px;
}

.reminder-card h4 {
  margin: 0 0 10px;
  font-size: 0.92rem;
  color: var(--moss);
}

.reminder-card.birth h4 { color: #2f6fad; }
.reminder-card.death h4 { color: #8b4d57; }

.reminder-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.reminder-card li {
  display: block;
  margin: 0;
  padding: 0;
}

.reminder-person {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.reminder-person:hover,
.reminder-person:focus-visible {
  background: rgba(47, 107, 79, 0.1);
  outline: none;
}

.reminder-card.death .reminder-person:hover,
.reminder-card.death .reminder-person:focus-visible {
  background: rgba(139, 77, 87, 0.1);
}

.reminder-card li strong {
  display: block;
  font-size: 0.92rem;
}

.reminder-card li span {
  display: block;
  font-size: 0.78rem;
  color: #567463;
}

.tree-select-label {
  display: block;
  max-width: 320px;
  margin: 4px 0 8px;
}

.tree-switch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  margin: 4px 0 10px;
}

.tree-switch-row .tree-select-label {
  margin: 0;
  flex: 1 1 200px;
}

.tree-switch-row #btn-my-tree {
  flex: 0 0 auto;
}

.share-list-title {
  margin: 18px 0 8px;
  color: var(--moss);
  font-family: var(--font-display);
}

.settings-block {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(26, 51, 41, 0.12);
}

.settings-block:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-block h4 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--moss);
  font-family: var(--font-display);
}

.settings-check {
  margin-top: 12px;
  align-items: flex-start;
}

.person-picker {
  position: relative;
  margin-bottom: 4px;
}

.person-picker-face {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
}

.person-picker-input {
  width: 100%;
  margin: 0;
}

.person-picker-clear {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(26, 51, 41, 0.08);
  color: #3a5246;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.person-picker-clear.hidden {
  visibility: hidden;
  pointer-events: none;
}

.person-picker-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 12px;
  background: #f7fbf8;
  border: 1px solid rgba(47, 107, 79, 0.22);
  box-shadow: 0 12px 28px rgba(20, 40, 28, 0.18);
}

.person-picker-list.hidden {
  display: none;
}

.person-picker-list li[data-id] {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.person-picker-list li[data-id]:hover {
  background: rgba(47, 107, 79, 0.12);
}

.person-picker-list li strong {
  font-size: 0.92rem;
  color: #1a3329;
}

.person-picker-list li span {
  font-size: 0.75rem;
  color: #5a7264;
}

.person-picker-empty {
  padding: 10px;
  color: #678575;
  font-size: 0.85rem;
  cursor: default;
}

.person-rel-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #2f6b4f;
  letter-spacing: 0.02em;
}

.person-rel {
  color: #2f6b4f;
  font-weight: 650;
}

.hint-banner {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(196, 163, 90, 0.18);
  color: #1a3329;
  font-size: 0.9rem;
}

.hint-banner .linkish {
  border: 0;
  background: none;
  padding: 0;
  color: #2f6b4f;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.share-list {
  display: grid;
  gap: 8px;
}

.share-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: white;
  border: 1px solid rgba(47, 107, 79, 0.12);
}

.share-row .meta {
  display: block;
  font-size: 0.8rem;
}

.check-row {
  display: flex !important;
  align-items: center;
  margin-bottom: 14px;
  font-weight: 600;
  color: #456353;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 6px;
}

.rel-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(47, 107, 79, 0.12);
  color: var(--leaf);
}

.rel-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

@media (min-width: 520px) {
  .rel-chip-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.rel-chip {
  border: 1px solid rgba(47, 107, 79, 0.2);
  background: white;
  border-radius: 14px;
  padding: 10px 8px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: #3f5a4a;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rel-chip.active {
  background: var(--moss);
  border-color: var(--moss);
  color: white;
  box-shadow: 0 8px 18px rgba(26, 51, 41, 0.2);
}

.role-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
  background: rgba(232, 217, 168, 0.22);
  color: var(--gold-soft);
  border: 1px solid rgba(232, 217, 168, 0.35);
  max-width: 130px;
  line-height: 1.25;
  white-space: normal;
}

.step-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 12px;
}

.step-row .tree-node .card {
  border-style: dashed;
  opacity: 0.92;
}

.device-sync {
  margin: 8px 0 16px;
  padding-top: 4px;
}

.device-sync .field-hint {
  margin: 0 0 10px;
}

.device-sync-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.device-sync-actions .btn {
  width: 100%;
}

.hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100vw;
  background: rgba(15, 28, 22, 0.48);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fade 0.2s ease both;
}

@media (min-width: 720px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: min(560px, 100%);
  max-height: min(92dvh, 92vh, 900px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  padding: 18px 14px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow);
  animation: slideUp 0.28s ease both;
  box-sizing: border-box;
}

@media (min-width: 720px) {
  .modal {
    border-radius: 24px;
    max-width: min(560px, calc(100vw - 32px));
    padding: 22px 20px 28px;
  }
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  min-width: 0;
}

.modal header h3 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--moss);
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}

.modal form,
.modal .grid-2,
.modal .rel-chip-grid,
.modal .segment {
  min-width: 0;
  max-width: 100%;
}

.icon-btn {
  border: 0;
  background: var(--fog);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--moss);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
  min-width: 0;
}

.grid-2 > * {
  min-width: 0;
}

@media (max-width: 520px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.field-hint {
  font-size: 0.78rem;
  color: #678575;
  margin: -8px 0 12px;
}

.smart-hint {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(61, 138, 100, 0.1);
  color: #2f5f48;
  line-height: 1.35;
}

/* TREE VIEW */
.tree-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(800px 400px at 50% 0%, rgba(61, 138, 100, 0.18), transparent 60%),
    linear-gradient(180deg, #10241c 0%, #1a3329 40%, #243f33 100%);
  color: white;
  display: flex;
  flex-direction: column;
}

.tree-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(8, 20, 15, 0.45);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
}

.tree-toolbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tree-toolbar .tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.tree-depth-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(232, 217, 168, 0.22);
  color: #e8d9a8;
  font-size: 0.78rem;
  font-weight: 600;
}

.tree-depth-label select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: rgba(8, 20, 15, 0.55);
  color: #f5ecd0;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 0.8rem;
  max-width: 9.5rem;
  cursor: pointer;
}

.tree-filter-label select {
  max-width: 11.5rem;
}

.tree-toolbar .btn {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.tree-toolbar .btn.active {
  background: rgba(232, 217, 168, 0.28);
  border-color: rgba(196, 163, 90, 0.55);
  color: #f5ecd0;
}

.tree-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  touch-action: none;
  cursor: grab;
}

.tree-viewport.dragging { cursor: grabbing; }

.tree-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  padding: 40px 60px 80px;
  min-width: 100%;
  will-change: transform;
}

.tree-canvas.nature-mode {
  padding: 0;
  min-width: 100%;
  width: 100%;
  height: 100%;
  display: block;
}

.pine-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  aspect-ratio: auto;
  margin: 0;
  flex: none;
  overflow: hidden;
}

.pine-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: center center;
  pointer-events: none;
  user-select: none;
  filter: saturate(1.08) contrast(1.06) brightness(1.02);
  z-index: 0;
}

.pine-overlay {
  position: absolute;
  left: 50%;
  top: 2.5%;
  width: 90%;
  height: 80%;
  transform: translateX(-50%);
  transform-origin: 50% 45%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  z-index: 1;
  pointer-events: none;
  will-change: transform;
}

.tree-screen.is-nature {
  background:
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(20, 40, 28, 0.9), transparent 70%),
    linear-gradient(180deg, #0b1520 0%, #12241c 55%, #0d1812 100%);
  background-color: #0b1520;
}

.tree-screen.is-nature .tree-viewport {
  background: transparent;
  flex: 1 1 auto;
  min-height: 0;
}

.tree-screen.is-nature .tree-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  margin: 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, rgba(8, 16, 12, 0.72));
  pointer-events: none;
}

.gen-stage {
  position: relative;
  display: inline-block;
  min-width: min(720px, 92vw);
  padding: 24px 36px 56px;
  margin: 0 auto;
}

.gen-stage > .pine-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none !important;
  z-index: 1;
  overflow: visible;
}

.gen-stage .gen-stack {
  position: relative;
  z-index: 2;
}

.gen-stack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 110px;
  min-width: 100%;
}

.gen-stage .pine-gen {
  display: flex;
  width: max-content;
  max-width: none;
  min-width: 0;
  gap: 14px;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
}

.gen-cluster {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  padding: 0 4px;
  position: relative;
}

.gen-cluster + .gen-cluster {
  margin-left: 28px;
  padding-left: 28px;
  border-left: 1px dashed rgba(232, 217, 168, 0.32);
}

.gen-stage .pine-couple {
  gap: 6px;
  flex: 0 0 auto;
}

.gen-stage .tree-node {
  width: 118px;
  flex: 0 0 118px;
  position: relative;
  z-index: 2;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.gen-stage .tree-node.is-draggable,
.pine-stage .tree-node.is-draggable {
  cursor: grab;
  animation: none;
}

.gen-stage .tree-node.is-dragging,
.pine-stage .tree-node.is-dragging {
  cursor: grabbing;
  z-index: 30;
}

.gen-stage .tree-node.is-dragging .card {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.gen-stage .tree-node.is-moved,
.pine-stage .tree-node.is-moved {
  animation: none;
}

.pine-stage .tree-node.is-draggable {
  touch-action: none;
  user-select: none;
}

.pine-wires,
.pine-wires * {
  pointer-events: none !important;
}

.gen-stage .tree-node .card {
  padding: 8px 6px 10px;
  border-radius: 16px;
}

.gen-stage .tree-node .card .nm {
  font-size: 0.72rem;
  line-height: 1.15;
  max-width: 108px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gen-stage .tree-node .card .dates {
  font-size: 0.62rem;
}

.gen-stage .role-tag {
  font-size: 0.55rem;
  max-width: 110px;
  top: -8px;
}

.gen-stage.is-dense .gen-stack {
  gap: 96px;
}

.gen-stage.is-dense .pine-gen {
  gap: 10px;
}

.gen-stage.is-dense .gen-cluster {
  gap: 4px;
}

.gen-stage.is-dense .pine-couple {
  gap: 4px;
}

.gen-stage.is-dense .tree-node {
  width: 96px;
  flex-basis: 96px;
}

.gen-stage.is-dense .tree-node .card .avatar,
.gen-stage.is-dense .tree-node .card img {
  width: 36px;
  height: 36px;
  font-size: 0.75rem;
}

.gen-stage.is-dense .tree-node .card .nm {
  font-size: 0.64rem;
  max-width: 88px;
}

.gen-stage.is-dense .tree-node .card .dates {
  display: none;
}

.gen-stage.is-dense .gen-cluster {
  gap: 4px;
  padding: 0 2px;
}

.gen-stage.is-crowded .gen-stack {
  gap: 84px;
}

.gen-stage.is-crowded .tree-node {
  width: 78px;
  flex-basis: 78px;
}

.gen-stage.is-crowded .tree-node .card {
  padding: 5px 3px 6px;
  border-radius: 12px;
}

.gen-stage.is-crowded .tree-node .card .avatar,
.gen-stage.is-crowded .tree-node .card img {
  width: 28px;
  height: 28px;
  font-size: 0.65rem;
  margin-bottom: 2px;
}

.gen-stage.is-crowded .tree-node .card .nm {
  font-size: 0.55rem;
  max-width: 72px;
  -webkit-line-clamp: 2;
}

.gen-stage.is-crowded .tree-node .card .dates,
.gen-stage.is-crowded .role-tag {
  display: none;
}

.gen-stage.is-crowded .gen-cluster {
  gap: 3px;
  padding: 0 2px;
}

.gen-stage.is-crowded .gen-cluster + .gen-cluster {
  margin-left: 18px;
  padding-left: 16px;
}

.gen-stage.is-crowded .pine-couple {
  gap: 3px;
}

.gen-stage .pine-wires .wire-under {
  stroke: rgba(12, 22, 18, 0.78);
  stroke-width: 5.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 1;
}

.gen-stage .family-wires .wire,
.gen-stage .pine-wires .wire {
  stroke: #e8d9a8;
  stroke-width: 2.35;
  fill: none;
  opacity: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: none;
}

.gen-stage .pine-wires .wire-child {
  stroke: #6fbf94;
  stroke-width: 2.35;
}

.gen-stage .pine-wires .wire-trunk,
.gen-stage .pine-wires .wire-rail {
  stroke: #e0b445;
  stroke-width: 2.5;
}

.gen-stage .pine-wires .wire-spouse {
  stroke: #e890b0;
  stroke-width: 2.7;
}

.gen-stage .pine-wires .wire-divorced {
  stroke-dasharray: 5 4;
  stroke: #d4889a;
}

.gen-stage .pine-wires .wire-dot {
  fill: #fff8e0;
  stroke: #142018;
  stroke-width: 1.5;
}

.gen-stage .pine-wires .wire-end {
  fill: #f5ecc0;
  stroke: #0f1a14;
  stroke-width: 1.6;
}

.gen-stage .pine-wires .wire-hub {
  fill: #f0c14d;
  stroke: #1a2820;
  stroke-width: 1.6;
}

.gen-stage .pine-wires .wire-hub-ring {
  fill: none;
  stroke: rgba(20, 32, 24, 0.9);
  stroke-width: 1.2;
}

.gen-stage.is-crowded .pine-wires .wire {
  stroke-width: 2;
}

.gen-stage.is-crowded .pine-wires .wire-under {
  stroke-width: 4.8;
}

.pine-overlay .gen-cluster {
  display: flex;
  gap: 4px;
}

.pine-stage.is-dense .pine-gen .tree-node .card,
.pine-stage.is-crowded .pine-gen .tree-node .card {
  width: 54px;
  height: 54px;
}

.pine-stage.is-crowded .pine-gen .tree-node .card .nm {
  font-size: 0.45rem;
  max-width: 48px;
}

.pine-overlay .tree-node,
.pine-overlay .pine-couple {
  pointer-events: auto;
}

.pine-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 5;
}

.pine-gen {
  position: relative;
  z-index: 1;
  width: var(--pine-w, 80%);
  max-width: 100%;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: clamp(3px, 0.8vw, 12px);
}

.pine-couple {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: clamp(2px, 0.5vw, 8px);
  flex: 0 0 auto;
}

.nature-mode .pine-gen .tree-node {
  width: auto;
  flex: 0 0 auto;
  flex-basis: auto;
}

.nature-mode .pine-gen .tree-node .card {
  width: 72px;
  height: 72px;
  padding: 4px 3px 6px;
  border-width: 1.5px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.nature-mode .pine-gen .tree-node .card .avatar,
.nature-mode .pine-gen .tree-node .card img {
  width: 28px;
  height: 28px;
  margin: 0 0 2px;
  font-size: 0.65rem;
}

.nature-mode .pine-gen .tree-node .card .nm {
  font-size: 0.55rem;
  max-width: 64px;
  -webkit-line-clamp: 2;
}

.nature-mode .pine-gen .role-tag {
  top: -8px;
  font-size: 0.48rem;
  max-width: 78px;
  padding: 1px 5px;
}

.pine-gens-1 .pine-gen .tree-node .card,
.pine-gens-2 .pine-gen .tree-node .card {
  width: 92px;
  height: 92px;
}

.pine-gens-1 .pine-gen .tree-node .card .avatar,
.pine-gens-1 .pine-gen .tree-node .card img,
.pine-gens-2 .pine-gen .tree-node .card .avatar,
.pine-gens-2 .pine-gen .tree-node .card img {
  width: 40px;
  height: 40px;
}

.pine-gens-1 .pine-gen .tree-node .card .nm,
.pine-gens-2 .pine-gen .tree-node .card .nm {
  font-size: 0.68rem;
  max-width: 84px;
}

.pine-gens-5 .pine-gen .tree-node .card,
.pine-gens-6 .pine-gen .tree-node .card,
.pine-gens-7 .pine-gen .tree-node .card,
.pine-gens-8 .pine-gen .tree-node .card {
  width: 58px;
  height: 58px;
}

.pine-gens-5 .pine-gen .tree-node .card .avatar,
.pine-gens-5 .pine-gen .tree-node .card img,
.pine-gens-6 .pine-gen .tree-node .card .avatar,
.pine-gens-6 .pine-gen .tree-node .card img,
.pine-gens-7 .pine-gen .tree-node .card .avatar,
.pine-gens-7 .pine-gen .tree-node .card img,
.pine-gens-8 .pine-gen .tree-node .card .avatar,
.pine-gens-8 .pine-gen .tree-node .card img {
  width: 22px;
  height: 22px;
}

.pine-gens-5 .pine-gen .tree-node .card .nm,
.pine-gens-6 .pine-gen .tree-node .card .nm,
.pine-gens-7 .pine-gen .tree-node .card .nm,
.pine-gens-8 .pine-gen .tree-node .card .nm {
  font-size: 0.48rem;
  max-width: 52px;
}

.nature-trunk {
  display: none;
}

.nature-mode .tree-node {
  width: 118px;
  flex-basis: 118px;
}

.nature-mode .tree-node .card {
  border-radius: 50%;
  width: 108px;
  height: 108px;
  padding: 8px 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.18), transparent 45%),
    linear-gradient(165deg, rgba(36, 63, 51, 0.95), rgba(20, 40, 32, 0.92));
  border: 2px solid rgba(232, 217, 168, 0.45);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(232, 217, 168, 0.12);
}

.nature-mode .tree-node .card .avatar,
.nature-mode .tree-node .card img {
  width: 44px;
  height: 44px;
  margin: 0 0 4px;
  font-size: 0.85rem;
}

.nature-mode .tree-node .card .nm {
  font-size: 0.72rem;
  line-height: 1.15;
  max-width: 92px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nature-mode .tree-node .card .dates {
  display: none;
}

.nature-mode .role-tag {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  max-width: 110px;
  font-size: 0.55rem;
  z-index: 2;
  background: rgba(14, 30, 24, 0.92);
}

.nature-mode .tree-node {
  position: relative;
}

.nature-mode .family-wires .wire {
  stroke-width: 3.2;
  filter: drop-shadow(0 0 6px rgba(226, 200, 120, 0.4));
}

.nature-mode .family-wires .wire-spouse {
  stroke-width: 3.6;
}

.nature-mode .family-wires .wire-trunk,
.nature-mode .family-wires .wire-rail,
.nature-mode .family-wires .wire-child {
  stroke: #e2c878;
  stroke-width: 3;
}

.nature-mode .spouse-bridge {
  width: 36px;
  flex-basis: 36px;
  margin-top: 48px;
}

.nature-mode .parents-pair.is-divorced .spouse-bridge {
  width: 52px;
  flex-basis: 52px;
}

.nature-mode .divorced-tag {
  font-size: 0.55rem;
  padding: 2px 6px;
}

.nature-mode .child-stem {
  height: 42px;
}

.nature-mode .children-row {
  gap: 48px;
}

.tree-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.85);
  pointer-events: none;
  z-index: 2;
}

.gen-row {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 0 0 54px;
  position: relative;
}

.tree-node {
  width: 138px;
  text-align: center;
  position: relative;
  z-index: 1;
  animation: nodeIn 0.45s ease both;
  flex: 0 0 138px;
}

@keyframes nodeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tree-node .card {
  background: linear-gradient(165deg, rgba(255,255,255,0.16), rgba(255,255,255,0.06));
  border: 1px solid rgba(232, 217, 168, 0.35);
  border-radius: 22px;
  padding: 12px 10px 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 36px rgba(0,0,0,0.28);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.tree-node .card.with-photo {
  border-color: rgba(232, 217, 168, 0.55);
  box-shadow:
    0 16px 36px rgba(0,0,0,0.3),
    0 0 0 1px rgba(232, 217, 168, 0.12);
}

.tree-node .card:hover {
  transform: translateY(-3px);
  border-color: var(--gold-soft);
}

.tree-node .card img,
.tree-node .card .avatar {
  width: 76px;
  height: 76px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.tree-node .card .nm {
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.2;
  margin: 0 0 4px;
}

.tree-node .card .dates {
  font-size: 0.72rem;
  opacity: 0.78;
  margin: 0;
}

.family-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.family-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

.family-wires .wire {
  fill: none;
  stroke: #e2c878;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 5px rgba(226, 200, 120, 0.35));
}

.family-wires .wire-spouse {
  stroke: #f0dfaa;
  stroke-width: 2.6;
}

.family-wires .wire-divorced {
  stroke: #d4c08a;
  stroke-dasharray: 5 4;
  stroke-width: 2.2;
  opacity: 0.95;
}

.family-wires .wire-trunk,
.family-wires .wire-rail {
  stroke: #e6cf86;
  stroke-width: 2.5;
}

.family-wires .wire-child {
  stroke: #dcc06a;
  stroke-width: 2.2;
}

.family-wires .wire-dot {
  fill: #f3e6b8;
  stroke: #c4a35a;
  stroke-width: 1.2;
}

.family-wires .wire-knot {
  fill: #f0dfaa;
  stroke: #c4a35a;
  stroke-width: 1.4;
  filter: drop-shadow(0 0 6px rgba(226, 200, 120, 0.55));
}

.parents-pair {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  z-index: 1;
  width: max-content;
  max-width: none;
}

.spouse-bridge {
  position: relative;
  width: 48px;
  height: 1px;
  margin-top: 52px;
  flex: 0 0 48px;
  align-self: flex-start;
  z-index: 2;
}

.divorced-tag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f3e6b8;
  background: rgba(14, 30, 24, 0.92);
  border: 1px solid rgba(232, 217, 168, 0.45);
  padding: 3px 7px;
  border-radius: 999px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 3;
}

.parents-pair.is-divorced .spouse-bridge {
  width: 64px;
  flex-basis: 64px;
}

.check-inline {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin: 4px 0 6px;
  font-size: 0.9rem;
  color: #456353;
  cursor: pointer;
}

.check-inline input {
  width: auto !important;
  margin: 0 !important;
}

.parents-pair::after { display: none; }

.lineage {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 8px;
  position: relative;
  z-index: 1;
}

.children-row {
  display: flex;
  gap: 40px;
  justify-content: center;
  align-items: flex-start;
  margin-top: 0;
  padding-top: 0;
  position: relative;
  flex-wrap: nowrap;
  width: max-content;
  max-width: none;
}

.children-row::before { display: none; }

.child-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.child-stem {
  width: 1px;
  height: 36px;
  opacity: 0;
  pointer-events: none;
}

.connector-down { display: none; }

.tree-sep {
  height: 48px;
}

.empty-tree {
  text-align: center;
  padding: 80px 20px;
  color: rgba(255,255,255,0.8);
}

.empty-tree h3 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin: 0 0 8px;
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.segment button {
  border: 1px solid rgba(47,107,79,0.2);
  background: white;
  border-radius: 12px;
  padding: 10px;
  font: inherit;
  cursor: pointer;
}

.segment button.active {
  background: var(--moss);
  color: white;
  border-color: var(--moss);
}

.pdf-exporting .tree-hint,
.pdf-exporting .tree-toolbar { display: none !important; }

.pdf-exporting {
  background: #1a3329 !important;
}

.pdf-exporting .tree-canvas,
.pdf-exporting .pine-overlay {
  will-change: auto !important;
}

.pdf-exporting svg.pine-wires {
  overflow: visible !important;
}

@media print {
  .topbar, .tree-toolbar, .tree-hint { display: none !important; }
}
