:root {
    --bg: #111827;
    --accent: #e67e22;
    --glass: rgba(255, 255, 255, 0.06);
    --text: #fff;
}

#flipbook-viewer-body {
    background: var(--bg);
    font-family: "Segoe UI", system-ui, sans-serif;
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* ── HIDE THEME ELEMENTS ── */
#header:not(#viewer-header),
#footer,
.header-nav,
.header-top,
.breadcrumb,
#wrapper>.breadcrumb,
.js-footer {
    display: none !important;
}

#wrapper,
.container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* ── HEADER ── */
#viewer-header {
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    z-index: 100;
    /* Higher than mask */
}

/* ── MOSAIC VIEW ── */
#mosaic-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.mosaic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.mosaic-header h3 {
    margin: 0;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.mosaic-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 2rem;
    transition: transform 0.2s ease;
}

.mosaic-close:hover {
    transform: scale(1.1);
    color: var(--accent);
}

.mosaic-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
    overflow-y: auto;
    padding-bottom: 40px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.mosaic-item {
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    background: #1e293b;
    /* Aspect ratio fallback (Padding hack) */
    width: 100%;
    height: 0;
    padding-bottom: 141.4%;
    /* 1.414 / 1 = 141.4% height relative to width */
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.mosaic-item:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.mosaic-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-low);
}

.mosaic-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mosaic-item .page-num {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.75rem;
    text-align: center;
    padding: 4px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.shop-logo-link {
    display: flex;
    align-items: center;
    height: 32px;
}

.shop-logo {
    max-height: 100%;
    width: auto;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.3));
}

.logo-separator {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
}

.logo-label {
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1rem;
}

#pdf-title {
    opacity: 0.5;
    font-size: 0.8rem;
    margin: 0;
}

/* ── VIEWPORT ── */
#viewport {
    flex: 1;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #1e293b 0%, #111827 70%);
    position: relative;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    display: block;
    padding: 0;
}

#viewport::-webkit-scrollbar {
    display: none;
}

#zoom-wrapper {
    transition: transform 0.15s ease-out;
    transform-origin: top left;
    position: absolute;
}

#flipbook .pdf-page {
    background: #fff;
    overflow: hidden;
    position: relative;
}

#flipbook .pdf-page img {
    display: block;
    user-select: none;
}

/* ── CONTROLS ── */
#controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    padding: 6px 12px;
    z-index: 10;
}

#controls-top-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

#controls-bottom-row {
    display: flex;
    align-items: center;
    padding: 0 8px;
}

#controls-bottom-row input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.btn {
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: white;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    pointer-events: none;
}

#page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.zoom-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 20px;
    background: rgba(255, 255, 255, 0.04);
    padding: 3px 12px;
    border-radius: 16px;
    font-size: 0.78rem;
}

.zoom-group input[type="range"] {
    width: 90px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── LOADING ── */
#loading {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.35s;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.load-text {
    margin-top: 14px;
    font-size: 0.85rem;
    opacity: 0.6;
}

/* ── MOBILE ── */
@media (max-width: 768px) {
    #viewer-header {
        height: 40px;
        padding: 0 10px;
    }

    .logo-label {
        font-size: 0.85rem;
    }

    #pdf-title {
        display: none;
    }

    #controls {
        height: auto;
        gap: 8px;
    }

    .btn span {
        display: none;
    }

    .btn {
        padding: 7px 10px;
    }

    .zoom-group {
        margin-left: 8px;
        padding: 3px 8px;
    }

    .zoom-group input[type="range"] {
        width: 60px;
    }
}

