/* Genealogía Sefardí — archival palette (not FamilySearch teal) */
:root {
  --bg: #f3efe6;
  --paper: #fffcf5;
  --ink: #2a2218;
  --muted: #6b5e4e;
  --line: #d4c7b0;
  --accent: #6b4423;
  --accent-dark: #4a2f18;
  --accent-soft: #e8dcc8;
  --ok: #2e5a3c;
  --err: #8b2e2e;
  --warn: #8a6d1d;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(42, 34, 24, 0.08);
  --font: "Source Serif 4", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

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

.site-header {
  background: var(--accent-dark);
  color: #f5efe4;
  border-bottom: 3px solid var(--accent);
}
.site-header a { color: #f5efe4; }
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}
.brand {
  font-family: var(--font);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none !important;
}
.brand span { opacity: 0.75; font-weight: 400; font-size: 0.85rem; margin-left: 0.4rem; }
.nav { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; font-size: 0.9rem; }
.nav a { opacity: 0.9; }
.nav a:hover { opacity: 1; text-decoration: underline; }
.user-chip { font-size: 0.8rem; opacity: 0.8; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

h1, h2, h3 {
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.25;
  color: var(--accent-dark);
}
h1 { font-size: 1.75rem; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1.05rem; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat .n { font-family: var(--font); font-size: 1.75rem; color: var(--accent); font-weight: 600; }
.stat .l { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid;
}
.flash.success { background: #e8f0ea; border-color: #9bb5a3; color: var(--ok); }
.flash.error { background: #f8eaea; border-color: #d4a5a5; color: var(--err); }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff !important;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none !important;
  font-family: var(--sans);
}
.btn:hover { background: var(--accent-dark); }
.btn-outline {
  background: transparent;
  color: var(--accent) !important;
  border: 1px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-soft); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-danger { background: var(--err); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.search-form { display: flex; gap: 0.4rem; flex: 1; max-width: 420px; }
.search-form input[type=search],
.search-form input[type=text] {
  flex: 1;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.75rem 0 0.25rem; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=file], select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hint { font-size: 0.8rem; color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--accent-soft);
}
tr:hover td { background: rgba(107, 68, 35, 0.04); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 2px solid var(--line);
  margin-bottom: 1rem;
}
.tabs a {
  padding: 0.5rem 0.9rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9rem;
}
.tabs a.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.probado { background: #d4e8da; color: var(--ok); }
.badge.pendiente { background: #f0e6c8; color: var(--warn); }
.badge.en_disputa { background: #f0d4d4; color: var(--err); }

.person-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}
.meta { color: var(--muted); font-size: 0.9rem; }
.meta strong { color: var(--ink); }

.timeline { border-left: 3px solid var(--accent-soft); padding-left: 1.25rem; margin: 1rem 0; }
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.55rem;
  top: 0.35rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--paper);
}
.timeline-date { font-size: 0.8rem; color: var(--muted); font-weight: 600; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.gallery-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.gallery-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: var(--accent-soft);
}
.gallery-card .body { padding: 0.75rem; }
.placeholder-media {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.85rem;
}

.media-viewer img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Pedigree */
.pedigree {
  overflow-x: auto;
  padding: 1rem 0;
}
.ped-gen {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.ped-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  min-width: 140px;
  max-width: 200px;
  text-align: center;
  box-shadow: var(--shadow);
}
.ped-card.root { border-color: var(--accent); border-width: 2px; }
.ped-card .name { font-family: var(--font); font-size: 0.95rem; font-weight: 600; }
.ped-card .dates { font-size: 0.75rem; color: var(--muted); }
.ped-card.spouse { border-style: dashed; opacity: 0.9; }
.ped-row { display: flex; justify-content: center; gap: 2rem; flex-wrap: wrap; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #3d2a1a 0%, #6b4423 40%, #f3efe6 40%);
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.login-box h1 { text-align: center; margin-bottom: 0.25rem; }
.login-box .sub { text-align: center; color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.empty { color: var(--muted); font-style: italic; padding: 1rem 0; }
.inline-form { display: inline; }
.rel-list { list-style: none; padding: 0; margin: 0; }
.rel-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

/* —— Landing —— */
.wrap-landing { max-width: none; padding: 0; }
.landing-hero {
  background: linear-gradient(165deg, #2a1a10 0%, #4a2f18 45%, #6b4423 70%, #f3efe6 70%);
  color: #f5efe4;
  padding: 3.5rem 1.25rem 4.5rem;
  text-align: center;
}
.landing-hero-inner { max-width: 720px; margin: 0 auto; }
.landing-hero h1 { color: #f5efe4; font-size: 2.4rem; margin-bottom: 0.5rem; }
.landing-hero .lede { font-size: 1.15rem; opacity: 0.92; line-height: 1.55; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; opacity: 0.8; margin-bottom: 0.75rem; }
.landing-ctas { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 1.75rem; }
.btn-lg { padding: 0.65rem 1.25rem; font-size: 1rem; }
.btn-outline-light {
  background: transparent;
  color: #f5efe4 !important;
  border: 1px solid #c4b59a;
}
.btn-outline-light:hover { background: rgba(255,255,255,0.1); }
.landing-section { max-width: 1100px; margin: 0 auto; padding: 2rem 1.25rem; }
.section-title { text-align: center; margin-bottom: 1.25rem; }
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: -3.5rem;
  position: relative;
  z-index: 1;
}
.feature-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 4px 16px rgba(42,34,24,0.08);
}
.feature-card h2 { margin-top: 0; font-size: 1.15rem; }
.about-block { padding-bottom: 3rem; }

.bio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.bio-card {
  display: flex; gap: 0.85rem; align-items: flex-start;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; text-decoration: none !important; color: inherit;
  box-shadow: var(--shadow);
}
.bio-card:hover { border-color: var(--accent); }
.bio-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); flex-shrink: 0; }

.bio-hero {
  display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start;
  margin-bottom: 1.25rem;
}
.bio-portrait {
  width: 180px; height: 180px; object-fit: cover;
  border-radius: 8px; border: 2px solid var(--accent);
  box-shadow: var(--shadow); background: var(--accent-soft);
}
.bio-sub { font-family: var(--font); color: var(--accent); margin: 0.25rem 0; }
.bio-body h3 { margin-top: 1.25rem; }
.cite-block blockquote {
  margin: 0; padding: 0.85rem 1rem; background: var(--accent-soft);
  border-left: 3px solid var(--accent); font-size: 0.95rem;
}

.lineage-chain { list-style: none; padding: 0; margin: 1rem 0 0; border-left: 3px solid var(--accent-soft); }
.lineage-step {
  position: relative; padding: 0.85rem 0 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.lineage-step::before {
  content: ""; position: absolute; left: -7px; top: 1.1rem;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--paper);
}
.lineage-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.25rem; }
.lineage-proofs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }

.archive-gallery .gallery-card { text-decoration: none !important; color: inherit; }

/* —— Archivo público atractivo —— */
.archive-hero {
  background: linear-gradient(135deg, #3d2a1a 0%, #6b4423 55%, #8a6240 100%);
  color: #f8f1e4;
  border-radius: 12px;
  padding: 2rem 1.75rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow);
}
.archive-hero h1 { color: #fff; margin: 0 0 .5rem; font-size: 2rem; }
.archive-hero p { margin: 0; opacity: .92; max-width: 40rem; }
.archive-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}
.archive-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none !important;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.archive-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(42,34,24,.14); }
.archive-card .cover {
  aspect-ratio: 4/3;
  background: #2a2218;
  overflow: hidden;
  position: relative;
}
.archive-card .cover img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.archive-card .cover .ribbon {
  position: absolute; left: .6rem; bottom: .6rem;
  background: rgba(42,34,24,.85); color: #f5efe4;
  font-size: .72rem; padding: .2rem .5rem; border-radius: 999px;
}
.archive-card .body { padding: .9rem 1rem 1.1rem; }
.archive-card .who {
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-dark);
  line-height: 1.3;
  margin: 0 0 .35rem;
}
.archive-card .what { font-size: .88rem; color: var(--muted); margin: 0 0 .5rem; }
.archive-card .meta-row { display:flex; flex-wrap:wrap; gap:.4rem; align-items:center; }
.doc-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 800px) { .doc-hero { grid-template-columns: 1fr; } }
.doc-hero .portrait {
  border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
  background: #1f1812; min-height: 280px;
}
.doc-hero .portrait img { width: 100%; height: 100%; object-fit: cover; display:block; max-height: 420px; }
.who-chip {
  display: inline-block; background: var(--accent-soft); color: var(--accent-dark);
  font-family: var(--font); font-weight: 600; padding: .35rem .75rem; border-radius: 999px;
  margin: 0 0 .75rem;
}

/* Consultation-only media viewer */
.media-viewer {
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}
.media-viewer img,
.media-viewer object,
.media-viewer iframe {
  max-width: 100%;
  pointer-events: auto;
}
.media-viewer img {
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-user-drag: none;
}
.media-consult-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.65rem;
  padding: 0.35rem 0.65rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  display: inline-block;
}
.pdf-cover-preview {
  margin-bottom: 0.75rem;
  max-width: 280px;
}
.pdf-cover-preview img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.pdf-object, .pdf-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1f1812;
}

/* Empty-state tree builder */
.empty-state-card {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 520px;
  margin: 1.5rem auto;
}
.empty-state-card h2 {
  margin-top: 0;
}
.empty-state-card .lead {
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.family-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}
.family-actions .card {
  margin: 0;
  padding: 0.9rem;
}
.family-actions h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.cta-banner {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.cta-banner p { margin: 0; }

/* Archive / global search */
.archive-search {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  margin: 0 0 1.25rem;
  padding: 1rem;
  background: #2a1c12;
  border: 1px solid #5a3d28;
  border-radius: 12px;
}
.archive-search input[type="search"] {
  flex: 1 1 220px;
  min-width: 0;
  padding: .75rem 1rem;
  border-radius: 8px;
  border: 1px solid #7a5640;
  background: #f7f1e6;
  color: #1a120c;
  font-size: 1.05rem;
}
.archive-search input[type="search"]:focus {
  outline: 2px solid #c4a574;
  border-color: #c4a574;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.list-plain { list-style: none; padding: 0; }
.list-plain li { padding: .35rem 0; border-bottom: 1px solid #e8dfd0; }

/* —— Adjuntar fuente (sugerencias estilo FamilySearch) —— */
.attach-source-panel {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e5dfd3);
}
.attach-source-panel .hint {
  margin: 0.25rem 0 0.75rem;
}
.source-suggest-input {
  width: 100%;
  max-width: 40rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border, #cfc6b6);
  border-radius: 6px;
  font-size: 1rem;
}
.source-suggest-results {
  margin: 0.75rem 0 1rem;
}
.suggest-heading {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-dark, #5c4a2f);
}
.source-suggest-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border, #e5dfd3);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.source-suggest-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, #eee8dc);
}
.source-suggest-item:last-child {
  border-bottom: none;
}
.source-suggest-main {
  min-width: 0;
  flex: 1;
}
.source-suggest-title {
  font-weight: 600;
  color: var(--ink, #2a2418);
}
.source-suggest-subject {
  font-size: 0.9rem;
  color: var(--ink, #2a2418);
  margin-top: 0.15rem;
}
.source-suggest-citation {
  font-size: 0.85rem;
  color: var(--muted, #7a6f5d);
  margin-top: 0.2rem;
}
.source-suggest-meta {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted, #7a6f5d);
}
.source-suggest-actions {
  flex-shrink: 0;
  padding-top: 0.1rem;
}
.badge.vis-private { background: #ebe6dc; color: #5a5245; }
.badge.vis-shared { background: #dce8f5; color: #2a4f7a; }
.badge.vis-archive { background: #d4e8da; color: #2d6a3e; }

@media (max-width: 640px) {
  .source-suggest-item {
    flex-direction: column;
  }
  .source-suggest-actions {
    align-self: stretch;
  }
  .source-suggest-actions .btn {
    width: 100%;
  }
}

/* Global header search — site-wide */
.header-search {
  display: flex;
  flex: 1 1 220px;
  max-width: 380px;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0.5rem;
}
.header-search input[type=search] {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.65rem;
  border: 1px solid #c4a574;
  border-radius: 4px;
  background: #faf6ee;
  color: #1a120c;
  font: inherit;
  font-size: 0.9rem;
}
.header-search input[type=search]::placeholder { color: #6b5a48; }
.header-search .btn {
  background: #c4a574;
  color: #1a120c !important;
  border: none;
  white-space: nowrap;
}
.header-search .btn:hover { background: #e8d9bc; }
.landing-search {
  display: flex;
  gap: 0.5rem;
  max-width: 560px;
  margin: 1.25rem auto 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.landing-search input[type=search] {
  flex: 1 1 240px;
  padding: 0.75rem 1rem;
  border: 2px solid #c4a574;
  border-radius: 6px;
  font-size: 1.05rem;
  background: #fff;
  color: #1a120c;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
@media (max-width: 720px) {
  .header-inner { flex-direction: column; align-items: stretch; }
  .header-search { max-width: none; margin: 0.25rem 0; }
}

.proof-banner {
  display: inline-block;
  margin-top: .75rem;
  padding: .45rem .8rem;
  background: #e8f0ea;
  border: 1px solid #9bb5a3;
  border-radius: 4px;
  color: #1a3d2a;
  font-size: .95rem;
}
.proof-list li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.proof-list li:last-child { border-bottom: none; }
