/* ═══════════════════════════════════════════
   ROOTZ v5 · Design System
   Paleta: tierra cálida + verde bosque + crema
   Tipografía: Montserrat
═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,600;1,700&display=swap');

:root {
  /* Colores principales */
  --earth:       #c2854a;
  --earth-deep:  #8b6914;
  --earth-soft:  #f5e6d3;
  --earth-pale:  #fdf6ee;
  --forest:      #3a7d44;
  --forest-deep: #2d6a35;
  --forest-soft: #d4edd9;
  --forest-pale: #f0f9f1;
  --bark:        #6b4c3b;
  --cream:       #fdf8f2;
  --cream-warm:  #f9f1e6;

  /* Neutros */
  --text:        #2c1f14;
  --text-soft:   #6b5a4e;
  --text-faint:  #a0907e;
  --border:      rgba(107, 76, 59, 0.12);
  --border-warm: rgba(194, 133, 74, 0.22);
  --surface:     rgba(255, 252, 248, 0.92);
  --surface-strong: #ffffff;
  --surface-muted:  #f9f4ef;

  /* Sombras */
  --shadow-sm: 0 4px 20px rgba(107, 76, 59, 0.07);
  --shadow-md: 0 12px 40px rgba(107, 76, 59, 0.10);
  --shadow-lg: 0 24px 60px rgba(107, 76, 59, 0.14);
  --shadow-warm: 0 16px 40px rgba(194, 133, 74, 0.18);

  /* Radios */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 36px;

  /* Árbol visual */
  --node-width: 280px;
  --node-height: 152px;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: 'Montserrat', sans-serif;
  background-color: var(--cream);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; }
a { color: inherit; }

input, textarea, select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 13px 16px;
  background: #fff;
  color: var(--text);
  transition: border-color .18s, box-shadow .18s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--earth);
  box-shadow: 0 0 0 4px rgba(194, 133, 74, 0.14);
}

textarea { resize: vertical; }
.hidden { display: none !important; }
.page { min-height: 100vh; }

/* ─── TEXTURA DE FONDO ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 10% 0%, rgba(194, 133, 74, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(58, 125, 68, 0.10) 0%, transparent 60%),
    linear-gradient(180deg, var(--cream) 0%, var(--cream-warm) 100%);
}

#landingView, #dashboardView, #editorView { position: relative; z-index: 1; }

/* ═══════════════════════════════════════════
   HEADERS
═══════════════════════════════════════════ */

.site-header,
.app-header,
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 36px;
}

.site-header, .app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(24px);
  background: rgba(253, 248, 242, 0.80);
  border-bottom: 1px solid var(--border);
}

.editor-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(24px);
}

/* ─── BRAND ─── */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(194, 133, 74, 0.16), rgba(58, 125, 68, 0.16));
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand-mark svg { width: 36px; height: 36px; }
.brand-mark.small { width: 44px; height: 44px; }
.brand-mark.small svg { width: 30px; height: 30px; }

.brand-name {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand.compact .brand-name { font-size: 1.25rem; }
.brand-sub { color: var(--text-soft); font-size: 0.85rem; font-weight: 400; }

.header-actions, .editor-controls, .editor-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ═══════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 11px 20px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--earth) 0%, var(--forest) 100%);
  box-shadow: var(--shadow-warm);
}
.btn-primary:hover { box-shadow: 0 20px 44px rgba(194, 133, 74, 0.28); }

.btn-secondary {
  color: var(--text);
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--border-warm); }

.btn-ghost {
  color: var(--text-soft);
  background: rgba(255,255,255,0.6);
  border: 1.5px solid var(--border);
}

.btn-outline {
  color: var(--text);
  background: transparent;
  border: 2px solid var(--border-warm);
}
.btn-outline:hover { background: rgba(194, 133, 74, 0.06); }

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #d63031, #e17055);
}

.btn-lg { padding: 14px 26px; font-size: 1rem; font-weight: 700; }
.w-full { width: 100%; justify-content: center; }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ─── EYEBROW ─── */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--forest-deep);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

/* ═══════════════════════════════════════════
   LANDING PAGE
═══════════════════════════════════════════ */

.landing-main {
  padding: 0 36px 0;
  overflow-x: hidden;
}

/* ─── HERO ─── */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 48px;
  align-items: center;
  padding: 56px 0 64px;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: -20px;
  left: -80px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(194, 133, 74, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-copy .eyebrow { margin-bottom: 18px; }

.hero-copy h1 {
  margin: 0 0 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(2.6rem, 4vw, 4.4rem);
  font-weight: 900;
  line-height: 1.06;
  letter-spacing: -0.03em;
  max-width: 14ch;
  color: var(--text);
}

.hero-copy h1 em {
  font-style: italic;
  color: var(--earth);
}

.hero-copy > p {
  max-width: 56ch;
  color: var(--text-soft);
  line-height: 1.78;
  font-size: 1.04rem;
  font-weight: 400;
}

.hero-actions {
  display: flex;
  gap: 14px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.hero-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.hero-trust span {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* ─── HERO VISUAL ─── */
.hero-visual {
  position: relative;
  display: flex;
  justify-content: center;
}

.preview-shell {
  width: 100%;
  max-width: 600px;
  border-radius: 24px;
  overflow: hidden;
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-lg), 0 0 0 8px rgba(194, 133, 74, 0.06);
}

.preview-browser-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.browser-dots {
  display: flex;
  gap: 6px;
}

.browser-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-warm);
}

.browser-url {
  flex: 1;
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-soft);
}

.preview-tree {
  position: relative;
  height: 340px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(194,133,74,.05) 0%, transparent 70%),
    linear-gradient(180deg, var(--earth-pale), #fff);
  overflow: hidden;
}

.preview-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.preview-node {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  min-width: 160px;
  transition: box-shadow .2s;
}

.preview-node.active-node {
  border-color: var(--earth);
  box-shadow: 0 0 0 3px rgba(194,133,74,.15), var(--shadow-md);
}

/* Positioning */
.preview-node.gen1.left  { left: 20px; top: 46px; }
.preview-node.gen1.right { right: 20px; top: 46px; }
.preview-node.gen2.center { left: 50%; top: 148px; transform: translateX(-50%); }
.preview-node.gen3.left  { left: 24px; bottom: 34px; }
.preview-node.gen3.right { right: 24px; bottom: 34px; }

.pn-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.pn-info strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.pn-info span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-soft);
}

.preview-stats {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
}

.pstat {
  flex: 1;
  padding: 14px 16px;
  text-align: center;
  border-right: 1px solid var(--border);
}

.pstat:last-child { border-right: none; }

.pstat strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.pstat span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-soft);
  margin-top: 2px;
}

.pstat-accent strong { color: var(--forest-deep); }

/* ─── FLOATING DECORATIONS ─── */
.hero-float {
  position: absolute;
  font-size: 1.6rem;
  opacity: 0.55;
  animation: floatBob 6s ease-in-out infinite;
  pointer-events: none;
}

.f1 { top: 10%; right: -20px; animation-delay: 0s; }
.f2 { bottom: 20%; right: -30px; animation-delay: 2s; font-size: 1.2rem; opacity: .4; }
.f3 { top: -10px; left: 50%; animation-delay: 4s; font-size: 1rem; opacity: .5; }

@keyframes floatBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33%       { transform: translateY(-10px) rotate(3deg); }
  66%       { transform: translateY(6px) rotate(-2deg); }
}

/* ─── FEATURES ─── */
.features-section {
  padding: 48px 0 56px;
}

.features-header {
  text-align: center;
  margin-bottom: 40px;
}

.features-header h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 12px 0 0;
  color: var(--text);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.feature-card {
  padding: 26px 22px;
  border-radius: var(--r-lg);
  border: 1.5px solid transparent;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity .2s;
  background: linear-gradient(135deg, rgba(255,255,255,.3), transparent);
}

.feature-card:hover { transform: translateY(-4px); }
.feature-card:hover::before { opacity: 1; }

.fc-warm  { background: linear-gradient(135deg, var(--earth-soft), #fffaf5); border-color: rgba(194,133,74,.2); }
.fc-green { background: linear-gradient(135deg, var(--forest-soft), #f0fdf4); border-color: rgba(58,125,68,.2); }
.fc-earth { background: linear-gradient(135deg, #fdf0e0, #fff9f2); border-color: rgba(139,105,20,.18); }
.fc-sage  { background: linear-gradient(135deg, #e8f5e2, #f5fff5); border-color: rgba(45,106,53,.18); }

.fc-icon { font-size: 2rem; margin-bottom: 14px; }

.feature-card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.feature-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.65;
  font-size: 0.9rem;
}

/* ─── CTA BAND ─── */
.cta-band {
  margin: 0 -36px;
  padding: 0 36px 80px;
}

.cta-band-inner {
  position: relative;
  background: linear-gradient(135deg, var(--text) 0%, var(--bark) 50%, var(--forest-deep) 100%);
  border-radius: var(--r-xl);
  padding: 60px 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.cta-band-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 80% at 0% 50%, rgba(194,133,74,.15) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 100% 50%, rgba(58,125,68,.15) 0%, transparent 60%);
  pointer-events: none;
}

.cta-leaf-deco {
  position: absolute;
  top: -20px;
  left: 30px;
  font-size: 5rem;
  opacity: 0.08;
  transform: rotate(-15deg);
  pointer-events: none;
}

.cta-content {
  position: relative;
  z-index: 1;
  max-width: 580px;
}

.cta-content h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(1.9rem, 3vw, 2.8rem);
  font-weight: 700;
  color: #fff;
  margin: 0 0 14px;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.cta-content h2 em {
  font-style: italic;
  color: #e8c49a;
}

.cta-content p {
  color: rgba(255,255,255,.75);
  line-height: 1.7;
  margin: 0 0 28px;
  font-size: 1rem;
}

.cta-content .btn-primary {
  background: linear-gradient(135deg, #e8c49a, #c2854a);
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0,0,0,.3);
}

.cta-visual {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.cta-tree-icon {
  width: 110px;
  height: 110px;
  background: rgba(255,255,255,.08);
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 16px rgba(255,255,255,.04);
}

.cta-tree-icon svg { width: 64px; height: 64px; }

/* ─── FOOTER ─── */
.site-footer {
  position: relative;
  z-index: 1;
  padding: 28px 36px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
}

.footer-brand .brand-name {
  font-size: 1rem;
  font-family: 'Montserrat', sans-serif;
}

.footer-brand span:last-child { color: var(--text-soft); font-size: 0.85rem; }

.site-footer > p {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.84rem;
}

/* ═══════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════ */

.dashboard-main { padding: 24px 36px 40px; }

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 24px;
}

.dashboard-hero .eyebrow { margin-bottom: 10px; }

.dashboard-hero h2 {
  margin: 0 0 10px;
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(1.8rem, 2.4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.08;
}

.dashboard-hero p {
  margin: 0;
  color: var(--text-soft);
  max-width: 54ch;
  line-height: 1.68;
  font-size: 0.95rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 12px;
  min-width: 320px;
}

.summary-card {
  padding: 18px 20px;
  border-radius: var(--r-md);
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.summary-card span {
  color: var(--text-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2.2rem;
  letter-spacing: -0.04em;
  font-family: 'Montserrat', sans-serif;
  color: var(--earth-deep);
}

.dashboard-toolbar { margin-bottom: 20px; }

.tree-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

/* ─── TREE CARD ─── */
.tree-card {
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
}

.tree-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tree-card-hero {
  padding: 22px 20px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--tree-color, var(--earth)), rgba(45, 106, 53, 0.92));
  position: relative;
  overflow: hidden;
}

.tree-card-hero::after {
  content: '🌳';
  position: absolute;
  right: 14px;
  bottom: -6px;
  font-size: 3.5rem;
  opacity: 0.12;
  pointer-events: none;
}

.tree-card-hero h3 { margin: 0; font-size: 1.18rem; font-weight: 700; }

.tree-card-hero p {
  margin: 7px 0 0;
  opacity: 0.88;
  font-size: 0.88rem;
  line-height: 1.55;
}

.tree-card-body {
  padding: 16px 18px 18px;
  display: grid;
  gap: 14px;
  flex: 1;
}

.tree-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tree-meta div {
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-muted);
}

.tree-meta span {
  display: block;
  color: var(--text-faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}

.tree-meta strong {
  display: block;
  margin-top: 3px;
  font-weight: 700;
}

.tree-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.empty-dashboard {
  padding: 48px;
  border-radius: var(--r-lg);
  text-align: center;
  background: rgba(255,255,255,.9);
  border: 2px dashed var(--border-warm);
  color: var(--text-soft);
}

/* ═══════════════════════════════════════════
   EDITOR
═══════════════════════════════════════════ */

.editor-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.editor-sub { color: var(--text-soft); font-size: 0.88rem; }

.editor-main {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 86px);
}

.editor-sidebar {
  padding: 20px 16px 24px 22px;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.5);
}

.sidebar-card {
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 14px;
  background: rgba(255,255,255,0.9);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.sidebar-card.accent {
  background: linear-gradient(135deg, rgba(194,133,74,.9), rgba(58,125,68,.85));
  color: #fff;
  border-color: transparent;
}

.sidebar-card.accent .eyebrow { color: rgba(255,255,255,.8); }
.sidebar-card.accent p { color: rgba(255,255,255,.88); margin: 6px 0 0; font-size: 0.88rem; }
.sidebar-card h3, .sidebar-card h4 { margin: 0; }
.sidebar-card h3 { font-family: 'Montserrat', sans-serif; font-size: 1.15rem; }
.sidebar-card h4 { font-size: 0.95rem; }
.sidebar-card p { color: var(--text-soft); line-height: 1.6; }

.sidebar-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stats-list { display: grid; gap: 10px; }

.stats-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-muted);
}

.stats-list span { color: var(--text-soft); font-size: 0.88rem; }

.member-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.member-list-item {
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.member-list-item:hover { background: rgba(194,133,74,.08); }

.member-list-item.active {
  border-color: rgba(194,133,74,.4);
  background: rgba(194,133,74,.1);
}

.member-list-meta { display: grid; gap: 3px; }
.member-list-meta strong { font-size: 0.88rem; }
.member-list-meta span { color: var(--text-soft); font-size: 0.78rem; }

.member-list-item button {
  padding: 7px 11px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ─── CANVAS ─── */
.canvas-section {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(107, 76, 59, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(107, 76, 59, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,.85), rgba(255,255,255,.9));
  background-size: 32px 32px, 32px 32px, auto;
}

.canvas-hint {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 5;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
  max-width: calc(100% - 32px);
}

.tree-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}

.tree-viewport.dragging { cursor: grabbing; }

.tree-stage {
  position: absolute;
  inset: 0 auto auto 0;
  transform-origin: top left;
  min-width: 1000px;
  min-height: 780px;
  user-select: none;
}

.tree-stage svg.connection-layer {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}

/* ─── NODE CARDS ─── */
.node-card {
  position: absolute;
  width: var(--node-width);
  min-height: var(--node-height);
  padding: 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.96);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  overflow: hidden;
}

.node-gender-corner {
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 28px 28px 0;
  border-color: transparent;
}

.node-gender-corner.gender-f {
  border-right-color: #f9a8d4;
}

.node-gender-corner.gender-m {
  border-right-color: #93c5fd;
}

.node-gender-corner.gender-n {
  border-right-color: #d1d5db;
}

.node-card:hover { box-shadow: var(--shadow-lg); }

.node-card.active {
  border-color: var(--earth);
  box-shadow: 0 0 0 4px rgba(194, 133, 74, 0.14), var(--shadow-md);
}

.node-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.node-avatar {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  flex: 0 0 50px;
  background: linear-gradient(135deg, var(--earth-soft), var(--forest-soft));
  color: var(--forest-deep);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  overflow: hidden;
}

.node-avatar img { width: 100%; height: 100%; object-fit: cover; }

.node-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
}

.node-rel-label {
  display: inline-block;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(194, 133, 74, 0.15);
  color: var(--earth-deep);
  letter-spacing: 0.03em;
}

.node-meta { color: var(--text-soft); font-size: 0.82rem; line-height: 1.5; }

.node-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.node-tag {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface-muted);
  color: var(--text-soft);
}

.node-actions { display: flex; flex-wrap: wrap; gap: 7px; }

.node-actions button {
  padding: 8px 11px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}

.node-actions button.primary-action {
  background: rgba(194, 133, 74, 0.12);
  border-color: rgba(194, 133, 74, 0.25);
  color: var(--earth-deep);
}

.node-actions button:hover { background: var(--earth-soft); border-color: var(--earth); }

/* Empty state */
.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
  min-height: 100%;
}

.empty-state-card {
  max-width: 520px;
  padding: 30px;
  border-radius: var(--r-lg);
  background: rgba(255,255,255,.94);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
}

.empty-state-card h3 { margin: 0 0 10px; font-family: 'Montserrat', sans-serif; font-size: 1.5rem; }
.empty-state-card p { margin: 0 0 22px; color: var(--text-soft); line-height: 1.7; }

/* ─── CONNECTION PATHS ─── */
.connection-path {
  fill: none;
  stroke: rgba(58, 125, 68, 0.55);
  stroke-width: 3;
  stroke-linecap: round;
}

.connection-spouse {
  fill: none;
  stroke: rgba(194, 133, 74, 0.6);
  stroke-width: 2.5;
  stroke-dasharray: 8 5;
  stroke-linecap: round;
}

/* ═══════════════════════════════════════════
   MODALS
═══════════════════════════════════════════ */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  background: rgba(44, 31, 20, 0.45);
  backdrop-filter: blur(12px);
  z-index: 40;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-card {
  position: relative;
  width: min(100%, 560px);
  border-radius: var(--r-xl);
  padding: 28px;
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-lg);
  margin: auto;
  flex-shrink: 0;
}

.modal-card h3 {
  margin: 0 0 6px;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.modal-card > p {
  margin: 0 0 18px;
  color: var(--text-soft);
  line-height: 1.6;
  font-size: 0.92rem;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  transition: background .15s;
}

.modal-close:hover { background: var(--earth-soft); color: var(--earth-deep); }

/* ─── AUTH MODAL ─── */
.auth-card { max-width: 480px; }

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.auth-tab {
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background .15s, color .15s;
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--earth-soft), var(--forest-soft));
  color: var(--text);
}

.auth-panel { display: none; gap: 13px; }
.auth-panel.active { display: grid; }
.auth-panel h3 { font-family: 'Montserrat', sans-serif; font-size: 1.35rem; margin: 0 0 4px; }
.auth-panel > p { color: var(--text-soft); margin: 0 0 6px; font-size: 0.9rem; line-height: 1.6; }

/* ─── TREE MODAL (MEJORADO) ─── */
.tree-modal-card {
  max-width: 520px;
  background: linear-gradient(180deg, #fff 0%, var(--earth-pale) 100%);
}

.tree-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1.5px solid var(--border);
}

.tree-modal-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--earth-soft), var(--forest-soft));
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.tree-modal-header h3 {
  margin: 0 0 4px;
  font-size: 1.4rem;
}

.tree-modal-sub {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.tree-form-body {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.field-label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-soft);
}

.field-label > span { color: var(--text); }

.field-label small {
  color: var(--text-faint);
  font-size: 0.78rem;
  font-weight: 400;
}

.field-input {
  border-radius: var(--r-sm) !important;
}

/* ─── COLOR PICKER ─── */
.color-picker-section { display: grid; gap: 10px; }

.field-label-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.color-palette {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-swatch {
  cursor: pointer;
}

.color-swatch input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.swatch-dot {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2.5px solid transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  transition: transform .15s, border-color .15s, box-shadow .15s;
  position: relative;
}

.swatch-dot::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0);
  transition: background .15s;
}

.color-swatch input:checked + .swatch-dot {
  border-color: var(--text);
  transform: scale(1.15);
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}

.color-swatch input:checked + .swatch-dot::after {
  background: rgba(255,255,255,.25);
}

.color-swatch:hover .swatch-dot { transform: scale(1.1); }

/* ─── TREE SUBMIT BUTTON ─── */
.btn-tree-submit {
  border-radius: var(--r-sm) !important;
  padding: 15px 20px !important;
  font-size: 1rem !important;
  background: linear-gradient(135deg, var(--earth) 0%, var(--forest) 100%);
  box-shadow: var(--shadow-warm);
  margin-top: 4px;
}

/* ─── FORM COMMON ─── */
.stack-form { display: grid; gap: 14px; }

.auth-panel label,
.stack-form label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 600;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.member-modal-card { width: min(100%, 720px); }
.member-modal-hint { margin-bottom: 14px; font-size: 0.9rem; }

/* ─── UI COMPONENTS ─── */
.user-chip {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  border: 1.5px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
}

.search-input {
  background: rgba(255,255,255,.95);
  border-radius: 999px;
  padding: 13px 18px;
  border: 1.5px solid var(--border);
}

.search-input.compact {
  width: 230px;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* ─── TOAST ─── */
#toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
}

.toast-item {
  min-width: 280px;
  max-width: 400px;
  padding: 14px 16px;
  border-radius: 16px;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: toastIn .22s ease;
  font-size: 0.9rem;
  font-weight: 500;
}

.toast-item.success { background: linear-gradient(135deg, #2d6a35, #3a7d44); }
.toast-item.error   { background: linear-gradient(135deg, #b22222, #d63031); }
.toast-item.info    { background: linear-gradient(135deg, #8b6914, #c2854a); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── SHARE MODAL ─── */
.share-modal-card { max-width: 620px; }

.share-status-panel {
  display: grid;
  gap: 5px;
  padding: 15px 18px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--earth-soft), var(--forest-soft));
  border: 1.5px solid var(--border-warm);
  margin: 16px 0;
}

.share-status-panel strong { font-size: 0.98rem; }
.share-status-panel span  { color: var(--text-soft); font-size: 0.88rem; }

.share-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

/* ─── DEBUG ─── */
.debug-link {
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 0.84rem;
  line-height: 1.5;
  word-break: break-word;
}

.debug-link a { color: var(--earth-deep); font-weight: 700; }

.debug-token {
  display: block;
  margin: 10px 0;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: rgba(194, 133, 74, 0.1);
  border: 1.5px dashed var(--border-warm);
  color: var(--earth-deep);
  font-weight: 700;
  font-size: 0.9rem;
}

.debug-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.mini-action {
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 0.82rem;
}

/* Public view */
.public-view .editor-header { background: rgba(255,255,255,.88); }

.public-view .canvas-hint {
  background: linear-gradient(135deg, var(--earth-soft), var(--forest-soft));
  border: 1px solid var(--border-warm);
}

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */

@media (max-width: 1200px) {
  .hero { grid-template-columns: 1fr; gap: 40px; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-hero { flex-direction: column; align-items: flex-start; }
  .summary-grid { min-width: 0; width: 100%; }
  .editor-main { grid-template-columns: 1fr; }
  .editor-sidebar { display: none; }
}

@media (max-width: 860px) {
  body { overflow: auto; }

  .site-header, .app-header, .editor-header {
    padding: 16px 20px;
    flex-wrap: wrap;
  }

  .landing-main, .dashboard-main {
    padding-left: 20px;
    padding-right: 20px;
  }

  .cta-band { margin: 0 -20px; padding: 0 20px 60px; }
  .cta-band-inner { padding: 36px 28px; flex-direction: column; }
  .cta-visual { display: none; }

  .feature-grid { grid-template-columns: 1fr; }

  .hero-copy h1 { font-size: 2.4rem; }

  .preview-node { min-width: 130px; }
  .preview-node.gen1.left  { left: 10px; }
  .preview-node.gen1.right { right: 10px; }
  .preview-node.gen3.left  { left: 10px; }
  .preview-node.gen3.right { right: 10px; }

  .editor-controls { width: 100%; flex-wrap: wrap; }
  .search-input.compact { width: 100%; }

  .two-col { grid-template-columns: 1fr; }
  .modal {
    padding: 12px;
    padding-bottom: 32px;
    align-items: flex-start;
  }
  .modal-card {
    padding: 20px 16px;
    border-radius: var(--r-lg);
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  .member-modal-card { width: 100%; max-width: 100%; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .btn-tree-submit { font-size: 0.95rem !important; }

  #toast { left: 12px; right: 12px; top: 12px; }
  .toast-item { min-width: 0; max-width: none; }
}

@media (max-width: 720px) {
  .share-actions-grid { grid-template-columns: 1fr; }
}

.connect-modal-card {
  max-width: 480px;
}

.connection-path {
  stroke-width: 3;
}

.connection-spouse {
  stroke-width: 2.5;
}

@media (max-width: 768px) {
  .connection-path { stroke-width: 3.5; stroke: rgba(58, 125, 68, 0.7); }
  .connection-spouse { stroke-width: 3; stroke: rgba(194, 133, 74, 0.75); }
}

@media (max-width: 480px) {
  .hero-copy h1 { font-size: 1.9rem; }
  .hero-trust { gap: 6px; }
  .hero-trust span { font-size: 0.78rem; padding: 6px 10px; }
  .auth-tabs { gap: 6px; }
  .auth-tab { padding: 8px 10px; font-size: 0.82rem; }
  .node-card { width: 240px; min-height: 130px; padding: 12px; }
  .editor-header { gap: 8px; }
  .editor-controls { gap: 6px; }
  .editor-controls .btn { padding: 9px 12px; font-size: 0.82rem; }
  .tree-modal-card { padding: 18px 14px; }
  .color-palette { gap: 8px; }
  .swatch-dot { width: 30px; height: 30px; }
  .dashboard-hero h2 { font-size: 1.6rem; }
}
