:root {
  --fondo: #f7f4ef;
  --tarjeta: #ffffff;
  --texto: #2b2622;
  --suave: #675e56;
  --borde: #e3dcd2;
  --linea: #928679; /* bordes de controles: contraste 3:1 con el fondo */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --acento: #7a5c9e;
  --acento-texto: #ffffff;
  --acento-suave: #efe8f6;
  --no: #b5523b;
  --verde: #2f7a4f; /* persona con sanación reciente */
  --verde-suave: #e6f2ea;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #1b1820; --tarjeta: #25212c; --texto: #ece7f1; --suave: #a79fb1;
    --borde: #3a3443; --linea: #6f6680; --acento: #b596dc; --acento-texto: #1b1820; --acento-suave: #332b3f;
    --no: #e48d75; --verde: #7fcf9c; --verde-suave: #1f3328; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fondo: #1b1820; --tarjeta: #25212c; --texto: #ece7f1; --suave: #a79fb1;
  --borde: #3a3443; --linea: #6f6680; --acento: #b596dc; --acento-texto: #1b1820; --acento-suave: #332b3f;
  --no: #e48d75; --verde: #7fcf9c; --verde-suave: #1f3328; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: clip; }
body {
  margin: 0;
  background: var(--fondo); color: var(--texto);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.progreso { position: fixed; inset: 0 0 auto; height: 4px; background: var(--borde); z-index: 2; }
.progreso span { display: block; height: 100%; width: 0; background: var(--acento); transition: width .35s ease; }

/* Cada paso ocupa la pantalla entera */
main { outline: none; }
.paso {
  min-height: 100dvh; max-width: 680px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: 28px 16px calc(20px + env(safe-area-inset-bottom));
  animation: entra .35s ease both;
}
.paso.atras { animation-name: entra-atras; }
@keyframes entra { from { opacity: 0; transform: translateX(40px); } }
@keyframes entra-atras { from { opacity: 0; transform: translateX(-40px); } }
@media (prefers-reduced-motion: reduce) { .paso { animation: none; } }

.centro { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 10px; }
.etiqueta { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--suave); margin: 0; }
.pregunta { font: 600 clamp(1.7rem, 6.4vw, 2.5rem)/1.2 var(--serif); margin: 0; text-wrap: balance; }
.sub { color: var(--suave); margin: 0; }

.grande {
  width: 100%; border: 0; border-bottom: 2px solid var(--linea); margin-top: 22px; background: none; color: inherit;
  font: 600 clamp(2rem, 9vw, 3.4rem)/1.2 var(--serif); text-align: center; padding: 10px 0; border-radius: 0;
}
.grande:focus { outline: none; border-bottom-color: var(--acento); }
.grande::placeholder { color: var(--suave); opacity: .6; font-weight: 400; }

/* Fecha: rueda deslizante */
.fecha-grande { font-size: clamp(1.5rem, 6.5vw, 2.2rem); font-weight: 600; line-height: 1.15; margin: 8px 0 18px; }
.ruedas { position: relative; display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: 6px; height: 220px; }
.ruedas::before {
  content: ""; position: absolute; left: 0; right: 0; top: 88px; height: 44px; pointer-events: none;
  background: var(--acento-suave); border-radius: 10px; z-index: 0;
}
.rueda {
  position: relative; z-index: 1; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none;
  padding: 88px 0; margin: 0; list-style: none; touch-action: pan-y;
  mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent);
}
.rueda::-webkit-scrollbar { display: none; }
.rueda li { height: 44px; line-height: 44px; scroll-snap-align: center; font-size: 1.2rem; color: var(--suave); cursor: pointer; }
.rueda li.sel { color: var(--texto); font-weight: 600; }

/* Péndulo: dos respuestas grandes */
.respuestas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 18px; }
.respuestas button {
  min-height: 34vh; font-size: clamp(2rem, 9vw, 3rem); font-weight: 600; border-radius: 18px;
  border: 2px solid var(--linea); transition: transform .12s ease, background-color .12s ease;
}
/* Sí y No con el mismo peso visual: la app no debe inclinar la respuesta del péndulo. */
button.si { color: var(--acento); }
button.no { color: var(--no); }
.respuestas button:active { transform: scale(.97); background: var(--acento-suave); }

/* Bloqueos */
.lista { display: grid; gap: 10px; margin: 18px 0 0; padding: 0; border: 0; text-align: left; }
.opcion { display: flex; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--linea); border-radius: 12px; background: var(--tarjeta); cursor: pointer; font-size: 1.05rem; }
.opcion input { width: 22px; height: 22px; margin: 0; accent-color: var(--acento); flex: none; }
.opcion:has(input:checked) { background: var(--acento-suave); border-color: var(--acento); }
textarea { width: 100%; font: inherit; color: inherit; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 12px; min-height: 64px; margin-top: 10px; }

/* Barra inferior */
.pie { display: flex; align-items: center; gap: 10px; padding-top: 20px; }
.separa { flex: 1; }
button { font: inherit; min-height: 48px; border-radius: 12px; padding: 12px 20px; cursor: pointer; border: 1px solid var(--linea); background: var(--tarjeta); color: var(--texto); }
button.principal { background: var(--acento); border-color: var(--acento); color: var(--acento-texto); font-weight: 600; min-width: 140px; }
button.principal:disabled { opacity: .4; cursor: default; }
button.enlace { background: none; border: 0; padding: 8px 4px; min-width: 48px; color: var(--suave); }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

.recientes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.recientes button { min-height: 44px; padding: 6px 12px; font-size: .9rem; }

/* Resumen */
.resumen { text-align: left; }
.resumen dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 14px 0; }
.resumen dt { color: var(--suave); }
.resumen dd { margin: 0; }
.resumen h3 { font-size: 1rem; margin: 20px 0 6px; }
.resumen ul { margin: 4px 0 8px; padding-left: 20px; }
.peticion { font-family: var(--serif); font-size: 1.1rem; background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 12px; padding: 14px 16px; }
.peticion p { margin: 0 0 10px; }
.peticion p:last-child { margin: 0; }
.nota { font-size: .85rem; color: var(--suave); text-align: center; margin-top: 16px; }
.respuestas.tipo button { font-size: clamp(1.4rem, 6vw, 2rem); }
.rezo { text-align: left; margin-top: 8px; }
.pregunta.pequena { font-size: 1.3rem; margin-top: 18px; }
.respuestas.bajo { margin-top: 8px; }
.respuestas.bajo button { min-height: 0; padding: 22px; font-size: 1.6rem; }

/* Lista de personas */
.persona { display: flex; align-items: center; gap: 8px; }
.persona .opcion { flex: 1; min-width: 0; }
/* Sanación en las últimas 48 horas: al final de la lista, en verde. */
.persona.sanada .opcion { border-color: var(--verde); background: var(--verde-suave); }
.hecha { display: block; font-style: normal; font-size: .85rem; font-weight: 600; color: var(--verde); }
.opcion strong { display: block; }
.opcion small { display: block; color: var(--suave); font-size: .85rem; }
button.nueva { border-style: dashed; padding: 16px; }
button.no { color: var(--no); }

/* Rezo por fragmentos */
.titulo-rezo { font-size: 1.05rem; font-weight: 600; color: var(--acento); margin: 0; }
.fragmento {
  font: 500 clamp(1.5rem, 5.8vw, 2.1rem)/1.45 var(--serif); text-wrap: pretty;
  margin: 18px 0 6px; min-height: max(7.5em, 42dvh); display: flex; align-items: center; justify-content: center;
  cursor: pointer; animation: .4s ease both;
}
/* Cada fragmento entra como una pantalla nueva: desde abajo al avanzar, desde arriba al volver. */
.fragmento.sube { animation-name: desde-abajo; }
.fragmento.baja { animation-name: desde-arriba; }
@keyframes desde-abajo { from { opacity: 0; transform: translateY(30vh); } }
@keyframes desde-arriba { from { opacity: 0; transform: translateY(-30vh); } }
@media (prefers-reduced-motion: reduce) { .fragmento { animation: none; } }
/* Texto para leer sin lector: petición de sintonización y cierre. */
.fragmento.fijo { cursor: auto; min-height: 0; margin: 24px 0; animation: none; }
.barra-frag { height: 4px; border-radius: 2px; background: var(--borde); margin: 4px 0 18px; overflow: hidden; }
.barra-frag span { display: block; height: 100%; background: var(--acento); transition: width .3s ease; }
button.seguir { width: 100%; padding: 20px; font-size: 1.3rem; }
#lector { overflow: clip; touch-action: none; }
.logo { width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 22px; }
.respuestas.bajo button:active { transform: scale(.97); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
h1, h2 { margin: 0; font-size: inherit; font-weight: inherit; }
label.pregunta { display: block; }
.fecha-grande { color: var(--acento); }
.pie button { white-space: nowrap; }

/* Aviso para instalar la app */
.aviso { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--linea); border-radius: 14px; background: var(--acento-suave); text-align: left; }
.aviso p { margin: 0 0 6px; }
.aviso-t { font-weight: 600; }
.aviso-x { font-size: .95rem; color: var(--suave); }
.aviso-botones { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 6px; }
.aviso-botones .principal { min-width: 0; }

/* Aviso de versión nueva */
.actualizar {
  position: fixed; z-index: 3; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top));
  max-width: 520px; margin: 0 auto; padding: 12px 16px;
  background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .15); animation: entra-arriba .3s ease both;
}
.actualizar p { margin: 0; }
@keyframes entra-arriba { from { opacity: 0; transform: translateY(-20px); } }
@media (prefers-reduced-motion: reduce) { .actualizar { animation: none; } }

/* Página de privacidad */
.texto-legal { min-height: 0; text-align: left; }
.texto-legal h2 { font: 600 1.2rem/1.3 var(--serif); margin: 26px 0 6px; }
.texto-legal p, .texto-legal ul { margin: 0 0 10px; }
.texto-legal .nota { text-align: left; }
a { color: var(--acento); }
.boton-enlace { display: inline-flex; align-items: center; min-height: 48px; color: var(--suave); text-decoration: none; }

/* Pie con el enlace a la privacidad */
.legal { text-align: center; padding-top: 6px; font-size: .85rem; }
.legal p { margin: 8px 0 0; color: var(--suave); }
.legal a { display: inline-block; padding: 12px; color: var(--suave); }
button.yo-datos { justify-self: start; margin-top: -4px; padding: 8px 4px; color: var(--acento); }
.texto-legal button.no { border-color: var(--no); }

/* Resumen por persona */
.persona-resumen { border-top: 1px solid var(--borde); padding-top: 12px; margin-top: 16px; }
.persona-resumen h2 { font: 600 1.25rem/1.3 var(--serif); margin: 0; }
.persona-resumen li small { display: block; color: var(--suave); font-size: .85rem; margin-top: 2px; }
.persona-resumen li b { color: var(--texto); font-weight: 600; }
.persona.sanada .opcion:has(input:checked) { border-color: var(--acento); }

/* Donativo */
.donativos { display: grid; gap: 12px; margin-top: 18px; }
.donar { display: block; padding: 18px 20px; border-radius: 12px; background: var(--acento); color: var(--acento-texto); font-weight: 600; font-size: 1.15rem; text-decoration: none; }
.donar:active { transform: scale(.97); }
.donar:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
.codigo { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 18px; text-align: left; }
.codigo label { grid-column: 1 / -1; font-size: .95rem; color: var(--suave); }
.codigo input { font: inherit; min-height: 48px; padding: 10px 12px; border: 1px solid var(--linea); border-radius: 12px; background: var(--tarjeta); color: var(--texto); }
.codigo .sub { grid-column: 1 / -1; }

/* Rejilla de números para que el péndulo señale uno (vivienda). */
.numeros { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; margin-top: 18px; }
.numeros button {
  min-height: 52px; border: 2px solid var(--linea); border-radius: 12px; background: var(--tarjeta);
  color: var(--texto); font-size: 1.15rem; font-weight: 600; transition: transform .12s ease, background-color .12s ease;
}
.numeros.pocos { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.numeros.pocos button:last-child { grid-column: span 2; }
.numeros button:active { transform: scale(.97); background: var(--acento-suave); }
