/* =========================================================
   ANTES DE QUE SE NOS OLVIDE — Estilos v2
   Crema cálido + terracota · Nunito/Inter · microanimaciones
   ========================================================= */

:root {
  --bg: #fdf8ec;
  --card: #ffffff;
  --card-border: #f0e8d5;
  --ink: #3d342a;
  --ink-soft: #7c7163;
  --ink-faint: #ab9f8e;
  --primary: #df7857;
  --primary-dark: #c9603f;
  --primary-soft: #fbeee7;
  --accent-gold: #e8b54a;
  --accent-green: #5ba47f;
  --danger: #c75c4a;
  --night: #232746;
  --shadow: 0 2px 6px rgba(125, 98, 60, 0.05), 0 8px 24px rgba(125, 98, 60, 0.08);
  --shadow-lift: 0 4px 10px rgba(125, 98, 60, 0.08), 0 14px 34px rgba(125, 98, 60, 0.14);
  --radius: 22px;
  --radius-sm: 14px;
  --font-display: "Nunito", "Inter", system-ui, sans-serif;
  --font-body: "Inter", "Roboto", -apple-system, "Segoe UI", system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Fondo cálido con halos suaves */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(560px 420px at 18% -5%, rgba(242, 169, 59, .13), transparent 70%),
    radial-gradient(640px 480px at 105% 12%, rgba(223, 120, 87, .10), transparent 70%),
    radial-gradient(700px 540px at 50% 115%, rgba(232, 99, 140, .07), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Marco móvil centrado ---------- */
#app {
  position: relative; z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px 18px 48px;
  display: flex;
  flex-direction: column;
}

.screen { animation: fadeIn .3s ease both; flex: 1; display: flex; flex-direction: column; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Tipografía ---------- */
h1, h2, h3 { font-family: var(--font-display); }
h1 { font-size: 1.9rem; line-height: 1.18; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.32rem; line-height: 1.25; font-weight: 800; letter-spacing: -0.01em; }
h3 { font-size: 1.04rem; font-weight: 700; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .85rem; font-weight: 400; }
.center { text-align: center; }
.small { font-size: .88rem; }
.full-width { width: 100%; justify-content: center; }

/* ---------- Cabeceras ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px; min-height: 42px;
}
.topbar .title-wrap { flex: 1; text-align: center; min-width: 0; }
.topbar .title-wrap h2 { margin: 0; }
.topbar .title-wrap .sub { font-size: .82rem; color: var(--ink-soft); }
.topbar-spacer { width: 42px; flex: 0 0 42px; }

.icon-btn {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--ink);
  font-size: 1.05rem;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.icon-btn:hover { box-shadow: var(--shadow-lift); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.ghost { border: none; background: transparent; box-shadow: none; }
.icon-btn.small { width: 34px; height: 34px; flex: 0 0 34px; font-size: .9rem; }
.icon-btn.danger { color: var(--danger); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 14px 22px;
  border-radius: 16px;
  border: none;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, filter .14s ease;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-big { padding: 16px 24px; font-size: 1.05rem; border-radius: 18px; }
.btn-primary {
  background: linear-gradient(135deg, #e8865f, #d96a47);
  color: #fff;
  box-shadow: 0 6px 16px rgba(217, 106, 71, .32), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled {
  background: #e9dfcd; color: #ab9f8e; box-shadow: none; cursor: not-allowed; filter: none;
}
.btn-ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
}
.btn-ghost:hover { border-color: #e3d6ba; box-shadow: var(--shadow-lift); }
.btn-text {
  background: transparent; color: var(--ink-soft);
  font-weight: 600; box-shadow: none; padding: 10px;
}
.btn-text:hover { color: var(--ink); }
.btn-sm { padding: 9px 14px; font-size: .88rem; width: auto; border-radius: 12px; }
.btn-danger-text { background: transparent; color: var(--danger); font-weight: 600; padding: 10px; }
.btn-night {
  background: linear-gradient(135deg, #f0c24b, #e8964a);
  color: #3a2c10;
  box-shadow: 0 6px 18px rgba(240, 194, 75, .35);
}

.btn-row { display: flex; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.divider { height: 1px; background: var(--card-border); margin: 22px 0; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.clickable { cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.card.clickable:active { transform: scale(.985); }
.card.locked { opacity: .6; }
.card + .card { margin-top: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef7ee;
  border: 1px solid #d9ead9;
  color: #4a7c59;
  padding: 7px 15px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
}
.badge.gray { background: #f3efe6; border-color: #e4dcc9; color: var(--ink-soft); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--ink-soft);
  font-size: .85rem; font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  font-family: var(--font-body);
}
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }

/* ---------- HOME ---------- */
.home {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center;
  gap: 8px; padding-top: 5vh;
}
.mascot-wrap { position: relative; width: 150px; height: 130px; margin-bottom: 6px; }
.mascot {
  font-size: 3.6rem;
  width: 146px; height: 146px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle, #fff1d2 0%, rgba(255, 241, 210, 0) 74%);
  margin: 0 auto;
  animation: floaty 4.5s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-9px) rotate(2deg); } }
.float-emoji { position: absolute; font-size: 1.15rem; opacity: .85; animation: floaty 5s ease-in-out infinite; }
.float-emoji.f1 { left: -4px; top: 8px; animation-delay: -1.2s; }
.float-emoji.f2 { right: 0; top: 0; animation-delay: -2.6s; font-size: .95rem; }
.float-emoji.f3 { right: -10px; bottom: 14px; animation-delay: -.6s; }
.float-emoji.f4 { left: 2px; bottom: 2px; animation-delay: -3.4s; font-size: .95rem; }
.home h1 { font-size: 2.15rem; }
.home .subtitle { color: var(--ink-soft); max-width: 290px; margin-bottom: 10px; }
.home .actions { width: 100%; max-width: 330px; margin-top: 18px; }
.home .links { display: flex; gap: 18px; margin-top: 16px; }
.home .links a { color: var(--ink-faint); font-size: .86rem; text-decoration: none; font-weight: 500; }
.home .links a:hover { color: var(--ink-soft); }
.home .credit { margin-top: auto; padding-top: 40px; font-size: .78rem; color: var(--ink-faint); }

/* ---------- RITUAL ---------- */
.ritual {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center;
}
.ritual .heart {
  font-size: 2.6rem;
  width: 100px; height: 100px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe9d9, #ffd9cf);
  animation: pulse 2.6s ease-in-out infinite;
  margin-bottom: 26px;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(238, 125, 139, .28); }
  50% { transform: scale(1.07); box-shadow: 0 0 0 26px rgba(238, 125, 139, 0); }
}
.ritual .lines { font-family: var(--font-display); font-size: 1.65rem; font-weight: 800; line-height: 1.5; }
.ritual .countdown { font-family: var(--font-display); font-size: 2.8rem; font-weight: 800; color: var(--primary); min-height: 66px; }
.ritual .actions { width: 100%; max-width: 330px; margin-top: 28px; }

/* ---------- SETUP / SESIÓN ---------- */
.person-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: var(--card);
  font-family: var(--font-body); font-size: .98rem; font-weight: 500; color: var(--ink);
  cursor: pointer;
  transition: all .15s ease;
  text-align: left;
}
.person-option .emoji { font-size: 1.45rem; }
.person-option.selected {
  border-color: var(--accent-gold);
  background: #fffaf0;
  box-shadow: 0 0 0 3px rgba(232, 181, 74, .16), var(--shadow);
}
.person-option:active { transform: scale(.97); }
.person-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.person-grid .person-option { flex-direction: column; text-align: center; padding: 18px 10px; gap: 6px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.field input[type="text"], .field input[type="number"], .field input[type="password"], .field textarea {
  font-family: var(--font-body); font-size: 1rem;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: #fffdf8; color: var(--ink);
  outline: none;
  transition: border-color .15s ease;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.field input.center { text-align: center; }
.pin-input { font-size: 1.4rem !important; text-align: center; letter-spacing: .4em; }

.check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: var(--card);
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color .15s ease;
}
.check-row:hover { border-color: #e3d6ba; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.child-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.child-row input[type="text"] {
  font-family: var(--font-body); font-size: .95rem;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: #fffdf8;
  outline: none;
}
.child-row input[type="text"]:focus { border-color: var(--primary); }
.child-row .name { flex: 1; min-width: 0; }
.child-row .emoji-in { width: 64px; text-align: center; }

/* ---------- BARRA DE ENERGÍA ---------- */
.energy-card { padding: 14px 16px; }
.energy-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.energy-head .label { font-size: .88rem; font-weight: 700; display: flex; align-items: center; gap: 6px; font-family: var(--font-display); }
.energy-head .count { font-size: .88rem; font-weight: 800; color: var(--accent-gold); font-family: var(--font-display); }
.energy-track {
  height: 12px; border-radius: 999px;
  background: #f1e9d5; overflow: hidden;
  position: relative;
}
.energy-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #f0c24b, #e8964a);
  transition: width .7s cubic-bezier(.22, 1, .36, 1);
  position: relative;
  overflow: hidden;
}
.energy-fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%);
  animation: shimmer 2.6s ease-in-out infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }
.energy-gain { font-size: .8rem; color: var(--accent-green); font-weight: 700; margin-top: 6px; }

/* ---------- CAPÍTULOS ---------- */
.streak-chip {
  display: inline-flex; align-items: center; gap: 6px;
  align-self: center;
  background: #fdf1dc; border: 1px solid #f3ddb5;
  color: #9a6b1f;
  padding: 7px 16px; border-radius: 999px;
  font-size: .82rem; font-weight: 700;
  font-family: var(--font-display);
}

.daily-card {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  font-family: var(--font-body); font-size: .95rem; color: var(--ink);
  background: linear-gradient(135deg, #fff8ea, #fdeede);
  border: 1px solid #f3ddb5;
}
.daily-card .daily-emoji { font-size: 1.5rem; }
.daily-card .daily-body { flex: 1; display: flex; flex-direction: column; }
.daily-card .daily-body strong { font-family: var(--font-display); font-size: 1rem; }

.memory-card { background: linear-gradient(135deg, #fdfbff, #f6f1fc); border-color: #e6dcf2; }
.memory-card .mem-label { font-size: .78rem; font-weight: 800; color: #8b6fc0; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.memory-card .mem-q { font-weight: 700; font-size: .92rem; font-family: var(--font-display); margin-bottom: 4px; }
.memory-card .mem-a { font-size: .88rem; color: var(--ink-soft); font-style: italic; }
.memory-card .mem-meta { font-size: .76rem; color: var(--ink-faint); margin-top: 6px; }

.chapter-card { display: flex; align-items: center; gap: 14px; }
.chapter-card .ch-emoji {
  font-size: 1.5rem;
  width: 50px; height: 50px; flex: 0 0 50px;
  border-radius: 16px;
  background: #fdf3e3;
  display: flex; align-items: center; justify-content: center;
}
.chapter-card.locked .ch-emoji { background: #f3efe6; }
.chapter-card .ch-body { flex: 1; min-width: 0; }
.chapter-card .ch-body h3 { margin-bottom: 2px; }
.chapter-card .ch-body .intro { font-size: .82rem; color: var(--ink-soft); }
.chapter-card .ch-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.chapter-card .chevron { color: var(--ink-faint); font-size: 1.3rem; transition: transform .15s ease; }
.chapter-card.clickable:hover .chevron { transform: translateX(3px); color: var(--accent, var(--ink-soft)); }
.mini-track {
  flex: 1; max-width: 110px;
  height: 6px; border-radius: 999px; background: #f1e9d5; overflow: hidden;
}
.mini-fill { height: 100%; border-radius: 999px; background: var(--accent-green); transition: width .4s ease; }
.mini-count { font-size: .75rem; color: var(--ink-faint); font-weight: 700; }
.mini-count.done-check { color: var(--accent-green); font-size: .9rem; }
.lock-pill {
  font-size: .7rem; font-weight: 700;
  background: #f3efe6; color: var(--ink-faint);
  border-radius: 999px; padding: 4px 10px;
  max-width: 130px; text-align: center;
}

.bottom-access { display: flex; gap: 10px; margin-top: 22px; }
.bottom-access .btn { flex: 1; }
.pill-count {
  background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 999px; font-size: .75rem; font-weight: 800;
  padding: 2px 8px;
}

/* ---------- DETALLE CAPÍTULO ---------- */
.chapter-hero { text-align: center; margin-bottom: 18px; }
.chapter-hero .big-emoji {
  font-size: 2.6rem;
  width: 88px; height: 88px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 28px;
  background: #fdf3e3;
  margin-bottom: 10px;
  animation: popIn .4s cubic-bezier(.18, 1.3, .4, 1) both;
}
.q-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.q-row .q-state {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .84rem; font-weight: 800;
  font-family: var(--font-display);
  background: #f3efe6; color: var(--ink-faint);
}
.q-row .q-state.done { background: #e3f2e7; color: var(--accent-green); }
.q-row .q-text { flex: 1; font-size: .9rem; }
.q-row .q-text.done { color: var(--ink-faint); }
.q-row .chevron { color: var(--ink-faint); }

/* ---------- PREGUNTA ---------- */
.dots { display: flex; gap: 8px; justify-content: center; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #e9dfca;
  transition: all .2s ease;
}
.dot.filled { background: var(--accent, var(--primary)); opacity: .45; }
.dot.current {
  background: var(--accent, var(--primary));
  transform: scale(1.35);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, var(--primary)) 18%, transparent);
}

.question-big {
  font-family: var(--font-display);
  font-size: 1.42rem; font-weight: 800; line-height: 1.32;
  letter-spacing: -0.01em; margin-bottom: 12px;
}

.hint-box {
  background: #fdf6e3;
  border: 1px solid #f1e4bd;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: .88rem;
  color: #8a7340;
  display: flex; gap: 8px;
  margin-bottom: 10px;
  animation: fadeIn .25s ease both;
}
.hint-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--ink-faint); font-size: .84rem; font-weight: 700;
  font-family: var(--font-display);
  padding: 4px 0; margin-bottom: 8px;
}
.hint-toggle:hover { color: var(--ink-soft); }

.honesty { font-size: .82rem; color: var(--ink-faint); text-align: center; margin: 8px 0 16px; }

.turn-card { margin-bottom: 12px; }
.turn-card .turn-label {
  font-size: .8rem; font-weight: 800; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .04em;
  font-family: var(--font-display);
}
.turn-card textarea {
  width: 100%;
  min-height: 96px;
  font-family: var(--font-body); font-size: .96rem; line-height: 1.5;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: #fffdf8; color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color .15s ease;
}
.turn-card textarea:focus { border-color: var(--primary); }
.turn-card .turn-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.turn-card.done-state { background: #f7faf4; border-color: #ddead6; }
.turn-card .saved-answer { font-size: .94rem; white-space: pre-wrap; }
.turn-card .passed-note { font-size: .9rem; color: var(--ink-faint); font-style: italic; }
.turn-status { font-size: .78rem; font-weight: 700; color: var(--accent-green); text-transform: none; letter-spacing: 0; }

.extra-actions { display: flex; gap: 8px; justify-content: center; margin: 4px 0 14px; }
.extra-actions .btn { width: auto; }

/* ---------- CÁPSULA GUARDADA ---------- */
.saved-hero { text-align: center; margin: 18px 0; }
.saved-hero .check {
  font-size: 2rem;
  width: 80px; height: 80px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #e3f2e7;
  display: flex; align-items: center; justify-content: center;
  animation: popIn .5s cubic-bezier(.18, 1.4, .4, 1) both;
}
@keyframes popIn { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.capsule-summary .row { display: flex; gap: 10px; padding: 7px 0; font-size: .9rem; }
.capsule-summary .row .k { color: var(--ink-faint); flex: 0 0 92px; }
.capsule-summary .row .v { flex: 1; font-weight: 500; }

/* ---------- CÁPSULAS (archivo) ---------- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 999px;
  padding: 11px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.search-box input {
  flex: 1; border: none; outline: none; background: none;
  font-family: var(--font-body); font-size: .95rem; color: var(--ink);
}
.capsule-card { border-left: 4px solid var(--accent, var(--card-border)); }
.capsule-card .cap-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.capsule-card .cap-meta { font-size: .78rem; color: var(--ink-faint); }
.capsule-card .cap-q { font-weight: 700; font-size: .95rem; margin: 8px 0 10px; font-family: var(--font-display); }
.capsule-card .cap-answer { font-size: .9rem; margin-bottom: 8px; }
.capsule-card .cap-answer .who {
  font-size: .74rem; font-weight: 800; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 2px;
  font-family: var(--font-display);
}
.capsule-card .cap-answer.empty { color: var(--ink-faint); font-style: italic; }
.fav-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.15rem; padding: 2px;
  filter: grayscale(1); opacity: .4;
  transition: all .15s ease;
}
.fav-btn.active { filter: none; opacity: 1; transform: scale(1.12); }
.archive-footer { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

select.filter-select {
  font-family: var(--font-body); font-size: .88rem;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: var(--card); color: var(--ink);
  outline: none;
}

.empty-state { text-align: center; color: var(--ink-soft); padding: 30px 18px; }
.empty-emoji { font-size: 2.2rem; display: block; margin-bottom: 8px; }

/* ---------- CARLOTINES ---------- */
.carlotin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.carlotin-grid .card + .card { margin-top: 0; }
.carlotin-card {
  text-align: center; padding: 18px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.carlotin-card .c-emoji {
  font-size: 2.2rem;
  width: 68px; height: 68px;
  border-radius: 50%;
  background: #f3efe6;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.carlotin-card .c-emoji.unlocked {
  background: radial-gradient(circle, #fdf0d4, #fbe6c4);
  box-shadow: 0 0 0 4px rgba(232, 181, 74, .18);
}
.carlotin-card.locked .c-emoji { filter: grayscale(1) blur(3px); opacity: .5; }
.carlotin-card .c-keeps { font-size: .78rem; color: var(--ink-soft); min-height: 2.4em; }
.carlotin-card .c-cond { font-size: .72rem; color: var(--ink-faint); }
.carlotin-card .default-tag {
  font-size: .68rem; font-weight: 800; color: var(--accent-green);
  background: #e3f2e7; border-radius: 999px; padding: 3px 9px;
  font-family: var(--font-display);
}
.how-born {
  margin-top: 18px;
  background: #fdf6e3; border: 1px solid #f1e4bd;
  border-radius: var(--radius);
  padding: 16px;
  font-size: .88rem; color: #8a7340;
}

/* ---------- CÓMO SE JUEGA ---------- */
.howto-step { display: flex; gap: 14px; align-items: flex-start; }
.howto-step .s-icon {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
}
.howto-step .s-body h3 { margin-bottom: 3px; font-size: .98rem; }
.howto-step .s-body p { font-size: .86rem; color: var(--ink-soft); }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(61, 52, 42, .45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 50;
  animation: fadeIn .2s ease both;
}
.modal {
  background: var(--card);
  border-radius: 28px;
  padding: 28px 22px;
  max-width: 390px; width: 100%;
  max-height: 84vh; overflow-y: auto;
  text-align: center;
  box-shadow: 0 24px 70px rgba(61, 52, 42, .35);
  animation: popIn .4s cubic-bezier(.18, 1.3, .4, 1) both;
  position: relative;
}
.modal .m-emoji { font-size: 2.6rem; display: block; margin-bottom: 8px; }
.modal .m-emoji.big { font-size: 3.4rem; margin: 10px 0 6px; }
.modal .m-emoji.pop { animation: popIn .5s cubic-bezier(.18, 1.5, .4, 1) both; }
.modal h2 { margin-bottom: 6px; }
.modal .stack { margin-top: 16px; }

/* Modal nocturno para cuentos */
.night-backdrop { background: rgba(18, 20, 40, .62); }
.modal.night {
  background: linear-gradient(170deg, #2b3057 0%, #232746 55%, #1d2038 100%);
  color: #f3eedd;
  overflow: hidden;
}
.modal.night h2 { color: #ffe9b0; }
.modal.night .night-sub { color: #aab0d8; font-size: .85rem; margin-bottom: 4px; }
.modal.night .story {
  text-align: left;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-size: .95rem; line-height: 1.85;
  margin: 14px 0 4px;
  white-space: pre-line;
  position: relative; z-index: 1;
}
.night-stars { position: absolute; inset: 0; pointer-events: none; }
.night-stars::before, .night-stars::after {
  content: "✦";
  position: absolute;
  color: #ffe9b0;
  animation: twinkle 2.8s ease-in-out infinite;
}
.night-stars::before { top: 22px; left: 26px; font-size: .8rem; }
.night-stars::after { top: 48px; right: 32px; font-size: .6rem; animation-delay: -1.4s; }
@keyframes twinkle { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

/* Modal claro: story por si se usa fuera del modo noche */
.modal .story {
  text-align: left;
  background: #fdf6e9; border-radius: var(--radius-sm);
  padding: 16px;
  font-size: .92rem; line-height: 1.75;
  margin: 14px 0;
  white-space: pre-line;
}
.modal.night .story { background: rgba(255, 255, 255, .06); }

/* ---------- CONFETI ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i {
  position: absolute; top: -14px;
  border-radius: 2px;
  animation: confetti-fall linear both;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(106vh) rotate(680deg); opacity: .85; }
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow-lift);
  z-index: 80;
  animation: toastIn .25s ease both;
  max-width: 88vw; text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- MODO CREADOR (admin) ---------- */
.tabs {
  display: flex; gap: 6px;
  background: #f3ecd9;
  border-radius: 999px;
  padding: 5px;
}
.tab {
  flex: 1;
  border: none; background: transparent;
  font-family: var(--font-display); font-size: .85rem; font-weight: 700;
  color: var(--ink-soft);
  padding: 9px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.tab.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.admin-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.admin-row.row-hidden { opacity: .55; }
.admin-row .a-emoji {
  font-size: 1.3rem;
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 14px;
  background: #f7f1e2;
  display: flex; align-items: center; justify-content: center;
}
.admin-row .a-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-row .a-body strong { font-family: var(--font-display); }
.admin-row .a-body .faint { font-size: .76rem; }
.admin-row .a-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.tag {
  display: inline-block;
  font-size: .66rem; font-weight: 800;
  border-radius: 999px; padding: 2px 8px;
  margin-right: 4px; margin-top: 3px;
  font-family: var(--font-display);
  text-transform: uppercase; letter-spacing: .04em;
}
.tag.base { background: #eef3f8; color: #5b7ba4; }
.tag.custom { background: #eaf6ee; color: #3f8f63; }
.tag.edited { background: #fdf1dc; color: #9a6b1f; }
.tag.hidden-tag { background: #f3e9e7; color: #b06a5a; }

.editor-head-row { display: flex; gap: 10px; }
.q-edit-row { padding: 14px 16px; }
.q-edit-row .q-edit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.q-edit-row .q-edit-head strong { font-family: var(--font-display); font-size: .88rem; }
.q-edit-row textarea, .q-edit-row input {
  width: 100%;
  font-family: var(--font-body); font-size: .92rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: #fffdf8; color: var(--ink);
  outline: none;
  resize: vertical;
}
.q-edit-row textarea:focus, .q-edit-row input:focus { border-color: var(--primary); }
.q-edit-row input { margin-top: 8px; }

.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .12s ease;
}
.color-dot:hover { transform: scale(1.12); }
.color-dot.selected { border-color: var(--ink); transform: scale(1.12); }

.danger-zone { border-color: #f0d9d3; background: #fdf8f6; }
.publish-card { border-color: #e8d9a8; background: linear-gradient(135deg, #fffaf0, #fdf3df); }
.publish-card h3 { display: flex; align-items: center; gap: 6px; }

/* ---------- Utilidades ---------- */
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 22px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 14px; } .mb-3 { margin-bottom: 22px; }
.hidden { display: none !important; }

@media (max-width: 380px) {
  .person-grid { grid-template-columns: 1fr; }
  .editor-head-row { flex-wrap: wrap; }
}

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

/* =========================================================
   v3 — Iconos SVG, avatares y figuras Doodol
   ========================================================= */

.ic { flex-shrink: 0; vertical-align: -0.18em; }
.btn .ic, .chip .ic, .badge .ic { margin-right: 2px; }
.home .links a { display: inline-flex; align-items: center; gap: 5px; }

/* Avatares de personas */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  font-family: var(--font-display);
  line-height: 1;
}
.avatar.solid { color: #fff; font-weight: 800; }
.avatar.ghost-avatar { background: #f3efe6; color: var(--ink-faint); }

/* Figura Doodol */
.doodol { flex-shrink: 0; vertical-align: -0.25em; }
.mascot .doodol { filter: drop-shadow(0 8px 14px rgba(125, 98, 60, .22)); }
.c-fig {
  width: 76px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  margin-bottom: 6px;
}
.c-fig.unlocked {
  background: radial-gradient(circle at 50% 42%, #fdf0d4, rgba(253, 240, 212, 0) 72%);
}
.carlotin-card.locked .c-fig { opacity: .45; filter: blur(1px) grayscale(.4); }
.carlotin-card.locked h3 { color: var(--ink-faint); }

.m-doodol { display: flex; justify-content: center; margin: 8px 0 4px; position: relative; z-index: 1; }
.m-doodol.pop { animation: popIn .55s cubic-bezier(.18, 1.5, .4, 1) both; }
.m-icon { display: inline-flex; color: var(--ink-soft); margin-bottom: 6px; }
.m-icon.gold { color: var(--accent-gold); }
.modal.night .m-doodol .doodol { filter: drop-shadow(0 0 18px rgba(255, 233, 176, .35)); }

.doodol-preview {
  flex: 0 0 76px;
  display: flex; align-items: center; justify-content: center;
  background: #f7f1e2;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  overflow: hidden;
}
.doodol-preview img { max-height: 76px; max-width: 72px; object-fit: contain; }

/* Fotos reales de los Doodols */
.doodol-photo {
  object-fit: contain;
  vertical-align: middle;
  filter: drop-shadow(0 4px 10px rgba(125, 98, 60, .2));
}

/* Carlotín real en portada */
.mascot-photo {
  height: 138px;
  filter: drop-shadow(0 12px 20px rgba(125, 98, 60, .28));
}

/* Enlaces a doodols.es */
.credit a { color: var(--primary-dark); font-weight: 600; text-decoration: none; }
.credit a:hover { text-decoration: underline; }
.ext-link {
  display: inline-block;
  margin-top: 10px;
  color: #8a7340;
  font-weight: 700;
  font-family: var(--font-display);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ext-link:hover { color: #6f5a2c; }
.how-born-img { display: block; height: 96px; margin: 0 auto 12px; filter: drop-shadow(0 6px 12px rgba(125, 98, 60, .2)); }

/* Dormido → despierto (gana su pajarita) */
.born-pair {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 12px;
}
.born-pair img { height: 88px; filter: drop-shadow(0 6px 12px rgba(125, 98, 60, .18)); }
.born-pair .born-arrow { color: #c5a648; display: inline-flex; }
.cap-meta .doodol-photo { vertical-align: -0.3em; border-radius: 4px; }
.modal.night .doodol-photo { filter: drop-shadow(0 0 18px rgba(255, 233, 176, .4)); border-radius: 10px; }
.c-fig .doodol-photo { border-radius: 8px; }

/* Detalles de color de iconos */
.energy-head .label.gold .ic { color: var(--accent-gold); }
.ritual .heart { color: #e8506b; }
.saved-hero .check { color: var(--accent-green); }
.streak-chip .ic { color: #e07b39; }
.daily-card .daily-emoji { color: #b98a2e; display: inline-flex; }
.memory-card .mem-label { display: inline-flex; align-items: center; gap: 4px; }
.chip .ic { vertical-align: -0.22em; }
.empty-ic { display: block; color: var(--ink-faint); margin: 0 auto 10px; width: fit-content; }
.capsule-summary .guardian-v { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cap-meta .doodol { vertical-align: -0.2em; }
.turn-label .avatar { margin-right: 2px; }
.child-row .avatar { flex: 0 0 38px; }

/* Marco de app en pantallas grandes (PC) */
@media (min-width: 720px) {
  body { padding: 28px 0; }
  #app {
    min-height: calc(100vh - 56px);
    border-radius: 40px;
    background: linear-gradient(180deg, #fffdf6, #fdf8ec);
    border: 1px solid #f0e8d5;
    box-shadow: 0 30px 80px rgba(125, 98, 60, .14);
    padding: 28px 26px 52px;
    overflow: hidden;
  }
}
