:root {
  --azul: #0d1b33;
  --azul-2: #16294a;
  --oro: #e2b04a;
  --oro-claro: #f6dc95;
  --crema: #fbf6ec;
  --papel: #ffffff;
  --texto: #1f2430;
  --suave: #6b6f7a;
  --borde: #ebe3d2;
  --verde: #2f8a5b;
  --radio: 16px;
  --sombra: 0 6px 20px rgba(13, 27, 51, .10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--crema);
  color: var(--texto);
  font: 16px/1.55 "Inter", system-ui, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: "Cinzel", Georgia, serif; line-height: 1.2; margin: 0; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--azul);
  min-height: 52px;
  padding: 14px 16px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.brand { font-family: "Cinzel", serif; font-weight: 700; color: var(--oro-claro); letter-spacing: .04em; font-size: 18px; }
.brand span { color: var(--oro); }

main { max-width: 960px; margin: 0 auto; padding: 16px; outline: none; }

/* ---------- Barra de pestañas ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--azul);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(226,176,74,.25);
}
.tabbar a {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: #a9b3c6; font-size: 11px; font-weight: 500; padding: 4px 2px;
  white-space: nowrap;
}
.tabbar { padding-left: 4px; padding-right: 4px; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tabbar a.activo { color: var(--oro); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 22px; border-radius: 999px;
  font: 600 15px "Inter", sans-serif; border: 0; cursor: pointer;
}
.btn-oro { background: linear-gradient(180deg, var(--oro-claro), var(--oro)); color: var(--azul); box-shadow: 0 4px 12px rgba(226,176,74,.35); }
.btn-linea { background: transparent; color: var(--azul); border: 1.5px solid var(--azul); }
.btn-full { width: 100%; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #9a7420; background: #f6ebcf; padding: 4px 10px; border-radius: 999px; }
.chip-claro { background: rgba(226,176,74,.18); color: var(--oro-claro); }

/* ---------- Inicio ---------- */
.hero { position: relative; border-radius: var(--radio); overflow: hidden; min-height: 200px; display: flex; align-items: flex-end; background: var(--azul); }
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 100% center; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(13,27,51,.92) 0%, rgba(13,27,51,.65) 55%, rgba(13,27,51,.1) 100%); }
.hero-txt { position: relative; z-index: 1; padding: 22px; max-width: 460px; color: #fff; }
.hero h1 { color: var(--oro-claro); font-size: 28px; margin-bottom: 6px; }
.hero p { margin: 0; color: #e7eaf1; font-size: 15px; }

.hoy {
  display: block; margin-top: 16px; padding: 20px; border-radius: var(--radio);
  background: radial-gradient(circle at 85% 0%, #2a467a 0%, var(--azul) 65%); color: #fff;
  box-shadow: var(--sombra);
}
.hoy-etq { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--oro); }
.hoy-tit { font-family: "Cinzel", serif; font-size: 22px; margin: 6px 0 10px; color: var(--oro-claro); }
.hoy-vers { font-family: "Lora", serif; font-style: italic; color: #dfe4ee; margin-bottom: 16px; }
.hoy-vers em { font-style: normal; font-family: "Inter", sans-serif; font-size: 13px; color: var(--oro); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stats div { background: var(--papel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; text-align: center; }
.stats b { display: block; font-size: 24px; color: var(--azul); }
.stats span { font-size: 13px; color: var(--suave); }

.bloque { margin-top: 28px; }
.bloque h2 { font-size: 19px; color: var(--azul); }
.bloque-sub { margin: 4px 0 0; color: var(--suave); font-size: 14px; }
.bloque-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bloque-cab a { font-size: 14px; font-weight: 600; color: #9a7420; white-space: nowrap; }

.destacado {
  display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center;
  margin-top: 12px; padding: 16px; border-radius: var(--radio);
  background: var(--papel); border: 1px solid var(--borde); box-shadow: var(--sombra);
}
.destacado h3 { font-size: 18px; color: var(--azul); }
.destacado p { margin: 6px 0 12px; color: var(--suave); font-size: 14px; }
.destacado-img img { border-radius: 8px; }

.carrusel { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 12px 2px 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.carrusel::-webkit-scrollbar { display: none; }
.carrusel .libro { flex: 0 0 140px; scroll-snap-align: start; }

/* ---------- Libros ---------- */
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; margin-top: 14px; }
.libro-portada {
  position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden;
  background: #fff; border: 1px solid var(--borde); box-shadow: var(--sombra);
  display: flex; align-items: center; justify-content: center;
}
.libro-portada img { width: 100%; height: 100%; object-fit: cover; }
.libro-titulo { margin-top: 8px; font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--azul); }
.sello { position: absolute; top: 8px; right: 8px; background: var(--verde); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }

.portada-gen {
  width: 100%; height: 100%; padding: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; color: var(--oro-claro); font-family: "Cinzel", serif;
  border: 3px double rgba(226,176,74,.6); outline: 6px solid var(--azul); outline-offset: -9px;
}
.portada-gen strong { font-size: 15px; line-height: 1.25; }
.pg-orn { color: var(--oro); font-size: 14px; }
.tono-oro   { background: radial-gradient(circle at 50% 35%, #3a5385, var(--azul) 70%); }
.tono-rubi  { background: radial-gradient(circle at 50% 35%, #7a2c34, #2b0f15 75%); }
.tono-cielo { background: radial-gradient(circle at 50% 35%, #2e6e8e, #0e2433 75%); }
.tono-verde { background: radial-gradient(circle at 50% 35%, #3e6b47, #13241a 75%); }

.titulo-pag { font-size: 26px; color: var(--azul); }
.sub-pag { margin: 4px 0 0; color: var(--suave); }

.volver { display: inline-block; font-size: 14px; font-weight: 600; color: #9a7420; margin-bottom: 14px; }

.ficha { display: grid; grid-template-columns: 1fr; gap: 20px; }
.ficha-portada { max-width: 240px; margin: 0 auto; width: 100%; }
.ficha-portada img, .ficha-portada .portada-gen { border-radius: 12px; box-shadow: var(--sombra); aspect-ratio: 3/4; }
.ficha-portada img { object-fit: cover; width: 100%; }
.ficha h1 { font-size: 24px; color: var(--azul); margin: 10px 0 8px; }
.ficha p { color: var(--suave); margin: 0 0 18px; }
.acciones { display: flex; flex-wrap: wrap; gap: 10px; }
.marcar { margin-top: 16px; background: none; border: 0; padding: 8px 0; color: var(--suave); font: 500 15px "Inter", sans-serif; cursor: pointer; text-decoration: underline; }
.marcar.activo { color: var(--verde); text-decoration: none; font-weight: 600; }

/* ---------- Devocional ---------- */
.devo-cab {
  padding: 24px 20px; border-radius: var(--radio); color: #fff;
  background: radial-gradient(circle at 80% 0%, #c08a2b 0%, #5a3b16 35%, var(--azul) 80%);
  box-shadow: var(--sombra);
}
.devo-cab h1 { font-size: 30px; color: var(--oro-claro); margin: 10px 0 8px; }
.devo-cab p { color: #e7eaf1; margin: 0 0 18px; font-size: 15px; }
.barra { height: 8px; background: rgba(255,255,255,.18); border-radius: 999px; overflow: hidden; }
.barra div { height: 100%; background: var(--oro); border-radius: 999px; transition: width .3s; }
.barra-txt { font-size: 13px; color: #cfd6e4; margin: 6px 0 16px; }

.dias { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 8px; }
.dia {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--papel); border: 1px solid var(--borde); border-radius: 12px;
}
.dia-n {
  flex: 0 0 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: #f3ecdc; color: var(--azul); font-weight: 700; font-size: 14px;
}
.dia-txt { display: flex; flex-direction: column; min-width: 0; }
.dia-txt b { font-weight: 600; color: var(--azul); }
.dia-txt small { color: var(--suave); font-size: 13px; }
.dia.hecho .dia-n { background: var(--verde); color: #fff; }
.dia.actual { border-color: var(--oro); box-shadow: 0 0 0 2px rgba(226,176,74,.35); }
.dia.actual .dia-n { background: var(--oro); }

.lectura { max-width: 680px; margin: 0 auto; background: var(--papel); border-radius: var(--radio); padding: 24px 20px; border: 1px solid var(--borde); }
.lectura-dia { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #9a7420; }
.lectura h1 { font-size: 26px; color: var(--azul); margin: 6px 0 18px; }
.lectura h2 { font-size: 16px; color: #9a7420; margin: 26px 0 8px; letter-spacing: .04em; }
.lectura p { font-family: "Lora", Georgia, serif; font-size: 17px; line-height: 1.75; margin: 0 0 12px; }
.lectura blockquote {
  margin: 0; padding: 18px 18px 14px; border-left: 4px solid var(--oro); background: #fbf3e0; border-radius: 0 12px 12px 0;
  font-family: "Lora", serif; font-style: italic; font-size: 18px; line-height: 1.6; color: var(--azul);
}
.lectura cite { display: block; margin-top: 8px; font: 600 14px "Inter", sans-serif; font-style: normal; color: #9a7420; }
.oracion { font-style: italic; color: #3a3f4b; }
.paso { margin: 24px 0; padding: 16px; border-radius: 12px; background: var(--azul); color: #fff; }
.paso b { color: var(--oro); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.paso p { font-family: "Inter", sans-serif; font-size: 15px; line-height: 1.55; margin: 6px 0 0; color: #e7eaf1; }
.completar.activo { background: var(--verde); color: #fff; box-shadow: none; }
.nav-dias { display: flex; justify-content: space-between; margin-top: 18px; font-weight: 600; color: #9a7420; }

/* ---------- Los 13 códigos ---------- */
.etq { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: #9a7420; }
.cab-pag { margin: 4px 0 18px; }
.cab-pag h1 { font-family: "Marcellus", Georgia, serif; font-weight: 400; font-size: clamp(30px, 8vw, 40px); color: var(--azul); margin: 6px 0; }
.cab-pag p { margin: 0; color: var(--suave); font-size: 15px; }

.afirmacion {
  display: block; margin-top: 14px; padding: 20px; border-radius: var(--radio);
  background: var(--papel); border: 1px solid var(--borde); box-shadow: var(--sombra);
}
.afirmacion blockquote { margin: 8px 0 10px; font-family: "Marcellus", Georgia, serif; font-size: 21px; line-height: 1.35; color: var(--azul); }
.afirmacion .fuente { font-size: 13px; color: #9a7420; }

.cod-progreso { display: flex; align-items: center; gap: 16px; margin: 12px 0; }
.cod-progreso h3 { font-family: "Marcellus", Georgia, serif; font-weight: 400; font-size: 20px; color: var(--azul); }
.cod-progreso p { margin: 2px 0 0; font-size: 14px; color: var(--suave); }
.anillo { width: 74px; height: 74px; flex: none; }
.anillo circle { fill: none; stroke-width: 6; }
.anillo-fondo { stroke: var(--borde); }
.anillo-oro { stroke: var(--oro); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.anillo text { fill: var(--azul); font: 600 17px "Inter", sans-serif; }

.cod-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-radius: 16px; background: #9a7420; color: #fff;
  font-weight: 600; font-size: 16px; margin: 6px 0 4px;
}
.cod-cta small { display: block; font-weight: 400; font-size: 13px; opacity: .85; }

.camino { list-style: none; margin: 18px 0 0; padding: 0 0 0 4px; position: relative; }
.camino::before { content: ""; position: absolute; left: 25px; top: 24px; bottom: 24px; width: 2px; background: var(--borde); }
.paso-cod { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: center; padding: 9px 0; position: relative; }
.paso-cod b { display: block; font-family: "Marcellus", Georgia, serif; font-weight: 400; font-size: 19px; color: var(--azul); }
.paso-cod small { color: var(--suave); font-size: 13px; }
.num {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--borde); background: var(--crema); color: #9a7420; font-family: "Marcellus", Georgia, serif; font-size: 15px;
}
.paso-cod.hecho .num { background: #9a7420; border-color: #9a7420; color: #fff; }
.paso-cod.siguiente .num { border-color: #9a7420; box-shadow: 0 0 0 5px rgba(154,116,32,.15); }

.cod { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.cod-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 6px; }
.sello-cod {
  width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid #9a7420; color: #9a7420; font-family: "Marcellus", Georgia, serif; font-size: 22px;
  box-shadow: 0 0 0 6px rgba(154,116,32,.12);
}
.cod-hero h1 { font-family: "Marcellus", Georgia, serif; font-weight: 400; font-size: clamp(30px, 8vw, 38px); color: var(--azul); }
.cod-verso { margin: 0; font-family: "Lora", Georgia, serif; font-style: italic; font-size: 19px; color: var(--texto); max-width: 30em; }
.cod-verso cite { display: block; margin-top: 6px; font: 600 13px "Inter", sans-serif; font-style: normal; color: #9a7420; letter-spacing: .06em; }

.pestanas {
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 999px;
  background: var(--papel); border: 1px solid var(--borde); position: sticky; top: 60px; z-index: 5;
}
.pestanas button { background: none; border: 0; border-radius: 999px; padding: 10px 4px; font: 500 14px "Inter", sans-serif; color: var(--suave); cursor: pointer; }
.pestanas button[aria-selected="true"] { background: #9a7420; color: #fff; }

.panel { display: flex; flex-direction: column; gap: 14px; }
.panel > p { margin: 0; font-family: "Lora", Georgia, serif; font-size: 17px; line-height: 1.75; }
.capitular::first-letter { float: left; font-family: "Marcellus", Georgia, serif; font-size: 3.1em; line-height: .9; padding: 4px 8px 0 0; color: #9a7420; }
.tarea {
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; text-align: left; width: 100%;
  padding: 16px; border-radius: 16px; background: var(--papel); border: 1px solid var(--borde);
  font: 16px/1.5 "Lora", Georgia, serif; color: var(--texto); cursor: pointer;
}
.caja { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--suave); display: grid; place-items: center; color: #fff; font-size: 14px; }
.tarea.on .caja { background: var(--verde); border-color: var(--verde); }
.tarea.on span:last-child { color: var(--suave); }
#nota {
  width: 100%; min-height: 130px; resize: vertical; padding: 14px; border-radius: 16px;
  border: 1px solid var(--borde); background: var(--papel); font: 16px/1.6 "Lora", Georgia, serif; color: var(--texto);
}
#nota:focus { outline: none; border-color: var(--oro); box-shadow: 0 0 0 3px rgba(226,176,74,.25); }
.guardado { min-height: 1.2em; font-size: 13px; color: var(--suave); }

.declarar { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; padding: 8px 0; }
.declarar blockquote { margin: 0; font-family: "Marcellus", Georgia, serif; font-size: 25px; line-height: 1.35; color: var(--azul); max-width: 22em; }
.pulsar {
  position: relative; width: 132px; height: 132px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--papel); box-shadow: inset 0 0 0 1px var(--borde); color: #9a7420;
  font: 600 14px "Inter", sans-serif; touch-action: none; user-select: none; -webkit-user-select: none;
}
.pulsar svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.pulsar circle { fill: none; stroke: #9a7420; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 402; stroke-dashoffset: 402; }
.pulsar.go circle { transition: stroke-dashoffset 3s linear; stroke-dashoffset: 0; }
.pulsar.ok { background: #9a7420; color: #fff; }
.pista { margin: 0; font-size: 13px; color: var(--suave); }

.cod-acciones { display: flex; flex-wrap: wrap; gap: 10px; }
.cod-acciones .btn { flex: 1 1 150px; }
.fav.activo { color: #9a7420; border-color: #9a7420; }
.btn-hecho { background: var(--verde); color: #fff; }

.entrada {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; padding: 18px;
  border-radius: 18px; background: var(--papel); border: 1px solid var(--borde);
}
.entrada p { margin: 0; font-family: "Lora", Georgia, serif; font-size: 17px; line-height: 1.6; white-space: pre-wrap; color: var(--texto); }
.entrada-afirmacion { font-family: "Marcellus", Georgia, serif !important; font-size: 20px !important; color: var(--azul) !important; }
.ejemplo { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #9a7420; }
.vacio-caja {
  display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center;
  padding: 36px 16px; border: 1px dashed var(--borde); border-radius: 18px; color: var(--suave); font-size: 15px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 20; pointer-events: none;
  transform: translateX(-50%) translateY(20px); opacity: 0; transition: .3s;
  padding: 10px 18px; border-radius: 999px; background: #9a7420; color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
@media (prefers-reduced-motion: reduce) { .toast, .anillo-oro, .pulsar.go circle { transition: none; } }

/* ---------- Acceso ---------- */
.salir {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: 1px solid rgba(226,176,74,.45); color: var(--oro-claro);
  font: 500 13px "Inter", sans-serif; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.sin-sesion .tabbar { display: none; }
.sin-sesion { padding-bottom: 0; }
.acceso {
  max-width: 420px; margin: 24px auto; padding: 28px 22px; text-align: center;
  background: var(--papel); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra);
}
.acceso h1 { font-size: 24px; color: var(--azul); margin-bottom: 10px; }
.acceso p { color: var(--suave); margin: 0 0 18px; }
.acceso code { font-size: 13px; background: #f3ecdc; padding: 1px 5px; border-radius: 4px; }
.acceso-libro { width: 150px; margin: -8px auto 8px; }
.acceso form { display: grid; gap: 12px; }
.acceso input {
  width: 100%; min-height: 50px; padding: 0 16px; border-radius: 12px;
  border: 1.5px solid var(--borde); background: #fffdf8; font: 16px "Inter", sans-serif; color: var(--texto);
}
#codigo { text-align: center; font-size: 24px; letter-spacing: .3em; }
.acceso input:focus { outline: none; border-color: var(--oro); box-shadow: 0 0 0 3px rgba(226,176,74,.25); }
.btn[disabled] { opacity: .6; cursor: wait; }
.aviso { margin: 0 !important; color: #a3321f !important; font-size: 14px; text-align: left; }
.enlace { display: block; margin: 14px auto 0; background: none; border: 0; color: #9a7420; font: 600 14px "Inter", sans-serif; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.velo { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(13,27,51,.55); }
.velo .ico-candado { width: 34px; height: 34px; stroke: #fff; }
.libro.bloqueado .libro-titulo { color: var(--suave); }
.ico-candado { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; flex: none; }
.bloqueo {
  display: flex; align-items: center; gap: 10px; padding: 14px; margin-bottom: 14px; text-align: left;
  border-radius: 12px; background: #f3ecdc; color: var(--azul); font-size: 15px;
}
.girando { width: 36px; height: 36px; margin: 0 auto; border: 3px solid var(--borde); border-top-color: var(--oro); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

.vacio { text-align: center; padding: 60px 0; }
.vacio h1 { color: var(--azul); margin-bottom: 20px; }

@media (min-width: 720px) {
  .hero { min-height: 280px; }
  .hero h1 { font-size: 36px; }
  .ficha { grid-template-columns: 260px 1fr; align-items: start; }
  .ficha-portada { margin: 0; }
  .destacado { grid-template-columns: 160px 1fr; }
  .lectura { padding: 36px 40px; }
}
