@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap");

:root {
    --bg-color: #0f1012;
    --page-color: #ffffff;
    --cover-color: #1a1c20;
    --duration: 1.5s;
    --book-width: 800px;
    --book-height: 550px;
    --accent-color: #3b82f6;
    --zoom-level: 1;
}

body {
    background-color: var(--bg-color);
    color: #ffffff;
    font-family: "Inter", sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    transition: background 0.5s ease;
    touch-action: none;
}

/* Fondos personalizables */
body.bg-black {
    background-color: #000000;
}

body.bg-dark {
    background-color: #0f1012;
}

body.bg-gradient-blue {
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
}

body.bg-gradient-purple {
    background: linear-gradient(135deg, #581c87 0%, #1e1b4b 100%);
}

body.bg-gradient-warm {
    background: linear-gradient(135deg, #7c2d12 0%, #1c1917 100%);
}

body.bg-wood {
    background: linear-gradient(135deg, #451a03 0%, #292524 100%);
    background-image:
        linear-gradient(135deg, #451a03 0%, #292524 100%),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px);
}

body.bg-library {
    background: linear-gradient(to bottom,
            #1a1410 0%,
            #0a0806 100%);
}

body.bg-soft-light {
    background: linear-gradient(135deg, #f5f5f4 0%, #e7e5e4 100%);
}

body.bg-clouds {
    background: linear-gradient(to bottom,
            #0ea5e9 0%,
            #38bdf8 50%,
            #e0f2fe 100%);
}

/* Fondos con imágenes personalizadas */
body.bg-custom-image {
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

body.bg-custom-image::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 0;
}

body.bg-custom-image #viewport {
    position: relative;
    z-index: 1;
}

/* Vista iframe minimalista */
body.iframe-mode {
    background-color: #000000;
}

#viewport {
    perspective: 2500px;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 80px;
    transition: background 0.5s ease;
    overflow-x: auto;
    overflow-y: hidden;
    cursor: grab;
    scroll-behavior: auto;
    /* Cambiado de smooth para evitar saltos en zoom */
}

body.is-zoomed #viewport {
    padding: 50vh 50vw;
    /* Más espacio para panear */
}

#viewport::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#viewport::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

#viewport::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 4px;
}

#viewport::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.5);
}

#viewport:active {
    cursor: grabbing;
    scroll-behavior: auto;
}

/* Viewport para iframe - sin padding, pantalla completa */
body.iframe-mode #viewport {
    padding: 40px;
    height: 100vh;
}

.book {
    position: relative;
    width: calc(var(--book-width) * var(--zoom-level));
    height: calc(var(--book-height) * var(--zoom-level));
    transform-style: preserve-3d;
    display: flex;
    justify-content: flex-end;
    transition:
        width 0.2s ease-out,
        height 0.2s ease-out,
        transform var(--duration) cubic-bezier(0.15, 0.45, 0.2, 1);
    margin: auto;
    flex-shrink: 0;
    user-select: none;
}

/* Centrado consistente en zoom */
body.is-zoomed .book {
    margin: auto;
}

/* Libro más grande en modo iframe */
body.iframe-mode .book {
    width: calc(min(95vw, 900px) * var(--zoom-level));
    height: calc(min(85vh, 650px) * var(--zoom-level));
}

.leaf {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform var(--duration) cubic-bezier(0.15, 0.45, 0.2, 1);
    z-index: 1;
}

.page-front,
.page-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    background: var(--page-color);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow:
        inset 3px 0 10px rgba(0, 0, 0, 0.1),
        0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Sombra dinámica para el efecto de curvatura */
.page-shadow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity var(--duration) ease;
    opacity: 0;
}

.page-front .page-shadow {
    background: linear-gradient(to right,
            rgba(0, 0, 0, 0.2) 0%,
            rgba(0, 0, 0, 0.05) 15%,
            rgba(0, 0, 0, 0.1) 40%,
            rgba(0, 0, 0, 0.2) 50%,
            rgba(0, 0, 0, 0) 80%);
}

.page-back .page-shadow {
    background: linear-gradient(to left,
                    rgba(0, 0, 0, 0.2) 0%,
                    rgba(0, 0, 0, 0.05) 15%,
                    rgba(0, 0, 0, 0.1) 40%,
                    rgba(0, 0, 0, 0.2) 50%,
                    rgba(0, 0, 0, 0) 80%);
}

.leaf.flipped .page-back .page-shadow {
    opacity: 1;
}

.leaf:not(.flipped) .page-front .page-shadow {
    opacity: 1;
}

.page-back {
    transform: rotateY(-180deg);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.page-front {
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.is-cover-front .page-front,
.is-cover-back .page-back {
    background: var(--cover-color);
    color: white;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        5px 5px 15px rgba(0, 0, 0, 0.3);
}

.leaf.flipped {
    transform: rotateY(-180deg) rotateZ(-0.5deg) translateZ(0.5px);
}

/* Efecto de brillo al pasar la página */
.leaf::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right,
            transparent 0%,
            rgba(255, 255, 255, 0.1) 30%,
            rgba(255, 255, 255, 0.2) 50%,
            rgba(255, 255, 255, 0.1) 70%,
            transparent 100%);
    z-index: 10;
    opacity: 0;
    transition: opacity var(--duration) ease;
    pointer-events: none;
}

.leaf.flipped::before {
    opacity: 0.3;
    transform: rotateY(-180deg);
}

/* Esquinas para arrastrar */
.page-front::after,
.page-back::after {
    content: "";
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 10;
    cursor: pointer;
    transition: background 0.3s ease;
}

.page-front::after {
    bottom: 0;
    right: 0;
    background: linear-gradient(135deg,
            transparent 50%,
            rgba(59, 130, 246, 0.1) 50%);
    border-bottom-right-radius: 12px;
}

.page-back::after {
    bottom: 0;
    left: 0;
    background: linear-gradient(-135deg,
            transparent 50%,
            rgba(59, 130, 246, 0.1) 50%);
    border-bottom-left-radius: 12px;
}

.page-front:hover::after,
.page-back:hover::after {
    background-color: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    background-color: #ffffff;
}

.spine {
    position: absolute;
    left: 50%;
    top: 0;
    width: 14px;
    height: 100%;
    background: #124a38;
    background: linear-gradient(to right,
            #0b2e23 0%,
            #124a38 20%,
            #1e7a5d 50%,
            #124a38 80%,
            #0b2e23 100%);
    z-index: 1000;
    transform: translateX(-50%);
    box-shadow:
        0 0 15px rgba(0, 0, 0, 0.3),
        inset 0 0 8px rgba(0, 0, 0, 0.4);
    border-radius: 4px;
}

/* Efecto de relieve en el lomo (nervios/ribs) */
.spine::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(to bottom,
            transparent,
            transparent 70px,
            rgba(0, 0, 0, 0.3) 70px,
            rgba(0, 0, 0, 0.4) 71px,
            rgba(255, 255, 255, 0.05) 71px,
            rgba(255, 255, 255, 0.08) 72px,
            transparent 72px);
    opacity: 0.6;
    pointer-events: none;
}

/* Sombra proyectada sobre las páginas cercanas al eje */
.spine::before {
    content: "";
    position: absolute;
    top: 0;
    left: -15px;
    right: -15px;
    height: 100%;
    background: linear-gradient(to right,
            transparent 0%,
            rgba(0, 0, 0, 0.25) 45%,
            transparent 50%,
            rgba(0, 0, 0, 0.25) 55%,
            transparent 100%);
    pointer-events: none;
    z-index: -1;
}

/* UI Overlay normal */
.ui-overlay {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 16, 18, 0.85);
    backdrop-filter: blur(15px);
    padding: 10px 25px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 2000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* UI Overlay minimalista para iframe */
body.iframe-mode .ui-overlay {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 20px;
    gap: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Ocultar botón de pantalla completa en la barra inferior en modo iframe */
body.iframe-mode #fullscreen-btn {
    display: none !important;
}

/* Ocultar separadores en modo iframe */
body.iframe-mode .ui-divider {
    display: none !important;
}

/* UI Overlay para fondos claros */
body.bg-soft-light .ui-overlay,
body.bg-clouds .ui-overlay {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.bg-soft-light .ui-overlay button,
body.bg-clouds .ui-overlay button {
    color: #000;
}

body.bg-soft-light .ui-overlay button:hover,
body.bg-clouds .ui-overlay button:hover {
    color: #3b82f6;
}

/* Controles de Zoom Laterales */
.lateral-zoom-controls {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(15, 16, 18, 0.85);
    backdrop-filter: blur(15px);
    padding: 10px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 2000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    opacity: 0.7;
}

.lateral-zoom-controls:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.05);
}

.lateral-zoom-controls button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.2s ease;
    color: white;
}

.lateral-zoom-controls button:hover {
    background: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

.lateral-zoom-controls .zoom-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

/* Modo iframe para controles laterales */
body.iframe-mode .lateral-zoom-controls {
    right: 10px;
    padding: 8px;
}

/* Modo fullscreen */
.fullscreen-btn {
    margin-left: 8px;
}

/* Botón de silencio */
#mute-btn-float {
    display: flex;
}

/* Botones Flotantes Inferior Derecha */
.floating-controls {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2100;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.floating-controls:hover {
    opacity: 1;
}

.floating-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(15, 16, 18, 0.85);
    backdrop-filter: blur(15px);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.floating-btn:hover {
    background: #3b82f6;
    transform: scale(1.1) translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
}

.share-btn:hover {
    background: #10b981 !important;
}

.floating-btn i {
    font-size: 1.2rem;
}

/* Botón Flotante Izquierdo */
.left-floating-controls {
    position: fixed;
    left: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2100;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.left-floating-controls:hover {
    opacity: 1;
}

.left-floating-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(15, 16, 18, 0.85);
    backdrop-filter: blur(15px);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.left-floating-btn:hover {
    background: #3b82f6;
    transform: scale(1.1) translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
}

.left-floating-btn i {
    font-size: 1.2rem;
}

/* Tooltip Estilizado */
.left-tooltip {
    position: absolute;
    bottom: calc(100% + 20px);
    left: 0;
    background: rgba(26, 28, 32, 0.98);
    backdrop-filter: blur(20px);
    padding: 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 320px;
    opacity: 0;
    visibility: hidden;
    /* Agregamos un ligero delay al ocultar para facilitar el click */
    transition:
        opacity 0.4s ease 0.1s,
        transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.1s,
        visibility 0s 0.5s;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    z-index: 2200;
    text-align: left;
    transform: translateY(15px) scale(0.9);
    transform-origin: bottom left;
}

/* Puente invisible para mantener el hover entre el botón y el tooltip */
.left-tooltip::before {
    content: '';
    position: absolute;
    bottom: -25px;
    left: 0;
    width: 100%;
    height: 25px;
    background: transparent;
}

/* Flecha del tooltip */
.left-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 18px;
    width: 15px;
    height: 15px;
    background: rgba(26, 28, 32, 0.98);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    transform: rotate(45deg);
    z-index: -1;
}

.left-floating-btn:hover .left-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    /* Quitar delay al mostrar para que sea instantáneo */
    transition:
        opacity 0.4s ease 0s,
        transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0s,
        visibility 0s 0s;
}

.tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tooltip-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.tooltip-row i {
    width: 32px;
    height: 32px;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    font-size: 14px;
    flex-shrink: 0;
}

.tooltip-divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    margin: 4px 0;
}

.left-tooltip a {
    color: #ffffff;
    transition: all 0.3s ease;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    line-height: 1.4;
}

.left-tooltip a:hover {
    color: #3b82f6;
    transform: translateX(3px);
}

.left-tooltip .credits-title {
    font-size: 10px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800;
    margin-bottom: 2px;
}

@media (max-width: 850px) {
    .floating-controls {
        top: 15px;
        right: 15px;
        bottom: auto;
        flex-direction: row !important;
        gap: 8px !important;
    }

    .floating-controls > div {
        flex-direction: row !important;
        gap: 8px !important;
    }

    .left-floating-controls {
        top: 15px;
        left: 15px;
        bottom: auto;
    }

    .left-tooltip {
        bottom: auto !important;
        top: calc(100% + 15px) !important;
        transform-origin: top left !important;
        transform: translateY(-15px) scale(0.9) !important;
    }

    .left-floating-btn:hover .left-tooltip {
        transform: translateY(0) scale(1) !important;
    }

    .left-tooltip::after {
        bottom: auto !important;
        top: -8px !important;
        transform: rotate(225deg) !important;
        border-right: 1px solid rgba(255, 255, 255, 0.15) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    }

    #cloud-badge {
        top: 70px;
        right: 15px;
    }

    .floating-btn {
        width: 44px;
        height: 44px;
    }

    .floating-btn i {
        font-size: 1.1rem;
    }
}

body.fullscreen-mode #viewport {
    padding: 0;
}

body.fullscreen-mode .book {
    width: calc(min(95vw, 1200px) * var(--zoom-level));
    height: calc(min(90vh, 800px) * var(--zoom-level));
}

#loading-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(26, 28, 32, 0.98) 0%, rgba(15, 16, 18, 1) 100%);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.loading-bar-indeterminate {
    width: 100%;
    height: 100%;
    background-color: #3b82f6;
    animation: indeterminate-loading 1.5s infinite linear;
    transform-origin: 0% 50%;
    border-radius: 20px;
}

@keyframes indeterminate-loading {
    0% { transform: translateX(-100%) scaleX(0.2); }
    50% { transform: translateX(0%) scaleX(0.5); }
    100% { transform: translateX(100%) scaleX(0.2); }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 16, 18, 0.92);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 6000;
    padding: 20px;
}

.cloud-badge {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 2000;
}

.cloud-badge.visible {
    display: flex;
}

/* Ocultar badge en modo iframe */
body.iframe-mode .cloud-badge {
    display: none !important;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background: #3b82f6;
    width: 0%;
    transition: width 0.3s ease;
}

/* Botones minimalistas en modo iframe */
body.iframe-mode .ui-overlay button {
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

body.iframe-mode .ui-overlay button:hover {
    opacity: 1;
}

/* Estilos para el selector de fondos */
.bg-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.bg-selector::-webkit-scrollbar {
    width: 8px;
}

.bg-selector::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.bg-selector::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 4px;
}

.bg-option {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    overflow: hidden;
}

.bg-option:hover {
    transform: scale(1.05);
    border-color: rgba(59, 130, 246, 0.5);
}

.bg-option.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.bg-option .checkmark {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #3b82f6;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 2;
}

.bg-option.selected .checkmark {
    display: flex;
}

.bg-option .label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px;
    font-size: 11px;
    text-align: center;
    font-weight: 600;
}

.bg-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Previews de fondos predefinidos */
.bg-black-preview {
    background: #000;
}

.bg-dark-preview {
    background: #0f1012;
}

.bg-gradient-blue-preview {
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
}

.bg-gradient-purple-preview {
    background: linear-gradient(135deg, #581c87 0%, #1e1b4b 100%);
}

.bg-gradient-warm-preview {
    background: linear-gradient(135deg, #7c2d12 0%, #1c1917 100%);
}

.bg-wood-preview {
    background: linear-gradient(135deg, #451a03 0%, #292524 100%);
    background-image:
        linear-gradient(135deg, #451a03 0%, #292524 100%),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px);
}

.bg-library-preview {
    background: linear-gradient(to bottom,
            #1a1410 0%,
            #0a0806 100%);
}

.bg-soft-light-preview {
    background: linear-gradient(135deg, #f5f5f4 0%, #e7e5e4 100%);
}

.bg-clouds-preview {
    background: linear-gradient(to bottom,
            #0ea5e9 0%,
            #38bdf8 50%,
            #e0f2fe 100%);
}

.section-title {
    font-size: 14px;
    font-weight: 700;
    color: #3b82f6;
    margin-top: 24px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title:first-child {
    margin-top: 0;
}

/* Toggle switches para opciones */
.option-group {
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.option-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.option-item:first-child {
    padding-top: 0;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-switch.active {
    background: #3b82f6;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: left 0.3s ease;
}

.toggle-switch.active::after {
    left: 26px;
}

@media (max-width: 850px) {
    :root {
        --book-width: 95vw;
        --book-height: 50vh;
    }

    #viewport {
        padding: 40px 10px;
    }

    .ui-overlay {
        width: 92%;
        bottom: 25px;
        padding: 8px 12px;
        gap: 5px;
        border-radius: 20px;
        justify-content: center;
    }

    .ui-overlay button {
        padding: 0 2px;
        flex-shrink: 0;
    }

    .ui-overlay .ui-divider {
        display: none !important;
    }

    .left-tooltip {
        width: 280px !important;
        max-width: 85vw !important;
    }

    /* Ocultar botones de navegación extremos en móviles muy pequeños */
    @media (max-width: 400px) {
        .ui-overlay button[onclick="firstPage()"],
        .ui-overlay button[onclick="lastPage()"] {
            display: none;
        }
    }

    .ui-overlay .text-center.min-w-\[120px\] {
        min-width: 90px !important;
    }

    #page-status {
        font-size: 0.7rem;
    }

    #page-label {
        font-size: 7px;
    }

    .modal > div {
        padding: 1.5rem !important;
        border-radius: 20px !important;
        margin: 10px;
    }

    #setup-view > div {
        padding: 2rem 1.5rem !important;
        border-radius: 30px !important;
        width: 90%;
    }

    #setup-view h2 {
        font-size: 1.5rem;
    }

    body.iframe-mode .book {
        width: calc(98vw * var(--zoom-level));
        height: calc(80vh * var(--zoom-level));
    }

    .bg-selector {
        grid-template-columns: repeat(2, 1fr);
    }

    .lateral-zoom-controls {
        display: none;
    }

    .option-item {
        padding: 8px 0 !important;
    }

    .option-group {
        padding: 12px !important;
    }
}
