.jpv-flipbook,
.jpv-flipbook * {
    box-sizing: border-box;
}

.jpv-flipbook {
    --jpv-viewer-height: 760px;
    width: 100%;
    margin: 1.5rem 0;
    overflow: hidden;
    border: 1px solid #2c3338;
    border-radius: 12px;
    background: #181a1d;
    color: #fff;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
}

.jpv-flipbook:focus-visible {
    outline: 3px solid #72aee6;
    outline-offset: 3px;
}

.jpv-toolbar {
    position: relative;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 9px 12px;
    background: #1d2327;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.jpv-toolbar-section {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.jpv-view-controls {
    justify-content: flex-end;
}

.jpv-book-title {
    max-width: 32vw;
    overflow: hidden;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jpv-control,
.jpv-page-input {
    min-height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 7px !important;
    font: inherit !important;
    line-height: 1 !important;
}

.jpv-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 38px;
    margin: 0 !important;
    padding: 8px 11px !important;
    background: #fff !important;
    color: #1d2327 !important;
    text-decoration: none !important;
    cursor: pointer;
    font-size: 14px !important;
    font-weight: 700 !important;
    box-shadow: none !important;
}

.jpv-control:hover,
.jpv-control:focus-visible {
    background: #f0f0f1 !important;
    color: #000 !important;
}

.jpv-control:focus-visible,
.jpv-page-input:focus-visible {
    outline: 3px solid #72aee6 !important;
    outline-offset: 2px;
}

.jpv-control:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.jpv-page-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
}

.jpv-page-input {
    width: 64px !important;
    margin: 0 !important;
    padding: 6px 8px !important;
    background: #fff !important;
    color: #1d2327 !important;
    text-align: center;
}

.jpv-page-total {
    min-width: 34px;
    font-variant-numeric: tabular-nums;
}

.jpv-zoom-reset {
    min-width: 66px;
}

.jpv-stage-wrap {
    position: relative;
    width: 100%;
    height: var(--jpv-viewer-height);
    min-height: 320px;
    max-height: 85vh;
    overflow: auto;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.12), transparent 44%),
        linear-gradient(135deg, #3b4045, #22272b);
    scrollbar-color: #8c8f94 #2c3338;
}

.jpv-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100%;
    min-height: 100%;
    padding: 26px;
}

.jpv-book-scale {
    width: 100%;
    transform-origin: top left;
    transition: transform 180ms ease;
    will-change: transform;
}

.jpv-book {
    margin: 0 auto;
}

.jpv-page {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #fff;
    color: #1d2327;
}

.jpv-page-surface {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.07);
}

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

.jpv-page-image:not([src]),
.jpv-page-image[src=""] {
    visibility: hidden;
}

.jpv-page-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: #fff;
}

.jpv-page-loading[hidden] {
    display: none !important;
}

.jpv-page-number {
    position: absolute;
    right: 9px;
    bottom: 7px;
    z-index: 2;
    min-width: 24px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(29, 35, 39, 0.72);
    color: #fff;
    font-size: 10px;
    line-height: 1.5;
    text-align: center;
    pointer-events: none;
}

.jpv-page-cover .jpv-page-number {
    display: none;
}

.jpv-page-render-error .jpv-page-surface::after {
    content: "Page unavailable";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #8a2424;
    background: #fff3f3;
    font-weight: 700;
}

.jpv-loading,
.jpv-message {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 25;
    transform: translate(-50%, -50%);
    max-width: calc(100% - 40px);
    padding: 16px 20px;
    border-radius: 10px;
    background: rgba(20, 23, 26, 0.94);
    color: #fff;
    text-align: center;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}

.jpv-loading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.jpv-loading[hidden],
.jpv-message[hidden] {
    display: none !important;
}

.jpv-message {
    border-left: 4px solid #d63638;
}

.jpv-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border: 3px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    border-radius: 50%;
    animation: jpv-spin 0.8s linear infinite;
}

.jpv-page-loading .jpv-spinner {
    border-color: rgba(29, 35, 39, 0.18);
    border-top-color: #1d2327;
}

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

.jpv-status {
    min-height: 32px;
    padding: 7px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: #1d2327;
    color: #c3c4c7;
    font-size: 12px;
    text-align: center;
}

.jpv-error {
    margin: 1rem 0;
    padding: 12px 14px;
    border-left: 4px solid #d63638;
    background: #fff;
    color: #1d2327;
}

.jpv-flipbook .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Required StPageFlip layout rules. */
.jpv-flipbook .stf__parent {
    position: relative;
    display: block;
    box-sizing: border-box;
    transform: translateZ(0);
    -ms-touch-action: pan-y;
    touch-action: pan-y;
}

.jpv-flipbook .sft__wrapper {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.jpv-flipbook .stf__parent canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
}

.jpv-flipbook .stf__block {
    position: absolute;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    perspective: 2000px;
}

.jpv-flipbook .stf__item {
    display: none;
    position: absolute;
    transform-style: preserve-3d;
}

.jpv-flipbook .stf__outerShadow,
.jpv-flipbook .stf__innerShadow,
.jpv-flipbook .stf__hardShadow,
.jpv-flipbook .stf__hardInnerShadow {
    position: absolute;
    left: 0;
    top: 0;
}

.jpv-flipbook:fullscreen,
.jpv-flipbook.jpv-is-fullscreen {
    width: 100vw;
    height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #181a1d;
}

.jpv-flipbook:fullscreen .jpv-stage-wrap,
.jpv-flipbook.jpv-is-fullscreen .jpv-stage-wrap {
    height: calc(100vh - 90px);
    max-height: none;
}

.jpv-flipbook:fullscreen .jpv-status,
.jpv-flipbook.jpv-is-fullscreen .jpv-status {
    display: none;
}

@media (max-width: 820px) {
    .jpv-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .jpv-book-title {
        display: none;
    }

    .jpv-stage {
        padding: 18px;
    }
}

@media (max-width: 560px) {
    .jpv-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px;
    }

    .jpv-toolbar-section {
        flex: 1 1 100%;
        justify-content: center;
    }

    .jpv-control {
        min-width: 36px;
        padding: 8px !important;
    }

    .jpv-control-text {
        display: none;
    }

    .jpv-stage-wrap {
        height: min(var(--jpv-viewer-height), 74vh);
    }

    .jpv-stage {
        padding: 12px;
    }

    .jpv-page-number {
        right: 5px;
        bottom: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .jpv-book-scale,
    .jpv-spinner {
        transition: none;
        animation-duration: 0.01ms;
    }
}

.jpv-access-gate,
.jpv-access-gate * {
    box-sizing: border-box;
}

.jpv-access-gate {
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 420px;
    margin: 1.5rem 0;
    padding: 28px;
    border: 1px solid #2c3338;
    border-radius: 12px;
    background:
        radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.12), transparent 40%),
        linear-gradient(135deg, #3b4045, #181a1d);
    color: #fff;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
}

.jpv-access-card {
    width: min(100%, 520px);
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    background: rgba(29, 35, 39, 0.96);
    text-align: center;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

.jpv-access-icon {
    margin-bottom: 10px;
    font-size: 38px;
    line-height: 1;
}

.jpv-access-card h2 {
    margin: 0 0 10px;
    color: #fff;
    font-size: clamp(24px, 4vw, 34px);
}

.jpv-access-card > p {
    margin: 0 0 24px;
    color: #dcdcde;
}

.jpv-access-form {
    display: grid;
    gap: 10px;
    text-align: left;
}

.jpv-access-form label {
    color: #fff;
    font-weight: 700;
}

.jpv-access-input {
    width: 100% !important;
    min-height: 50px;
    margin: 0 !important;
    padding: 10px 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.34) !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: #1d2327 !important;
    font: 700 18px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    letter-spacing: 0.1em;
    text-align: center;
    text-transform: uppercase;
}

.jpv-access-input:focus {
    outline: 3px solid #72aee6 !important;
    outline-offset: 2px;
}

.jpv-access-submit {
    min-height: 48px;
    margin: 4px 0 0 !important;
    padding: 10px 18px !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: #1d2327 !important;
    font: 700 16px/1.2 inherit !important;
    cursor: pointer;
}

.jpv-access-submit:hover,
.jpv-access-submit:focus-visible {
    background: #f0f0f1 !important;
}

.jpv-access-submit:disabled {
    opacity: 0.65;
    cursor: wait;
}

.jpv-access-message {
    min-height: 24px;
    margin-top: 4px;
    color: #d7f0df;
    font-size: 14px;
    text-align: center;
}

.jpv-access-message.is-error {
    color: #ffb4b4;
}

.jpv-access-message.is-success {
    color: #b8f2c8;
}

@media (max-width: 600px) {
    .jpv-access-gate {
        min-height: 360px;
        padding: 16px;
    }

    .jpv-access-card {
        padding: 24px 18px;
    }
}
