/* =========================================================
   PROGREEK — ЗАЩИЩЁННАЯ ЧИТАЛКА
   ========================================================= */

.reader-page {
    min-height: 100vh;
    margin: 0;

    background:
        radial-gradient(
            circle at top right,
            rgba(205, 166, 91, 0.12),
            transparent 32%
        ),
        #f5f3ee;

    color: #173f3a;
}


/* =========================================================
   ОСНОВНАЯ ОБЛАСТЬ
   ========================================================= */

.book-reader {
    width: min(100% - 32px, 1180px);
    margin: 0 auto;
    padding: 42px 0 70px;
    box-sizing: border-box;
}


/* =========================================================
   ЗАГОЛОВОК
   ========================================================= */

.reader-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;

    margin-bottom: 28px;
}

.reader-label {
    display: block;

    margin-bottom: 8px;

    color: #b58a3b;

    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.reader-heading h1 {
    margin: 0;

    color: #123f39;

    font-size: clamp(27px, 4vw, 44px);
    line-height: 1.1;
}

.reader-account-link {
    flex-shrink: 0;

    padding: 11px 18px;

    border: 1px solid rgba(18, 63, 57, 0.16);
    border-radius: 999px;

    background: rgba(255, 255, 255, 0.72);
    color: #123f39;

    font-size: 14px;
    font-weight: 800;
    text-decoration: none;

    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.reader-account-link:hover {
    background: #ffffff;
    transform: translateY(-1px);
}


/* =========================================================
   ЗАГРУЗКА
   ========================================================= */

.reader-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    min-height: 420px;
    padding: 40px;

    box-sizing: border-box;

    border: 1px solid rgba(18, 63, 57, 0.10);
    border-radius: 28px;

    background: #ffffff;

    text-align: center;

    box-shadow:
        0 20px 55px rgba(22, 55, 48, 0.08);
}

.reader-status strong {
    margin-top: 20px;

    color: #123f39;

    font-size: 22px;
}

.reader-status span {
    margin-top: 8px;

    color: #71807d;

    font-size: 15px;
}

.reader-loader {
    width: 48px;
    height: 48px;

    border: 5px solid #e6efec;
    border-top-color: #146b5b;
    border-radius: 50%;

    animation:
        reader-loading 0.8s linear infinite;
}

@keyframes reader-loading {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   ОШИБКА
   ========================================================= */

.reader-error {
    max-width: 680px;
    margin: 50px auto;
    padding: 46px 32px;

    box-sizing: border-box;

    border: 1px solid rgba(180, 66, 66, 0.16);
    border-radius: 26px;

    background: #ffffff;

    text-align: center;

    box-shadow:
        0 20px 55px rgba(22, 55, 48, 0.08);
}

.reader-error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 54px;
    height: 54px;

    border-radius: 50%;

    background: #fff0ee;
    color: #b44242;

    font-size: 28px;
    font-weight: 900;
}

.reader-error h2 {
    margin: 20px 0 10px;

    color: #123f39;

    font-size: 30px;
}

.reader-error p {
    max-width: 520px;
    margin: 0 auto;

    color: #687975;

    font-size: 16px;
    line-height: 1.6;
}

.reader-error-button {
    display: inline-flex;

    margin-top: 24px;
    padding: 13px 22px;

    border-radius: 999px;

    background: #123f39;
    color: #ffffff;

    font-weight: 800;
    text-decoration: none;
}

.reader-error-button:hover {
    background: #0f5047;
}


/* =========================================================
   РАБОЧАЯ ОБЛАСТЬ
   ========================================================= */

.reader-workspace {
    position: relative;

    border: 1px solid rgba(18, 63, 57, 0.10);
    border-radius: 26px;

    background: #e9ece9;

    overflow: hidden;

    box-shadow:
        0 22px 60px rgba(22, 55, 48, 0.12);
}


/* =========================================================
   ПАНЕЛЬ УПРАВЛЕНИЯ
   ========================================================= */

.reader-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    min-height: 72px;
    padding: 12px 18px;

    box-sizing: border-box;

    border-bottom: 1px solid rgba(18, 63, 57, 0.10);

    background:
        rgba(255, 255, 255, 0.94);

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.reader-control-button,
.reader-zoom-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;
    padding: 0;

    border: 1px solid rgba(18, 63, 57, 0.14);
    border-radius: 12px;

    background: #ffffff;
    color: #123f39;

    font-size: 22px;
    font-weight: 800;

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.reader-control-button:hover:not(:disabled),
.reader-zoom-button:hover:not(:disabled) {
    background: #123f39;
    color: #ffffff;

    transform: translateY(-1px);
}

.reader-control-button:disabled,
.reader-zoom-button:disabled,
.reader-navigation-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.reader-page-control {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 0 8px;

    color: #5f716d;

    font-size: 14px;
    font-weight: 700;
}

.reader-page-control input {
    width: 60px;
    height: 40px;
    padding: 0 8px;

    box-sizing: border-box;

    border: 1px solid rgba(18, 63, 57, 0.16);
    border-radius: 10px;

    background: #ffffff;
    color: #123f39;

    font-size: 15px;
    font-weight: 800;
    text-align: center;

    outline: none;
}

.reader-page-control input:focus {
    border-color: #197864;

    box-shadow:
        0 0 0 3px rgba(25, 120, 100, 0.10);
}

.reader-toolbar-divider {
    width: 1px;
    height: 30px;
    margin: 0 5px;

    background: rgba(18, 63, 57, 0.12);
}

.reader-zoom-value {
    min-width: 48px;

    color: #52645f;

    font-size: 13px;
    font-weight: 800;
    text-align: center;
}


/* =========================================================
   СТРАНИЦА КНИГИ
   ========================================================= */

.reader-canvas-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;

    min-height: 600px;
    padding: 28px 16px;

    box-sizing: border-box;

    overflow: auto;

    background:
        linear-gradient(
            135deg,
            #e4e8e5,
            #f0f1ee
        );
}

#readerCanvas {
    display: block;
    flex-shrink: 0;

    max-width: none;

    background: #ffffff;

    border-radius: 3px;

    box-shadow:
        0 12px 38px rgba(20, 40, 36, 0.18);
}


/* =========================================================
   НИЖНЯЯ НАВИГАЦИЯ
   ========================================================= */

.reader-bottom-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    padding: 18px 22px;

    border-top: 1px solid rgba(18, 63, 57, 0.10);

    background: #ffffff;
}

.reader-bottom-navigation > span {
    color: #60716d;

    font-size: 14px;
    font-weight: 800;
    text-align: center;
}

.reader-navigation-button {
    padding: 11px 18px;

    border: 1px solid rgba(18, 63, 57, 0.16);
    border-radius: 999px;

    background: #ffffff;
    color: #123f39;

    font-size: 14px;
    font-weight: 800;

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.reader-navigation-button:hover:not(:disabled) {
    background: #123f39;
    color: #ffffff;
}


/* =========================================================
   ФОКУС КНОПОК
   ========================================================= */

.reader-control-button:focus-visible,
.reader-zoom-button:focus-visible,
.reader-navigation-button:focus-visible,
.reader-account-link:focus-visible,
.reader-error-button:focus-visible {
    outline: 3px solid rgba(25, 120, 100, 0.28);
    outline-offset: 2px;
}


/* =========================================================
   HIDDEN
   ========================================================= */

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


/* =========================================================
   ПЛАНШЕТ
   ========================================================= */

@media (max-width: 760px) {

    .book-reader {
        width: min(100% - 20px, 1180px);
        padding-top: 26px;
    }

    .reader-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }

    .reader-toolbar {
        flex-wrap: wrap;
    }

    .reader-canvas-container {
        min-height: 480px;
        padding: 18px 10px;
    }

}


/* =========================================================
   МОБИЛЬНЫЙ ТЕЛЕФОН
   ========================================================= */

@media (max-width: 520px) {

    .book-reader {
        width: 100%;
        padding: 22px 10px 40px;
    }

    .reader-heading {
        padding: 0 4px;
    }

    .reader-heading h1 {
        font-size: 27px;
    }

    .reader-account-link {
        padding: 9px 14px;

        font-size: 13px;
    }

    .reader-workspace {
        border-radius: 18px;
    }

    .reader-toolbar {
        gap: 7px;
        padding: 10px 8px;
    }

    .reader-control-button,
    .reader-zoom-button {
        width: 38px;
        height: 38px;

        border-radius: 10px;
    }

    .reader-page-control {
        gap: 5px;
        padding: 0 2px;

        font-size: 12px;
    }

    .reader-page-control > span:first-child {
        display: none;
    }

    .reader-page-control input {
        width: 48px;
        height: 38px;
    }

    .reader-toolbar-divider {
        display: none;
    }

    .reader-zoom-value {
        min-width: 42px;

        font-size: 12px;
    }

    .reader-canvas-container {
        min-height: 420px;
        padding: 12px 6px;
    }

    .reader-bottom-navigation {
        gap: 8px;
        padding: 14px 10px;
    }

    .reader-navigation-button {
        padding: 10px 13px;

        font-size: 12px;
    }

    .reader-bottom-navigation > span {
        font-size: 11px;
    }

    .reader-status {
        min-height: 350px;
        padding: 30px 20px;

        border-radius: 20px;
    }

    .reader-error {
        margin: 30px 0;
        padding: 36px 20px;

        border-radius: 20px;
    }

}