:root {
    color-scheme: light;
    --reader-blue: #1a4d7c;
    --reader-pink: #ee1e6e;
    --reader-surface: #eaf4fb;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; min-width: 0; overflow: hidden; }
body {
    background: var(--reader-surface);
    color: var(--reader-blue);
    font-family: 'Outfit', 'Lato', Arial, sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

#book-stage {
    position: fixed;
    inset: 0 0 58px 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 12px 0;
    background: var(--reader-surface);
    overscroll-behavior: contain;
}

#book-container {
    position: relative;
    width: var(--book-width, 1120px) !important;
    height: var(--book-height, 725px) !important;
    max-width: 100%;
    border-color: transparent !important;
    background: var(--reader-surface) !important;
    transform-origin: center center;
    transition: transform .22s ease;
}

#book-container.cover-only,
#book-container.cover-only .stf__wrapper,
#book-container.cover-only .stf__block {
    overflow: visible !important;
    background: var(--reader-surface) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.page {
    position: relative;
    overflow: hidden;
    background: #fff;
    color: #111;
}
.page img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    background: #fff;
    user-select: none;
    -webkit-user-drag: none;
}
.page:not(.full-cover-page)::after {
    content: '';
    position: absolute;
    z-index: 12;
    top: 0;
    bottom: 0;
    width: 9px;
    pointer-events: none;
    opacity: 1;
    transition: opacity .3s ease;
}
.page.--left:not(.full-cover-page)::after {
    right: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(15,40,65,.025) 45%, rgba(15,40,65,.13) 100%);
}
.page.--right:not(.full-cover-page)::after {
    left: 0;
    background: linear-gradient(90deg, rgba(15,40,65,.13) 0%, rgba(15,40,65,.025) 55%, transparent 100%);
}
.full-cover-page::before,
.back-cover-page::before {
    content: '';
    position: absolute;
    z-index: 20;
    top: 0;
    bottom: 0;
    width: 18px;
    pointer-events: none;
    mix-blend-mode: multiply;
}
.full-cover-page::before {
    left: 0;
    background: linear-gradient(90deg, rgba(5,31,57,.34) 0%, rgba(17,72,116,.16) 36%, rgba(255,255,255,.22) 72%, transparent 100%);
}
.back-cover-page::before {
    right: 0;
    background: linear-gradient(270deg, rgba(5,31,57,.34) 0%, rgba(17,72,116,.16) 36%, rgba(255,255,255,.22) 72%, transparent 100%);
}
#book-container.cover-only .stf__outerShadow,
#book-container.cover-only .stf__innerShadow,
#book-container.cover-only .stf__hardShadow,
#book-container.cover-only .stf__hardInnerShadow {
    display: none !important;
    opacity: 0 !important;
}

.reader-ui-layer {
    position: fixed;
    inset: 0 0 58px 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}
.reader-top-spacer { padding: 12px; }
.reader-midbar {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 18px;
}
.reader-nav-btn {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff, #eef3f8);
    box-shadow: 0 6px 18px rgba(26,77,124,.25), 0 0 0 1px rgba(26,77,124,.08);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.reader-nav-btn svg { width: 18px; height: 18px; stroke: var(--reader-blue); }
.reader-nav-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 10px 24px rgba(26,77,124,.35), 0 0 0 1px rgba(26,77,124,.12);
}
.reader-nav-btn:active:not(:disabled) { transform: scale(.96); }
.reader-nav-btn:disabled { opacity: .35; cursor: not-allowed; }

.reader-bottom-bar {
    position: fixed;
    left: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 58px;
    pointer-events: none;
}
.reader-toolbar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 24px;
    background: rgba(255,255,255,.85);
    box-shadow: 0 8px 24px rgba(0,0,0,.18), 0 0 0 1px rgba(26,77,124,.08);
    font-family: 'Outfit', 'Cambria', sans-serif;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.reader-toolbar-btn {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--reader-blue);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, transform .15s ease;
}
.reader-toolbar-btn svg { width: 15px; height: 15px; }
.reader-toolbar-btn:hover { background: #eef3f8; transform: scale(1.08); }
.reader-toolbar-divider { width: 1px; height: 16px; background: rgba(26,77,124,.18); }
.reader-page-info {
    min-width: 70px;
    color: var(--reader-blue);
    font-size: 9pt;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: nowrap;
}
.reader-progress-track {
    width: 210px;
    height: 5px;
    overflow: hidden;
    border-radius: 6px;
    background: rgba(26,77,124,.12);
}
.reader-progress-bar {
    display: block;
    width: calc(100% / 116);
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--reader-pink), var(--reader-blue));
    transition: width .3s ease;
}
.reader-jump-label { display: flex; }
.reader-jump-input {
    width: 32px;
    min-height: 22px;
    padding: 1px;
    border: 1px solid rgba(26,77,124,.25);
    border-radius: 6px;
    color: var(--reader-blue);
    background: #fff;
    font-size: 8.5pt;
    font-weight: 600;
    text-align: center;
}
.reader-jump-input:focus { outline: none; border-color: var(--reader-blue); }
.reader-jump-input::-webkit-inner-spin-button { appearance: none; }

.loading-card {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 180;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid rgba(26,77,124,.12);
    border-radius: 20px;
    background: rgba(255,255,255,.9);
    box-shadow: 0 8px 24px rgba(15,40,65,.16);
    color: var(--reader-blue);
    font-size: 12px;
    transform: translate(-50%, -50%);
}
.loading-card[hidden] { display: none !important; }
.loading-spinner { width: 16px; height: 16px; border: 2px solid rgba(26,77,124,.18); border-top-color: var(--reader-pink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
noscript { position: fixed; inset: 20px 20px auto; z-index: 300; padding: 14px; background: #fff; color: #8d2929; text-align: center; }

@media (max-width: 768px) {
    #book-stage { inset: 0 0 calc(58px + env(safe-area-inset-bottom)) 0; padding: 8px 0; }
    .reader-ui-layer { height: calc(100dvh - 58px); }
    .reader-bottom-bar { height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
    .reader-midbar { padding-inline: 8px; }
    .reader-nav-btn { width: 44px; height: 44px; flex: 0 0 44px; }
    .reader-toolbar { max-width: calc(100vw - 20px); padding: 5px 8px; gap: 5px; }
    .reader-toolbar-btn { width: 44px; height: 44px; flex: 0 0 44px; }
    .reader-toolbar-btn svg { width: 18px; height: 18px; }
    .reader-page-info { min-width: 68px; font-size: .72rem; }
    .reader-progress-track { width: min(24vw, 110px); }
    .reader-jump-input { width: 38px; min-height: 30px; font-size: .75rem; }
}
@media (max-width: 600px) {
    #book-container.front-cover-only,
    #book-container.back-cover-only { transform-origin: center center; }
}
@media (max-width: 520px) {
    .reader-progress-track, .responsive-divider { display: none; }
    .reader-toolbar { justify-content: center; }
    .reader-nav-btn { width: 40px; height: 40px; flex-basis: 40px; }
}
@media (max-width: 380px) {
    .reader-toolbar-divider { display: none; }
    .reader-page-info { min-width: 60px; }
    .reader-jump-input { width: 34px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
    .reader-ui-layer, .loading-card { display: none !important; }
    body, #book-stage { overflow: visible; background: #fff; }
}