:root{
    --bg:#f5f5f7;
    --card:#ffffff;
    --text:#2c2c2e;
    --muted:#70757e;
    --border:#e5e5ea;
    --primary:#2563eb;
    --shadow:0 24px 70px rgba(0,0,0,.10);
}

*{
    box-sizing:border-box;
}

html,
body{
    min-height:100%;
}

body{
    margin:0;
    background:linear-gradient(180deg,#f8f8fa,#ececf1);
    font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Arial,sans-serif;
    color:var(--text);
    overflow-x:hidden;
}

/* =========================
   TOPBAR
========================= */

.viewer-topbar{
    position:sticky;
    top:0;
    z-index:50;
    height:72px;
    backdrop-filter:blur(18px);
    background:rgba(255,255,255,.86);
    border-bottom:1px solid rgba(229,229,234,.8);
    padding:0 24px;
    display:flex;
    justify-content:space-between;
    align-items:center;
}

.viewer-title{
    font-size:18px;
    font-weight:700;
    letter-spacing:-.03em;
}

.viewer-actions{
    display:flex;
    gap:10px;
}

.viewer-btn{
    border:1px solid var(--border);
    background:#fff;
    width:42px;
    height:42px;
    border-radius:14px;
    cursor:pointer;
    font-size:15px;
    color:var(--text);
    box-shadow:0 4px 14px rgba(0,0,0,.04);
    transition:.2s ease;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    text-decoration:none;
}

.viewer-btn:hover{
    transform:translateY(-1px);
    background:#fbfbfd;
}

/* =========================
   CONTENEDOR GENERAL
========================= */

.viewer-shell{
    min-height:calc(100vh - 72px);
    display:flex;
    align-items:flex-start;
    justify-content:center;
    padding:36px 20px 56px;
}

.viewer-stage{
    width:100%;
    max-width:1250px;
    height:788px;
    background:rgba(255,255,255,.58);
    border:1px solid rgba(255,255,255,.7);
    border-radius:34px;
    box-shadow:var(--shadow);
    backdrop-filter:blur(20px);
    padding:34px;
    display:flex;
    align-items:center;
    justify-content:center;
    position:relative;
    overflow:hidden;
}

/* =========================
   LIBRO
========================= */

#book{
    width:1100px;
    height:720px;
    opacity:0;
    visibility:hidden;
    transition:opacity .35s ease;
    flex-shrink:0;
}

#book.book-ready{
    opacity:1;
    visibility:visible;
}

#book > div{
    backface-visibility:hidden;
}

.page{
    background:#fff;
    overflow:hidden;
    box-shadow:0 10px 30px rgba(0,0,0,.08);
}

.page canvas{
    width:100%;
    height:100%;
    object-fit:contain;
    display:block;
    background:#fff;
}

/* =========================
   LOADING
========================= */

.loading{
    position:absolute;
    inset:0;
    display:flex;
    align-items:center;
    justify-content:center;
    color:var(--muted);
    font-size:15px;
    z-index:40;
    background:rgba(255,255,255,.72);
    backdrop-filter:blur(10px);
    border-radius:34px;
    transition:.3s ease;
}

.loading.is-hidden{
    opacity:0;
    visibility:hidden;
    pointer-events:none;
}

/* =========================
   FLECHAS LATERALES
========================= */

.nav-btn{
    position:absolute;
    top:50%;
    transform:translateY(-50%);
    width:48px;
    height:48px;
    border:1px solid var(--border);
    background:rgba(255,255,255,.92);
    border-radius:50%;
    cursor:pointer;
    z-index:30;
    box-shadow:0 8px 25px rgba(0,0,0,.08);
    color:var(--text);
    transition:.2s ease;
}

.nav-btn:hover{
    background:#fff;
    transform:translateY(-50%) scale(1.04);
}

.nav-prev{
    left:24px;
}

.nav-next{
    right:24px;
}

/* =========================
   TOAST
========================= */

.viewer-toast{
    position:fixed;
    right:24px;
    bottom:24px;
    z-index:100;
    background:rgba(44,44,46,.94);
    color:#fff;
    padding:13px 18px;
    border-radius:999px;
    font-size:14px;
    box-shadow:0 12px 30px rgba(0,0,0,.14);
    opacity:0;
    visibility:hidden;
    transform:translateY(10px);
    transition:.25s ease;
}

.viewer-toast.is-visible{
    opacity:1;
    visibility:visible;
    transform:translateY(0);
}

/* =========================
   ZOOM
========================= */

.viewer-stage.is-zoomed{
    overflow:auto;
    cursor:grab;
}

.viewer-stage.is-zoomed #book{
    transform:scale(1.22);
    transform-origin:center center;
}

.viewer-stage.is-zoomed .nav-btn{
    position:fixed;
}

/* =========================
   MODO EMBED LIMPIO
========================= */

body.modo-embed{
    background:transparent;
    overflow:hidden;
}

body.modo-embed .viewer-topbar{
    display:none;
}

body.modo-embed .viewer-shell{
    display:flex;
    align-items:flex-start;
    justify-content:center;
    width:100%;
    min-height:100vh;
    padding:0;
    margin:0;
    overflow:hidden;
}

body.modo-embed .viewer-stage{
    width:100%;
    max-width:none;
    height:820px;
    min-height:820px;
    padding:0;
    margin:0;
    border:0;
    border-radius:0;
    box-shadow:none;
    background:transparent;
    display:flex;
    align-items:flex-start;
    justify-content:center;
    overflow:hidden;
}

body.modo-embed #book{
    width:100%;
    max-width:100%;
    height:820px;
    margin:0 auto;
}

body.modo-embed .viewer-toast{
    display:none;
}

body.modo-embed .nav-prev{
    left:10px;
}

body.modo-embed .nav-next{
    right:10px;
}

/* =========================
   RESPONSIVE TABLET
========================= */

@media(max-width:900px){

    .viewer-stage{
        height:584px;
        padding:22px;
        border-radius:26px;
    }

    #book{
        width:100%;
        height:540px;
    }

    .nav-btn{
        width:42px;
        height:42px;
    }

    .nav-prev{
        left:10px;
    }

    .nav-next{
        right:10px;
    }

    body.modo-embed .viewer-shell{
        min-height:820px;
        padding:0;
    }

    body.modo-embed .viewer-stage{
        height:820px;
        min-height:820px;
        padding:0;
        border-radius:0;
    }

    body.modo-embed #book{
        height:820px;
    }
}

/* =========================
   RESPONSIVE MÓVIL
========================= */

@media(max-width:600px){

    .viewer-topbar{
        height:auto;
        min-height:72px;
        flex-direction:column;
        gap:10px;
        padding:14px;
        text-align:center;
    }

    .viewer-actions{
        flex-wrap:wrap;
        justify-content:center;
    }

    .viewer-shell{
        min-height:calc(100vh - 100px);
        padding:18px 10px 32px;
    }

    .viewer-stage{
        height:468px;
        padding:14px;
        border-radius:22px;
    }

    #book{
        height:440px;
    }

    .nav-btn{
        width:38px;
        height:38px;
    }

    .viewer-toast{
        right:14px;
        bottom:14px;
    }

    .viewer-stage.is-zoomed #book{
        transform:scale(1.14);
    }

    body.modo-embed .viewer-shell{
        width:100%;
        min-height:760px;
        height:760px;
        padding:0;
        margin:0;
        overflow:hidden;
    }

    body.modo-embed .viewer-stage{
        width:100%;
        min-height:760px;
        height:760px;
        padding:0;
        margin:0;
        border-radius:0;
        overflow:hidden;
        display:flex;
        align-items:flex-start;
        justify-content:center;
    }

    body.modo-embed #book{
        width:100%;
        height:760px;
        margin:0 auto;
    }

    body.modo-embed .nav-btn{
        top:50%;
    }
}

/* =========================
   MARCA EL CATÁLOGO
========================= */

.embed-brand{
    position:fixed;
    right:14px;
    bottom:12px;
    z-index:120;
    display:inline-flex;
    align-items:center;
    gap:5px;
    padding:7px 10px;
    border-radius:999px;
    background:rgba(255,255,255,.88);
    border:1px solid rgba(229,229,234,.9);
    box-shadow:0 8px 24px rgba(0,0,0,.08);
    backdrop-filter:blur(12px);
    color:#70757e;
    font-size:11px;
    line-height:1;
    text-decoration:none;
    transition:.2s ease;
}

.embed-brand span{
    font-weight:500;
}

.embed-brand strong{
    color:#2c2c2e;
    font-weight:700;
}

.embed-brand:hover{
    transform:translateY(-1px);
    background:#fff;
}

body:not(.modo-embed) .embed-brand{
    bottom:18px;
}

body.modo-embed .embed-brand{
    right:12px;
    bottom:10px;
}

@media(max-width:600px){

    .embed-brand{
        right:10px;
        bottom:8px;
        font-size:10px;
        padding:6px 9px;
    }
}

/* =========================
   OCULTAR FLECHAS LATERALES EN MÓVIL
========================= */

@media(max-width:600px){

    .nav-btn{
        display:none;
    }

}