.rsf-viewer {
    --rsf-gold: #7f6924;
    --rsf-black: #262626;
    --rsf-paper: #ffffff;
    width: 100%;
    max-width: 100%;
    position: relative;
    isolation: isolate;
    margin: 0;
    padding: 0;
    color: var(--rsf-black);
    font-family: "Host Grotesk", Arial, sans-serif;
}

.rsf-stage {
    width: 100%;
    height: auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    background: var(--rsf-paper);
    touch-action: pan-y;
}

.rsf-book-viewport {
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: var(--rsf-spread-aspect, 1.414);
    flex: 0 0 auto;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rsf-book-shell {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate3d(var(--rsf-pan-x, 0), var(--rsf-pan-y, 0), 0)
        scale(var(--rsf-zoom, 1));
    transform-origin: center center;
    transition: transform .2s ease;
    will-change: transform;
}

.rsf-book-shell.is-panning {
    transition: none;
    cursor: grabbing;
}

.rsf-book-shell.is-zoomed {
    cursor: grab;
    touch-action: none;
}

.rsf-book {
    width: 100%;
    height: 100%;
    margin: 0 auto;
}

.rsf-page {
    background: #fff;
    overflow: hidden;
}

.rsf-page-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #fff;
    user-select: none;
    -webkit-user-drag: none;
}

.rsf-loading {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(255, 255, 255, .96);
    color: var(--rsf-black);
    font-size: 15px;
    transition: opacity .25s ease, visibility .25s ease;
}

.rsf-loading.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.rsf-spinner {
    width: 34px;
    height: 34px;
    border: 2px solid rgba(127, 105, 36, .18);
    border-top-color: var(--rsf-gold);
    border-radius: 50%;
    animation: rsf-spin .8s linear infinite;
}

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

.rsf-side-arrow,
.rsf-control,
.rsf-fullscreen-close {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    outline: 0;
    font: inherit;
    cursor: pointer;
}

.rsf-side-arrow {
    width: 40px;
    height: 40px;
    position: absolute;
    top: calc(50% - 24px);
    z-index: 25;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 3px 12px rgba(0, 0, 0, .1);
    color: var(--rsf-gold);
    font-family: Arial, sans-serif;
    font-size: 27px;
    line-height: 1;
    transition: color .2s ease, transform .2s ease, opacity .2s ease;
}

.rsf-side-prev { left: 8px; }
.rsf-side-next { right: 8px; }

.rsf-side-arrow:hover {
    color: var(--rsf-gold);
    transform: scale(1.06);
}

.rsf-side-arrow:disabled,
.rsf-control:disabled {
    opacity: .25;
    cursor: default;
    transform: none;
}

.rsf-toolbar {
    min-height: 56px;
    max-width: calc(100% - 24px);
    position: relative;
    left: auto;
    bottom: auto;
    z-index: 30;
    transform: none;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
    margin: 0 auto;
    padding: 2px 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.rsf-control {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--rsf-black);
    font-size: 22px;
    line-height: 1;
    transition: color .2s ease, background-color .2s ease, transform .2s ease;
}

.rsf-control:hover {
    color: var(--rsf-gold);
    background: rgba(127, 105, 36, .07);
    transform: scale(1.06);
}

.rsf-control:focus-visible,
.rsf-side-arrow:focus-visible,
.rsf-fullscreen-close:focus-visible {
    outline: 2px solid var(--rsf-gold);
    outline-offset: 2px;
}

.rsf-counter,
.rsf-zoom-value {
    flex: 0 0 auto;
    text-align: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rsf-counter {
    min-width: 70px;
    font-size: 15px;
}

.rsf-zoom-value {
    min-width: 48px;
    color: #5c5c5c;
    font-size: 12px;
}

.rsf-toolbar-separator {
    width: 1px;
    height: 25px;
    background: rgba(38, 38, 38, .14);
}

.rsf-fullscreen-close {
    display: none;
}

.rsf-message {
    width: 100%;
    padding: 18px;
    box-sizing: border-box;
    border: 1px solid rgba(127, 105, 36, .3);
    background: #fff;
    color: #262626;
    text-align: center;
}

.rsf-viewer:fullscreen,
.rsf-viewer:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rsf-viewer:fullscreen .rsf-stage,
.rsf-viewer:-webkit-full-screen .rsf-stage {
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    padding: 56px 12px 6px;
}

.rsf-viewer:fullscreen .rsf-book-viewport,
.rsf-viewer:-webkit-full-screen .rsf-book-viewport {
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.rsf-viewer:fullscreen .rsf-fullscreen-close,
.rsf-viewer:-webkit-full-screen .rsf-fullscreen-close {
    width: 44px;
    height: 44px;
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(127, 105, 36, .3);
    border-radius: 50%;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
    color: var(--rsf-black);
    font-size: 34px;
    line-height: 1;
}

@media (max-width: 1024px) {
    .rsf-stage {
        height: auto;
        min-height: 0;
        padding: 0;
    }

    .rsf-side-arrow {
        width: 36px;
        height: 36px;
        font-size: 25px;
    }

    .rsf-side-prev { left: 6px; }
    .rsf-side-next { right: 6px; }
}

@media (max-width: 767px),
       (orientation: portrait) and (max-width: 1024px) {
    .rsf-stage {
        height: auto;
        min-height: 0;
        gap: 0;
        padding: 0;
    }

    .rsf-book-viewport {
        height: auto;
        max-height: none;
        aspect-ratio: var(--rsf-page-aspect, .707);
        padding: 0;
        box-sizing: border-box;
    }

    .rsf-side-arrow {
        width: 32px;
        height: 32px;
        top: calc(50% - 28px);
        border: 0;
        background: rgba(255, 255, 255, .92);
        font-size: 23px;
    }

    .rsf-side-prev { left: 5px; }
    .rsf-side-next { right: 5px; }

    .rsf-toolbar {
        width: calc(100% - 12px);
        max-width: 440px;
        min-height: 46px;
        bottom: auto;
        gap: 3px;
        margin: 0 auto;
        padding: 1px 6px;
        overflow-x: auto;
        justify-content: center;
        scrollbar-width: none;
    }

    .rsf-toolbar::-webkit-scrollbar {
        display: none;
    }

    .rsf-control {
        width: 34px;
        height: 38px;
        flex-basis: 34px;
        font-size: 20px;
    }

    .rsf-counter {
        min-width: 55px;
        font-size: 13px;
    }

    .rsf-zoom-value {
        min-width: 38px;
        font-size: 11px;
    }

    .rsf-toolbar-separator {
        height: 21px;
    }

    .rsf-viewer:fullscreen .rsf-stage,
    .rsf-viewer:-webkit-full-screen .rsf-stage {
        height: auto;
        flex: 1 1 auto;
        padding: 50px 7px 4px;
    }

    .rsf-viewer:fullscreen .rsf-book-viewport,
    .rsf-viewer:-webkit-full-screen .rsf-book-viewport {
        max-height: none;
        aspect-ratio: auto;
        flex: 1 1 auto;
    }
}

@media (max-width: 374px) {
    .rsf-toolbar {
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rsf-book-shell,
    .rsf-loading,
    .rsf-side-arrow,
    .rsf-control {
        transition: none;
    }

    .rsf-spinner {
        animation-duration: 1.6s;
    }
}
