/* --- 1. БАЗОВЫЕ ПЕРЕМЕННЫЕ И ОБЩИЕ СТИЛИ --- */
:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --header-bg: rgba(18, 18, 18, 0.85);
    --accent-color: #ffffff;
    --secondary-text: #8E8E93;
    --border-color: rgba(255, 255, 255, 0.1);
    --sheet-bg: #1c1c1e;
}

* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none; /* Отключает контекстное меню при долгом нажатии на iOS */
}

body {
    margin: 0; padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Raleway', sans-serif;
    -webkit-overflow-scrolling: touch;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Убирает системную подсветку при нажатии */
.book-card, button, a, .genre-chip, .mini-play-btn, #player-header, #player-progress-bg, #reader-minimized-bar {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    outline: none;
}

.book-card, 
.audio-list-item, 
.cover-wrapper, 
.category-section,
.book-row {-webkit-transform: translateZ(0);transform: translateZ(0);-webkit-backface-visibility: hidden;backface-visibility: hidden;will-change: transform;}
.book-row, .container {contain: layout paint;-webkit-transform: translateZ(0);}

featured-authors-section {margin-top:12px;}
.author-feature-block {background: #18181a;margin: 0 15px;border-radius: 18px;position: relative;overflow: visible;}
.author-feature-block .book-row {margin-right: -15px;/*margin-left:-15px; padding-left:30px;*/ padding-right: 30px;}
.author-feature-header {display:flex;align-items:flex-start;gap:10px;margin:0px 15px 8px 15px;padding-top:15px;}
.author-feature-header img{border-radius:50%; width:50px; height:50px; object-fit:cover; box-shadow:0 1px 7px #0002;}
.author-feature-name {font-size:16px; font-weight:700; margin-bottom:2px;}
.author-feature-desc {font-size:12px; color:var(--secondary-text);}

/* --- 2. HEADER --- */
header {
    height: 56px;
    background-color: var(--header-bg);
    /*background: rgba(18, 18, 18, 0.95);*/
    background: #1c1c1e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 0.5px solid var(--border-color);
}

header, .genres-filter {-webkit-transform: translate3d(0,0,0); transform: translate3d(0,0,0);outline: 1px solid transparent;}

.header-left { display: flex; align-items: center; gap: 16px; }
.logo { font-size: 17px; font-weight: 700; letter-spacing: 1.2px; text-decoration: none; color: var(--text-color); text-transform: uppercase; }
.header-right { display: flex; align-items: center; gap: 20px; }

#header-user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

.icon-svg {
    width: 24px; height: 24px;
    fill: none; stroke: var(--accent-color); stroke-width: 1.3px;
    stroke-linecap: round; stroke-linejoin: round;
    cursor: pointer; transition: opacity 0.2s;
}

.user-pill {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 12px; background: rgba(255,255,255,0.08);
    border: 0.5px solid var(--border-color);
    border-radius: 20px; font-size: 13px; font-weight: 500;
}

/* Отключаем стандартный эффект выделения при тапе на мобильных устройствах */
.icon-svg, #auth-header-zone, #search-btn, .header-left svg, .mini-play-btn, .sidebar-link, .lang-switch, .book-toggle {-webkit-tap-highlight-color: transparent;-webkit-touch-callout: none;user-select: none;outline: none;}
.icon-svg:active, #auth-header-zone:active {opacity: 0.6;transition: opacity 0.1s ease;}

/*Выдвижная панель*/
#user-fullname {font-size: 18px; font-weight: 700; margin-top: 5px;}


/* --- 3. ПОИСК И ФИЛЬТРЫ --- */
.search-container {
    max-height: 0; opacity: 0; overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0 20px; transform: translateY(-10px);
}
.search-container.show {
    max-height: 80px; opacity: 1; padding: 15px 20px; transform: translateY(0);
}

#clear-search {
    /* Убирает синюю подсветку на мобильных устройствах (iOS/Android) */
    -webkit-tap-highlight-color: transparent;
    
    /* Убирает контур (outline), который появляется при фокусе в некоторых браузерах */
    outline: none;
    
    /* Убирает стандартный эффект системного "акцента" */
    user-select: none;
    
    /* Делаем клик визуально чистым (опционально можно добавить свой легкий эффект) */
    cursor: pointer;
}

/* Если крестик — это button, убираем дефолтные стили */
#clear-search:focus, #clear-search:active {
    outline: none;
    background: none;
}

.genres-filter {
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0; 
    position: sticky;
    top: 56px;
    background: var(--bg-color);
    z-index: 999;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin: 0;
    /* Добавляем это: гарантирует, что даже пустой блок 
       будет визуально начинаться с нужной точки */
    contain: layout; 
}

/* Скроллируемая часть с жанрами */
.filter-scrollable-part {
    padding: 5px 0;
}

.filter-scrollable-part::-webkit-scrollbar { 
    display: none; /* Скрываем скроллбар в Chrome/Safari */
}

.genre-chip {
    flex-shrink: 0;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    margin: 0; 
    /* ВОТ ЭТА СТРОКА ВЕРНЕТ ОБВОДКУ: */
    border: 0.5px solid var(--border-color); 
    background: rgba(255, 255, 255, 0.08); /* Чуть заметный фон */
    color: var(--secondary-text);
    transition: all 0.2s ease;
    cursor:pointer;
}

#genres-filter:empty {
    height: 64px;
    background: var(--bg-color);
}

#genres-filter:empty::before {
    content: "";
    display: block;
    width: 20px; /* Тот самый отступ слева */
    height: 100%;
}

/* Состояния активных кнопок */
.genre-chip.active { 
    background: white !important; 
    color: black !important; 
    font-weight: 600; 
}

/* Оранжевая подсветка для Аудио, когда активно */
#audio-filter-chip {
    border-color: rgba(255, 149, 0, 0.5); /* Полупрозрачный оранжевый */
    color: #ff9500;
}

/* Яркий оранжевый, когда кнопка нажата */
#audio-filter-chip.active {
    background: #ff9500 !important;
    color: white !important;
    border-color: #ff9500 !important;
}
/* --- 4. BOOKS GRID & CARDS --- */
/* В твоем style.css или в теге <style> на странице */
#main-content {
    opacity: 0; /* Скрываем контент до вызова stopSkeleton */
    transition: opacity 0.5s ease;
}

#library {}
.container { padding: 10px 0 80px 0; }
.section-title { padding: 0 15px; margin: 25px 0 12px 0; font-size: 20px; font-weight: 700; width: 100vw; /* Четко по ширине вьюпорта */
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;}
.shelf-grid {
    padding-bottom: 100px; /* Чтобы нижние книги не перекрывались навигацией телефона */
}
.shelf-grid .book-card {
    width: 100% !important; /* Чтобы карточка занимала всю ширину ячейки грида */
}
.show-all-btn {color: #ff9500;font-size: 14px;font-weight: 600;cursor: pointer; padding: 0 15px;}
.book-row { display: flex; overflow-x: auto; gap: 16px; padding: 10px 15px 25px; scrollbar-width: none; }
.book-row::-webkit-scrollbar { display: none; }

.book-card { flex: 0 0 130px; cursor: pointer; transition: transform 0.2s; }
.book-card:active { transform: scale(0.95); }

.cover-wrapper { 
    position: relative; width: 130px; height: 195px; 
    background: #1c1c1e; border-radius: 8px; overflow: hidden; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); 
    -webkit-user-drag: none;
}
.cover-wrapper img { width: 100%; height: 100%; object-fit: cover; decoding: async;}

.book-title { font-size: 14px; font-weight: 600; margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-author { color: var(--secondary-text); font-size: 12px; margin-top: 4px; }


.playlist-container .read-btn {margin-top:0px;}
.audio-cover {width: 40px;height: 60px;border-radius: 10px;object-fit: cover;box-shadow: 0 4px 8px rgba(0,0,0,0.3);cursor: pointer;}
.audio-info {flex: 1; min-width: 0; cursor: pointer;-webkit-tap-highlight-color: transparent;-webkit-user-select: none;user-select: none;outline: none;}
.audio-list-item {display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.03); padding: 12px; border-radius: 16px; margin:0 15px 12px; border: 1px solid rgba(255,255,255,0.05);}
.audio-title {font-weight: 600; color: #fff; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;}
.audio-author {font-size: 13px; color: #8E8E93;}
.audio-play-btn {width: 44px; height: 44px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; box-shadow: 0 4px 12px rgba(255,255,255,0.1);-webkit-tap-highlight-color: transparent;outline: none;user-select: none;-webkit-touch-callout: none;}
.sheet-genres {font-size: 13px; color: #10b981; margin-top: 5px; line-height: 1.3; font-weight: 500;}
/*.sheet-desc {margin-top:20px; color: #EBEBF5; line-height: 1.6; font-size: 15px;}*/
.sheet-desc {white-space: pre-line;font-size: 15px; line-height: 1.6; color: #ccc; margin-top: 25px; /*border-top: 0.5px solid var(--border-color); padding-top: 20px;*/ }
.sheet-another {margin: 15px 0 20px; /*padding: 12px; background: rgba(255,255,255,0.03); border-radius: 10px; */font-size: 13px; color: #8E8E93; /*border: 1px solid rgba(255,255,255,0.05);*/}
.filter-fixed-part {
    display: flex;
    align-items: center;
    gap: 12px;
    /* Увеличиваем зону, чтобы она резервировала место */
    padding-left: 15px; 
    padding-right: 15px;
    border-right: 1px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
    height: 32px;
}
.filter-scrollable-part {
    display: flex;
    align-items: center;
    gap: 10px;          /* Расстояние между чипсами жанров */
    padding: 0 15px;    /* Внутренние отступы при прокрутке */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
}

/* Бейджи на обложках */
.book-badge {
    position: absolute; padding: 2px 6px; border-radius: 4px;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    z-index: 10; background: rgba(0, 0, 0, 0.85);
}
.badge-age { top: 8px; right: 8px; background: rgba(255, 69, 58, 0.9); color: white; }
.badge-lang { bottom: 8px; left: 8px; background: rgba(0, 0, 0, 0.6); border: 0.5px solid rgba(255, 255, 255, 0.3); color: white; }
.badge-lang.kg-green { background: #10b981; border-color: rgba(255, 255, 255, 0.4); }
.badge-audio {
    position: absolute; bottom: 8px; right: 8px; background: rgba(16, 185, 129, 0.95);
    color: white; width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3); z-index: 10;
}
.badge-audio svg { width: 10px; height: 10px; }
.badge-premium {
    top: 8px;
    left: 8px; /* Слева, чтобы не мешать возрасту (который обычно справа) */
    background: linear-gradient(45deg, #ffd700, #ffa500); /* Золотистый градиент */
    color: #000;
    /*box-shadow: 0 2px 10px rgba(0,0,0,0.5);*/
}

.badge-premium svg {
    width: 10px;
    height: 10px;
}


#shelf-search {flex: 1; height: 40px; padding: 0 15px; border-radius: 10px; border: none; background: #2c2c2e; color: white; box-sizing: border-box;}
/* 1. Стили для инпута поиска, чтобы не вылетал */
.shelf-input-style {
    box-sizing: border-box !important;
}

/* Контейнер списка */
.shelf-list-container {
    display: flex;
    flex-direction: column;
    padding: 0 16px; /* Отступы только по бокам */
    background: #1c1c1e; /* Глубокий темный фон */
}

/* Строка книги в стиле "Modern List" */
.shelf-item-horizontal {
    display: flex;
    align-items: center;
    padding: 12px 0; /* Вертикальные отступы между книгами */
    border-bottom: 0.5px solid #2c2c2e; /* Тонкая линия разделителя */
    cursor: pointer;
    background: transparent !important; /* Убираем серый фон карточки */
}

.shelf-item-horizontal:last-child {
    border-bottom: none; /* У последней книги нет линии */
}

/* Обложка (делаем чуть крупнее и четче) */
.shelf-item-cover-wrapper {
    width: 56px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); /* Легкая тень для объема */
}

/* Текстовый блок */
.shelf-item-details {
    margin-left: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.shelf-item-title {
    font-size: 16px;
    font-weight: 500;
    color: #ffffff;
    line-height: 1.2;
}

.shelf-item-author {
    font-size: 14px;
    color: #8e8e93; /* Текст автора делаем приглушенным */
    margin-top: 4px;
}

/* 6. Стрелочка или иконка перехода */
.shelf-item-arrow {
    color: #444;
    margin-left: 10px;
    display: flex;
    align-items: center;
}

/* 7. Универсальная сетка (для режима Grid) */
.book-grid-universal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    padding: 15px;
}

/* --- 5. BOTTOM SHEET (СТРАНИЦА КНИГИ) --- */
#book-sheet-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    /*background: rgba(0,0,0,0.6); */display: none; z-index: 2100; /*backdrop-filter: blur(8px);*/
    background: rgba(0, 0, 0, 0.75);
    overscroll-behavior-y: contain; 
    touch-action: pan-y; 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#book-sheet.active {
transform: translateY(0) !important;
    display: block !important; /* На всякий случай, если где-то есть display: none */
}

.bottom-sheet {
    position: fixed; left: 0; bottom: 0; width: 100%;
    max-height: 80vh; background: var(--sheet-bg);
    border-radius: 24px 24px 0 0; z-index: 2200;
    transform: translateY(100%); will-change: transform; transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), padding-bottom 0.3s ease;
    overflow-y: auto; padding-bottom: 20px;webkit-overflow-scrolling: touch;
}
.bottom-sheet.active { transform: translateY(0); }

/* Динамические отступы шторки в зависимости от плеера */
/*body.has-player .bottom-sheet { padding-bottom: 20px !important; }*/
body.player-expanded .bottom-sheet { padding-bottom: 283px !important; }

.sheet-drag-handle { width: 36px; height: 5px; background: rgba(255,255,255,0.2); border-radius: 10px; margin: 12px auto; }
.sheet-content { padding: 0 24px; }
.sheet-header { display: flex; gap: 20px; margin-top: 10px; }
.sheet-cover { width: 110px; height: 160px; object-fit: cover; border-radius: 10px; box-shadow: 0 10px 20px rgba(0,0,0,0.5); }
.sheet-title { font-size: 20px; font-weight: 700; margin: 0; line-height: 1.2; }
.sheet-author { color: var(--secondary-text); margin-top: 6px; font-size: 15px; display: block; }
.sheet-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag { background: rgba(255,255,255,0.08); padding: 5px 12px; border-radius: 8px; font-size: 11px; color: #ddd; font-weight: 500; }

.sheet-footer { font-size: 12px; color: var(--secondary-text); margin-top: 20px; line-height: 1.8; }

.action-btns { margin-top: 25px; display: flex; gap: 10px; width: 100%; }

/* Базовые стили кнопки */
.read-btn {flex: 5;display: flex;justify-content: center;align-items: center;background: linear-gradient(180deg, #ffffff 0%, #f7f7f7 100%);color: #000;font-weight: 700;border: none;margin: 0;cursor: pointer;font-family: inherit;padding: 16px 10px;transition: all 0.2s ease;;border-radius: 25px;text-align: center;text-decoration: none; font-size: 15px;white-space: nowrap;  gap: 8px;border: none;-webkit-tap-highlight-color: transparent;outline: none;}
.read-btn:active {background: #e9e9e9;transform: scale(0.97);}
.read-btn:hover {background: linear-gradient(180deg, #ffffff 0%, #eeeeee 100%);}
.read-btn-half {border-radius: 25px 0 0 25px;}
.read-btn-half:active {transform: unset !important;}
.read-btn-full {border-radius: 25px;}



.hear-btn {background: linear-gradient(180deg, #ffae35 0%, #ff9500 100%);color: #fff;}
.hear-btn:hover {background: linear-gradient(180deg, #ffb84d 0%, #fb8c00 100%);opacity: 1;}
.hear-btn:active {background: linear-gradient(180deg, #e68600 0%, #cc7700 100%);}
.hear-btn-half {border-radius: 0 25px 25px 0;border-left: 1px solid #ddd;}
.hear-btn-half:active {transform: unset !important;}
.hear-btn-full {border-radius: 25px;}



.audio-btn { flex: 1; background: #10b981; color: white; font-size: 14px; border-radius: 25px; display: flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 700; }

/* --- 6. PLAYER & DONATE BUTTON --- */
#persistent-player {
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    /*animation: playerSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);*/
    z-index: 1100;
}
@keyframes playerSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

#player-header { border-radius: 12px; transition: background 0.2s, transform 0.2s; user-select: none; }
#player-header:active { background: rgba(255, 255, 255, 0.05); opacity: 0.7; transform: scale(0.98); }

/* Основной ряд управления */
.player-controls-row {
    display: flex;
    align-items: center;
    /* Распределяет элементы равномерно: первый в начало, последний в конец */
    justify-content: space-between; 
    width: 100%;
    max-width: 400px; /* Ограничь ширину, чтобы кнопки не разъехались слишком далеко на десктопе */
    margin: 0px auto 30px;
    padding: 0 10px;  /* Небольшие отступы от краев экрана */
    box-sizing: border-box;
}

/* Кнопки-иконки */
.icon-control-btn {
background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: white;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Убирает синий/серый квадрат при нажатии на мобилках */
    -webkit-tap-highlight-color: transparent;
    
    /* Запрещает выделение текста/иконок при клике */
    -webkit-user-select: none;
    user-select: none;
    
    /* Убирает контур при фокусе (для чистоты) */
    outline: none;
}

.icon-control-btn:active {
    transform: scale(0.9);
}

/* Стили для иконки скорости (спидометр) */
.speed-control-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.speed-label {
    position: absolute;
    bottom: -12px; /* Чуть ниже иконки */
    font-size: 9px;
    font-weight: 800;
    color: #10b981;
    pointer-events: none; /* Чтобы клик по цифрам не блокировал кнопку */
    -webkit-user-select: none;
    user-select: none;
}

/* Бейдж таймера над секундомером */
.timer-control-wrapper {
    position: relative;
}
.timer-badge {
    position: absolute;
    top: 35px;
    right: 11px;
    background: #10b981;
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 4px;
    display: none; /* Включается через JS */
    pointer-events: none;
}

/* Главная кнопка Play */
.main-play-circle {
    background: white;
    border: none;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(255,255,255,0.2);
    cursor: pointer;
    flex-shrink: 0;
}

.player-actions-row {
    display: flex;
    justify-content: center; /* Центрируем кнопки */
    gap: 10px;
    margin-top: 15px;
    width: 100%;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px; /* Отступы по 5px сверху/снизу, 12px по бокам для формы */
    border-radius: 8px;
    font-size: 12px;   /* Компактный шрифт */
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    width: auto;       /* Кнопка не растягивается */
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
}

.action-btn.primary {
    border-color: #fff;
    background: #fff;
    color: #000;
}

.action-btn:active {
    transform: scale(0.95);
    background: #ddd;
        border-color: #ddd;
}

.speed-control-wrapper, 
.timer-control-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 40px; /* Фиксированная ширина поможет "отцентровать" центральный Play */
}

#player-progress-bg {
    height: 4px; border-radius: 10px; cursor: pointer; position: relative;
    padding: 10px 0; margin-top: -6px; background-clip: content-box; touch-action: none;
}
#player-progress-fill div { transition: transform 0.1s ease; }
body.dragging #player-progress-fill div { transform: scale(1.5); }
#player-progress-bg:active #progress-dot { transform: scale(1.4); background: #ffffff; box-shadow: 0 0 10px rgba(16, 185, 129, 0.8); }
#progress-dot { transition: transform 0.2s ease, box-shadow 0.2s ease; }


#player-view-book:active, #player-read-book:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* Если плеер развернут на весь экран в приложении, 
   можно добавить отступ снизу для Safe Area айфонов */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #persistent-player {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

.donate-button {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: linear-gradient(135deg, #FF6B6B 0%, #FFD166 100%);
    color: white; padding: 12px 24px; border-radius: 50px;
    text-decoration: none; font-size: 15px; font-weight: 700;
    box-shadow: 0 6px 15px rgba(255,107,107,0.4); z-index: 900;
    white-space: nowrap; text-align: center;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s, transform 0.3s;
}
body.has-player .donate-button { bottom: 84px; }
body.player-expanded .donate-button { bottom: 275px; }
body.sheet-open .donate-button { opacity: 0; pointer-events: none; transform: translateX(-50%) scale(0.8); }

/* --- 7. SIDEBAR --- */
/* Сайдбар теперь прижат к правому краю */
.sidebar {
    position: fixed;
    top: 0;
    right: -280px; /* Прячем за правую границу экрана */
    width: 280px;
    height: 100%;
    background: #1c1c1e; /* Цвет под твой интерфейс */
    z-index: 1900;
    transition: right 0.3s ease; /* Анимация справа налево */
    padding: 20px;
    box-sizing: border-box;
    box-shadow: -5px 0 15px rgba(0,0,0,0.5);
}

/* Когда меню активно, оно выезжает на позицию 0 */
.sidebar.active {
    right: 0;
}

/* Затемнение фона */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    z-index: 1800;
    background: rgba(44, 44, 46, 0.8);
}

.sidebar-overlay.active {
    display: block;
}
.sidebar-user-info { padding: 30px 25px; border-bottom: 0.5px solid var(--border-color); margin-bottom: 0px; }
.sidebar-link { display: flex; align-items: center; padding: 18px 25px; color: white; text-decoration: none; font-size: 16px; border-bottom: 0.5px solid var(--border-color); }

/* Контейнер для отступа в сайдбаре */
.sidebar-action-container {
    padding: 0 16px;
    margin-top: 15px;
}

/* Сама кнопка-карточка */
.suggest-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    padding: 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #8e8e93; /* Приглушенный серый */
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    user-select: none;
}

/* Эффект при наведении */
.suggest-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

/* Эффект при нажатии */
.suggest-card:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.1);
}

.suggest-card .plus-icon {
    font-size: 20px;
    font-weight: 300;
}


/* --- 8. PROMO --- */
/* Общие стили для рекламных ссылок */
.ads-link {
    text-decoration: none;
    display: block;
    -webkit-tap-highlight-color: transparent; /* Убираем синюю рамку на мобильных */
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Эффект "проседания" при нажатии */
.ads-link:active {
    transform: scale(0.97);
}

.ads-container {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* Блик (эффект стекла) при наведении или появлении */
.ads-container::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.05), transparent);
    transform: rotate(45deg);
    pointer-events: none;
}

/* Анимация иконки внутри баннера при нажатии */
.ads-link:active svg {
    transform: rotate(-10deg) scale(1.1);
    transition: transform 0.1s ease;
}

.ads-container svg {
    transition: transform 0.3s ease;
}

/* Контейнер баннера */
.ads-container-home {
    margin: 20px 15px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(0,122,255,0.12) 0%, rgba(0,122,255,0.04) 100%);
    border-radius: 18px;
    border: 1px solid rgba(0,122,255,0.2);
    display: flex !important;
    align-items: center !important;
    gap: 14px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

/* Бокс для иконки */
.ads-icon-wrapper {
    background: rgba(0,122,255,0.15);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Анимация мерцания для иконки */
.ads-icon-wrapper svg {
    animation: ads-blink 2s ease-in-out infinite;
}

@keyframes ads-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Текстовые стили */
.ads-text-box { text-align: left; flex: 1; }
.ads-label { font-size: 10px; color: #007AFF; text-transform: uppercase; font-weight: 800; letter-spacing: 1px; margin-bottom: 2px; }
.ads-main-text { color: #fff; font-size: 14px; font-weight: 600; line-height: 1.3; }

/* Реакция на нажатие */
.ads-link:active .ads-container-home {
    transform: scale(0.98);
    background: rgba(0,122,255,0.15);
}

/*Окно читалки*/
/* --- ОБНОВЛЕННАЯ ЧИТАЛКА (КЛОН ПЛЕЕРА) --- */

#full-reader-container {
    position: fixed;
    left: 0;
    width: 100%;
    /* Тот же цвет, блюр и граница, что у плеера */
    background: #1c1c1e; 
    border-top: 0.5px solid var(--border-color);
    z-index: 3100; 
    background: rgba(18, 18, 18, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Используем цепочку ID, чтобы перебить любые внешние стили */


/* Состояния */
.reader-state-hidden { 
    transform: translateY(100%); 
    opacity: 0; 
}

.reader-state-mini { 
    transform: translateY(0);
    height: 65px; /* Точная высота твоего свернутого плеера */
    bottom: 0;
    padding: 12px 16px;
}

/* Эффект нажатия для свернутой книги */
#reader-minimized-bar:active {
    background: rgba(255, 255, 255, 0.05);
    opacity: 0.8;
    transform: scale(0.98);
    transition: transform 0.1s ease, opacity 0.1s ease;
    border-radius:12px;
}



.reader-state-full { 
    transform: translateY(0);
    height: 100% !important; 
    bottom: 0;
}

/* ЛОГИКА СТЕКА (Один над другим) */
/* Если плеер виден, поднимаем мини-читалку выше него */
body.has-player #full-reader-container.reader-state-mini {
    bottom: 65px; /* Высота плеера */
    border-bottom: 0.5px solid var(--border-color);
}
/* --- ОБНОВЛЕННАЯ ЧИТАЛКА (ПОЛНАЯ КОПИЯ ПЛЕЕРА) --- */

#full-reader-container {
    position: fixed;
    left: 0;
    width: 100%;
    background: #1c1c1e; 
    border-top: 0.5px solid var(--border-color);
    z-index: 3100;
    background: rgba(18, 18, 18, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
}

/* Состояния контейнера */
.reader-state-hidden { transform: translateY(100%); opacity: 0; }
.reader-state-mini { transform: translateY(0); height: 65px; bottom: 0; padding: 12px 16px; }
.reader-state-full { transform: translateY(0); height: 100% !important; bottom: 0; }

/* Логика отступа: если есть плеер, читалка прыгает выше */
body.has-player #full-reader-container.reader-state-mini {
    bottom: 65px !important; /* Высота плеера */
}

/* Свернутая панель управления */
#reader-minimized-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* Кнопка "Читать" с круглыми углами */
.btn-mini-read {
    background: #007AFF; /* Фирменный синий iOS/Android */
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px; /* Те самые круглые углы */
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.1s;
}

.btn-mini-read:active {
    transform: scale(0.95);
    background: #0056b3;
}

/* Текстовая область */
.reader-mini-info {
    flex: 1;
    min-width: 0;
}

#reader-mini-title {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.reader-mini-author {
    font-size: 11px;
    color: var(--secondary-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Иконка стрелочки слева */
#expand-icon-reader {
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
}

/* Шапка развернутого ридера */




/* Переключатели отображения */
.reader-state-full #reader-expanded-header,
.reader-state-full #reader-frame { display: flex !important; }
.reader-state-full #reader-minimized-bar { display: none !important; }

/* Скрытие заголовка читалки */
/* Пример стиля для заголовка окна */
.window-header {
    transition: transform 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    height: 50px; /* Ваша высота заголовка */
    opacity: 1;
}

/* Класс, который мы добавляем через JS */


/* Убедитесь, что iframe занимает оставшееся место */
iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Контейнер для iframe в главном окне */
/* Контейнер для iframe в главном окне */
#reader-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    
    /* Запасные варианты для разных браузеров */
    height: 100vh; /* Для старых браузеров */
    height: -webkit-fill-available; /* Для старых iOS Safari */
    height: 100dvh !important;
    
    border: none;
    background: #000;
    z-index: 3150;
    display: none; 
}

/* Шапка поверх iframe */
#reader-expanded-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 3200;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    
    border-bottom: 0.5px solid var(--border-color);
    background: rgba(18, 18, 18, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.3s ease;
}

/* Класс для скрытия шапки */
#reader-expanded-header.hidden-header {
    transform: translateY(-100%);
}

/*Страница окно*/
/* Базовое состояние окна полки */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 100%; /* Уведено вправо */
    width: 100%;
    height: 100%;
    background: #1c1c1e; /* Цвет фона как у плеера */
    z-index: 1800; /* Выше всех остальных элементов */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Когда добавили класс .active */
.fullscreen-overlay.active {
    transform: translateX(-100%); /* Выезжает на экран */
}

.shelf-nav {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #1c1c1e;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.shelf-back-btn {
    background: none;
    border: none;
    color: #888; /* Синий цвет как в iOS */
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
}

#shelf-title {
    margin: 0;
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    margin-right: 70px; /* Чтобы отцентровать текст относительно кнопки назад */
}
/*Моя полка*/

.my-book-item {
    transition: transform 0.2s, background 0.2s;
}
.my-book-item:active {
    transform: scale(0.98);
}
.delete-btn {
    opacity: 0.6;
    transition: opacity 0.2s;
}
.delete-btn:hover {
    opacity: 1;
}


/*Окно*/

/* Класс для отзывов — должен перекрывать шторку книги */
#shelf-overlay.high-priority {
    z-index: 3000 !important;
}


/* Стили для контейнера лайка */
/* 1. Контейнер кнопки */
.like-btn {
    display: flex; 
    align-items: center; 
    gap: 6px; 
    cursor: pointer; 
    padding: 6px 12px; 
    background: rgba(255,255,255,0.05); 
    border-radius: 12px; 
    transition: all 0.2s ease;
    border: none;
    outline: none;
    user-select: none;
}

.like-btn:hover {
    background: rgba(255,255,255,0.08);
}

.like-btn:active {
    transform: scale(0.95); /* Эффект нажатия всей кнопки */
}

/* 2. Иконка сердце (Линейная, без заливки) */
.like-icon-svg {
    width: 16px;
    height: 16px;
    fill: none; /* Всегда пусто внутри по твоему запросу */
    stroke: #888; /* Цвет по умолчанию */
    stroke-width: 2.2; 
    stroke-linecap: round;
    stroke-linejoin: round;
    /* Упругая анимация для иконки */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 3. Счетчик лайков */
.like-count {
    font-size: 13px;
    color: #888;
    font-weight: 600;
    transition: color 0.3s ease;
}

/* 4. СОСТОЯНИЕ "ЛАЙКНУТО" */
.like-btn.is-liked .like-icon-svg {
    stroke: #ff453a; /* Только краснеет контур */
    /*transform: scale(1.15);*/ /* Легкое увеличение иконки */
}

.like-btn.is-liked .like-count {
    color: #ff453a !important; /* Текст тоже становится красным */
}

/* Микро-эффект при самом клике именно на иконку */
.like-btn:active .like-icon-svg {
    transform: scale(0.85);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#load-more-reviews:hover {
    background: rgba(255,255,255,0.08) !important;
    color: #fff !important;
}

/* Базовый стиль для иконок в сайдбаре */
.sidebar-link .icon-svg {
    width: 20px;
    height: 20px;
    margin-right: 12px; /* Отступ от текста */
    vertical-align: middle;
    /* Иконка будет принимать цвет текста ссылки */
    color: inherit; 
}
.sidebar-link[onclick*="MySales"] .icon-svg {
    color: #32d74b; /* Выделим иконку продаж зеленым */
}

.reader-close-x {background: none;border: none;color: rgba(255, 255, 255, 0.5);font-size: 24px;cursor: pointer;padding: 0 5px;}

.audio-author-block {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 0.5px solid var(--border-color);
}

.aa-photo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.1);
}

.aa-info {
    flex: 1;
}

.aa-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.aa-yt {
    font-size: 13px;
    color: #ff0000; /* Цвет YouTube или акцентный */
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.aa-yt svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
