* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: Georgia, serif;
    background: linear-gradient(135deg, #006f66, #2aa198);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ================= HEADER ================= */
.top-bar {
    height: 45px;
    background: #bfe6ea;
    display: flex;
    align-items: center;
    padding: 0 30px;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .1em;
    color: #1b2b44;
}

#brandLogo {
    height: 34px;
    object-fit: contain;
}
.toolbar {
    /*position: absolute;
    left: 50%;
    transform: translateX(-50%);*/
    display: flex;
    gap: 22px;
    justify-content: center;
}

.toolbar i,
.toolbar a i {
    font-size: 18px;
    color: #1b2b44;
    cursor: pointer;
}

.toolbar i:hover {
    opacity: .7;
}

.toolbar2 {
    position: absolute;
    float: right;
    right: 5%;
    display: flex;
    gap: 22px;
}

/* ================= VIEWER ================= */
.viewer {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* NAV ARROWS */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    z-index: 20;
}

.nav-arrow.left {
    left: 40px;
}

.nav-arrow.right {
    right: 40px;
}

/* ================= BOOK ================= */
#flipbook {
    /* width: 960px;
    height: 620px; */
    position: relative;
    overflow: hidden;
    /* IMPORTANT: no transform transition -> no delayed slide */
    transition: none;
}

#flipbook .page {
    width: 100%;
    height: 100%;
    background: transparent;
}

/* 🔑 REQUIRED FOR MOUSE DRAG */
.page canvas {
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
}

/* ================= FOOTER ================= */
.bottom-bar {
    height: 45px;
    background: #d9f3f6;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.bottom-bar button {
    border: none;
    background: none;
    font-size: 16px;
    cursor: pointer;
}

.page-box {
    width: 90px;
    text-align: center;
    padding: 4px;
    font-size: 14px;
}

/* Download Image MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-box {
    width: 640px;
    background: #8fd6d2;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}

.modal-header {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 600;
}

.modal-header button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
}

.modal-content {
    display: flex;
    padding: 20px;
    gap: 20px;
}

.modal-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-left label {
    font-size: 14px;
    cursor: pointer;
}

.modal-download-btn {
    margin-top: 20px;
    padding: 10px;
    border: none;
    background: #bfe6ea;
    font-size: 14px;
    cursor: pointer;
}

.modal-right {
    width: 200px;
    text-align: center;
}

.modal-right img {
    width: 100%;
    border: 1px solid #fff;
}

#pageLabel {
    margin-top: 6px;
    font-size: 13px;
}

.viewer {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    /* allows panning when zoomed */
}

#flipbook {
    transition: transform 0.25s ease;
}

/* THUMB OVERLAY */
.thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 120, 120, 0.75);

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 200;
}

.thumb-overlay.hidden {
    display: none;
}

.thumb-strip {
    display: flex;
    gap: 14px;
    padding: 20px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

.thumb-strip::-webkit-scrollbar {
    display: none;
}
.thumb-wrapper {
    width: 85%;
    overflow: hidden;
}
.thumb {
    width: 120px;
    background: #fff;
    padding: 4px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform .2s, border-color .2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.thumb-label {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #003c3c;
}
.thumb.active .thumb-label {
    color: #ff6b4a;
}
.thumb canvas {
    width: 100%;
    height: auto;
}

.thumb:hover {
    transform: scale(1.05);
}

.thumb.active {
    border-color: #ff6b4a;
}

.thumb-close {
    position: absolute;
    right: 30px;
    top: 66px;
    font-size: 28px;
    cursor: pointer;
    color: #fff;
}

.modal-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.bottom-bar {
    position: relative;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.15);
}

.mobile-toolbar,
.mobile-nav-bar {
    display: none;
}

.settings_div {
    max-height: 98vh;
    overflow: auto;
    overflow-y: auto;
}
.page {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f5f5f5; /* prevents white flash */
    overflow: hidden;
}

.page-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ccc;
    border-top: 4px solid #1bb3ad;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}