/*
 * Офлайн-полка Erolate: общие элементы, которые видны и на страницах сайта
 * (кнопки «Сохранить на устройство», окна, всплывающие сообщения, чтение вслух,
 * строка «Нет сети»). Все классы начинаются с .ofl-, чтобы не задеть дизайн сайта.
 */
.ofl-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 38px; padding: 6px 14px; border: 1px solid rgba(0, 0, 0, .18); border-radius: 19px;
    background: transparent; color: inherit; font: inherit; font-size: 14px; line-height: 1.3;
    text-decoration: none; cursor: pointer; box-sizing: border-box;
}
.ofl-btn:hover, .ofl-btn:focus-visible { border-color: rgba(0, 0, 0, .45); text-decoration: none; }
.ofl-btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.ofl-btn[disabled], .ofl-btn.disabled { opacity: .5; pointer-events: none; }
.ofl-btn[hidden], .ofl-save [hidden], .ofl-site-bar [hidden] { display: none !important; }
.ofl-btn-main { background: #c2185b; border-color: #c2185b; color: #fff !important; }
.ofl-btn-main:hover { background: #a3134c; border-color: #a3134c; }
.ofl-btn-danger { color: #b42318; border-color: rgba(180, 35, 24, .35); }
.ofl-btn-icon { min-width: 38px; padding: 0; font-size: 20px; }
.ofl-btn.active { background: rgba(194, 24, 91, .12); border-color: #c2185b; }
.ofl-muted { color: #6b7280; font-size: 13px; }

/* Блок сохранения в читалке и на странице книги */
.ofl-save { margin: 12px 0; padding: 12px; border: 1px dashed rgba(0, 0, 0, .2); border-radius: 10px; }
.ofl-save-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ofl-save-status { margin-top: 8px; font-size: 13px; }
.ofl-save-title { display: block; margin-bottom: 6px; font-weight: 600; }
.ofl-promo { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 18px auto; font-size: 14px; }
.ofl-promo button.ofl-link { background: none; border: 0; color: #c2185b; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* Окно поверх страницы */
.ofl-sheet-overlay { position: fixed; inset: 0; z-index: 100000; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.ofl-sheet {
    width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; box-sizing: border-box;
    background: #fff; color: #1f2937; border-radius: 16px 16px 0 0; padding: 14px 16px 18px;
    box-shadow: 0 -6px 30px rgba(0, 0, 0, .2); font-size: 15px; line-height: 1.45;
}
@media (min-width: 700px) { .ofl-sheet-overlay { align-items: center; } .ofl-sheet { border-radius: 16px; } }
.ofl-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ofl-sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.ofl-sheet label { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-weight: normal; }
.ofl-sheet input[type="number"] { width: 80px; }
.ofl-sheet .ofl-input { width: 100%; box-sizing: border-box; min-height: 38px; padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; }

/* Всплывающее сообщение */
.ofl-toast {
    position: fixed; left: 50%; bottom: 84px; z-index: 100001; transform: translate(-50%, 20px);
    max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 12px; background: #111827; color: #fff;
    font-size: 14px; line-height: 1.4; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.ofl-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Строка «Нет сети» на страницах сайта */
.ofl-netbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 99999; padding: 8px 12px; text-align: center;
    background: #111827; color: #fff; font-size: 14px;
}
.ofl-netbar a { color: #fbcfe8; text-decoration: underline; }

/* Чтение вслух */
.ofl-tts-bar {
    position: fixed; left: 50%; bottom: 70px; z-index: 100000; transform: translateX(-50%);
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
    width: max-content; max-width: 96vw; padding: 8px 12px; border-radius: 16px;
    background: #1f2937; color: #fff; font-size: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}
.ofl-tts-label { max-width: 60vw; }
.ofl-tts-btn, .ofl-tts-select {
    min-height: 34px; padding: 4px 10px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 17px;
    background: transparent; color: #fff; font: inherit; cursor: pointer;
}
.ofl-tts-select option { color: #111827; }
.ofl-speaking { background: rgba(250, 204, 21, .28); border-radius: 4px; }

/* Плавающая панель читалки: иконка + короткая подпись, полупрозрачный фон */
.ofl-bar-btn {
    flex: 1; min-width: 0; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 48px; padding: 4px 2px; border: 0; border-radius: 14px; background: transparent; color: inherit;
    font: inherit; font-size: 11px; line-height: 1.2; letter-spacing: .01em; cursor: pointer; opacity: .78;
    -webkit-tap-highlight-color: transparent; transition: opacity .15s, background-color .15s;
}
.ofl-bar-btn:hover, .ofl-bar-btn:focus-visible { opacity: 1; }
.ofl-bar-btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: -2px; }
.ofl-bar-btn:active { background: rgba(127, 127, 127, .14); }
.ofl-bar-btn.active { opacity: 1; color: #c2185b; }
.ofl-bar-btn[hidden] { display: none !important; }
.ofl-ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ofl-ico-text { display: inline-flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; letter-spacing: -.02em; stroke: none; }

/* Полоска прогресса: видна, только пока меню спрятано */
.ofl-progress {
    position: fixed; left: 0; right: 0; top: 0; z-index: 9991; height: 2px; background: #c2185b; opacity: 0;
    transform: scaleX(0); transform-origin: 0 50%; pointer-events: none; transition: opacity .25s;
}
body.ofl-chrome-hidden .ofl-progress { opacity: .55; }

/* Нижняя панель новой читалки сайта (только на узких экранах) */
.ofl-site-bar { display: none; }
@media (max-width: 768px) {
    .ofl-site-bar {
        position: fixed; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 9990;
        display: flex; gap: 2px; width: calc(100% - 20px); max-width: 440px; padding: 4px; box-sizing: border-box;
        transform: translateX(-50%); border-radius: 20px; background: rgba(255, 255, 255, .86); color: #1f2937;
        -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
        box-shadow: 0 6px 24px rgba(0, 0, 0, .12), 0 0 0 1px rgba(0, 0, 0, .05);
        transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s;
    }
    body.ofl-chrome-hidden .ofl-site-bar { transform: translate(-50%, calc(100% + 24px)); opacity: 0; pointer-events: none; }
    body.ofl-chrome-hidden .reader-header { display: none !important; }
    #reader .reader-content { padding-bottom: 84px; }
    .ofl-tts-bar { bottom: calc(76px + env(safe-area-inset-bottom)); }
    body.ofl-chrome-hidden .ofl-tts-bar { bottom: calc(16px + env(safe-area-inset-bottom)); }
    body.dark-theme .ofl-site-bar, body.brightness-1 .ofl-site-bar, body.brightness-2 .ofl-site-bar {
        background: rgba(28, 28, 32, .82); color: #e5e7eb; box-shadow: 0 6px 24px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .07);
    }
    body.dark-theme .ofl-bar-btn.active, body.brightness-1 .ofl-bar-btn.active, body.brightness-2 .ofl-bar-btn.active { color: #f48fb1; }
}
body.dark-theme .ofl-btn, body.brightness-1 .ofl-btn, body.brightness-2 .ofl-btn { border-color: rgba(255, 255, 255, .3); }
body.dark-theme .ofl-save, body.brightness-1 .ofl-save, body.brightness-2 .ofl-save { border-color: rgba(255, 255, 255, .25); }

@media (prefers-reduced-motion: reduce) { .ofl-toast, .ofl-site-bar, .ofl-progress, .ofl-bar-btn { transition: none; } }
