/* =========================================================
   BIBLIOTEKA.KG READER PAGE
   Новый интерфейс читалки: 9/3, одна страница за раз
   ========================================================= */

.reader-page {
    position: relative;
    padding: 24px 0 56px;
    color: var(--text);
}

/* =========================================================
   COMMON GLASS BLOCKS
   ========================================================= */

.reader-ad-section,
.reader-book-header,
.reader-workspace,
.reader-sidebar-block,
.reader-final-block {
    position: relative;
    overflow: hidden;
    color: var(--text);
    background: rgba(var(--surface-rgb), var(--glass-alpha));
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow: var(--shadow);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.05);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.05);
}

.reader-book-header::before,
.reader-workspace::before,
.reader-sidebar-block::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(900px 320px at 0% -14%, rgba(103, 232, 249, .17), transparent 62%),
        radial-gradient(700px 280px at 110% 110%, rgba(var(--tint-rgb), .18), transparent 62%);
    pointer-events: none;
}

.reader-book-header-inner,
.reader-toolbar-main,
.reader-progress-wrap,
.reader-canvas,
.reader-bottom-nav,
.reader-sidebar-block > * {
    position: relative;
    z-index: 2;
}

/* =========================================================
   ADS
   ========================================================= */

.reader-ad-section {
    padding: 10px;
}

.reader-ad-item a,
.reader-side-ad-item a {
    display: block;
    text-decoration: none;
}

.reader-ad-item img,
.reader-side-ad-item img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* =========================================================
   KICKER / BUTTONS
   ========================================================= */

.reader-kicker {
    display: inline-flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 7px 12px;
    color: var(--bg);
    background: var(--accent);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.reader-primary-btn,
.reader-outline-btn,
.reader-tool-btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 850;
    text-decoration: none;
    transition:
        color .18s ease,
        background-color .18s ease,
        border-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.reader-primary-btn {
    color: var(--bg) !important;
    background: var(--accent);
    border: 1px solid var(--accent);
    box-shadow: 0 10px 24px rgba(103, 232, 249, .22);
}

.reader-primary-btn:hover,
.reader-primary-btn:focus {
    color: var(--accent) !important;
    background: var(--bg);
    border-color: var(--accent);
    box-shadow: 0 0 22px rgba(103, 232, 249, .42);
    transform: translateY(-1px);
}

.reader-outline-btn,
.reader-tool-btn {
    color: var(--text) !important;
    background: rgba(var(--surface-rgb), .62);
    border: 1px solid var(--border);
}

.reader-outline-btn:hover,
.reader-outline-btn:focus,
.reader-tool-btn:hover,
.reader-tool-btn:focus {
    color: var(--bg) !important;
    background: var(--text);
    border-color: var(--text);
    transform: translateY(-1px);
}

/* =========================================================
   HEADER
   ========================================================= */

.reader-book-header {
    min-height: 170px;
}

.reader-book-header-inner {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    gap: 22px;
    align-items: center;
    padding: 26px;
}

.reader-book-cover-small {
    width: 92px;
    height: 124px;
    background: rgba(var(--surface-rgb), .58);
    border: 1px solid var(--border);
    overflow: hidden;
}

.reader-book-cover-small img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.reader-book-title-block {
    min-width: 0;
}

.reader-book-title-block h1 {
    max-width: 980px;
    margin: 0 0 12px;
    color: var(--text);
    font-size: clamp(28px, 3.5vw, 48px);
    font-weight: 950;
    line-height: 1.05;
    letter-spacing: -.03em;
}

.reader-book-meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.reader-book-meta-line span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    color: var(--text);
    background: rgba(var(--surface-rgb), .6);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 800;
}

.reader-book-meta-line i {
    color: var(--accent);
}

.reader-book-header-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    min-width: 170px;
}

/* =========================================================
   WORKSPACE
   ========================================================= */

.reader-workspace {
    min-height: 780px;
    display: flex;
    flex-direction: column;
}

/* =========================================================
   TOOLBAR
   ========================================================= */

.reader-toolbar-main {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(var(--surface-rgb), .7);
}

.reader-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reader-toolbar-group:last-child {
    justify-content: flex-end;
}

.reader-toolbar-center {
    justify-content: center;
}

.reader-tool-btn {
    min-width: 42px;
    width: 42px;
    height: 42px;
    padding: 0;
}

.reader-page-indicator {
    min-width: 94px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--bg);
    background: var(--accent);
    border: 1px solid var(--accent);
    font-size: 15px;
    font-weight: 950;
    font-variant-numeric: tabular-nums;
}

.reader-zoom-value {
    min-width: 68px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    background: rgba(var(--surface-rgb), .62);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

/* =========================================================
   PROGRESS
   ========================================================= */

.reader-progress-wrap {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(var(--surface-rgb), .44);
}

.reader-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.reader-progress-info strong {
    color: var(--accent);
    font-weight: 950;
}

.reader-progress-track {
    width: 100%;
    height: 8px;
    overflow: hidden;
    background: rgba(var(--surface-rgb), .72);
    border: 1px solid var(--border);
}

.reader-progress-fill {
    width: 0;
    height: 100%;
    background: var(--accent);
    box-shadow: 0 0 18px rgba(103, 232, 249, .5);
    transition: width .25s ease;
}

/* =========================================================
   CANVAS
   ========================================================= */

.reader-canvas {
    flex: 1 1 auto;
    min-height: 640px;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 28px;
    background:
        linear-gradient(180deg, rgba(var(--surface-rgb), .34), rgba(var(--surface-rgb), .18)),
        radial-gradient(900px 420px at 50% 0%, rgba(103, 232, 249, .11), transparent 65%);
}

.reader-pages {
    width: 100%;
    min-height: 580px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reader-page-frame {
    --reader-zoom: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .04)),
        #111827;
    border: 1px solid rgba(255, 255, 255, .22);
    box-shadow:
        0 22px 55px rgba(0, 0, 0, .28),
        0 0 0 10px rgba(var(--surface-rgb), .34);
    overflow: auto;
}

.reader-page-frame::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .05), transparent 18%, transparent 82%, rgba(0, 0, 0, .14)),
        radial-gradient(600px 260px at 50% 0%, rgba(255, 255, 255, .14), transparent 60%);
    pointer-events: none;
    z-index: 1;
}

.reader-fit-width {
    width: min(100%, 980px);
    min-height: 640px;
}

.reader-fit-page {
    width: auto;
    height: min(72vh, 820px);
    max-width: 100%;
    min-height: 0;
}

.reader-page-img {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    transform: scale(var(--reader-zoom));
    transform-origin: center center;
    transition: transform .18s ease;
    background: #fff;
}

.reader-fit-page .reader-page-img {
    width: auto;
    height: 100%;
    object-fit: contain;
}

.reader-fit-width .reader-page-img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* =========================================================
   LOADING / ERROR
   ========================================================= */

.reader-loading,
.reader-error {
    max-width: 520px;
    width: 100%;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 30px;
    color: var(--text);
    background: rgba(var(--surface-rgb), .7);
    border: 1px solid var(--border);
    text-align: center;
}

.reader-loading-icon,
.reader-error-icon {
    width: 74px;
    height: 74px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--bg);
    background: var(--accent);
    font-size: 30px;
    box-shadow: 0 18px 34px rgba(103, 232, 249, .22);
}

.reader-error-icon {
    background: #ef4444;
    box-shadow: 0 18px 34px rgba(239, 68, 68, .22);
}

.reader-loading div:last-child {
    color: var(--muted);
    font-size: 15px;
    font-weight: 850;
}

.reader-error h3 {
    margin: 0;
    color: var(--text);
    font-size: 24px;
    font-weight: 950;
}

.reader-error p {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.65;
}

/* =========================================================
   BOTTOM NAV
   ========================================================= */

.reader-bottom-nav {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr) 170px;
    gap: 14px;
    align-items: end;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: rgba(var(--surface-rgb), .7);
}

.reader-jump-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    max-width: 360px;
    justify-self: center;
    width: 100%;
}

.reader-jump-form label {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
    text-align: center;
}

.reader-jump-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 8px;
}

.reader-jump-row .form-control {
    min-height: 44px;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    font-weight: 850;
    text-align: center;
    box-shadow: none;
}

.reader-jump-row .form-control:focus {
    color: var(--text);
    background: var(--input-bg);
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(103, 232, 249, .15);
}

/* =========================================================
   SIDEBAR
   ========================================================= */

.reader-sidebar {
    position: sticky;
    top: 96px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.reader-sidebar-block {
    padding: 22px;
}

.reader-sidebar-ad {
    padding: 10px;
}

.reader-sidebar-block h3 {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 23px;
    font-weight: 950;
    line-height: 1.12;
}

.reader-sidebar-block p {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.65;
}

.reader-access-card {
    background:
        linear-gradient(180deg, rgba(103, 232, 249, .14), rgba(var(--surface-rgb), .72)),
        rgba(var(--surface-rgb), var(--glass-alpha));
}

.reader-access-status {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 14px 0 16px;
    padding: 11px 12px;
    color: var(--text);
    background: rgba(var(--surface-rgb), .62);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 850;
}

.reader-access-status i {
    color: var(--accent);
}

.reader-book-info-list {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.reader-book-info-list li {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
    color: var(--text);
    background: rgba(var(--surface-rgb), .58);
    border: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.35;
}

.reader-book-info-list strong {
    color: var(--accent);
    font-weight: 900;
}

.reader-book-info-list span {
    color: var(--text);
    font-weight: 750;
}

.reader-sidebar-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 850;
    text-decoration: none;
}

.reader-sidebar-link:hover,
.reader-sidebar-link:focus {
    color: var(--text);
}

/* =========================================================
   POPULAR BOOKS
   ========================================================= */

.reader-popular-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.reader-popular-item {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    color: var(--text);
    text-decoration: none;
}

.reader-popular-item:hover span,
.reader-popular-item:focus span {
    color: var(--accent);
}

.reader-popular-item img {
    width: 52px;
    height: 72px;
    object-fit: contain;
    background: rgba(var(--surface-rgb), .58);
    border: 1px solid var(--border);
}

.reader-popular-item span {
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.3;
}

/* =========================================================
   FULLSCREEN
   ========================================================= */

.reader-workspace:fullscreen {
    width: 100vw;
    height: 100vh;
    overflow: auto;
    background: var(--bg);
}

.reader-workspace:fullscreen .reader-canvas {
    min-height: calc(100vh - 170px);
}

.reader-workspace:fullscreen .reader-fit-page {
    height: calc(100vh - 220px);
}

/* =========================================================
   OWL FIXES
   ========================================================= */

.reader-page .owl-carousel .owl-nav button.owl-prev,
.reader-page .owl-carousel .owl-nav button.owl-next {
    color: var(--bg);
    background: var(--accent);
    border: 1px solid var(--accent);
    min-width: 34px;
    min-height: 34px;
}

.reader-page .owl-carousel .owl-dots .owl-dot span {
    background: var(--muted);
}

.reader-page .owl-carousel .owl-dots .owl-dot.active span,
.reader-page .owl-carousel .owl-dots .owl-dot:hover span {
    background: var(--accent);
}

/* =========================================================
   DARK MODE TUNING
   ========================================================= */

html.theme-dark .reader-page-frame,
body.theme-dark .reader-page-frame {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .03)),
        #020617;
    box-shadow:
        0 24px 62px rgba(0, 0, 0, .55),
        0 0 0 10px rgba(255, 255, 255, .04);
}

html.theme-dark .reader-canvas,
body.theme-dark .reader-canvas {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .015)),
        radial-gradient(900px 420px at 50% 0%, rgba(103, 232, 249, .13), transparent 65%);
}

/* =========================================================
   NO RADIUS
   ========================================================= */

.reader-ad-section,
.reader-book-header,
.reader-workspace,
.reader-sidebar-block,
.reader-kicker,
.reader-primary-btn,
.reader-outline-btn,
.reader-tool-btn,
.reader-book-cover-small,
.reader-book-cover-small img,
.reader-book-meta-line span,
.reader-page-indicator,
.reader-zoom-value,
.reader-progress-track,
.reader-page-frame,
.reader-page-img,
.reader-loading,
.reader-error,
.reader-loading-icon,
.reader-error-icon,
.reader-jump-row .form-control,
.reader-access-status,
.reader-book-info-list li,
.reader-popular-item img,
.reader-page .owl-carousel .owl-nav button.owl-prev,
.reader-page .owl-carousel .owl-nav button.owl-next {
    border-radius: 0 !important;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1199.98px) {
    .reader-toolbar-main {
        grid-template-columns: 1fr;
    }

    .reader-toolbar-group,
    .reader-toolbar-group:last-child,
    .reader-toolbar-center {
        justify-content: center;
        flex-wrap: wrap;
    }

    .reader-sidebar {
        position: static;
        top: auto;
    }

    .reader-fit-page {
        height: min(68vh, 760px);
    }
}

@media (max-width: 991.98px) {
    .reader-page {
        padding-top: 20px;
    }

    .reader-book-header-inner {
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .reader-book-header-actions {
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .reader-sidebar-block.reader-sidebar-ad {
        max-width: 420px;
        margin-left: auto;
        margin-right: auto;
    }

    .reader-workspace {
        min-height: auto;
    }

    .reader-canvas {
        min-height: 560px;
    }

    .reader-pages {
        min-height: 500px;
    }

    .reader-fit-width {
        min-height: 560px;
    }
}

@media (max-width: 767.98px) {
    .reader-bottom-nav {
        grid-template-columns: 1fr;
    }

    .reader-bottom-nav .btn {
        width: 100%;
    }

    .reader-jump-form {
        max-width: none;
        order: -1;
    }

    .reader-canvas {
        padding: 18px;
        min-height: 500px;
    }

    .reader-pages {
        min-height: 450px;
    }

    .reader-fit-width {
        min-height: 500px;
    }

    .reader-fit-page {
        height: min(64vh, 640px);
    }
}

@media (max-width: 575.98px) {
    .reader-book-header-inner {
        grid-template-columns: 1fr;
        padding: 22px 18px;
    }

    .reader-book-cover-small {
        width: 108px;
        height: 146px;
    }

    .reader-book-header-actions {
        grid-template-columns: 1fr;
    }

    .reader-book-title-block h1 {
        font-size: 28px;
    }

    .reader-toolbar-main,
    .reader-progress-wrap,
    .reader-bottom-nav {
        padding-left: 12px;
        padding-right: 12px;
    }

    .reader-tool-btn {
        min-width: 40px;
        width: 40px;
        height: 40px;
    }

    .reader-page-indicator,
    .reader-zoom-value {
        height: 40px;
    }

    .reader-canvas {
        padding: 12px;
        min-height: 460px;
    }

    .reader-pages {
        min-height: 420px;
    }

    .reader-fit-width {
        min-height: 460px;
    }

    .reader-jump-row {
        grid-template-columns: 1fr;
    }

    .reader-sidebar-block {
        padding: 20px;
    }
}