.book-chapters-menu {
    max-width: 1180px;
    margin: 0 auto;
} 

.chapters-list {
    display: flex;
    justify-content: center;
    list-style: none;
    gap: 35px;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
}

.chapters-list li {
    position: relative; /* Чтобы `position: absolute` у подменю работал относительно родителя */
    padding-bottom: 15px;
    padding-top: 15px;
}

.chapters-list a {
    color: #003C09;  
    padding-left: 5px;
    padding-right: 5px;
}

.chapters-list a:hover {
    color: #00a017ff;
    text-decoration: underline; 
}

/* Настойка подменю */
.chapters-list .subchapters-list { 
    display: none; /* Скрываем подменю по умолчанию */
    position: absolute; /* Делаем его выпадающим поверх контента */
    top: 100%; /* Размещаем под родительским пунктом */
    left: 50%; /* Смещаем подменю вправо на 50% от ширины родителя */
    transform: translateX(-50%); /* Сдвигаем подменю влево на 50% его собственной ширины */
    z-index: 99999;
    background: #ffffff;
    min-width: 200px;
    width: auto; /* Явно указываем, что ширина определяется содержимым */
    white-space: nowrap; /* Запрещаем перенос текста на новую строку */
    text-align: center;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    max-width: 90vw;
    z-index: 1000;
}

.subchapters-list {
    border: 1px solid #003C09;
    border-radius: 3px;
}

.subchapters-list li {
    margin: 3px;
    padding-bottom: 10px;
}

.subchapters-list li:hover {
    background-color: #f2f2f2;
}

.chapters-list li:hover > .subchapters-list {
    display: block; 
    list-style: none;
}

/* Шапка навигации */
.nav-book {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
}

/* ===== КНОПКА-ГАМБУРГЕР (СКРЫТА НА ДЕСКТОПЕ) ===== */
.book-menu-toggle {
    display: none;
    align-items: center; /* Выравниваем по вертикали */
    gap: 12px; /* Расстояние между текстом и иконкой */
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1002;
}

/* Контейнер для иконок гамбургера */
.book-hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
}

.hamburger-line {
    display: block;
    width: 100%;
    height: 3px;
    background: #003C09;
    border-radius: 3px;
    transition: all 0.3s ease;
}

/* ===== ТЕКСТ "МЕНЮ КНИГИ" ===== */
.book-menu-label {
    font-size: 16px;
    font-weight: 600;
    color: #003C09;
    transition: opacity 0.3s ease, transform 0.3s ease;
    user-select: none; /* Запрещаем выделение текста */
}

.book-menu-toggle.active .book-menu-label {
    display: none;
}

/* Анимация гамбургера в крестик (при открытом меню) */
.book-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.book-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.book-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

@media (min-width: 1068px) {
    .nav-book {
        display: none;
    }
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ ОСНОВНОГО МЕНЮ (ПЛАНШЕТЫ И ТЕЛЕФОНЫ) ===== */
@media (max-width: 1068px) {
    /* Показываем кнопку-гамбургер */
    .book-menu-toggle {
        display: flex;
    }

    /* Скрываем меню по умолчанию на мобильных */
    .chapters-list {
        display: none;
        flex-direction: column;
        align-items: center;
        gap: 0;
        width: 100%;
        background: #ffffff;
        position: relative; /* Меняем absolute на relative */
        top: auto; /* Убираем привязку к верху */
        left: 0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        padding: 10px 0;
        z-index: 999;
    }
    
    /* Показываем меню, когда есть класс active */
    .chapters-list.active {
        display: flex;
    }
    
    /* Пункты меню в мобильной версии */
    .chapters-list li {
        width: 100%;
        padding: 8px 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .chapters-list li:last-child {
        border-bottom: none;
    }
    
    /* Ссылки в мобильной версии */
    .chapters-list a {
        text-align: left;
        display: block;
        padding: 10px 20px;
        font-size: 18px;
    }
    
    /* ===== ПОДМЕНЮ В МОБИЛЬНОЙ ВЕРСИИ ===== */
    .chapters-list .subchapters-list {
        position: static; /* Убираем абсолютное позиционирование */
        transform: none;
        left: auto;
        top: auto;
        display: none;
        width: 100%;
        box-shadow: none;
        border: none;
        border-top: 1px solid #e0e0e0;
        border-radius: 0;
        background: #f9f9f9;
        min-width: auto;
        white-space: normal;
        margin-top: 8px;
    }
    
    /* Показываем подменю при нажатии (не наведении) */
    .chapters-list li.open > .subchapters-list {
        display: block;
    }
    
    /* Пункты подменю в мобильной версии */
    .chapters-list .subchapters-list li {
        margin: 0;
        padding: 0;
        border-bottom: 1px solid #e8e8e8;
    }
    
    .chapters-list .subchapters-list li:last-child {
        border-bottom: none;
    }
    
    .chapters-list .subchapters-list li a {
        padding: 12px 20px;
        font-size: 16px;
        color: #003C09;
    }
    
    .chapters-list .subchapters-list li:hover {
        background-color: transparent;
    }
    
    /* Индикатор для пунктов с подменю (стрелка) */
    .chapters-list .chapter-item-has-children > a::after {
        content: ' ▼';
        font-size: 12px;
        margin-left: 5px;
        transition: transform 0.3s ease;
    }
    
    .chapters-list .chapter-item-has-children.open > a::after {
        transform: rotate(180deg);
    }
}