* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Main container */
#viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Pages container */
#book {
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Navigation arrows */
.nav-arrow {
    position: absolute;
    top: 0;
    width: 60px;
    height: 100%;
    z-index: 20;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0);
    font-size: 24px;
    transition: color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.nav-arrow:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.08);
}

.nav-arrow:active {
    background: rgba(0, 0, 0, 0.15);
}

.nav-prev {
    left: 0;
    border-radius: 0;
}

.nav-next {
    right: 0;
    border-radius: 0;
}

/* Page indicator */
.page-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    color: #6D6E71;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, 0.85);
    padding: 3px 12px;
    border-radius: 12px;
    user-select: none;
    pointer-events: none;
}

/* Controls (fullscreen, download) */
.viewer-controls {
    position: absolute;
    bottom: 8px;
    right: 12px;
    z-index: 20;
    display: flex;
    gap: 6px;
}

.viewer-controls button {
    background: rgba(255, 255, 255, 0.85);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: #6D6E71;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.viewer-controls button:hover {
    background: #96D6D3;
    color: #fff;
}

/* Loading overlay */
#loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #6D6E71;
    font-size: 14px;
    gap: 12px;
}

#loading-overlay .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #ddd;
    border-top-color: #96D6D3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error overlay */
#error-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #6D6E71;
    font-size: 16px;
    text-align: center;
    padding: 20px;
    gap: 12px;
}

#error-overlay i {
    font-size: 48px;
    color: #ccc;
}

/* Page canvases */
#book canvas {
    display: none;
    max-width: 100%;
    max-height: 100%;
}

#book canvas.active {
    display: block;
}

/* Fullscreen */
body.fullscreen {
    background: #2a2a2a;
}

body.fullscreen #viewer-container {
    background: #2a2a2a;
}

body.fullscreen .page-indicator {
    background: rgba(50, 50, 50, 0.85);
    color: #ccc;
}

body.fullscreen .viewer-controls button {
    background: rgba(50, 50, 50, 0.85);
    color: #ccc;
}

body.fullscreen .viewer-controls button:hover {
    background: #96D6D3;
    color: #fff;
}

body.fullscreen .nav-arrow:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.06);
}

/* Mobile */
@media (max-width: 736px) {
    .nav-arrow {
        width: 40px;
        font-size: 18px;
    }

    .page-indicator {
        font-size: 12px;
        bottom: 4px;
        padding: 2px 10px;
    }

    .viewer-controls {
        bottom: 4px;
        right: 6px;
    }

    .viewer-controls button {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}
