/* ============================================
   FamilyTree — Main Stylesheet
   Identidad: clásica, cálida, atemporal
   ============================================ */

:root {
  /* Paleta principal — tinta, vino, arena, marfil */
  --ink-900:    #211b14;
  --ink-700:    #2c2418;
  --ink-500:    #5c4a3a;
  --ink-300:    #8a7560;
  --sand-100:   #f5f0e6;
  --sand-200:   #ede4d3;
  --sand-300:   #d9cfba;
  --wine-900:   #401a1a;
  --wine-700:   #6b2c2c;
  --wine-600:   #7d3434;
  --wine-100:   #f3e3e0;
  --wine-50:    #faf3f1;
  --cream:      #fdfbf6;
  --white:      #ffffff;

  /* Compatibilidad con nombres usados en el HTML/JS existente */
  --green-50:   var(--wine-50);
  --green-100:  var(--wine-100);
  --green-200:  #e6c9c4;
  --green-300:  #d4a8a1;
  --green-500:  var(--wine-600);
  --green-600:  var(--wine-700);
  --green-700:  var(--wine-900);
  --green-800:  var(--wine-900);
  --blue-500:   #5b6f8c;

  --gray-50:    var(--sand-100);
  --gray-100:   var(--sand-200);
  --gray-200:   var(--sand-300);
  --gray-300:   #c2b6a0;
  --gray-400:   var(--ink-300);
  --gray-500:   var(--ink-500);
  --gray-700:   var(--ink-700);
  --gray-900:   var(--ink-900);

  --red-500:    #a4453f;
  --red-600:    #8a3631;

  --white:      var(--white);

  --shadow-sm:  0 1px 2px rgba(33,27,20,.06);
  --shadow:     0 3px 10px rgba(33,27,20,.08);
  --shadow-lg:  0 14px 32px rgba(33,27,20,.12);

  --radius:     8px;
  --radius-lg:  16px;

  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body:    'Inter', -apple-system, sans-serif;
  --font-ui:      'Inter', -apple-system, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  font-size: 17px;
  color: var(--ink-700);
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 20% 15%, rgba(217,207,186,.35) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(217,207,186,.3) 0%, transparent 50%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--wine-700); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: .01em; }

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  background: var(--cream);
  border-bottom: 1px solid var(--sand-300);
  position: sticky; top: 0; z-index: 100;
  box-shadow: none;
}
.nav-container {
  max-width: 1200px; margin: 0 auto;
  padding: 0 1.5rem;
  height: 76px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-logo {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none; color: var(--ink-900);
}
.logo-icon {
  font-family: var(--font-display);
  font-size: 1.3rem;
  width: 34px; height: 34px;
  border: 1px solid var(--wine-700);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--wine-700);
}
.logo-icon-img {
  width: 38px; height: 38px;
  object-fit: contain;
}
.logo-text {
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 500;
  letter-spacing: .02em;
  color: var(--ink-900);
}
.nav-links { display: flex; align-items: center; gap: 1.25rem; }
.nav-link {
  color: var(--ink-700); font-weight: 500;
  font-size: .95rem;
  padding: .4rem .2rem; border-radius: 0;
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.nav-link:hover { border-bottom-color: var(--wine-700); text-decoration: none; background: none; }
.nav-user { color: var(--ink-500); font-size: .88rem; }
.btn-logout {
  background: none; border: 1px solid var(--sand-300);
  padding: .4rem .9rem; border-radius: 6px;
  cursor: pointer; font-size: .85rem; color: var(--ink-700);
  font-family: var(--font-ui);
  letter-spacing: .02em;
  transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--wine-700); color: var(--wine-700); background: none; }
.btn-nav-primary {
  background: var(--wine-700); color: var(--cream);
  padding: .5rem 1.3rem; border-radius: 6px;
  font-weight: 500; font-size: .88rem;
  letter-spacing: .02em;
  border: 1px solid var(--wine-700);
  box-shadow: 0 2px 8px rgba(107,44,44,.15);
}
.btn-nav-primary:hover { background: var(--wine-900); border-color: var(--wine-900); text-decoration: none; }
.btn-nav-outline {
  border: 1px solid var(--sand-300); color: var(--ink-700);
  padding: .5rem 1.3rem; border-radius: 6px;
  font-weight: 500; font-size: .88rem;
  letter-spacing: .02em;
}
.btn-nav-outline:hover { background: var(--sand-100); border-color: var(--ink-300); text-decoration: none; }

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--wine-700); color: var(--cream);
  padding: .7rem 1.6rem; border-radius: 6px;
  font-weight: 500; font-size: .92rem; border: 1px solid var(--wine-700);
  font-family: var(--font-ui); letter-spacing: .02em;
  cursor: pointer; transition: background .2s, box-shadow .2s, transform .15s;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(107,44,44,.18);
}
.btn-primary:hover { background: var(--wine-900); border-color: var(--wine-900); text-decoration: none; color: var(--cream); box-shadow: 0 4px 14px rgba(107,44,44,.25); transform: translateY(-1px); }
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cream); color: var(--ink-700);
  padding: .7rem 1.6rem; border-radius: 6px;
  font-weight: 500; font-size: .92rem;
  font-family: var(--font-ui); letter-spacing: .02em;
  border: 1px solid var(--sand-300);
  cursor: pointer; transition: all .2s; text-decoration: none;
}
.btn-outline:hover { background: var(--sand-100); border-color: var(--ink-300); text-decoration: none; transform: translateY(-1px); }
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cream); color: var(--red-600);
  padding: .45rem 1rem; border-radius: var(--radius);
  font-weight: 500; font-size: .85rem; border: 1px solid var(--red-600);
  font-family: var(--font-ui);
  cursor: pointer; transition: background .15s, color .15s;
}
.btn-danger:hover { background: var(--red-600); color: var(--cream); }
.btn-lg { padding: .85rem 2.2rem; font-size: 1rem; }
.btn-sm { padding: .4rem .9rem; font-size: .82rem; }
.btn-full { width: 100%; }

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: .85rem 1.1rem; border-radius: var(--radius);
  margin-bottom: 1rem; font-size: .92rem;
  border-left: 3px solid transparent;
}
.alert-error { background: var(--wine-50); color: var(--wine-900); border-left-color: var(--red-600); }
.alert-success { background: var(--sand-100); color: var(--ink-900); border-left-color: var(--wine-700); }

/* ============================================
   FORMS
   ============================================ */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label {
  font-size: .82rem; font-weight: 500; color: var(--ink-500);
  text-transform: uppercase; letter-spacing: .06em;
  font-family: var(--font-ui);
}
.form-input {
  border: 1px solid var(--sand-300); border-radius: 10px;
  padding: .65rem .9rem; font-size: .95rem; width: 100%;
  transition: border-color .15s, box-shadow .15s;
  background: var(--white); color: var(--ink-900);
  font-family: var(--font-ui);
}
.form-input:focus {
  outline: none; border-color: var(--wine-700);
  box-shadow: 0 0 0 3px var(--wine-50);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
textarea.form-input { resize: vertical; }

/* ============================================
   HOME PAGE
   ============================================ */
.home-page { overflow-x: hidden; }

.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 3.5rem;
  max-width: 1200px; margin: 0 auto;
  padding: 5.5rem 1.5rem 4.5rem;
  align-items: center; min-height: 78vh;
}
.hero-title {
  font-family: var(--font-display);
  font-size: 3rem; font-weight: 600; line-height: 1.2;
  color: var(--ink-900); margin-bottom: 1.5rem;
  position: relative;
  padding-bottom: 1.2rem;
}
.hero-title::after {
  content: '';
  position: absolute; left: 0; bottom: 0;
  width: 64px; height: 2px;
  background: var(--wine-600);
  border-radius: 2px;
}
.hero-subtitle {
  font-size: 1.15rem; color: var(--ink-500); margin-bottom: 2.2rem; line-height: 1.65;
  max-width: 480px;
}
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

.tree-preview {
  background: var(--white); border-radius: 24px;
  padding: 2rem; box-shadow: var(--shadow-lg);
  border: 1px solid var(--sand-300);
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
}
.tree-preview-img {
  max-width: 100%;
  width: 280px;
  display: block;
}
.preview-node {
  background: var(--sand-100); border: 1px solid var(--sand-300);
  padding: .65rem 1.4rem; border-radius: var(--radius);
  font-size: .88rem; font-weight: 500; color: var(--ink-700);
  font-family: var(--font-ui); letter-spacing: .01em;
}
.preview-node.root { background: var(--wine-700); color: var(--cream); border-color: var(--wine-700); }
.preview-node.you { background: var(--ink-700); color: var(--cream); border-color: var(--ink-700); }
.preview-row { display: flex; gap: 1rem; }
.preview-line { width: 1px; height: 22px; background: var(--sand-300); }

.features { background: var(--sand-100); padding: 5.5rem 1.5rem; }
.section-title {
  text-align: center; font-size: 2rem; font-weight: 600;
  margin-bottom: 3.5rem; color: var(--ink-900);
  position: relative; padding-bottom: 1.3rem;
}
.section-title::after {
  content: '';
  position: absolute; left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 56px; height: 2px;
  background: var(--wine-600);
  border-radius: 2px;
}
.features-grid {
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem;
}
.feature-card {
  background: var(--white); border-radius: 18px;
  padding: 2.2rem 1.8rem; text-align: center;
  border: 1px solid var(--sand-300); transition: box-shadow .25s, transform .2s, border-color .2s;
}
.feature-card:hover { box-shadow: var(--shadow-lg); border-color: var(--wine-600); transform: translateY(-3px); }
.feature-icon { font-size: 1.6rem; margin-bottom: 1.1rem; color: var(--wine-700); }
.feature-card h3 { font-size: 1.1rem; font-weight: 500; margin-bottom: .6rem; font-family: var(--font-display); }
.feature-card p { color: var(--ink-500); font-size: .92rem; line-height: 1.6; }

.cta-section {
  background: var(--ink-900); color: var(--cream);
  text-align: center; padding: 4.5rem 1.5rem;
}
.cta-section h2 { font-size: 2rem; font-weight: 500; margin-bottom: .85rem; }
.cta-section p { font-size: 1.05rem; margin-bottom: 2.2rem; opacity: .85; }
.cta-section .btn-primary { background: var(--cream); color: var(--ink-900); border-color: var(--cream); }
.cta-section .btn-primary:hover { background: var(--sand-200); border-color: var(--sand-200); }

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-page {
  background: var(--sand-100);
}
.auth-container {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 76px - 56px);
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--white); border-radius: 22px;
  padding: 3rem 2.5rem; width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--sand-300);
}
.auth-header { text-align: center; margin-bottom: 2.2rem; }
.auth-logo {
  font-family: var(--font-display); font-size: 1.4rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border: 1px solid var(--wine-700);
  border-radius: 50%; color: var(--wine-700);
}
.auth-logo-img {
  width: 64px; height: 64px;
  object-fit: contain;
  margin-bottom: .3rem;
}
.auth-header h1 { font-size: 1.5rem; font-weight: 500; margin: 1rem 0 .35rem; }
.auth-header p { color: var(--ink-500); font-size: .92rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.2rem; }
.auth-footer { text-align: center; margin-top: 1.7rem; font-size: .9rem; color: var(--ink-500); }

/* ============================================
   APP LAYOUT (Dashboard)
   ============================================ */
.app-page { display: flex; flex-direction: column; min-height: 100vh; }
.app-container { display: flex; flex: 1; max-width: 1300px; margin: 0 auto; width: 100%; padding: 0 1.5rem; gap: 2rem; }

.sidebar {
  width: 260px; flex-shrink: 0; padding: 1.5rem 0;
}
.sidebar-user {
  display: flex; align-items: center; gap: .85rem;
  padding: 1.1rem; background: var(--white);
  border-radius: var(--radius-lg); border: 1px solid var(--sand-300);
  margin-bottom: 1rem;
}
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--wine-700); color: var(--cream);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: 500; flex-shrink: 0;
  font-family: var(--font-display);
}
.sidebar-user-info { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-user-info strong { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sidebar-user-info small { color: var(--ink-300); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { display: flex; flex-direction: column; gap: .3rem; }
.sidebar-link {
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem 1rem; border-radius: var(--radius);
  color: var(--ink-700); font-size: .9rem; font-weight: 500;
  transition: background .15s; text-decoration: none;
}
.sidebar-link:hover, .sidebar-link.active {
  background: var(--sand-100); color: var(--wine-700); text-decoration: none;
}

.main-content { flex: 1; padding: 1.5rem 0; min-width: 0; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.7rem;
}
.page-header h1 { font-size: 1.6rem; font-weight: 500; }
.back-link { color: var(--ink-500); font-size: .9rem; margin-bottom: .5rem; display: inline-block; }

/* ============================================
   DASHBOARD — TREES GRID
   ============================================ */
.trees-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.tree-card {
  background: var(--white); border-radius: 18px;
  border: 1px solid var(--sand-300); padding: 1.6rem;
  display: flex; flex-direction: column; gap: .8rem;
  transition: box-shadow .25s, transform .2s, border-color .2s;
}
.tree-card:hover { box-shadow: var(--shadow-lg); border-color: var(--wine-600); transform: translateY(-2px); }
.tree-card-icon { font-size: 1.3rem; color: var(--wine-700); }
.tree-card-body h3 { font-size: 1.1rem; font-weight: 500; margin-bottom: .3rem; font-family: var(--font-display); }
.tree-desc { color: var(--ink-500); font-size: .85rem; }
.tree-card-body small { color: var(--ink-300); font-size: .78rem; display: block; }
.tree-card-members { margin-top: .25rem; }
.tree-card-members span {
  background: var(--sand-100); color: var(--ink-700);
  font-size: .76rem; padding: .25rem .7rem; border-radius: var(--radius); font-weight: 500;
  border: 1px solid var(--sand-300);
}
.tree-card-actions { display: flex; gap: .5rem; margin-top: auto; }

.empty-state {
  text-align: center; padding: 4.5rem 2rem;
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px dashed var(--sand-300);
}
.empty-icon { font-size: 2.2rem; margin-bottom: 1.1rem; color: var(--ink-300); }
.empty-state h2 { font-size: 1.3rem; margin-bottom: .6rem; }
.empty-state p { color: var(--ink-500); margin-bottom: 1.7rem; }

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(33,27,20,.55);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--white); border-radius: 20px;
  padding: 2.2rem; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--sand-300);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.6rem;
}
.modal-header h2 { font-size: 1.2rem; font-weight: 500; }
.modal-close {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: var(--ink-300); padding: .2rem .4rem;
  border-radius: var(--radius);
  font-family: var(--font-ui);
}
.modal-close:hover { color: var(--ink-900); background: var(--sand-100); }
.modal-form { display: flex; flex-direction: column; gap: 1rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: .5rem; }

/* ============================================
   TREE LAYOUT
   ============================================ */
.tree-page { overflow: hidden; }
.tree-layout {
  display: flex; height: calc(100vh - 76px); overflow: hidden;
}

.tree-sidebar {
  width: 300px; flex-shrink: 0;
  background: var(--white); border-right: 1px solid var(--sand-300);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.tree-sidebar-header {
  padding: 1.3rem; border-bottom: 1px solid var(--sand-300);
}
.tree-sidebar-header h2 { font-size: 1.15rem; font-weight: 500; margin: .5rem 0 .3rem; }
.tree-sidebar-desc { color: var(--ink-500); font-size: .85rem; }
.tree-sidebar-actions { padding: 1rem; border-bottom: 1px solid var(--sand-300); }

.members-list { flex: 1; overflow-y: auto; padding: 1rem; }
.members-list h3 { font-size: .8rem; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .8rem; font-family: var(--font-ui); }
.members-empty { color: var(--ink-300); font-size: .85rem; text-align: center; padding: 1rem 0; }

.member-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem; border-radius: var(--radius);
  cursor: pointer; transition: background .15s; margin-bottom: .25rem;
}
.member-item:hover { background: var(--sand-100); }
.member-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--sand-200); color: var(--ink-700);
  display: flex; align-items: center; justify-content: center;
  font-size: .88rem; font-weight: 500; font-family: var(--font-display);
}
.member-avatar.male { background: #e3e7ee; color: #364866; }
.member-avatar.female { background: var(--wine-100); color: var(--wine-900); }
.member-info { flex: 1; min-width: 0; }
.member-info strong { font-size: .88rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.member-info small { font-size: .76rem; color: var(--ink-300); }
.member-info .deceased { color: var(--ink-300); }
.member-actions { display: flex; gap: .25rem; opacity: 0; transition: opacity .15s; }
.member-item:hover .member-actions { opacity: 1; }
.icon-btn {
  background: none; border: none; cursor: pointer; padding: .25rem .35rem;
  border-radius: var(--radius); font-size: .9rem; line-height: 1; text-decoration: none;
  color: var(--ink-500);
}
.icon-btn:hover { background: var(--sand-200); color: var(--ink-900); }
.icon-btn.danger:hover { background: var(--wine-50); color: var(--red-600); }

.tree-canvas-area {
  flex: 1; position: relative; overflow: hidden;
  background: var(--sand-100);
}
#familyTreeCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.canvas-toolbar {
  position: absolute; top: 1rem; right: 1rem; z-index: 10;
  display: flex; align-items: center; gap: .5rem;
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--sand-300);
  padding: .4rem .6rem; box-shadow: var(--shadow);
}
.toolbar-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; padding: .2rem .5rem;
  border-radius: var(--radius); font-weight: 500; color: var(--ink-700);
  font-family: var(--font-ui);
}
.toolbar-btn:hover { background: var(--sand-100); }
.toolbar-hint { font-size: .74rem; color: var(--ink-300); }

.canvas-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.canvas-empty-content {
  text-align: center; background: var(--white);
  border-radius: var(--radius-lg); padding: 3rem;
  box-shadow: var(--shadow-lg); border: 1px solid var(--sand-300);
}
.canvas-empty-content span { font-size: 1.8rem; display: block; margin-bottom: 1.1rem; color: var(--ink-300); }
.canvas-empty-content p { color: var(--ink-500); margin-bottom: 1.6rem; }

/* Tooltip */
.person-tooltip {
  position: absolute; z-index: 50;
  background: var(--white); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow-lg);
  border: 1px solid var(--sand-300); min-width: 200px;
}
.tooltip-header { display: flex; gap: .75rem; align-items: center; margin-bottom: .75rem; }
.tooltip-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--wine-100); color: var(--wine-900);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 500; flex-shrink: 0;
  font-family: var(--font-display);
}
.tooltip-header strong { display: block; font-size: .9rem; }
.tooltip-header small { color: var(--ink-300); font-size: .8rem; }
.tooltip-actions { display: flex; gap: .5rem; }

/* ============================================
   PERSON FORM PAGE
   ============================================ */
.form-page { max-width: 720px; }
.form-card {
  background: var(--white); border-radius: 18px;
  border: 1px solid var(--sand-300); overflow: hidden;
}
.person-form { display: flex; flex-direction: column; }
.form-section { padding: 1.6rem; border-bottom: 1px solid var(--sand-200); }
.form-section h2 {
  font-size: .82rem; font-weight: 600; color: var(--wine-700);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 1.1rem;
  font-family: var(--font-ui);
}
.form-actions {
  display: flex; gap: .75rem; justify-content: flex-end;
  padding: 1.3rem 1.6rem;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  background: var(--ink-900); color: var(--ink-300);
  padding: 1.4rem; text-align: center; font-size: .85rem; margin-top: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: 1fr; text-align: center; min-height: auto; }
  .hero-actions { justify-content: center; }
  .hero-subtitle { margin-left: auto; margin-right: auto; }
  .hero-visual { display: none; }
}
@media (max-width: 768px) {
  .app-container { padding: 0 1rem; flex-direction: column; }
  .sidebar { width: 100%; }
  .tree-sidebar { width: 100%; max-height: 40vh; }
  .tree-layout { flex-direction: column; height: auto; }
  .tree-canvas-area { height: 60vh; }
  .form-row { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 2.1rem; }
}

/* ============================================
   MOBILE — ÁRBOL GENEALÓGICO (fix completo)
   ============================================ */

.mobile-toggle-bar {
  display: none;
}

@media (max-width: 768px) {

  .tree-page { overflow: auto; }
  .tree-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 76px);
    overflow: visible;
  }

  .tree-canvas-area {
    height: 55vh;
    min-height: 320px;
    position: relative;
    flex-shrink: 0;
    order: 1;
  }

  #familyTreeCanvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
  }

  .canvas-toolbar {
    top: .5rem;
    right: .5rem;
    padding: .3rem .4rem;
    gap: .3rem;
  }
  .toolbar-hint { display: none; }
  .toolbar-btn { font-size: .9rem; padding: .25rem .4rem; }

  .tree-sidebar {
    width: 100%;
    max-height: 45vh;
    min-height: 180px;
    order: 2;
    border-right: none;
    border-top: 1px solid var(--sand-300);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tree-sidebar-header { padding: .75rem 1rem; }
  .tree-sidebar-header h2 { font-size: 1rem; margin: .25rem 0; }

  .tree-sidebar-actions {
    padding: .75rem 1rem;
    display: flex;
    gap: .5rem;
    flex-direction: column;
  }

  .mobile-toggle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 1rem;
    background: var(--sand-100);
    border-bottom: 1px solid var(--sand-300);
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    color: var(--ink-700);
    user-select: none;
  }
  .mobile-toggle-bar:active { background: var(--sand-200); }
  .mobile-toggle-icon { font-size: 1rem; transition: transform .2s; }
  .mobile-toggle-icon.open { transform: rotate(180deg); }

  .members-list {
    padding: .75rem 1rem;
    overflow-y: auto;
  }
  .members-list.collapsed { display: none; }

  .member-item { padding: .5rem .6rem; }
  .member-avatar { width: 30px; height: 30px; font-size: .8rem; }
  .member-info strong { font-size: .82rem; }
  .member-info small { font-size: .72rem; }

  .member-actions { opacity: 1; }

  .person-tooltip {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.25rem;
    z-index: 300;
    box-shadow: 0 -4px 24px rgba(33,27,20,.18);
    min-width: unset;
  }

  .whatsapp-fab-container { bottom: 12px; right: 12px; }
  .fab-label { display: none; }
  .whatsapp-fab { padding: 13px; border-radius: 50%; }
  .whatsapp-fab-tooltip { display: none; }

  .share-modal {
    width: 96% !important;
    max-height: 90vh;
    overflow-y: auto;
  }
}

@media (max-width: 400px) {
  .tree-canvas-area { height: 50vh; min-height: 280px; }
  .tree-sidebar { max-height: 50vh; }
}
