/* Family Book — warm, personal, mobile-first */
/* Design: Instagram meets a photo album meets a family tree */

/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Nunito:wght@300;400;500;600;700&display=swap');

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Warm, earthy, family-oriented palette */
  --bg: #faf8f5;
  --bg-warm: #f5f0e8;
  --cream: #faf6f0;
  --cream-dark: #ede5d5;

  /* Primary: deep forest green */
  --green-deep: #2d5016;
  --green-mid: #3d6b22;
  --green-light: #7db356;
  --green-pale: #e8f0de;

  /* Warm brown tones */
  --brown-dark: #3e2c1c;
  --brown-mid: #5c4033;
  --brown-light: #a67c5b;

  /* Golden amber accent */
  --amber: #c49a3c;
  --amber-light: #f0dba8;
  --amber-pale: #fdf6e3;

  /* Warm neutrals */
  --warm-white: #fefcf9;
  --warm-gray: #8a7e72;
  --text: #2c2c2c;
  --text-muted: #6b6054;
  --text-light: #9a8e82;
  --border: #e0d6c8;
  --border-light: #ede7dd;

  /* Status colors */
  --danger: #b33a3a;
  --danger-light: #f5e0e0;
  --info: #2a6496;
  --info-light: #dce8f4;
  --success: #2d5016;
  --success-light: #e8f0de;

  /* Shadows — warm toned */
  --shadow-sm: 0 1px 3px rgba(60,40,20,0.06), 0 1px 2px rgba(60,40,20,0.04);
  --shadow-md: 0 4px 12px rgba(60,40,20,0.08), 0 2px 4px rgba(60,40,20,0.04);
  --shadow-lg: 0 12px 32px rgba(60,40,20,0.12), 0 4px 8px rgba(60,40,20,0.06);
  --shadow-hover: 0 8px 24px rgba(60,40,20,0.14), 0 4px 8px rgba(60,40,20,0.06);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Typography */
  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;

  /* Layout */
  --max-w: 640px;
  --nav-h: 60px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-med: 0.25s ease;
  --transition-slow: 0.4s ease;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--green-deep); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--green-mid); }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; color: var(--text); }

/* ===== Layout ===== */
.page { padding-top: var(--nav-h); min-height: 100dvh; }
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 16px; }
.container-wide { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ===== Navigation ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--bg);
  color: var(--text);
  display: flex; align-items: center; padding: 0 20px;
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(250, 248, 245, 0.92);
}
.nav__brand {
  font-family: var(--font-serif);
  font-size: 1.25rem; font-weight: 600;
  color: var(--brown-dark);
  margin-right: auto;
  display: flex; align-items: center; gap: 8px;
  letter-spacing: -0.01em;
}
.nav__brand:hover { text-decoration: none; color: var(--brown-dark); }
.nav__brand-demo {
  font-family: var(--font);
  font-size: 0.6em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-pale);
  padding: 2px 6px;
  border-radius: 4px;
}
.nav__links { display: flex; align-items: center; gap: 2px; }
.nav__link {
  color: var(--text-muted);
  padding: 8px 14px; border-radius: var(--radius-full);
  font-size: 0.88rem; font-weight: 600;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}
.nav__link:hover { background: var(--cream-dark); color: var(--text); text-decoration: none; }
.nav__link--active {
  color: var(--green-deep);
  background: var(--green-pale);
}
.nav__link--icon { font-size: 1.2rem; padding: 8px; }
.nav__hamburger {
  display: none; background: none; border: none; color: var(--text);
  font-size: 1.5rem; padding: 8px; cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.nav__hamburger:hover { background: var(--cream-dark); }

@media (max-width: 640px) {
  .nav__links {
    display: none; position: fixed; top: var(--nav-h); left: 0; right: 0;
    background: rgba(250, 248, 245, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column; padding: 8px 16px 16px;
    box-shadow: var(--shadow-lg); gap: 2px;
    border-bottom: 1px solid var(--border-light);
  }
  .nav__links--open { display: flex; }
  .nav__link { width: 100%; padding: 14px 16px; font-size: 1rem; border-radius: var(--radius-md); }
  .nav__hamburger { display: block; }
}

/* ===== Cards ===== */
.card {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
  border: 1px solid var(--border-light);
  transition: box-shadow var(--transition-med);
}
.card + .card { margin-top: 16px; }
.card__body { padding: 20px; }
.card__header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 12px;
}
.card__footer {
  padding: 14px 20px; border-top: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 16px;
}

/* ===== Avatar ===== */
.avatar {
  width: 44px; height: 44px; border-radius: var(--radius-full);
  object-fit: cover; background: linear-gradient(135deg, var(--green-pale), var(--amber-pale)); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--green-deep); font-size: 0.9rem;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(60,40,20,0.1);
  letter-spacing: -0.02em;
}
.avatar--sm { width: 30px; height: 30px; font-size: 0.7rem; border-width: 1.5px; }
.avatar--lg { width: 80px; height: 80px; font-size: 1.5rem; border-width: 3px; }
.avatar--xl { width: 120px; height: 120px; font-size: 2rem; border-width: 3px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-full); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-full); border: none;
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--green-deep); color: white; }
.btn--primary:hover { background: var(--green-mid); text-decoration: none; color: white; box-shadow: var(--shadow-md); }
.btn--secondary { background: var(--cream-dark); color: var(--text); }
.btn--secondary:hover { background: var(--border); text-decoration: none; }
.btn--amber { background: var(--amber); color: white; }
.btn--amber:hover { background: #b38a30; text-decoration: none; color: white; box-shadow: var(--shadow-md); }
.btn--danger { background: var(--danger); color: white; }
.btn--danger:hover { background: #992e2e; text-decoration: none; color: white; }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--cream-dark); text-decoration: none; }
.btn--outline { background: transparent; color: var(--green-deep); border: 1.5px solid var(--green-deep); }
.btn--outline:hover { background: var(--green-pale); text-decoration: none; }
.btn--sm { padding: 6px 14px; font-size: 0.82rem; }
.btn--lg { padding: 14px 28px; font-size: 1rem; }
.btn--block { width: 100%; }
.btn--icon { padding: 10px; border-radius: var(--radius-full); }
.btn[disabled], .btn.htmx-request { opacity: 0.6; pointer-events: none; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 0.82rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-md); background: white; font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(45,80,22,0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* ===== Moment Card ===== */
.moment {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: box-shadow var(--transition-med);
}
.moment:hover { box-shadow: var(--shadow-md); }
.moment + .moment { margin-top: 20px; }

.moment__header {
  padding: 14px 18px; display: flex; align-items: center; gap: 12px;
}
.moment__meta { flex: 1; min-width: 0; }
.moment__author {
  font-family: var(--font-serif);
  font-weight: 600; font-size: 0.95rem;
  color: var(--text); display: block;
}
.moment__author:hover { color: var(--green-deep); }
.moment__time {
  font-size: 0.8rem; color: var(--text-light);
  font-weight: 400;
}
.moment__date-elegant {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.moment__source {
  font-size: 0.72rem; color: var(--text-light);
  background: var(--cream-dark); padding: 2px 8px;
  border-radius: var(--radius-full); display: inline-block;
  font-weight: 500; letter-spacing: 0.02em;
  margin-left: 6px;
}

.moment__media {
  width: 100%; position: relative; overflow: hidden;
  background: var(--cream-dark);
}
.moment__media img {
  width: 100%; display: block;
  transition: transform var(--transition-slow);
}
.moment__media img:hover { transform: scale(1.02); }
.moment__media-grid {
  display: grid; gap: 2px;
}
.moment__media-grid--2 { grid-template-columns: 1fr 1fr; }
.moment__media-grid--3 { grid-template-columns: 1fr 1fr; }
.moment__media-grid--3 > :first-child { grid-row: span 2; }
.moment__media-grid--4 { grid-template-columns: 1fr 1fr; }

.moment__body { padding: 14px 18px; }
.moment__body p { font-size: 0.95rem; line-height: 1.65; color: var(--text); }
.moment__body--truncated {
  max-height: 4.5em; overflow: hidden; position: relative;
}
.moment__body--truncated::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 1.5em; background: linear-gradient(transparent, white);
}

.moment__milestone {
  padding: 24px 18px; text-align: center;
  background: linear-gradient(135deg, var(--amber-pale) 0%, var(--cream) 100%);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}
.moment__milestone-icon { font-size: 2.5rem; margin-bottom: 8px; }
.moment__milestone-text {
  font-family: var(--font-serif); font-size: 1.15rem;
  color: var(--brown-dark); font-weight: 500;
}

.moment__actions {
  padding: 10px 18px; border-top: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 8px;
}

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 6px; }
.reaction-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: var(--radius-full);
  border: 1px solid var(--border); background: white;
  font-size: 0.85rem; cursor: pointer;
  transition: all var(--transition-fast);
}
.reaction-btn:hover { background: var(--cream-dark); border-color: var(--border); transform: scale(1.05); }
.reaction-btn--active { border-color: var(--amber); background: var(--amber-pale); }
.reaction-btn__count { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.reaction-picker {
  display: flex; gap: 4px; padding: 8px 12px;
  background: white; border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-light);
}
.reaction-picker button {
  background: none; border: none; font-size: 1.4rem; cursor: pointer;
  padding: 4px; border-radius: var(--radius-sm);
  transition: transform var(--transition-fast);
}
.reaction-picker button:hover { transform: scale(1.3); }

/* Comments */
.comments { padding: 14px 18px; border-top: 1px solid var(--border-light); background: var(--bg); }
.comment {
  display: flex; gap: 10px; padding: 10px 0;
}
.comment + .comment { border-top: 1px solid var(--border-light); }
.comment__body { flex: 1; min-width: 0; }
.comment__name {
  font-family: var(--font-serif);
  font-weight: 600; font-size: 0.85rem;
  color: var(--brown-dark);
}
.comment__text { font-size: 0.9rem; word-break: break-word; color: var(--text); margin-top: 2px; }
.comment__time { font-size: 0.72rem; color: var(--text-light); margin-top: 2px; display: block; }
.comment-form {
  display: flex; gap: 8px; padding-top: 10px; margin-top: 10px;
  border-top: 1px solid var(--border-light);
}
.comment-form input {
  flex: 1; padding: 10px 16px; border: 1.5px solid var(--border);
  border-radius: var(--radius-full); font-size: 0.9rem;
  background: white;
}
.comment-form input:focus { outline: none; border-color: var(--green-mid); }
.comment-form button {
  background: var(--green-deep); color: white; border: none;
  border-radius: var(--radius-full); padding: 10px 18px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: background var(--transition-fast);
}
.comment-form button:hover { background: var(--green-mid); }

/* ===== Compose bar (bottom of feed) ===== */
.compose-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-light);
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
  z-index: 50;
}
.compose-bar input[type="file"] { display: none; }
.compose-bar__photo-btn {
  background: none; border: none; font-size: 1.3rem; cursor: pointer;
  color: var(--amber); padding: 4px;
  transition: transform var(--transition-fast);
}
.compose-bar__photo-btn:hover { transform: scale(1.15); }
.compose-bar__input {
  flex: 1; padding: 10px 16px; border: 1.5px solid var(--border);
  border-radius: var(--radius-full); font-size: 0.9rem;
  background: white;
}
.compose-bar__input:focus { outline: none; border-color: var(--green-mid); }
.compose-bar__send {
  background: var(--green-deep); color: white; border: none;
  border-radius: var(--radius-full); width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem;
  transition: all var(--transition-fast);
}
.compose-bar__send:hover { background: var(--green-mid); transform: scale(1.05); }

/* ===== Person Profile ===== */
.profile-header {
  background: linear-gradient(135deg, var(--brown-dark) 0%, var(--brown-mid) 50%, var(--amber) 100%);
  color: white; padding: 40px 16px 32px; text-align: center;
  position: relative;
  overflow: hidden;
}
.profile-header::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(196,154,60,0.2) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(45,80,22,0.15) 0%, transparent 50%);
}
.profile-header > * { position: relative; z-index: 1; }
.profile-header .avatar {
  margin: 0 auto 16px;
  border: 4px solid rgba(255,255,255,0.4);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.profile-header__name {
  font-family: var(--font-serif); font-size: 1.6rem; font-weight: 600;
  letter-spacing: -0.01em;
}
.profile-header__nickname {
  font-family: var(--font-serif);
  font-style: italic; opacity: 0.85; font-size: 1rem;
  margin-top: 4px;
}
.profile-header__meta {
  margin-top: 10px; font-size: 0.85rem; opacity: 0.8;
  display: flex; justify-content: center; flex-wrap: wrap; gap: 16px;
  font-weight: 400;
}
.profile-section { padding: 20px; }
.profile-section + .profile-section { border-top: 1px solid var(--border-light); }
.profile-section__title {
  font-family: var(--font-serif);
  font-size: 0.85rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--amber); margin-bottom: 10px;
}

.contact-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.contact-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-full);
  border: 1.5px solid var(--border); background: white;
  font-size: 0.85rem; font-weight: 500; cursor: pointer; color: var(--text);
  transition: all var(--transition-fast);
}
.contact-btn:hover { background: var(--cream-dark); text-decoration: none; border-color: var(--amber); }

/* Relationship chips */
.rel-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rel-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-full);
  background: var(--green-pale); font-size: 0.85rem; color: var(--green-deep);
  font-weight: 500;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}
.rel-chip:hover { background: var(--green-deep); color: white; text-decoration: none; }
.rel-chip a { color: inherit; font-weight: 500; }

/* Media gallery */
.media-gallery {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 16px;
}
.media-gallery__item {
  aspect-ratio: 1; overflow: hidden; border-radius: var(--radius-md);
  cursor: pointer; position: relative;
}
.media-gallery__item img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform var(--transition-med);
}
.media-gallery__item:hover img { transform: scale(1.08); }

/* ===== People Grid ===== */
.people-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 16px; padding: 16px 0;
}
.person-card-sm {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 24px 16px 20px; text-align: center;
  transition: all var(--transition-med);
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
}
.person-card-sm::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--green-deep), var(--amber));
  opacity: 0;
  transition: opacity var(--transition-med);
}
.person-card-sm:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
  text-decoration: none;
  border-color: var(--amber-light);
}
.person-card-sm:hover::before { opacity: 1; }
.person-card-sm .avatar { margin: 0 auto 12px; }
.person-card-sm__name {
  font-family: var(--font-serif);
  font-weight: 600; font-size: 0.95rem; color: var(--text);
  display: block;
  letter-spacing: -0.01em;
}
.person-card-sm__detail {
  font-size: 0.78rem; color: var(--text-light);
  margin-top: 4px; display: block;
  font-weight: 400;
}
.person-card-sm__branch {
  font-size: 0.72rem; color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-top: 4px;
}
.person-card-sm__country { font-size: 1.1rem; margin-top: 4px; }

/* ===== Search ===== */
.search-bar {
  position: relative; margin-bottom: 16px;
}
.search-bar input {
  width: 100%; padding: 12px 16px 12px 44px;
  border: 1.5px solid var(--border); border-radius: var(--radius-full);
  background: white; font-size: 0.95rem;
  transition: all var(--transition-fast);
}
.search-bar input:focus {
  outline: none; border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(45,80,22,0.1);
}
.search-bar__icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-light); font-size: 0.9rem;
}

/* ===== Tree ===== */
.tree-page {
  position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0;
  background: var(--bg); overflow: hidden;
}
.tree-controls {
  position: absolute; top: 16px; right: 16px; z-index: 10;
  display: flex; flex-direction: column; gap: 6px;
}
.tree-controls button {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: white; border: 1px solid var(--border-light); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md); font-size: 1.1rem;
  transition: all var(--transition-fast);
  color: var(--text);
}
.tree-controls button:hover { background: var(--cream-dark); transform: scale(1.05); }
#tree-svg { width: 100%; height: 100%; }

/* Tree nodes */
.person-node { cursor: pointer; }
.person-node circle.photo-clip {
  fill: var(--green-pale);
  stroke: var(--amber);
  stroke-width: 2.5;
  transition: all 0.2s;
}
.person-node circle.tap-target { fill: transparent; }
.person-node text.name-label {
  fill: var(--text); font-size: 11px; text-anchor: middle;
  font-weight: 600; pointer-events: none;
  font-family: 'Playfair Display', Georgia, serif;
}
.person-node text.birth-label {
  fill: var(--text-light); font-size: 9px; text-anchor: middle;
  pointer-events: none;
  font-family: 'Nunito', sans-serif;
}
.person-node text.rel-label {
  fill: var(--text-muted); font-size: 9px; text-anchor: middle;
  pointer-events: none;
}
.person-node:hover circle.photo-clip {
  stroke: var(--green-deep);
  stroke-width: 3;
  filter: drop-shadow(0 2px 8px rgba(45,80,22,0.25));
}
.person-node--branch-rivera circle.photo-clip { fill: #dce8d4; }
.person-node--branch-santos circle.photo-clip { fill: #d4dce8; }
.person-node--branch-maternal circle.photo-clip { fill: #e8d4dc; }

.partnership-line {
  stroke: var(--amber);
  stroke-width: 2.5;
  fill: none;
  opacity: 0.7;
}
.partnership-line--dissolved { stroke-dasharray: 6,4; opacity: 0.5; }
.parent-child-line {
  stroke: var(--brown-light);
  stroke-width: 1.5;
  fill: none;
  opacity: 0.5;
}

/* Hover tooltip for tree nodes */
.tree-tooltip {
  position: absolute;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 30;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.tree-tooltip--visible { opacity: 1; }
.tree-tooltip__name {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text);
}
.tree-tooltip__year {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* Person sidebar (slide-out on tree node click) */
.person-sidebar {
  position: absolute; top: 0; right: 0; bottom: 0; width: 340px;
  background: white; box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  transform: translateX(100%); transition: transform var(--transition-med);
  z-index: 20; overflow-y: auto;
  border-left: 1px solid var(--border-light);
}
.person-sidebar--open { transform: translateX(0); }
.person-sidebar__close {
  position: absolute; top: 12px; right: 12px;
  background: var(--cream-dark); border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--text-muted); padding: 6px 10px;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}
.person-sidebar__close:hover { background: var(--border); }
@media (max-width: 640px) {
  .person-sidebar { width: 100%; }
}

/* ===== Auth Pages ===== */
.auth-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.auth-page::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(45,80,22,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(196,154,60,0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 100%, rgba(92,64,51,0.05) 0%, transparent 40%);
}
.auth-card {
  background: white; border-radius: var(--radius-xl); padding: 40px 32px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  position: relative;
  z-index: 1;
}
.auth-card__title {
  font-family: var(--font-serif); font-size: 1.75rem; text-align: center;
  margin-bottom: 8px; color: var(--brown-dark);
  letter-spacing: -0.02em;
}
.auth-card__subtitle {
  text-align: center; color: var(--text-muted); font-size: 0.9rem;
  margin-bottom: 28px;
  font-style: italic;
}
.auth-card__divider {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0; color: var(--text-light); font-size: 0.85rem;
}
.auth-card__divider::before, .auth-card__divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ===== Admin ===== */
.admin-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
@media (min-width: 768px) {
  .admin-grid { grid-template-columns: 1fr 1fr; }
}
.stat-card {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 24px;
  border: 1px solid var(--border-light);
  transition: all var(--transition-med);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card__label {
  font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600;
}
.stat-card__value {
  font-family: var(--font-serif);
  font-size: 2rem; font-weight: 700; color: var(--green-deep);
  margin-top: 4px;
}
.stat-card__desc { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; }

.audit-row {
  display: flex; gap: 12px; padding: 12px 0; align-items: flex-start;
  border-bottom: 1px solid var(--border-light); font-size: 0.85rem;
}
.audit-row__action {
  padding: 3px 10px; border-radius: var(--radius-full); font-size: 0.72rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.audit-row__action--create { background: var(--green-pale); color: var(--green-deep); }
.audit-row__action--update { background: var(--info-light); color: var(--info); }
.audit-row__action--delete { background: var(--danger-light); color: var(--danger); }
.audit-row__detail { flex: 1; }
.audit-row__time { color: var(--text-light); white-space: nowrap; }

/* Invite list */
.invite-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border-light);
}
.invite-row__name { font-weight: 600; flex: 1; font-family: var(--font-serif); }
.invite-row__status {
  font-size: 0.78rem; padding: 3px 10px;
  border-radius: var(--radius-full); font-weight: 600;
}
.invite-row__status--active { background: var(--green-pale); color: var(--green-deep); }
.invite-row__status--claimed { background: var(--cream-dark); color: var(--text-muted); }
.invite-row__status--expired { background: var(--danger-light); color: var(--danger); }

/* ===== Settings ===== */
.settings-section {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 24px; margin-bottom: 16px;
  border: 1px solid var(--border-light);
}
.settings-section__title {
  font-family: var(--font-serif);
  font-size: 1.05rem; font-weight: 600; margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-light);
  color: var(--brown-dark);
}
.lang-picker { display: flex; gap: 8px; }
.lang-btn {
  padding: 10px 20px; border: 1.5px solid var(--border);
  border-radius: var(--radius-full); background: white; cursor: pointer;
  font-size: 0.9rem; font-weight: 500;
  transition: all var(--transition-fast);
}
.lang-btn:hover { border-color: var(--amber); }
.lang-btn--active { border-color: var(--green-deep); background: var(--green-pale); color: var(--green-deep); }

/* ===== Country Flag ===== */
.flag { font-size: 1.2rem; line-height: 1; }

/* ===== Loading / HTMX ===== */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border); border-top-color: var(--amber);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast-container {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 200;
}
.toast {
  background: var(--brown-dark); color: white;
  padding: 12px 24px; border-radius: var(--radius-full);
  font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ===== Empty states ===== */
.empty-state {
  text-align: center; padding: 56px 24px; color: var(--text-muted);
}
.empty-state__icon { font-size: 3.5rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state__text { font-size: 1rem; font-weight: 500; }
.empty-state__action { margin-top: 20px; }

/* ===== Misc Utilities ===== */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.text-serif { font-family: var(--font-serif); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.hidden { display: none !important; }

/* Feed bottom spacing for compose bar */
.feed-spacer { height: 72px; }

/* ===== Modal / Lightbox ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: white; border-radius: var(--radius-xl);
  max-width: 500px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}
.modal__header {
  padding: 20px 24px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal__title {
  font-family: var(--font-serif);
  font-size: 1.15rem; font-weight: 600; color: var(--brown-dark);
}
.modal__close {
  background: var(--cream-dark); border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--text-muted); padding: 6px 10px;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}
.modal__close:hover { background: var(--border); }
.modal__body { padding: 24px; }
.modal__footer {
  padding: 16px 24px; border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Lightbox for photos */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  z-index: 400; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.lightbox img { max-width: 95%; max-height: 95vh; object-fit: contain; border-radius: var(--radius-sm); }
.lightbox__close {
  position: absolute; top: 16px; right: 16px;
  color: white; font-size: 1.5rem; background: rgba(255,255,255,0.15);
  border: none; cursor: pointer;
  width: 44px; height: 44px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition-fast);
}
.lightbox__close:hover { background: rgba(255,255,255,0.3); }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.filter-chip {
  padding: 7px 16px; border-radius: var(--radius-full);
  border: 1.5px solid var(--border); background: white;
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition-fast);
}
.filter-chip:hover { background: var(--cream-dark); border-color: var(--amber); text-decoration: none; color: var(--text); }
.filter-chip--active {
  background: var(--green-deep); color: white; border-color: var(--green-deep);
}

/* ===== Landing page ===== */
.landing {
  min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
.landing__hero {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 48px 24px 32px;
  position: relative;
  background: linear-gradient(180deg, var(--bg) 0%, var(--cream-dark) 100%);
}
.landing__hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 25% 25%, rgba(45,80,22,0.06) 0%, transparent 40%),
    radial-gradient(circle at 75% 60%, rgba(196,154,60,0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(92,64,51,0.05) 0%, transparent 35%);
}
.landing__hero > * { position: relative; z-index: 1; }
.landing__icon {
  font-size: 4rem;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(60,40,20,0.15));
}
.landing__title {
  font-family: var(--font-serif); font-size: 2.8rem;
  font-weight: 700; margin-bottom: 12px;
  color: var(--brown-dark);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.landing__tagline {
  font-size: 1.15rem; color: var(--text-muted);
  margin-bottom: 36px;
  font-style: italic;
  max-width: 400px;
}
.landing__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.landing__actions .btn--primary {
  background: var(--green-deep); color: white;
  font-size: 1.05rem; padding: 14px 32px;
  box-shadow: var(--shadow-md);
}
.landing__actions .btn--primary:hover { background: var(--green-mid); box-shadow: var(--shadow-lg); }
.landing__actions .btn--outline {
  color: var(--green-deep);
  border: 2px solid var(--green-deep);
  font-size: 1.05rem; padding: 14px 32px;
  background: transparent;
}
.landing__actions .btn--outline:hover { background: var(--green-pale); }

/* Feature cards */
.landing__features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px 48px;
}
.feature-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all var(--transition-med);
}
.feature-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.feature-card__icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
}
.feature-card__title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--brown-dark);
  margin-bottom: 8px;
}
.feature-card__desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Landing footer */
.landing__footer {
  text-align: center;
  padding: 20px 24px;
  font-size: 0.82rem;
  color: var(--text-light);
  border-top: 1px solid var(--border-light);
}

/* ===== Demo Banner ===== */
.demo-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--amber-pale);
  color: var(--brown-dark);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--amber-light);
  font-size: 0.88rem;
}
.demo-banner__icon {
  font-size: 1.1rem;
}
.demo-banner__text {
  font-weight: 500;
  color: var(--brown-mid);
}
.demo-banner__cta {
  background: var(--green-deep) !important;
  color: white !important;
  font-weight: 600;
  white-space: nowrap;
  padding: 6px 18px !important;
  border-radius: var(--radius-full) !important;
  font-size: 0.85rem !important;
  transition: all var(--transition-fast) !important;
}
.demo-banner__cta:hover {
  background: var(--green-mid) !important;
  box-shadow: var(--shadow-md) !important;
}
@media (max-width: 480px) {
  .demo-banner { flex-direction: column; text-align: center; gap: 8px; padding: 10px 16px; }
  .demo-banner__text { font-size: 0.82rem; }
}

/* ===== Page Headers ===== */
.page-header {
  margin-bottom: 20px;
}
.page-header__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--brown-dark);
  letter-spacing: -0.01em;
}
.page-header__subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Section Divider ===== */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  color: var(--text-light);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
