:root {
    --papel: #efe6d6;
    --papel-alto: #f6f0e4;
    --tinta: #1c1610;
    --tinta-suave: #5a4e42;
    --linea: rgba(28, 22, 16, 0.12);
    --vino: #6b1d2a;
    --navy: #16324f;
    --oro: #b08948;
    --sombra: 0 18px 40px rgba(28, 22, 16, 0.16);
    --radio: 14px;
}

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

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: Figtree, "Segoe UI", sans-serif;
    color: var(--tinta);
    background: var(--papel);
    min-height: 100dvh;
}

body.ficha-abierta {
    overflow: hidden;
}

.grano {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(176, 137, 72, 0.14), transparent 55%),
        radial-gradient(900px 500px at 110% 10%, rgba(107, 29, 42, 0.08), transparent 50%),
        linear-gradient(180deg, var(--papel-alto), var(--papel));
}

.grano::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.18;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
}

.escena {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: 1.1rem clamp(1.1rem, 3vw, 2.4rem) 0.9rem;
    gap: 0.6rem;
}

.cabeza,
.pie {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.marca {
    font-family: Fraunces, Georgia, serif;
    font-size: 1.15rem;
    font-weight: 640;
    letter-spacing: 0.02em;
    color: var(--tinta);
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 1.1rem;
    font-size: 0.92rem;
}

.nav a,
.pie a {
    color: var(--tinta-suave);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.nav a:hover,
.pie a:hover {
    color: var(--tinta);
    border-bottom-color: var(--oro);
}

.pestanas {
    display: flex;
    gap: 0.2rem;
    padding: 0.18rem;
    background: rgba(255, 252, 246, 0.7);
    border: 1px solid var(--linea);
    border-radius: 999px;
}

.pestana {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 560;
    color: var(--tinta-suave);
    padding: 0.38rem 0.95rem;
    border-radius: 999px;
    cursor: pointer;
}

.pestana[aria-selected="true"] {
    background: var(--navy);
    color: #f6f0e4;
}

.sala {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.15rem;
    min-height: 0;
}

.panel {
    min-height: 0;
}

.panel-sienra,
#panel-sienra {
    display: grid;
    grid-template-columns: minmax(180px, 240px) 1fr;
    gap: 1.4rem 1.8rem;
    align-items: start;
}

#panel-sienra[hidden],
#panel-santiago[hidden] {
    display: none;
}

.retrato {
    margin: 0;
}

.retrato img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center top;
    border-radius: 8px;
    box-shadow: var(--sombra);
}

.retrato figcaption {
    margin-top: 0.45rem;
    font-family: Fraunces, Georgia, serif;
    font-size: 0.95rem;
}

.libros-sienra {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    min-width: 0;
}

.obra-sienra {
    display: grid;
    grid-template-columns: 118px 1fr;
    gap: 0.9rem 1.1rem;
    align-items: start;
}

.obra-sienra .libro {
    width: 118px;
}

.obra-texto h2 {
    margin: 0 0 0.4rem;
    font-family: Fraunces, Georgia, serif;
    font-size: 1.15rem;
    font-weight: 640;
    line-height: 1.2;
}

.presentacion {
    margin: 0 0 0.55rem;
    color: var(--tinta-suave);
    font-size: 0.9rem;
    line-height: 1.45;
}

.presentacion-lista {
    margin: 0 0 0.7rem;
    padding-left: 1.25rem;
    color: var(--tinta-suave);
    font-size: 0.9rem;
    line-height: 1.45;
}

.presentacion-lista li {
    margin: 0 0 0.28rem;
}

.lema {
    margin: 0;
    font-family: Fraunces, Georgia, serif;
    font-size: clamp(1.15rem, 2.4vw, 1.85rem);
    font-weight: 500;
    line-height: 1.25;
}

.lema-linea {
    white-space: nowrap;
}

.estante {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: 0.8rem 1rem;
    align-items: center;
}

.rotulo {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--tinta-suave);
}

.anaquel {
    display: flex;
    gap: 0.9rem;
    min-width: 0;
}

.tarjeta {
    appearance: none;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.libro {
    width: min(168px, 28vw);
    flex: 0 0 auto;
}

.libro img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4.24;
    object-fit: cover;
    border-radius: 4px 8px 8px 4px;
    box-shadow: var(--sombra);
    transform: rotate(-0.6deg);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.libro:nth-child(2) img {
    transform: rotate(0.7deg);
}

.libro:hover img,
.libro:focus-visible img {
    transform: translateY(-6px) rotate(0);
    box-shadow: 0 24px 48px rgba(28, 22, 16, 0.22);
}

.programa {
    flex: 1 1 0;
    min-width: 0;
    max-width: 240px;
    background: rgba(255, 252, 246, 0.72);
    border: 1px solid var(--linea);
    border-radius: var(--radio);
    padding: 0.85rem 0.9rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.programa:hover,
.programa:focus-visible {
    transform: translateY(-4px);
    box-shadow: var(--sombra);
}

.icono-programa {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--linea);
}

.icono-programa img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tarjeta-pie {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0.45rem;
}

.libro .tarjeta-pie {
    padding-inline: 0.1rem;
}

.tarjeta-titulo {
    font-family: Fraunces, Georgia, serif;
    font-size: 0.95rem;
    line-height: 1.2;
}

.tarjeta-autor {
    font-size: 0.75rem;
    color: var(--tinta-suave);
}

.pie {
    font-size: 0.8rem;
    color: var(--tinta-suave);
    padding-top: 0.2rem;
    border-top: 1px solid var(--linea);
}

.velo {
    position: fixed;
    inset: 0;
    z-index: 8;
    background: rgba(28, 22, 16, 0.38);
    backdrop-filter: blur(3px);
}

.ficha {
    position: fixed;
    z-index: 9;
    right: 0;
    top: 0;
    height: 100dvh;
    width: min(560px, 100vw);
    background: var(--papel-alto);
    box-shadow: -18px 0 40px rgba(28, 22, 16, 0.18);
    padding: 1.4rem 1.4rem 1.6rem;
    overflow: auto;
}

.ficha-cerrar {
    position: absolute;
    top: 0.7rem;
    right: 0.8rem;
    border: 0;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--tinta-suave);
    cursor: pointer;
}

.ficha-cuerpo {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1.1rem;
    align-items: start;
}

.ficha-imagen {
    width: 100%;
    border-radius: 6px;
    box-shadow: var(--sombra);
}

.ficha-imagen.es-icono {
    border-radius: 28px;
    background: #fff;
}

.ficha-kicker {
    margin: 0 0 0.25rem;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--vino);
}

.ficha-texto h2 {
    margin: 0 0 0.35rem;
    font-family: Fraunces, Georgia, serif;
    font-size: 1.55rem;
    font-weight: 640;
    line-height: 1.15;
}

.ficha-autor,
.ficha-resumen,
.ficha-aviso,
.ficha-proxima {
    margin: 0 0 0.7rem;
    color: var(--tinta-suave);
    line-height: 1.45;
}

.ficha-aviso {
    font-size: 0.82rem;
    border-left: 2px solid var(--oro);
    padding-left: 0.7rem;
}

.ficha-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.boton {
    display: inline-flex;
    align-items: center;
    background: var(--navy);
    color: #f6f0e4;
    text-decoration: none;
    padding: 0.62rem 0.95rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 560;
}

.boton:hover {
    background: #0f2438;
}

.pagina-secundaria {
    max-width: 42rem;
}

.pagina-secundaria h1 {
    font-family: Fraunces, Georgia, serif;
    font-size: 1.8rem;
    margin: 0 0 0.4rem;
}

.pagina-secundaria ul {
    padding-left: 1.1rem;
    line-height: 1.7;
}

.pagina-secundaria a {
    color: var(--navy);
}

.admin {
    max-width: 1100px;
    margin: 0 auto;
}

.admin table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
    background: rgba(255, 252, 246, 0.7);
}

.admin th,
.admin td {
    border-bottom: 1px solid var(--linea);
    padding: 0.45rem 0.5rem;
    text-align: left;
    vertical-align: top;
}

.admin form {
    display: flex;
    gap: 0.6rem;
    align-items: end;
    margin: 1rem 0;
}

.admin input[type="password"],
.admin input[type="text"] {
    font: inherit;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--linea);
    border-radius: 8px;
    background: #fff;
}

.admin button {
    font: inherit;
    border: 0;
    background: var(--navy);
    color: #fff;
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    cursor: pointer;
}

@media (max-width: 820px) {
    .escena {
        min-height: auto;
        padding-bottom: 1.4rem;
    }

    .cabeza,
    .pie {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.55rem;
    }

    #panel-sienra {
        grid-template-columns: 1fr;
    }

    .retrato {
        max-width: 220px;
    }

    .obra-sienra {
        grid-template-columns: 96px 1fr;
    }

    .obra-sienra .libro {
        width: 96px;
    }

    .estante {
        grid-template-columns: 1fr;
        gap: 0.45rem;
    }

    .anaquel {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 0.5rem;
    }

    .libro,
    .programa {
        scroll-snap-align: start;
    }

    .libro {
        width: 46vw;
    }

    .programa {
        flex: 0 0 58vw;
        max-width: none;
    }

    .ficha {
        top: auto;
        bottom: 0;
        height: min(86dvh, 640px);
        width: 100vw;
        border-radius: 18px 18px 0 0;
    }

    .ficha-cuerpo {
        grid-template-columns: 110px 1fr;
    }
}

@media (min-width: 821px) and (min-height: 820px) {
    html,
    body {
        overflow: hidden;
    }
}
