:root {
    --base: #852E4E;
    --sombra: #4C1D3D;
    --brillo: #A33757;
    --primario: #DC586D;
    --secundario: #FB9590;
    --texto: #FFBB94;
    --texto-2: #FB9590;
    --borde: rgba(255, 255, 255, 0.08);
    --radio: 24px;
    --radio-medio: 18px;
    --radio-peq: 12px;
    --sombra-x: 0px;
    --sombra-y: 0px;
    --resalto-ancho: 10px;
    --resalto-ancho-peq: 6px;
    --resalto-ancho-mini: 4px;
}

html.tema-claro {
    --base: #FFBB94;
    --sombra: #FB9590;
    --brillo: #FFFFFF;
    --primario: #DC586D;
    --secundario: #A33757;
    --texto: #4C1D3D;
    --texto-2: #852E4E;
    --borde: rgba(76, 29, 61, 0.1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--base);
    color: var(--texto-2);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.3s ease;
}

[hidden] {
    display: none !important;
}

button {
    font-family: inherit;
    color: inherit;
}

.contenedor {
    width: min(820px, 100% - 2rem);
    margin-inline: auto;
}

/* ---------- Cabecera ---------- */

.cabecera {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--base) 85%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--borde);
    padding: 0.9rem 0 0.6rem;
    transition: background-color 0.4s ease;
}

.cabecera-fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: 0.02em;
    color: var(--texto);
    transition: color 0.3s ease;
}

.logo span {
    color: var(--primario);
    font-weight: 300;
    margin-left: 0.35rem;
}

.dia {
    margin: 0.45rem 0 0;
    font-size: 0.92rem;
    color: var(--texto-2);
    text-align: center;
    transition: color 0.3s ease;
}

.dia strong {
    color: var(--texto);
    font-weight: 700;
}

/* ---------- Switch de tema ---------- */

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.5rem;
    flex: none;
    height: 30px;
    cursor: pointer;
    border-radius: 999px;
    box-shadow: inset 4px 4px 8px var(--sombra), inset -4px -4px 8px var(--brillo);
    color: var(--texto-2);
    font-size: 0.8rem;
}

.switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.perilla {
    position: relative;
    width: 22px;
    height: 22px;
    margin: 0 0.25rem;
    z-index: 3;
}

.switch .icon {
    position: relative;
    z-index: 1;
    line-height: 1;
    font-size: 1.2rem;
    font-family: system-ui, "Segoe UI Symbol", "Noto Sans Symbols 2", sans-serif;
    color: var(--texto);
    opacity: 0.7;
    -webkit-text-stroke: 0.6px currentColor;
    paint-order: stroke fill;
    transition: opacity 0.3s ease, color 0.3s ease, transform 0.3s ease, text-shadow 0.3s ease;
}

.switch .icon.izq {
    order: -1;
}

html:not(.tema-claro) .switch .icon.izq {
    opacity: 1;
    color: var(--texto);
    text-shadow: 0 0 7px currentColor;
}

html:not(.tema-claro) .switch .icon.der {
    opacity: 0.75;
    color: var(--texto-2);
    text-shadow: none;
}

html.tema-claro .switch .icon.izq {
    opacity: 0.75;
    color: var(--texto-2);
    text-shadow: none;
}

html.tema-claro .switch .icon.der {
    opacity: 1;
    color: var(--texto);
    text-shadow: 0 0 7px currentColor;
}

.perilla-nudo {
    position: absolute;
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--brillo), var(--sombra));
    box-shadow: 3px 3px 6px var(--sombra), -3px -3px 6px var(--brillo);
    will-change: transform;
}

.switch:focus-within .perilla {
    outline: 2px solid var(--primario);
    outline-offset: 3px;
    border-radius: 999px;
}

/* ---------- Pestañas de grupos ---------- */

.pestanas {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
    margin: 1.4rem 0 1.8rem;
}

.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.6rem 1.1rem;
    border: 1px solid var(--borde);
    border-radius: var(--radio-medio);
    background: transparent;
    color: var(--texto-2);
    cursor: pointer;
    box-shadow: 6px 6px 12px var(--sombra), -6px -6px 12px var(--brillo);
    transition: box-shadow 0.15s ease-out, transform 0.1s ease, background-color 0.4s ease, color 0.3s ease;
}

.tab small {
    font-size: 0.72rem;
    opacity: 0.75;
}

.tab-nombre {
    font-weight: 700;
}

.tab:hover {
    color: var(--texto);
}

.tab[aria-selected="true"],
.tab.activa {
    color: var(--texto);
    box-shadow: inset 6px 6px 12px var(--sombra), inset -6px -6px 12px var(--brillo), 0 0 14px color-mix(in srgb, var(--primario) 45%, transparent);
}

.tab.activa .tab-nombre {
    color: var(--primario);
}

.tab.pulsado,
.boton.pulsado {
    box-shadow: inset 6px 6px 12px var(--sombra), inset -6px -6px 12px var(--brillo);
    transform: translateY(1px);
}

/* ---------- Secciones ---------- */

.seccion {
    margin-bottom: 2.2rem;
}

.seccion-titulo {
    color: var(--texto);
    text-align: center;
    margin: 0 0 1.1rem;
    font-size: 1.25rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

/* ---------- Inicio / formas ---------- */

.intro p {
    text-align: center;
    color: var(--texto-2);
    margin: 0 0 1.2rem;
}

.formas {
    display: grid;
    gap: 1rem;
}

.forma {
    position: relative;
    text-align: left;
    width: 100%;
    padding: 0.95rem 1.05rem;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    background: transparent;
    cursor: pointer;
    box-shadow: 8px 8px 16px var(--sombra), -8px -8px 16px var(--brillo);
    transition: box-shadow 0.15s ease-out, transform 0.1s ease, background-color 0.4s ease, color 0.3s ease, border-color 0.3s ease;
    overflow: hidden;
}

.forma:hover {
    color: var(--texto);
}

.forma p {
    margin: 0.25rem 0 0;
    color: var(--texto-2);
    font-size: 0.94rem;
}

.forma-nombre {
    font-weight: 800;
    color: var(--texto);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.forma summary::-webkit-details-marker,
.forma-nombre::marker {
    display: none;
    content: "";
}

.forma-nombre::after {
    content: "+";
    color: var(--primario);
    font-size: 1.1rem;
    font-weight: 800;
}

.forma[open] .forma-nombre::after {
    content: "−";
}

.forma[open] .forma-nombre {
    margin-bottom: 0.4rem;
}

.forma.seleccionada {
    color: var(--texto);
    box-shadow: inset 8px 8px 16px var(--sombra), inset -8px -8px 16px var(--brillo), 0 0 16px color-mix(in srgb, var(--primario) 40%, transparent);
    border-color: color-mix(in srgb, var(--primario) 70%, transparent);
}

.forma.seleccionada .forma-nombre {
    color: var(--primario);
}

.forma.pulsado {
    box-shadow: inset 8px 8px 16px var(--sombra), inset -8px -8px 16px var(--brillo);
    transform: translateY(1px);
}

/* ---------- Tarjetas de misterio ---------- */

.card {
    position: relative;
    background: var(--base);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 1.4rem;
    overflow: hidden;
    transition: box-shadow 0.15s ease-out, transform 0.1s ease, background-color 0.4s ease, color 0.3s ease, border-color 0.3s ease;
}

.misterio {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.1rem 1.5rem;
    margin-bottom: 1.6rem;
    box-shadow:
        calc(var(--resalto-ancho) + var(--sombra-x)) calc(var(--resalto-ancho) + var(--sombra-y)) 22px var(--sombra),
        calc(-1 * (var(--resalto-ancho) + var(--sombra-x))) calc(-1 * (var(--resalto-ancho) + var(--sombra-y))) 21px var(--brillo);
}

.misterio.pulsado {
    box-shadow: inset 10px 10px 22px var(--sombra), inset -10px -10px 22px var(--brillo);
    transform: translateY(1px);
}

.misterio.completo {
    box-shadow:
        calc(var(--resalto-ancho) + var(--sombra-x)) calc(var(--resalto-ancho) + var(--sombra-y)) 22px var(--sombra),
        calc(-1 * (var(--resalto-ancho) + var(--sombra-x))) calc(-1 * (var(--resalto-ancho) + var(--sombra-y))) 21px var(--brillo),
        0 0 22px color-mix(in srgb, var(--primario) 55%, transparent);
    border-color: color-mix(in srgb, var(--primario) 60%, transparent);
}

.misterio-cabecera {
    grid-column: 1 / -1;
}

.numero-misterio {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--primario);
    margin-bottom: 0.2rem;
}

.misterio-titulo {
    margin: 0;
    color: var(--texto);
    font-size: 1.15rem;
    line-height: 1.35;
    transition: color 0.3s ease;
}

/* ---------- Imagen ---------- */

.marco-imagen {
    margin: 0;
    margin-inline: auto;
    width: 100%;
    max-width: 230px;
    height: 290px;
    padding: 10px;
    border-radius: var(--radio-medio);
    overflow: hidden;
    background: var(--base);
    box-shadow: 7px 7px 14px var(--sombra), -7px -7px 14px var(--brillo);
    transition: box-shadow 0.4s ease, background-color 0.4s ease;
}

.marco-imagen img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

/* ---------- Cuerpo del misterio ---------- */

.misterio-cuerpo {
    min-width: 0;
}

.etiqueta {
    margin: 0.55rem 0 0.15rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--secundario);
    transition: color 0.3s ease;
}

.cita {
    margin: 0;
    padding: 0.8rem 1rem;
    border-left: 3px solid var(--primario);
    border-radius: 0 var(--radio-peq) var(--radio-peq) 0;
    background: color-mix(in srgb, var(--base) 88%, var(--sombra) 12%);
    color: var(--texto-2);
    font-style: italic;
    transition: background-color 0.4s ease, color 0.3s ease;
}

.referencia {
    display: inline-block;
    margin-top: 0.4rem;
    color: var(--primario);
    font-style: normal;
    font-weight: 700;
    font-size: 0.9rem;
}

.nota {
    margin: 0.7rem 0 0;
    font-size: 0.86rem;
    color: var(--secundario);
}

.oracion {
    margin: 0.25rem 0 0;
    color: var(--texto-2);
    transition: color 0.3s ease;
}

.peticion {
    margin: 0.25rem 0 0;
    color: var(--texto);
    font-weight: 500;
    transition: color 0.3s ease;
}

.salve .oracion {
    color: var(--texto);
}

.salve-segunda {
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--borde);
    font-size: 1.02rem;
}

/* ---------- Decena ---------- */

.decena {
    grid-column: 1 / -1;
    border-top: 1px dashed var(--borde);
    padding-top: 0.2rem;
    margin-top: 0;
}

.decena-titulo {
    margin: 0;
    color: var(--texto);
    font-size: 1.02rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.decena-resumen {
    margin: 0.2rem 0 0.8rem;
    font-size: 0.9rem;
    color: var(--texto-2);
}

.cuentas {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.cuenta {
    position: relative;
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--texto-2);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 4px 4px 8px var(--sombra), -4px -4px 8px var(--brillo);
    transition: box-shadow 0.15s ease-out, transform 0.1s ease, background-color 0.4s ease, color 0.3s ease;
    overflow: hidden;
}

.cuenta.pulsado {
    box-shadow: inset 4px 4px 8px var(--sombra), inset -4px -4px 8px var(--brillo);
    transform: scale(0.94);
}

.cuenta.marcada {
    background: linear-gradient(145deg, var(--secundario), var(--primario));
    color: #fff;
    border: 1px solid color-mix(in srgb, var(--brillo) 60%, transparent);
    box-shadow: inset 3px 3px 7px color-mix(in srgb, var(--sombra) 55%, transparent), 0 0 12px color-mix(in srgb, var(--primario) 70%, transparent);
}

.cuenta.pop {
    animation: pop 0.4s ease;
}

@keyframes pop {
    0% { transform: scale(1); }
    35% { transform: scale(1.22); }
    100% { transform: scale(1); }
}

.decena-estado {
    margin: 0.7rem 0 0.4rem;
    color: var(--texto-2);
    font-size: 0.9rem;
}

.decena-estado .contador {
    color: var(--primario);
    font-weight: 800;
    font-size: 1.1rem;
}

.repetir {
    margin: 0 0.5rem 0.8rem 0;
}

.oraciones-decena {
    display: grid;
    gap: 0.35rem;
}

.plegable {
    border: 1px solid var(--borde);
    border-radius: var(--radio-medio);
    padding: 0.2rem 0.9rem;
    background: color-mix(in srgb, var(--base) 92%, var(--sombra) 8%);
    transition: box-shadow 0.15s ease-out, background-color 0.4s ease, color 0.3s ease;
}

.plegable[open] {
    box-shadow: var(--resalto-ancho-mini) var(--resalto-ancho-mini) 8px var(--sombra), calc(-1 * var(--resalto-ancho-mini)) calc(-1 * var(--resalto-ancho-mini)) 8px var(--brillo);
}

.plegable summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--texto);
    padding: 0.55rem 0;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.3s ease;
}

.plegable summary::-webkit-details-marker {
    display: none;
}

.plegable summary::after {
    content: "+";
    color: var(--primario);
    font-weight: 800;
}

.plegable[open] summary::after {
    content: "−";
}

.texto-oracion {
    margin: 0 0 0.8rem;
    color: var(--texto-2);
    font-size: 0.95rem;
}

/* ---------- Salve ---------- */

.salve {
    box-shadow: 8px 8px 18px var(--sombra), -8px -8px 18px var(--brillo);
}

/* ---------- Navegación inferior ---------- */

.navegacion {
    position: sticky;
    bottom: 1rem;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin: 1.2rem 0 2.2rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--borde);
    border-radius: 999px;
    background: color-mix(in srgb, var(--base) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 6px 6px 14px var(--sombra), -6px -6px 14px var(--brillo);
    transition: background-color 0.4s ease, box-shadow 0.15s ease-out;
}

.boton {
    border: 1px solid var(--borde);
    background: transparent;
    color: var(--texto-2);
    font-weight: 700;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 5px 5px 10px var(--sombra), -5px -5px 10px var(--brillo);
    transition: box-shadow 0.15s ease-out, transform 0.1s ease, background-color 0.4s ease, color 0.3s ease;
}

.boton:hover {
    color: var(--texto);
}

.puntos {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.punto {
    width: 11px;
    height: 11px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: color-mix(in srgb, var(--secundario) 60%, transparent);
    box-shadow: 2px 2px 4px var(--sombra), -2px -2px 4px var(--brillo);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease-out, background-color 0.3s ease;
}

.punto:hover {
    transform: scale(1.15);
}

.punto.activo {
    background: var(--primario);
    transform: scale(1.3);
    box-shadow: 0 0 10px color-mix(in srgb, var(--primario) 80%, transparent);
}

/* ---------- Destello (ripple neumórfico) ---------- */

.destello {
    position: absolute;
    z-index: 1;
    pointer-events: none;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 70%);
    filter: blur(8px);
    transform: scale(0);
    opacity: 0.85;
    animation: destello 0.65s ease-out forwards;
}

@keyframes destello {
    to {
        transform: scale(2.2);
        opacity: 0;
    }
}

/* ---------- Pie ---------- */

.pie {
    text-align: center;
    color: var(--texto-2);
    font-size: 0.85rem;
    padding: 0 0 1.4rem;
    border-top: 1px solid var(--borde);
    padding-top: 1rem;
}

/* ---------- Escritorio (mejora progresiva) ---------- */

@media (min-width: 641px) {
    .misterio {
        grid-template-columns: 258px 1fr;
    }

    .marco-imagen {
        max-width: 258px;
        height: 320px;
        margin-inline: 0;
    }

    .forma {
        padding: 1.1rem 1.3rem;
    }

    .cuenta {
        width: 46px;
        height: 46px;
    }

    .navegacion {
        gap: 1rem;
    }
}

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

    html {
        scroll-behavior: auto;
    }
}