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

:root {
  --bg:       #F5F0EB;
  --surface:  #FFFFFF;
  --text:     #2D1F1F;
  --muted:    #8B7B74;
  --accent:   #A85A4F;
  --line:     #C4AFA8;
  --nav-bg:   #3B2A2A;
  --nav-h:    88px;
}

:root.dark {
  --bg:      #08080F;
  --surface: #0F1020;
  --text:    #E0E4F8;
  --muted:   #7078B0;
  --accent:  #8898E8;
  --line:    #1A1C38;
  --nav-bg:  #05060D;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0 0 var(--nav-h) 0;
  overflow: hidden;
  z-index: 1;
}

/* ── Background animation ─────────────────────────────────────── */

#bg-anim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ── Nav ─────────────────────────────────────────────────────── */

#nav {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  height: 56px;
  background: rgba(45,26,26,0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 28px;
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 2px;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.05) inset;
}

.nav-btn {
  width: 50px;
  height: 42px;
  border-radius: 21px;
  border: none;
  background: transparent;
  color: #A09090;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Tree ────────────────────────────────────────────────────── */

.tree-view-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.tree-hud-left,
.tree-hud-right {
  position: absolute;
  top: 14px;
  z-index: 10;
  background: rgba(45,26,26,0.92);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
}
.tree-hud-left  { left: 14px; }
.tree-hud-right { right: 14px; }

:root.dark .tree-hud-left,
:root.dark .tree-hud-right {
  background: rgba(15,16,32,0.80);
  border-color: rgba(136,152,232,0.18);
}

.tree-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  touch-action: none;
  will-change: scroll-position;
}

.tree-scroll::-webkit-scrollbar { display: none; }

.tree-scale-spacer { position: relative; }

.tree-zoom {
  position: absolute;
  right: 14px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.zoom-btn.small { font-size: 14px; }

.tree-canvas {
  position: relative;
  background-image: radial-gradient(circle, rgba(139,74,58,0.10) 1px, transparent 1px);
  background-size: 28px 28px;
}

.gen-label {
  position: absolute;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-50%);
}

/* ── Card ────────────────────────────────────────────────────── */

.card {
  position: absolute;
  background: rgba(250,248,246,0.97);
  border-radius: 18px;
  box-shadow: 0 2px 20px rgba(59,42,42,0.10), 0 0 0 1px rgba(255,255,255,0.5), inset 0 0 20px rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.7);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.15s, transform 0.12s;
}

.card:active {
  transform: scale(0.96);
  box-shadow: 0 1px 8px rgba(59,42,42,0.12);
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 6px 26px rgba(59,42,42,0.14), 0 0 0 1px rgba(255,255,255,0.65), inset 0 0 20px rgba(255,255,255,0.15);
  }
}

/* ── Dark mode overrides ─────────────────────────────────────── */

:root.dark .card {
  background: rgba(14,15,28,0.84);
  border-color: rgba(136,152,232,0.10);
  box-shadow: 0 2px 20px rgba(0,0,0,0.5), 0 0 0 1px rgba(136,152,232,0.07), inset 0 0 24px rgba(136,152,232,0.03);
}

:root.dark .card--deceased {
  background: rgba(8,9,18,0.90);
  border-color: rgba(255,255,255,0.04);
}

:root.dark .card--deceased .card-name { color: #5060A0; }
:root.dark .card--deceased .card-dates { color: #303870; }

:root.dark .card-role {
  background: rgba(136,152,232,0.10);
  border-color: rgba(136,152,232,0.40);
  color: var(--text);
}

:root.dark .photo-placeholder {
  background: linear-gradient(135deg, #0E1028 0%, #141838 100%);
}

:root.dark .tree-canvas {
  background-image: radial-gradient(circle, rgba(136,152,232,0.16) 1px, transparent 1px);
}

:root.dark #nav {
  background: rgba(15,16,32,0.96);
  border-color: rgba(136,152,232,0.28);
}

:root.dark .btn-primary {
  background: rgba(136,152,232,0.18);
  border-color: rgba(136,152,232,0.45);
  color: var(--text);
}

:root.dark .legend-line.solid {
  background: rgba(136,152,232,0.55);
}
:root.dark .legend-line.dashed {
  background: repeating-linear-gradient(90deg, rgba(136,152,232,0.55) 0, rgba(136,152,232,0.55) 7px, transparent 7px, transparent 13px);
}
:root.dark .legend-line.marriage {
  background: rgba(136,152,232,0.55);
}

:root.dark .result-item:active,
:root.dark .relative-card:active {
  background: rgba(136,152,232,0.05);
}

:root.dark .birthday-pill--today { background: var(--accent); color: #08080F; }
:root.dark .birthday-pill--week  { background: rgba(136,152,232,0.18); color: var(--accent); }
:root.dark .birthday-pill--month { background: rgba(100,120,200,0.15); color: #7080C8; }

:root.dark .birthday-item--today {
  background: rgba(136,152,232,0.10);
  border-left-color: var(--accent);
}
:root.dark .birthday-item--today .birthday-name { color: var(--accent); }
:root.dark .birthday-item--week {
  background: rgba(136,152,232,0.05);
  border-left-color: rgba(136,152,232,0.4);
}
:root.dark .birthday-item--week .birthday-name { color: var(--accent); }

.card--deceased {
  background: rgba(180,162,154,0.45);
  border-color: rgba(180,162,154,0.5);
  box-shadow: 0 2px 14px rgba(30,20,20,0.18), 0 0 20px rgba(140,120,112,0.2);
}

.card--deceased .card-name { color: #5a4040; }
.card--deceased .card-dates { color: #7a5a52; }

.card-photo {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 10px;
  background: #D9CFC9;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(139,90,80,0.45);
}

:root.dark .card-photo {
  box-shadow: 0 0 0 2px rgba(136,152,232,0.45);
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-photo--dashed {
  overflow: visible;
  background: transparent;
  position: relative;
}

.card-photo--dashed .photo-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  outline: 2.5px dashed var(--muted);
  outline-offset: 2px;
}

.photo-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #D9CFC9 0%, #C4AFA8 100%);
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}


.card-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 4px;
}

.card-dates {
  font-size: 11px;
  color: var(--accent);
  text-align: center;
}

.card-role {
  margin-top: 7px;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(139,90,80,0.10);
  border: 1px solid rgba(139,90,80,0.35);
  border-radius: 8px;
  padding: 2px 9px;
}

/* ── Overview ────────────────────────────────────────────────── */

.overview-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.overview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 10px;
  flex-shrink: 0;
}

.overview-title {
  font-size: 17px;
  font-weight: 600;
}

.overview-count {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 12px;
  padding: 4px 12px;
}

.overview-canvas-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0 8px 8px;
}

.overview-canvas-inner {
  transform-origin: top center;
  flex-shrink: 0;
}

.overview-zoom {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zoom-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  -webkit-tap-highlight-color: transparent;
}

/* ── Search ──────────────────────────────────────────────────── */

.search-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  gap: 18px;
  overflow-y: auto;
}

.search-view::-webkit-scrollbar { display: none; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 14px;
  padding: 13px 16px;
  box-shadow: 0 1px 6px rgba(59,42,42,0.06);
  flex-shrink: 0;
  border: 1.5px solid transparent;
}

:root.dark .search-bar {
  background: rgba(136,152,232,0.10);
  border-color: rgba(136,152,232,0.40);
}

.search-icon { color: var(--muted); flex-shrink: 0; }

.search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  width: 100%;
  -webkit-appearance: none;
}

.search-input::placeholder { color: var(--muted); }

.search-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-tabs {
  display: flex;
  gap: 6px;
}

.sheet-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sheet-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.sheet-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(196,175,168,0.2);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 10px;
}

.recent-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-tag {
  background: var(--surface);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: 14px;
  padding: 13px 14px;
  cursor: pointer;
  border: none;
  text-align: left;
  width: 100%;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.result-photo {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--line);
  overflow: hidden;
  flex-shrink: 0;
}

.result-photo img { width: 100%; height: 100%; object-fit: cover; }

.result-name { font-size: 15px; font-weight: 500; }
.result-dates { font-size: 12px; color: var(--muted); margin-top: 2px; }
.result-arrow { margin-left: auto; color: var(--muted); font-size: 18px; }

.no-results {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
}

/* ── Profile ─────────────────────────────────────────────────── */

.profile-view {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.profile-view::-webkit-scrollbar { display: none; }

.profile-cover {
  height: 280px;
  background: linear-gradient(160deg, #C4AFA8 0%, #8B7B74 100%);
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 20px;
  overflow: hidden;
}

.profile-cover-bg {
  position: absolute;
  inset: -10px;
  background-size: cover;
  background-position: center top;
  filter: blur(18px) brightness(0.55) saturate(1.3);
}

.profile-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(45,31,31,0.1) 0%, rgba(45,31,31,0.5) 100%);
}

.profile-cover-photo {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: #D9CFC9;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.85);
  position: relative;
  z-index: 2;
  box-shadow: 0 4px 24px rgba(0,0,0,0.28);
}

.profile-cover-photo img { width: 100%; height: 100%; object-fit: cover; }

.back-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

.profile-body {
  padding: 22px 20px 40px;
}

.profile-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 25px;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-dates {
  font-size: 15px;
  color: var(--accent);
  margin-bottom: 10px;
}

.profile-role-badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: rgba(139,74,58,0.1);
  border-radius: 10px;
  padding: 3px 11px;
  margin-bottom: 14px;
}

.memorial-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 15px 20px;
  margin: 6px 0 18px;
  background: linear-gradient(135deg, #A85A4F 0%, #C4706A 100%);
  color: #fff;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 14px;
  text-decoration: none;
  box-sizing: border-box;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 18px rgba(168,90,79,0.32);
}
.memorial-btn:active {
  opacity: 0.88;
  transform: scale(0.985);
}
:root.dark .memorial-btn {
  background: linear-gradient(135deg, #6B7FCC 0%, #8898E8 100%);
  box-shadow: 0 4px 18px rgba(136,152,232,0.28);
}

.contribute-block {
  margin: 28px 0 8px;
  padding: 18px 18px 16px;
  background: var(--surface);
  border-radius: 16px;
  border: 1.5px solid var(--line);
}
.contribute-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}
.contribute-list {
  margin: 0 0 14px 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.8;
}
.contribute-btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.contribute-btn:active { opacity: 0.82; }
:root.dark .contribute-block {
  border-color: rgba(136,152,232,0.18);
}
:root.dark .contribute-btn {
  color: #0F1020;
}

.profile-info {
  background: var(--surface);
  border-radius: 16px;
  padding: 4px 16px;
  margin-bottom: 14px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid rgba(196,175,168,0.3);
  gap: 12px;
}

.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.info-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: right;
}

.profile-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.stat-item {
  flex: 1;
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 12px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
}

.profile-section {
  margin-bottom: 26px;
}

.profile-section-title {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.profile-bio {
  font-size: 14.5px;
  line-height: 1.65;
}

.profile-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--line);
  margin: 6px 0 20px;
}

.profile-tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  margin-bottom: -1.5px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, border-color 0.15s;
}

.profile-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.timeline-placeholder {
  font-size: 13.5px;
  color: var(--muted);
  font-style: italic;
}

.timeline-entry {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
}

.timeline-dot-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 3px;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.timeline-year {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 3px;
}

.timeline-text {
  font-size: 13.5px;
  line-height: 1.5;
}

.relatives-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.relative-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  border: none;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.relative-rel {
  position: absolute;
  top: 7px;
  left: 7px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-transform: uppercase;
  line-height: 1;
  background: rgba(139,90,80,0.10);
  border: 1px solid rgba(139,90,80,0.35);
  border-radius: 20px;
  padding: 3px 7px;
}

:root.dark .relative-rel {
  background: rgba(136,152,232,0.10);
  border-color: rgba(136,152,232,0.40);
  color: var(--text);
}

.relative-photo {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--line);
  overflow: hidden;
}

.relative-photo img { width: 100%; height: 100%; object-fit: cover; }

.relative-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

/* ── Overlays ────────────────────────────────────────────────── */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.42);
  z-index: 400;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 16px 20px 36px;
  z-index: 401;
  animation: slideUp 0.22s ease;
  max-height: 82vh;
  overflow-y: auto;
}

.bottom-sheet::-webkit-scrollbar { display: none; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 0 auto 18px;
}

/* Popup */
.popup-header {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
  align-items: flex-start;
}

.popup-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--line);
  overflow: hidden;
  flex-shrink: 0;
}

.popup-photo img { width: 100%; height: 100%; object-fit: cover; }

.popup-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 3px;
}

.popup-maiden {
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 2px;
}

.popup-dates {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 3px;
}

.popup-role {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.07em;
}

.popup-bio {
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 18px;
  color: var(--text);
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 15px;
  background: var(--nav-bg);
  color: #fff;
  border: 1.5px solid transparent;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  -webkit-tap-highlight-color: transparent;
}

/* Birthdays */
.birthday-list {
  display: flex;
  flex-direction: column;
}

.birthday-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(196,175,168,0.3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.birthday-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.birthday-name { font-size: 14.5px; font-weight: 600; color: var(--text); }
.birthday-date { font-size: 12px; color: var(--muted); }

.birthday-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.birthday-pill--today { background: var(--accent); color: #fff; }
.birthday-pill--week  { background: rgba(139,74,58,0.18); color: var(--accent); }
.birthday-pill--month { background: rgba(180,140,80,0.15); color: #8B6A3A; }
.birthday-pill--far   { background: rgba(196,175,168,0.25); color: var(--muted); }

.birthday-item--today {
  background: rgba(139,74,58,0.08);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 -12px;
  border-left: 3px solid var(--accent);
}
.birthday-item--today .birthday-name { color: var(--accent); }

.birthday-item--week {
  background: rgba(139,74,58,0.04);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 -12px;
  border-left: 3px solid rgba(139,74,58,0.35);
}
.birthday-item--week .birthday-name { color: var(--accent); }

/* Legend */
.legend-items {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 16px;
}

.legend-line {
  width: 48px;
  height: 2px;
  flex-shrink: 0;
}

.legend-line.solid    { background: var(--line); }
.legend-line.dashed   { background: repeating-linear-gradient(90deg, var(--line) 0, var(--line) 7px, transparent 7px, transparent 13px); }
.legend-line.marriage {
  background: var(--line);
  position: relative;
  overflow: visible;
}
.legend-line.marriage::after {
  content: '♡';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: var(--accent);
  background: var(--surface);
  padding: 0 3px;
  line-height: 1;
}

.legend-label { font-size: 14px; }

.btn-outline {
  display: block;
  width: 100%;
  padding: 14px;
  background: rgba(139,90,80,0.10);
  color: var(--text);
  border: 1.5px solid rgba(139,90,80,0.45);
  border-radius: 14px;
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:root.dark .btn-outline {
  background: rgba(136,152,232,0.10);
  border-color: rgba(136,152,232,0.40);
}

.find-in-tree-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 11px 16px;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 14px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.find-in-tree-btn:active {
  background: rgba(139,90,80,0.08);
}
:root.dark .find-in-tree-btn {
  border-color: rgba(136,152,232,0.25);
}

@keyframes card-pulse {
  0%, 100% { box-shadow: 0 2px 20px rgba(59,42,42,0.10), 0 0 0 1px rgba(255,255,255,0.5), inset 0 0 20px rgba(255,255,255,0.12); }
  50%       { box-shadow: 0 2px 20px rgba(59,42,42,0.10), 0 0 0 6px rgba(168,90,79,0.55), inset 0 0 20px rgba(255,255,255,0.12); }
}
.card--highlight {
  animation: card-pulse 0.7s ease-in-out 3;
}

.tree-view-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.tree-scale-spacer {
  position: relative;
}

#tree-scale-inner {
  position: relative;
  will-change: transform;
}

.tree-zoom {
  position: fixed;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 90;
}

.zoom-btn.small {
  font-size: 15px;
}

.onboarding-tips {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.onboarding-tip {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.onboarding-tip-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

.onboarding-tip-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  padding-top: 7px;
}

.onboarding-cta {
  margin-top: 22px;
  padding: 16px 18px;
  background: rgba(168,90,79,0.08);
  border: 1.5px solid rgba(168,90,79,0.25);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
:root.dark .onboarding-cta {
  background: rgba(136,152,232,0.08);
  border-color: rgba(136,152,232,0.22);
}
.onboarding-cta-text {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
}
.onboarding-cta-btn {
  display: inline-block;
  align-self: flex-start;
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.onboarding-cta-btn:active { opacity: 0.82; }
:root.dark .onboarding-cta-btn { color: #08080F; }

.onboarding-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
.onboarding-stat {
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.onboarding-stat-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.onboarding-stat-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.3;
}
:root.dark .onboarding-stat { background: rgba(255,255,255,0.06); }