* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    min-height: 100%;
    font-family: Figtree, ui-sans-serif, system-ui, sans-serif;
    background: #111;
    color: #f5f5f5;
}

body {
    overflow: hidden;
}

.app {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    width: 100%;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;

    background: linear-gradient(90deg, #023CA1 0%, #0B2E6A 100%);
    color: #ffffff;

    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-logo {
    width: 78px;
    height: 78px;
    object-fit: contain;
    flex-shrink: 0;
}

.topbar h1 {
    margin: 0;
    font-size: 25px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0;
    white-space: nowrap;
}

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.controls button {
    border: 0;
    border-radius: 8px;
    padding: 9px 15px;
    cursor: pointer;

    font-weight: 800;
    color: #023CA1;
    background: #FFDE21;

    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.controls button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
}

.controls button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.controls button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#page-indicator {
    min-width: 120px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 4px;
}

.controls .icon-button {
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
}

#zoom-indicator {
    min-width: 48px;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    color: #ffffff;
}

.book-wrapper {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 28px 16px;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#book {
    flex: 0 0 auto;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.65);
}

@media (min-width: 701px) {
    .book-wrapper.is-reader-active {
        cursor: grab;
    }

    .book-wrapper.is-reader-active.is-dragging {
        cursor: grabbing;
        user-select: none;
    }
}

.mobile-reader {
    display: none;
    overflow: visible;
    flex: 0 0 auto;
}

.mobile-reader img {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    background: #ffffff;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.58);
}

.mobile-reader[hidden] {
    display: none !important;
}

.mobile-reader img {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    background: #ffffff;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.58);
    image-rendering: auto;
}

@media (max-width: 700px) {
    body {
        overflow: hidden;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 10px;
        gap: 10px;
    }

    .brand {
        justify-content: center;
    }

    .brand-logo {
        width: 48px;
        height: 48px;
    }

    .topbar h1 {
        text-align: center;
        font-size: 20px;
        white-space: normal;
    }

    .controls {
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }

    .controls button {
        padding: 8px 14px;
    }

    #page-indicator {
        min-width: 112px;
    }

    .zoom-controls {
        display: flex;
        width: 100%;
        justify-content: center;
        padding-left: 0;
        margin-top: 2px;
    }

    .book-wrapper {
        align-items: flex-start;
        justify-content: center;
        padding: 12px 8px 20px;
        overflow: auto;
        touch-action: pan-x pan-y;
    }

    .book-wrapper.is-reader-active {
        justify-content: flex-start;
        align-items: flex-start;
        padding: 12px;
        touch-action: pan-x pan-y;
    }

    .book-wrapper.is-reader-active #book {
        display: none;
    }

    .book-wrapper.is-reader-active .mobile-reader {
        display: block;
        margin: 0;
    }
}