/* Archivo familiar Gil · Garralaga
   Warm, tactile, a bit playful — deliberately nothing like glauc.cat.
   Two palettes: "noche" (default) and "papel". */

:root {
  --aragon: #f0803c;
  --aragon-2: #ffc46b;
  --almeria: #3cb8f0;
  --almeria-2: #7fe3ff;
  --nosotros: #7ee08a;
  --nosotros-2: #c3f5b5;
  --rose: #ff6f91;

  --bg: #16110f;
  --bg-2: #1e1815;
  --panel: #241d1a;
  --panel-2: #2c231f;
  --line: #3d312b;
  --line-soft: #322822;
  --ink: #f8f1ea;
  --ink-2: #d5c6bb;
  --ink-3: #9c8b7f;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, .75);
  --glass: rgba(36, 29, 26, .82);

  --r-s: 12px;
  --r-m: 18px;
  --r-l: 26px;
  --r-xl: 34px;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
}

html[data-theme="papel"] {
  --bg: #f6efe6;
  --bg-2: #efe5d8;
  --panel: #fffaf3;
  --panel-2: #f7eee2;
  --line: #ddcdb8;
  --line-soft: #e8dbc9;
  --ink: #2a1f18;
  --ink-2: #5b4a3d;
  --ink-3: #8b7663;
  --shadow: 0 20px 44px -22px rgba(90, 60, 30, .38);
  --glass: rgba(255, 250, 243, .88);
  --aragon: #d2601b;
  --almeria: #1789c4;
  --nosotros: #3f9c52;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body {
  background-image:
    radial-gradient(1100px 620px at 12% -12%, rgba(240, 128, 60, .16), transparent 62%),
    radial-gradient(900px 560px at 92% 4%, rgba(60, 184, 240, .13), transparent 60%),
    radial-gradient(760px 520px at 50% 110%, rgba(126, 224, 138, .10), transparent 60%);
  background-attachment: fixed;
  transition: background-color .5s var(--ease), color .35s var(--ease);
}

/* Paper grain — cheap, and it stops the dark from feeling like a terminal. */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  opacity: .045; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.12; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
::selection { background: var(--aragon); color: #1a1210; }

:focus-visible {
  outline: 3px solid var(--aragon-2);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ───────────────────────── Gate (login / register) ───────────────────── */
.gate {
  min-height: 100dvh; display: grid; place-items: center; padding: 22px;
  position: relative; overflow: hidden;
}
.gate canvas.spark { position: fixed; inset: 0; z-index: 0; opacity: .55; }

.gate-card {
  position: relative; z-index: 1;
  width: min(480px, 100%);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.25);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 34px 30px 28px;
  box-shadow: var(--shadow);
  animation: rise .7s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(22px) scale(.98); } }

.crest {
  width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--aragon), var(--rose) 55%, var(--almeria));
  box-shadow: 0 12px 30px -10px rgba(240, 128, 60, .6);
  font-size: 28px; margin-bottom: 16px;
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: translateY(-4px) rotate(-2deg); } }

.eyebrow {
  font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--aragon); font-weight: 800;
}
.gate h1 { font-family: var(--serif); font-size: clamp(30px, 6vw, 40px); margin: 6px 0 10px; }
.gate .sub { color: var(--ink-2); font-size: 15px; line-height: 1.6; margin-bottom: 22px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; letter-spacing: .01em; }
.field input, .field textarea, .field select {
  width: 100%; padding: 13px 15px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-s); font-size: 15.5px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--aragon);
  box-shadow: 0 0 0 4px rgba(240, 128, 60, .16);
}
.field .hint { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 22px; border-radius: 999px; border: 1px solid transparent;
  background: linear-gradient(135deg, var(--aragon), #ff9d5c);
  color: #1a1210; font-weight: 800; font-size: 15.5px; cursor: pointer;
  box-shadow: 0 12px 26px -12px rgba(240, 128, 60, .8);
  transition: transform .18s var(--ease-back), box-shadow .2s, filter .2s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.btn:active { transform: translateY(0) scale(.98); }
.btn[disabled] { opacity: .55; cursor: progress; transform: none; }
.btn.block { width: 100%; }
.btn.ghost {
  background: transparent; border-color: var(--line); color: var(--ink); box-shadow: none;
}
.btn.ghost:hover { border-color: var(--aragon); background: rgba(240, 128, 60, .08); }
.btn.small { padding: 8px 15px; font-size: 13.5px; }
.btn.danger { background: linear-gradient(135deg, #e05a5a, #ff8a7a); }

.switcher { margin-top: 18px; font-size: 14px; color: var(--ink-3); text-align: center; }
.switcher button {
  background: none; border: none; color: var(--aragon); font-weight: 700; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; padding: 2px;
}

.msg { border-radius: var(--r-s); padding: 12px 14px; font-size: 14.2px; line-height: 1.5; margin-bottom: 14px; }
.msg.err { background: rgba(224, 90, 90, .14); border: 1px solid rgba(224, 90, 90, .42); color: #ffbdb2; }
.msg.ok { background: rgba(126, 224, 138, .13); border: 1px solid rgba(126, 224, 138, .4); color: #bdf0c4; }
.msg.info { background: rgba(60, 184, 240, .12); border: 1px solid rgba(60, 184, 240, .35); color: #b9e7ff; }
html[data-theme="papel"] .msg.err { color: #9c2a24; }
html[data-theme="papel"] .msg.ok { color: #1e6b32; }
html[data-theme="papel"] .msg.info { color: #12617f; }

/* ───────────────────────────── App shell ─────────────────────────────── */
.app { min-height: 100dvh; padding-bottom: 96px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(14px, 3vw, 30px);
  background: var(--glass); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; letter-spacing: -.01em; }
.brand .dot {
  width: 30px; height: 30px; border-radius: 10px;
  background: linear-gradient(140deg, var(--aragon), var(--almeria));
  display: grid; place-items: center; font-size: 15px;
}
.brand small { display: block; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.topbar .spacer { flex: 1; }

.iconbtn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  cursor: pointer; font-size: 16px; transition: transform .18s var(--ease-back), border-color .2s;
}
.iconbtn:hover { transform: translateY(-2px); border-color: var(--aragon); }
.iconbtn .badge {
  position: absolute; transform: translate(14px, -14px);
  background: var(--rose); color: #23121a; font-size: 10px; font-weight: 800;
  border-radius: 999px; padding: 1px 5px;
}

/* Bottom tab bar — this should feel like an app, not a website. */
.tabs {
  position: fixed; z-index: 60; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 3px; padding: 6px;
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.3);
  border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 20px); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: none; background: transparent; color: var(--ink-3); cursor: pointer;
  padding: 9px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: color .2s, background .25s var(--ease), transform .2s var(--ease-back);
  white-space: nowrap;
}
.tabs button i { font-style: normal; font-size: 17px; line-height: 1; }
.tabs button:hover { color: var(--ink); transform: translateY(-2px); }
.tabs button.on { color: #1a1210; background: linear-gradient(135deg, var(--aragon), #ffa869); }
html[data-theme="papel"] .tabs button.on { color: #fff; }

.view { padding: clamp(16px, 3vw, 34px); max-width: 1240px; margin: 0 auto; animation: fade .45s var(--ease) both; }
@keyframes fade { from { opacity: 0; transform: translateY(14px); } }

.page-head { margin-bottom: 22px; }
.page-head h2 { font-family: var(--serif); font-size: clamp(28px, 5vw, 42px); }
.page-head p { color: var(--ink-2); max-width: 68ch; margin-top: 8px; font-size: 15.5px; line-height: 1.65; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l);
  padding: 20px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
}
.chip.aragon { color: var(--aragon); border-color: color-mix(in srgb, var(--aragon) 45%, transparent); background: color-mix(in srgb, var(--aragon) 12%, transparent); }
.chip.almeria { color: var(--almeria); border-color: color-mix(in srgb, var(--almeria) 45%, transparent); background: color-mix(in srgb, var(--almeria) 12%, transparent); }
.chip.nosotros { color: var(--nosotros); border-color: color-mix(in srgb, var(--nosotros) 45%, transparent); background: color-mix(in srgb, var(--nosotros) 12%, transparent); }

/* ───────────────────────────── Home ──────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl); border: 1px solid var(--line);
  padding: clamp(24px, 5vw, 46px);
  background:
    radial-gradient(700px 320px at 8% 0%, color-mix(in srgb, var(--aragon) 26%, transparent), transparent 65%),
    radial-gradient(700px 340px at 100% 100%, color-mix(in srgb, var(--almeria) 22%, transparent), transparent 62%),
    var(--panel);
  margin-bottom: 22px;
}
.hero h2 { font-family: var(--serif); font-size: clamp(30px, 6.4vw, 56px); max-width: 18ch; }
.hero p { color: var(--ink-2); max-width: 60ch; margin-top: 12px; font-size: clamp(15px, 1.9vw, 17.5px); line-height: 1.66; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; margin: 20px 0 4px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 16px 16px 14px; transition: transform .25s var(--ease-back), border-color .25s;
}
.stat:hover { transform: translateY(-4px); border-color: var(--aragon); }
.stat b { display: block; font-family: var(--serif); font-size: clamp(26px, 4vw, 34px); line-height: 1; }
.stat span { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }

.branch-card { position: relative; overflow: hidden; }
.branch-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 5px;
  background: linear-gradient(180deg, var(--c), transparent);
}
.branch-card h3 { font-family: var(--serif); font-size: 22px; color: var(--c); }
.branch-card .sub { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin: 4px 0 10px; }
.branch-card p { color: var(--ink-2); font-size: 14.6px; line-height: 1.62; margin: 0; }

/* ───────────────────────────── Tree ──────────────────────────────────── */
.tree-wrap { position: relative; border-radius: var(--r-l); overflow: hidden; border: 1px solid var(--line); background: var(--bg-2); margin-bottom: 80px; }
#tree3d { display: block; width: 100%; height: min(64vh, 640px); touch-action: none; cursor: grab; }
#tree3d:active { cursor: grabbing; }
.tree-hud {
  position: absolute; left: 14px; top: 14px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 5;
}
.tree-hud .pill {
  background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  transition: transform .18s var(--ease-back), border-color .2s, color .2s;
}
.tree-hud .pill:hover { transform: translateY(-2px); }
.tree-hud .pill.on { border-color: var(--aragon); color: var(--aragon); }
.tree-legend {
  position: absolute; right: 14px; bottom: 14px; z-index: 5;
  background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 11px 13px; font-size: 12.2px; line-height: 1.9;
}
.tree-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.tree-tip {
  position: absolute; z-index: 6; pointer-events: none; opacity: 0;
  background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 12px; font-size: 13px; font-weight: 700;
  transform: translate(-50%, -130%); transition: opacity .18s;
  box-shadow: var(--shadow); white-space: nowrap;
}
.loading3d {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 4;
  color: var(--ink-3); font-size: 14px; background: var(--bg-2);
  transition: opacity .5s; text-align: center;
}

/* 2D fallback / alternative view */
.tree2d { overflow: auto; padding: 26px 14px; }
.tree2d .gen { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 26px; }
.node {
  width: 168px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 12px; cursor: pointer; text-align: center;
  transition: transform .22s var(--ease-back), border-color .2s, box-shadow .25s;
}
.node:hover { transform: translateY(-5px) scale(1.02); box-shadow: var(--shadow); }
.node .av { width: 54px; height: 54px; margin: 0 auto 8px; }
.node b { font-size: 13.4px; display: block; line-height: 1.25; }
.node span { font-size: 11.6px; color: var(--ink-3); }

.av {
  border-radius: 50%; display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; color: #1a1210;
  background: linear-gradient(140deg, var(--c, var(--aragon)), color-mix(in srgb, var(--c, var(--aragon)) 45%, #fff));
  border: 2px solid color-mix(in srgb, var(--c, var(--aragon)) 60%, transparent);
  overflow: hidden; flex: none;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
html[data-theme="papel"] .av { color: #fff; }

/* ─────────────────────── Person drawer ───────────────────────────────── */
.drawer-back {
  position: fixed; inset: 0; z-index: 200; background: rgba(8, 5, 4, .6);
  backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity .3s;
}
.drawer-back.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 201; right: 0; top: 0; bottom: 0;
  width: min(460px, 100%); background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(102%); transition: transform .42s var(--ease);
  overflow-y: auto; padding: 22px 22px 40px;
}
.drawer.on { transform: none; }
.drawer .close { position: sticky; top: 0; float: right; }
.drawer .hd { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.drawer .hd .av { width: 70px; height: 70px; font-size: 25px; }
.drawer h3 { font-family: var(--serif); font-size: 24px; line-height: 1.15; }
.drawer .role { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.drawer dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 16px 0; font-size: 14.4px; }
.drawer dt { color: var(--ink-3); font-weight: 700; }
.drawer dd { margin: 0; }
.drawer .prose { font-size: 15px; line-height: 1.68; color: var(--ink-2); }
.doubt {
  border-left: 3px solid var(--rose); background: color-mix(in srgb, var(--rose) 9%, transparent);
  padding: 11px 14px; border-radius: 0 var(--r-s) var(--r-s) 0; font-size: 14px; line-height: 1.6;
  margin: 14px 0; color: var(--ink-2);
}
.doubt b { color: var(--rose); display: block; margin-bottom: 3px; }
.relations { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.relations button {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px;
  padding: 6px 12px; font-size: 12.6px; cursor: pointer; font-weight: 600;
  transition: border-color .2s, transform .18s var(--ease-back);
}
.relations button:hover { border-color: var(--aragon); transform: translateY(-2px); }

/* ───────────────────────── Stories ───────────────────────────────────── */
.story-card {
  position: relative; overflow: hidden; cursor: pointer;
  border-radius: var(--r-l); border: 1px solid var(--line); background: var(--panel);
  padding: 22px; transition: transform .3s var(--ease-back), border-color .25s, box-shadow .3s;
}
.story-card:hover { transform: translateY(-6px); border-color: var(--c); box-shadow: var(--shadow); }
.story-card .icon { font-size: 34px; }
.story-card .yr { font-family: var(--mono); font-size: 12.5px; color: var(--c); font-weight: 700; letter-spacing: .06em; }
.story-card h3 { font-family: var(--serif); font-size: 23px; margin: 6px 0 8px; }
.story-card p { color: var(--ink-2); font-size: 14.6px; line-height: 1.6; margin: 0; }
.story-card::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 160px; height: 160px;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 26%, transparent), transparent 68%);
  transition: transform .5s var(--ease);
}
.story-card:hover::after { transform: scale(1.5); }

.reader { max-width: 70ch; margin: 0 auto; }
.reader h2 { font-family: var(--serif); font-size: clamp(30px, 5.4vw, 46px); margin-bottom: 10px; }
.reader .lede { font-size: clamp(17px, 2.3vw, 20px); color: var(--ink-2); font-style: italic; line-height: 1.6; margin-bottom: 26px; }
.reader p.body { font-size: 17px; line-height: 1.85; color: var(--ink); margin-bottom: 1.15em; }
.reader p.body:first-letter { }
.reader .oral-note {
  border: 1px dashed var(--line); border-radius: var(--r-m); padding: 14px 16px;
  font-size: 14px; color: var(--ink-3); line-height: 1.6;
}

/* ───────────────────────── Timeline ──────────────────────────────────── */
.tl { position: relative; padding-left: 8px; }
.tl::before {
  content: ""; position: absolute; left: 78px; top: 0; bottom: 0; width: 2px;
  background: linear-gradient(180deg, transparent, var(--line) 6%, var(--line) 94%, transparent);
}
.tl-item {
  position: relative; display: grid; grid-template-columns: 66px 1fr; gap: 26px;
  padding: 11px 0; opacity: 0; transform: translateY(18px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.tl-item.in { opacity: 1; transform: none; }
.tl-item .yr { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--c); text-align: right; padding-top: 12px; }
.tl-item .body {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 13px 16px; font-size: 14.8px; line-height: 1.6; color: var(--ink-2);
  transition: transform .25s var(--ease-back), border-color .2s;
}
.tl-item:hover .body { transform: translateX(5px); border-color: var(--c); }
.tl-item .body.hero { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--panel)); color: var(--ink); }
.tl-item::before {
  content: ""; position: absolute; left: 74px; top: 22px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--c); box-shadow: 0 0 0 4px var(--bg);
  z-index: 2;
}

/* ───────────────────────── Journeys map ─────────────────────────────── */
.map-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; background: var(--bg-2); }
#mapsvg { display: block; width: 100%; height: min(66vh, 620px); }
.map-list { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.map-list button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; font-weight: 700;
  transition: transform .18s var(--ease-back), border-color .2s, color .2s;
}
.map-list button:hover { transform: translateY(-2px); }
.map-list button.on { border-color: var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.place-dot { cursor: pointer; transition: r .25s var(--ease); }
.route { fill: none; stroke-linecap: round; stroke-dasharray: 6 9; }

/* ───────────────────────── Archive ──────────────────────────────────── */
.doc {
  display: grid; grid-template-columns: 62px 1fr; gap: 14px; align-items: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 14px; cursor: pointer; text-decoration: none; color: inherit;
  transition: transform .22s var(--ease-back), border-color .2s, box-shadow .25s;
}
.doc:hover { transform: translateY(-4px); border-color: var(--c); box-shadow: var(--shadow); }
.doc .num {
  width: 62px; height: 78px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 26%, var(--panel-2)), var(--panel-2));
  border: 1px solid var(--line); font-family: var(--mono); font-weight: 700; font-size: 17px; color: var(--c);
  overflow: hidden;
}
.doc .num img { width: 100%; height: 100%; object-fit: cover; }
.doc .dt { font-family: var(--mono); font-size: 11.6px; color: var(--ink-3); }
.doc h4 { margin: 3px 0 5px; font-size: 15px; line-height: 1.3; }
.doc p { margin: 0; font-size: 13.4px; color: var(--ink-3); line-height: 1.5; }

/* ───────────────────────── Quiz ─────────────────────────────────────── */
.quiz { max-width: 640px; margin: 0 auto; }
.quiz-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 26px; box-shadow: var(--shadow); animation: pop .45s var(--ease-back) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(14px); } }
.quiz-q { font-family: var(--serif); font-size: clamp(20px, 3.4vw, 26px); line-height: 1.35; margin-bottom: 18px; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opt {
  text-align: left; padding: 14px 16px; border-radius: var(--r-m);
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer;
  font-size: 15px; font-weight: 600; transition: transform .18s var(--ease-back), border-color .2s, background .25s;
}
.quiz-opt:hover:not(:disabled) { transform: translateX(5px); border-color: var(--aragon); }
.quiz-opt.right { border-color: var(--nosotros); background: color-mix(in srgb, var(--nosotros) 16%, transparent); }
.quiz-opt.wrong { border-color: #e05a5a; background: rgba(224, 90, 90, .14); }
.quiz-opt:disabled { cursor: default; }
.quiz-bar { height: 7px; border-radius: 999px; background: var(--panel-2); overflow: hidden; margin-bottom: 18px; }
.quiz-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--aragon), var(--almeria)); transition: width .5s var(--ease); }
.quiz-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-3); margin-bottom: 8px; font-weight: 700; }
.streak { color: var(--aragon); }
.medal { font-size: 62px; text-align: center; animation: pop .6s var(--ease-back) both; }

/* ───────────────────────── Questions / contribute ───────────────────── */
.q-card { border-left: 4px solid var(--rose); }
.q-card.urgent { border-left-color: var(--aragon); background: color-mix(in srgb, var(--aragon) 8%, var(--panel)); }
.q-card h3 { font-family: var(--serif); font-size: 21px; margin-bottom: 8px; }
.q-card p { color: var(--ink-2); font-size: 14.8px; line-height: 1.62; }
.q-card .ask { font-size: 13.6px; color: var(--ink-3); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 4px; }

.drop {
  border: 2px dashed var(--line); border-radius: var(--r-l); padding: 32px 20px;
  text-align: center; cursor: pointer; transition: border-color .25s, background .25s, transform .2s;
}
.drop:hover, .drop.over { border-color: var(--aragon); background: color-mix(in srgb, var(--aragon) 7%, transparent); transform: scale(1.01); }
.drop .big { font-size: 42px; }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: var(--r-m); overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .cap {
  position: absolute; inset: auto 0 0 0; padding: 6px 8px; font-size: 11px;
  background: linear-gradient(0deg, rgba(0, 0, 0, .8), transparent); color: #fff;
}

/* ───────────────────────── Admin ────────────────────────────────────── */
.row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--panel); margin-bottom: 9px;
}
.row .who { flex: 1; min-width: 190px; }
.row .who b { display: block; font-size: 14.6px; }
.row .who span { font-size: 12.6px; color: var(--ink-3); }
.status { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .06em; }
.status.active { background: color-mix(in srgb, var(--nosotros) 20%, transparent); color: var(--nosotros); }
.status.pending_approval { background: color-mix(in srgb, var(--aragon) 20%, transparent); color: var(--aragon); }
.status.pending_email { background: color-mix(in srgb, var(--almeria) 18%, transparent); color: var(--almeria); }
.status.rejected { background: rgba(224, 90, 90, .18); color: #ff9d92; }

/* ───────────────────────── Toast ────────────────────────────────────── */
#toasts { position: fixed; z-index: 400; left: 50%; top: 16px; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); }
.toast {
  background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 12px 15px; font-size: 14.2px; box-shadow: var(--shadow);
  animation: drop .4s var(--ease-back) both; line-height: 1.5;
}
@keyframes drop { from { opacity: 0; transform: translateY(-16px) scale(.96); } }
.toast.ok { border-color: color-mix(in srgb, var(--nosotros) 55%, transparent); }
.toast.err { border-color: rgba(224, 90, 90, .55); }

.skel { background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel) 37%, var(--panel-2) 63%); background-size: 400% 100%; animation: sh 1.4s infinite; border-radius: var(--r-m); }
@keyframes sh { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (max-width: 620px) {
  .drawer { width: 100%; border-left: none; border-top: 1px solid var(--line); border-radius: var(--r-xl) var(--r-xl) 0 0; top: 8vh; transform: translateY(102%); }
  .drawer.on { transform: none; }
  .tl::before { left: 52px; }
  .tl-item { grid-template-columns: 44px 1fr; gap: 16px; }
  .tl-item::before { left: 48px; }
  .tabs button span { display: none; }
  .tabs button { padding: 10px 12px; }
  .tabs button i { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   v2 — readable by design. A lot of the people using this are elderly, so
   the light "papel" theme is the default, text can be stepped up twice, and
   every target is finger-sized.
   ═══════════════════════════════════════════════════════════════════════ */

:root { --fs: 1; }
html[data-size="1"] { --fs: 1.14; }
html[data-size="2"] { --fs: 1.3; }

body { font-size: calc(16px * var(--fs)); }
.page-head p, .hero p, .card p, .story-card p, .tl-item .body,
.reader p.body, .q-card p, .drawer .prose, .feed-item, .contrib p {
  font-size: calc(15.5px * var(--fs));
}
.btn { font-size: calc(15.5px * var(--fs)); padding: calc(13px * var(--fs)) calc(22px * var(--fs)); }
.btn.big { font-size: calc(17px * var(--fs)); padding: calc(15px * var(--fs)) calc(26px * var(--fs)); }
.btn.small { font-size: calc(13.5px * var(--fs)); }
.field label { font-size: calc(13.5px * var(--fs)); }
.tabs button { font-size: calc(12.5px * var(--fs)); }
.tabs button i { font-size: calc(18px * var(--fs)); }

.big-input {
  width: 100%; padding: calc(14px * var(--fs)) 15px;
  background: var(--panel-2); border: 2px solid var(--line);
  border-radius: var(--r-s); font-size: calc(16.5px * var(--fs));
  transition: border-color .2s, box-shadow .2s;
}
.big-input:focus { outline: none; border-color: var(--aragon); box-shadow: 0 0 0 4px rgba(240,128,60,.18); }

.sec { font-family: var(--serif); font-size: calc(25px * var(--fs)); margin: 34px 0 14px; }
.muted { color: var(--ink-3); font-size: calc(14px * var(--fs)); }
.empty { text-align: center; }

/* ── home: what you can do + activity feed ── */
.act { text-align: center; }
.act-icon { font-size: 40px; margin-bottom: 6px; }
.act h4 { font-size: calc(18px * var(--fs)); margin: 0 0 6px; }
.act p { color: var(--ink-2); margin-bottom: 14px; }

.feed { display: grid; gap: 8px; }
.feed-item {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 12px 15px; cursor: pointer; transition: transform .18s var(--ease-back), border-color .2s;
}
.feed-item:hover { transform: translateX(4px); border-color: var(--aragon); }
.feed-item .fi { font-size: 22px; flex: none; }
.feed-item em { color: var(--ink-3); font-style: normal; }

/* ── the flat tree ── */
.tree-host { position: relative; }
.tree2-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tbtn {
  min-width: 52px; padding: 11px 18px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--panel); cursor: pointer;
  font-weight: 800; font-size: calc(15px * var(--fs));
  transition: transform .18s var(--ease-back), border-color .2s, background .2s;
}
.tbtn:hover { transform: translateY(-2px); border-color: var(--aragon); background: color-mix(in srgb, var(--aragon) 10%, transparent); }

.tree2-searchbox { position: relative; margin-bottom: 10px; max-width: 420px; }
.tree2-search {
  width: 100%; padding: 12px 16px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--panel);
  font-size: calc(15.5px * var(--fs));
}
.tree2-search:focus { outline: none; border-color: var(--aragon); }
.tree2-results {
  display: none; position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--r-m);
  overflow: hidden; box-shadow: var(--shadow);
}
.tree2-results.on { display: block; }
.tree2-results button {
  display: block; width: 100%; text-align: left; padding: 12px 16px;
  background: none; border: none; cursor: pointer; font-size: calc(15px * var(--fs));
  border-bottom: 1px solid var(--line-soft);
}
.tree2-results button:hover { background: color-mix(in srgb, var(--aragon) 14%, transparent); }

.tree2-wrap {
  position: relative; height: min(72vh, 720px);
  border: 1px solid var(--line); border-radius: var(--r-l);
  background:
    radial-gradient(1000px 500px at 50% -10%, color-mix(in srgb, var(--aragon) 8%, transparent), transparent 60%),
    var(--bg-2);
  overflow: hidden; touch-action: none;
}
svg.tree2 { width: 100%; height: 100%; cursor: grab; display: block; }
.tree2-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: calc(13.5px * var(--fs)); color: var(--ink-2); }
.tree2-legend .lg { display: inline-flex; align-items: center; gap: 7px; }
.tree2-legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

.pcard { cursor: pointer; }
.pcard .pcard-bg {
  fill: var(--panel); stroke: var(--line); stroke-width: 2;
  transition: stroke .2s, filter .2s;
}
.pcard:hover .pcard-bg, .pcard:focus .pcard-bg { stroke: var(--c); stroke-width: 3.5; }
.pcard.hero .pcard-bg { stroke: var(--c); stroke-width: 4; }
.pcard.ghost .pcard-bg { stroke-dasharray: 7 6; }
.pcard .av-fill { fill: var(--c); }
.pcard .ring { stroke: var(--c); stroke-width: 3; }
.pcard .av-ini { font-family: var(--serif); font-weight: 700; font-size: 23px; fill: #1a1210; }
html[data-theme="noche"] .pcard .av-ini { fill: #1a1210; }
.pcard .pname { font-size: 16px; font-weight: 700; fill: var(--ink); }
.pcard .pyears { font-size: 13px; fill: var(--ink-3); font-family: var(--mono); }
.pcard .added-dot { fill: var(--nosotros); }
.pcard.flash .pcard-bg { animation: cardflash 1.6s ease-out; }
@keyframes cardflash {
  0%, 100% { stroke: var(--c); }
  25%, 75% { stroke: var(--aragon); stroke-width: 6; }
}
.couple-label { font-size: 13px; fill: var(--rose); font-family: var(--mono); font-weight: 700; }

/* ── real map ── */
.map-wrap { min-height: 260px; }
.map-loading { padding: 60px 20px; text-align: center; color: var(--ink-3); }
svg.realmap { width: 100%; height: min(64vh, 620px); display: block; border-radius: var(--r-l); background: var(--sea-c); }
:root { --sea-c: #cfe6f2; --land-c: #fbf4e9; }
html[data-theme="noche"] { --sea-c: #12212b; --land-c: #241d1a; }
.realmap .sea { fill: var(--sea-c); }
.realmap .country { fill: var(--land-c); stroke: color-mix(in srgb, var(--ink-3) 55%, transparent); stroke-width: 1.1; }
.realmap .country.home { fill: color-mix(in srgb, var(--aragon) 20%, var(--land-c)); }
.realmap .place { cursor: pointer; }
.realmap .place:hover .pdot { r: 10; }
.realmap .plabel { fill: var(--ink); font-size: 15px; font-weight: 600; paint-order: stroke; stroke: var(--land-c); stroke-width: 4px; }
.realmap .plabel.major { fill: var(--ink); font-size: 18px; font-weight: 800; }
.realmap .pbadge { fill: var(--nosotros); }
.realmap .pbadge-t { font-size: 11px; font-weight: 800; fill: #14261a; }
.realmap .route-shadow { fill: none; stroke-width: 9; opacity: .18; stroke-linecap: round; }
.realmap .route-line { fill: none; stroke-width: 4; stroke-linecap: round; }
.map-caption { color: var(--ink-3); font-size: calc(14px * var(--fs)); margin-top: 12px; }

/* ── modal ── */
.modal-back {
  position: fixed; inset: 0; z-index: 300; background: rgba(8,5,4,.55);
  backdrop-filter: blur(4px); display: grid; place-items: start center;
  padding: 4vh 14px; overflow-y: auto; opacity: 0; transition: opacity .25s;
}
.modal-back.on { opacity: 1; }
.modal {
  width: min(560px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 22px; box-shadow: var(--shadow);
  animation: pop .35s var(--ease-back) both;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.modal-head h3 { font-family: var(--serif); font-size: calc(24px * var(--fs)); }

.relpick { display: grid; gap: 8px; }
.relpick button {
  text-align: left; padding: 13px 16px; border-radius: var(--r-m);
  border: 2px solid var(--line); background: var(--panel-2); cursor: pointer;
  font-size: calc(15.5px * var(--fs)); font-weight: 600;
  transition: border-color .2s, background .2s, transform .16s var(--ease-back);
}
.relpick button:hover { transform: translateX(4px); border-color: var(--aragon); }
.relpick button.on { border-color: var(--aragon); background: color-mix(in srgb, var(--aragon) 16%, transparent); font-weight: 800; }

/* ── contributions shown in context ── */
.contrib {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 13px; margin: 10px 0; background: var(--panel-2);
}
.contrib img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; flex: none; }
.contrib b { display: block; margin-bottom: 4px; }
.contrib p { margin: 0 0 6px; color: var(--ink-2); }
.contrib .by { font-size: 13px; color: var(--ink-3); }
.memory { border-left: 3px solid var(--nosotros); padding: 10px 14px; margin: 12px 0; background: var(--panel-2); border-radius: 0 var(--r-s) var(--r-s) 0; }
.memory b { display: block; }
.memory span { font-size: 13px; color: var(--ink-3); }

.qhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.q-card.answered { border-left-color: var(--nosotros); }
.relblock { margin-top: 16px; }
.rellabel { font-size: calc(13px * var(--fs)); color: var(--ink-3); font-weight: 700; margin-bottom: 7px; }
.drawer-actions { display: grid; gap: 10px; margin-top: 20px; }
.row-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.thumb.pdf { display: grid; place-items: center; background: var(--panel-2); font-size: 13px; text-align: center; padding: 8px; aspect-ratio: auto; min-height: 110px; }
.story-year { font-family: var(--mono); color: var(--c); font-weight: 700; margin: 20px 0 6px; letter-spacing: .06em; }
.doc.flash { box-shadow: 0 0 0 3px var(--aragon); }
.tl-item .body.added { border-style: dashed; }
.drop-t { font-weight: 700; margin-top: 6px; font-size: calc(16px * var(--fs)); }

@media (max-width: 620px) {
  .tabs button span { display: block; font-size: calc(10.5px * var(--fs)); }
  .tree2-wrap { height: 62vh; }
}

/* the tree page put 430px of chrome above the tree; pull it in */
.view.tight .page-head { margin-bottom: 12px; }
.view.tight .page-head p { max-width: 62ch; }
.tree-topline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.tree-topline .tree2-searchbox { margin: 0; flex: 1 1 220px; max-width: 340px; }

/* ── the brand button had no background of its own, so it fell back to the
   browser's default button chrome: a white box, unreadable in dark mode ── */
.brand {
  background: none; border: none; color: inherit; cursor: pointer;
  padding: 6px 10px; border-radius: 14px; text-align: left;
  transition: background .2s;
}
.brand:hover { background: color-mix(in srgb, var(--aragon) 12%, transparent); }
.brand small { color: var(--ink-3); }

/* Same trap anywhere else a button carries layout instead of chrome. */
.feed-item, .story-card, .doc, .tabs button, .relations button,
.map-list button, .tree2-results button, .relpick button { color: inherit; }

/* ── contrast pass, both themes ── */
html[data-theme="noche"] {
  --ink: #f7f1ec;
  --ink-2: #ded2c8;      /* was too dim against --panel */
  --ink-3: #a8968a;
  --line: #4a3c34;
  --panel: #251e1b;
  --panel-2: #2f2621;
}
html[data-theme="papel"] {
  --ink: #241a14;
  --ink-2: #4f4136;      /* darker: the old value failed AA on small text */
  --ink-3: #766252;
  --line: #d6c4ad;
}
.topbar { border-bottom: 1px solid var(--line); }
.iconbtn { background: var(--panel); color: var(--ink); }
.chip { color: var(--ink-2); }

/* ═══════════════════════════════════════════════════════════════════════
   v3 — the tree the way real genealogy products do it: a small window
   around a movable focus, chosen from a landing page. No fixed centre.
   ═══════════════════════════════════════════════════════════════════════ */

:root { --line-tree: color-mix(in srgb, var(--ink) 26%, transparent); }

.tree-top { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.viewswitch { display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px; border: 2px solid var(--line); background: var(--panel); }
.viewswitch button {
  border: none; background: none; cursor: pointer; color: var(--ink-2);
  padding: 11px 22px; border-radius: 999px; font-weight: 800;
  font-size: calc(15.5px * var(--fs)); min-height: 48px;
  transition: background .2s, color .2s;
}
.viewswitch button.on { background: linear-gradient(135deg, var(--aragon), #ff9d5c); color: #1a1210; }
html[data-theme="papel"] .viewswitch button.on { color: #fff; }

.focus-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 8px 10px 16px;
  border-radius: 999px; background: color-mix(in srgb, var(--nosotros) 16%, transparent);
  border: 2px solid color-mix(in srgb, var(--nosotros) 45%, transparent);
  font-size: calc(14.5px * var(--fs));
}
.chip-x { border: none; background: none; cursor: pointer; font-size: 17px; padding: 6px 10px; border-radius: 999px; color: inherit; }
.chip-x:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); }

.breadcrumb { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.breadcrumb .bc-l { font-size: calc(13.5px * var(--fs)); color: var(--ink-3); }
.breadcrumb button {
  border: 2px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 15px; cursor: pointer; font-size: calc(14px * var(--fs)); font-weight: 700; color: inherit;
}
.breadcrumb button.on { border-color: var(--aragon); color: var(--aragon); }

.tree-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.tree-actions .btn { min-height: 56px; }

/* ── family window ── */
.fam-wrap { overflow-x: auto; overflow-y: hidden; padding: 4px 0 10px; }
svg.famtree { display: block; }
.card3 { cursor: pointer; }
.card3 .c3-bg { fill: var(--panel); stroke: var(--line); stroke-width: 2; transition: stroke .2s, stroke-width .2s; }
.card3:hover .c3-bg, .card3:focus .c3-bg { stroke: var(--c); stroke-width: 4; }
.card3.focus .c3-bg { stroke: var(--c); stroke-width: 5; }
.card3.ghost .c3-bg { stroke-dasharray: 8 6; }
.card3 .c3-plate { fill: color-mix(in srgb, var(--c) 16%, var(--panel-2)); }
.card3 .c3-ini { font-family: var(--serif); font-size: 46px; font-weight: 700; fill: color-mix(in srgb, var(--c) 85%, var(--ink)); }
.card3 .c3-name { font-family: var(--serif); font-size: calc(18px * var(--fs)); font-weight: 600; fill: var(--ink); }
.card3 .c3-years { font-size: calc(14px * var(--fs)); fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.card3 .c3-edge { fill: var(--c); }
.card3 .c3-added { fill: var(--nosotros); }
.c3-chip { cursor: pointer; }
.c3-chip rect { fill: var(--panel); stroke: var(--line); stroke-width: 2; }
.c3-chip text { font-size: 15px; font-weight: 800; fill: var(--ink-2); }
.c3-chip:hover rect { stroke: var(--aragon); fill: color-mix(in srgb, var(--aragon) 14%, var(--panel)); }
.c3-chip:hover text { fill: var(--aragon); }

/* ── fan ── */
.fan-host { display: grid; place-items: center; }
svg.fan { width: 100%; height: min(62vh, 600px); }
.fan-seg { cursor: pointer; }
.fan-seg .seg { stroke: var(--bg); stroke-width: 2.5; opacity: .82; transition: opacity .2s; }
.fan-seg:hover .seg { opacity: 1; }
.fan-seg .seg.empty { fill: var(--panel-2); opacity: .5; }
.fan-label { font-size: 13px; font-weight: 700; fill: #1d1410; pointer-events: none; }
.fan-label.big { font-family: var(--serif); font-size: 19px; fill: #1d1410; }
html[data-theme="noche"] .fan-label { fill: #17100d; }

/* ── plain list ── */
.list-search { width: 100%; max-width: 460px; padding: 14px 18px; border-radius: 999px; border: 2px solid var(--line); background: var(--panel); font-size: calc(16px * var(--fs)); margin-bottom: 14px; }
.plist { display: grid; gap: 8px; }
.plist-h { font-family: var(--serif); font-size: calc(19px * var(--fs)); color: var(--ink-3); margin: 16px 0 4px; }
.plist-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 12px 16px; min-height: 76px; cursor: pointer; color: inherit;
  border: 2px solid var(--line); border-left: 6px solid var(--c); border-radius: var(--r-m);
  background: var(--panel); transition: transform .16s var(--ease-back), border-color .2s;
}
.plist-row:hover { transform: translateX(4px); border-color: var(--aragon); border-left-color: var(--c); }
.plist-av {
  width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 22%, var(--panel-2)); overflow: hidden;
  font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--ink);
}
.plist-av img { width: 100%; height: 100%; object-fit: cover; }
.plist-meta { flex: 1; display: grid; }
.plist-meta b { font-size: calc(17.5px * var(--fs)); }
.plist-meta span { font-size: calc(14px * var(--fs)); color: var(--ink-3); }
.plist-go { color: var(--aragon); font-weight: 800; font-size: calc(14.5px * var(--fs)); }

/* ── landing: no fixed centre ── */
.resume {
  display: block; width: 100%; text-align: left; padding: 16px 20px; margin-bottom: 18px;
  border: 2px solid var(--nosotros); border-radius: var(--r-l); cursor: pointer; color: inherit;
  background: color-mix(in srgb, var(--nosotros) 12%, transparent); font-size: calc(16px * var(--fs));
}
.landing-search-wrap { position: relative; max-width: 520px; margin-bottom: 8px; }
.landing-hits { display: grid; gap: 6px; margin-top: 8px; }
.landing-hits button {
  text-align: left; padding: 13px 18px; border-radius: var(--r-m); cursor: pointer; color: inherit;
  border: 2px solid var(--line); background: var(--panel); font-size: calc(15.5px * var(--fs));
}
.landing-hits button:hover { border-color: var(--aragon); }
.branch-portal {
  text-align: left; cursor: pointer; color: inherit; padding: 22px;
  border: 2px solid var(--line); border-top: 6px solid var(--c); border-radius: var(--r-l);
  background: var(--panel); display: grid; gap: 6px;
  transition: transform .22s var(--ease-back), border-color .2s, box-shadow .25s;
}
.branch-portal:hover { transform: translateY(-5px); border-color: var(--c); box-shadow: var(--shadow); }
.branch-portal h3 { font-family: var(--serif); font-size: calc(23px * var(--fs)); color: var(--c); }
.branch-portal .sub { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.branch-portal p { color: var(--ink-2); margin: 6px 0 0; font-size: calc(14.5px * var(--fs)); }
.branch-portal .go { color: var(--aragon); font-weight: 800; margin-top: 10px; font-size: calc(15px * var(--fs)); }

.facegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.face {
  display: grid; justify-items: center; gap: 6px; padding: 18px 10px; cursor: pointer; color: inherit;
  border: 2px solid var(--line); border-radius: var(--r-l); background: var(--panel);
  transition: transform .2s var(--ease-back), border-color .2s;
}
.face:hover { transform: translateY(-4px); border-color: var(--aragon); }
.face b { font-size: calc(15px * var(--fs)); text-align: center; line-height: 1.25; }
.face span { font-size: calc(13px * var(--fs)); color: var(--ink-3); }

/* ── whole-tree poster (secondary) ── */
.whole-wrap { position: relative; height: min(66vh, 660px); border: 1px solid var(--line); border-radius: var(--r-l); background: var(--bg-2); overflow: hidden; touch-action: none; }
svg.wholetree { width: 100%; height: 100%; display: block; cursor: grab; }
.whole-controls { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.pan-pads, .zoom-pads { display: flex; gap: 8px; }
.panbtn { width: 56px; height: 56px; border-radius: 16px; border: 2px solid var(--line); background: var(--panel); cursor: pointer; font-size: 20px; color: inherit; }
.panbtn:hover { border-color: var(--aragon); background: color-mix(in srgb, var(--aragon) 10%, transparent); }
.fan-empty { text-align: center; padding: 48px 24px; max-width: 46ch; margin: 0 auto; }
.fan-empty-i { font-size: 54px; }
.fan-empty h3 { font-family: var(--serif); font-size: calc(23px * var(--fs)); margin: 10px 0 8px; }
.fan-empty p { color: var(--ink-2); font-size: calc(15.5px * var(--fs)); line-height: 1.6; }

/* ═══════════════════════════════════════════════════════════════════════
   Móvil y tablet. Medido con Playwright en 375 / 390 / 430 / 768 / 1024:
   no había desbordamiento horizontal, pero la barra de pestañas no cabía
   (se cortaban Juego y Preguntas), la marca se partía en tres líneas y
   había 30 objetivos táctiles por debajo de los 44 px.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── objetivos táctiles: 44 px es el mínimo, aquí y en escritorio ── */
.iconbtn { width: 48px; height: 48px; font-size: 18px; }
.btn.small { min-height: 44px; padding: 11px 18px; }
.chip { min-height: 38px; padding: 8px 14px; display: inline-flex; align-items: center; }
button.chip { min-height: 44px; cursor: pointer; }
.map-list button, .relations button, .landing-hits button, .breadcrumb button,
.tree2-results button, .relpick button, .viewswitch button {
  min-height: 46px;
}
.relations button { padding: 11px 16px; font-size: calc(14.5px * var(--fs)); }
.map-list button { padding: 12px 18px; font-size: calc(14.5px * var(--fs)); }

/* ── letra: nada por debajo de 13.5 px ── */
.stat span { font-size: calc(13.5px * var(--fs)); }
.branch-card .sub, .branch-portal .sub { font-size: calc(13.5px * var(--fs)); letter-spacing: .1em; }
.doc p { font-size: calc(14px * var(--fs)); }
.tree2-legend, .map-caption, .contrib .by, .memory span { font-size: calc(13.5px * var(--fs)); }

@media (max-width: 760px) {
  /* Todas las pestañas visibles en dos filas: nada escondido tras un menú,
     que es justo lo que la investigación dice que pierde a la gente mayor. */
  .tabs {
    left: 8px; right: 8px; bottom: 8px; transform: none; width: auto; max-width: none;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
    border-radius: 24px; padding: 7px; overflow: visible;
  }
  .tabs button { min-height: 58px; padding: 8px 4px; border-radius: 18px; }
  .tabs button i { font-size: calc(20px * var(--fs)); }
  .tabs button span { display: block; font-size: calc(11.5px * var(--fs)); font-weight: 700; }
  .app { padding-bottom: 168px; }

  /* La marca cabía en una línea sólo en escritorio. */
  .brand { padding: 4px 6px; gap: 8px; }
  .brand small { display: none; }
  .brand .dot { width: 34px; height: 34px; }
  .topbar { gap: 6px; padding: 10px 12px; }

  .view { padding: 14px 14px 10px; }
  .page-head h2 { font-size: clamp(26px, 7.5vw, 34px); }
  .hero { padding: 22px 18px; }
  .btn, .btn.big { width: auto; }
  .cta .btn { flex: 1 1 100%; justify-content: center; }
  .tree-actions .btn { flex: 1 1 100%; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .modal { padding: 18px 16px; border-radius: 26px; }
  .modal-back { padding: 2vh 8px; }
  .drawer { padding: 18px 16px 40px; }
  .viewswitch { width: 100%; }
  .viewswitch button { flex: 1; padding: 12px 8px; }
  .tree-top { gap: 10px; }
  .focus-chip { width: 100%; justify-content: space-between; }
  .facegrid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .fam-wrap { margin: 0 -14px; padding: 4px 14px 12px; }
  svg.fan { height: 52vh; }
  .plist-row { min-height: 84px; }
  .whole-wrap { height: 58vh; }
  .contrib { flex-direction: column; }
  .contrib img { width: 100%; height: 180px; }
  .row { padding: 14px; }
}

@media (min-width: 761px) and (max-width: 1080px) {
  /* Tablet: las ocho pestañas caben en una fila, pero con más aire. */
  .tabs button { padding: 11px 15px; min-height: 56px; }
  .grid.three { grid-template-columns: repeat(2, 1fr); }
  .app { padding-bottom: 120px; }
}

/* En pantallas táctiles el hover no existe: que el foco se vea igual. */
@media (hover: none) {
  .btn:hover, .feed-item:hover, .story-card:hover, .doc:hover,
  .face:hover, .branch-portal:hover, .plist-row:hover { transform: none; }
  .btn:active { transform: scale(.97); }
  .plist-row:active, .face:active, .branch-portal:active { border-color: var(--aragon); }
}

.realmap .phit { pointer-events: all; }
.realmap .place:focus-visible .pdot { stroke: var(--ink); stroke-width: 3; }

/* El mapa encogía a ~390 px de ancho en un móvil, y con él los puntos, que
   quedaban de 6 px: imposible acertar con el dedo. En pantallas estrechas se
   dibuja a un tamaño mínimo legible y se desplaza en horizontal. */
@media (max-width: 760px) {
  .map-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
  svg.realmap { min-width: 720px; height: min(56vh, 460px); }
  .map-caption::after { content: " Desliza el mapa de lado para verlo entero."; color: var(--ink-3); }
}
/* Los enlaces de la pantalla de acceso eran de 20 px de alto: es lo primero
   que toca todo el mundo, y en un móvil no se acierta. */
.switcher { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; align-items: center; }
.switcher button { min-height: 46px; padding: 12px 14px; border-radius: 12px; }
.switcher button:hover { background: color-mix(in srgb, var(--aragon) 12%, transparent); }

.couple-break path { stroke: var(--rose); stroke-width: 4; stroke-linecap: round; }
.couple-cap rect { fill: var(--panel); stroke: var(--rose); stroke-width: 2; }
.couple-cap text { font-size: 14px; font-weight: 700; fill: var(--rose); font-variant-numeric: tabular-nums; }
.couple-year { font-size: 13px; font-weight: 700; fill: var(--rose); font-variant-numeric: tabular-nums; }
.regname { font-size: calc(13px * var(--fs)); color: var(--ink-3); margin-top: 2px; font-style: italic; }
.union-dot { stroke: var(--panel); stroke-width: 2.5; }
