#navigation-plugin {
    position: fixed;
    top: 235px;
    left: 10px;
    width: 300px;
    background-color: transparent;
    font-family: 'Merriweather', inherit; /* Шрифт Merriweather с наследованием */
    font-size: 15px;
    font-weight: normal;
    line-height: 1.4;
    z-index: 9990;

    max-height: calc(100vh - 255px);
    overflow-y: auto;
    padding: 5px 10px 5px 5px;
    box-sizing: border-box;
    
    /* Прозрачная полоса прокрутки справа */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

#navigation-plugin::-webkit-scrollbar {
    width: 8px;
}

#navigation-plugin::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

#navigation-plugin::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
    transition: background 0.2s ease;
}

#navigation-plugin::-webkit-scrollbar-thumb:hover {
    background: #4A5542;
}

/* === ВСЕ ЗАГОЛОВКИ БЛОКОВ - ПРЯМОУГОЛЬНИКИ === */
#navigation-plugin .collapsible-header {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 10px;
    margin: 0 0 15px 0;
    background-color: #F0EBD6;
    color: #4A5542;
    border-radius: 8px;
    font-size: 17px; /* ← Увеличено до 17px */
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-left: none !important;
    box-sizing: border-box;
    width: 100%;
}

#navigation-plugin .collapsible-header:hover {
    background-color: #E8E1C9;
    color: #384232;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Индикатор раскрытия/сворачивания */
#navigation-plugin .collapsible-header[aria-expanded="true"]::before {
    content: "▼";
    margin-right: 8px;
    font-size: 12px;
}

#navigation-plugin .collapsible-header[aria-expanded="false"]::before {
    content: "►";
    margin-right: 8px;
    font-size: 12px;
}

.collapsible-content {
    margin-bottom: 15px;
}

.collapsible-content.collapsed {
    display: none;
}

/* === ВСЕ ПРЯМОУГОЛЬНЫЕ БЛОКИ === */

/* Все ссылки в разделе 3 */
#navigation-plugin [data-block="current-section"] a:not([data-is-leaf]) {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    min-height: 40px;
    padding: 10px 10px;
    margin: 8px 0;
    background-color: #F0EBD6;
    color: #4A5542;
    border-radius: 6px;
    font-size: 15px; /* ← Оставлено 15px */
    font-weight: normal;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    box-sizing: border-box;
    width: 100%;
    border-left: none !important;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: normal;
}

/* Ссылки в других блоках */
#navigation-plugin [data-block="recent"] a,
#navigation-plugin [data-block="sections"] a {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    min-height: 36px;
    padding: 8px 12px;
    margin: 8px 0;
    background-color: #F0EBD6;
    color: #4A5542;
    border-radius: 6px;
    font-size: 15px; /* ← Увеличено с 14px до 15px */
    font-weight: normal;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    box-sizing: border-box;
    width: 100%;
    border-left: none !important;
}

/* Заголовки подразделов (раскрывающиеся) */
#navigation-plugin [data-block="current-section"] .group > span {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 40px;
    padding: 10px 10px;
    margin: 8px 0;
    background-color: #F0EBD6;
    color: #4A5542;
    border-radius: 6px;
    font-weight: normal;
    font-size: 15px; /* ← Оставлено 15px */
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: none !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    box-sizing: border-box;
    width: 100%;
    position: relative;
}

/* Индикатор раскрытия для подразделов */
#navigation-plugin [data-block="current-section"] .group > span::before {
    content: "►";
    margin-right: 8px;
    font-size: 12px;
    transition: transform 0.2s ease;
}

#navigation-plugin [data-block="current-section"] .group.expanded > span::before {
    content: "▼";
}

/* Элементы в списке "Вы посетили" */
#recent-pages-list li {
    margin: 8px 0 !important;
}

#recent-pages-list li a {
    margin: 0 !important;
}

/* === КВАДРАТИКИ === */
#navigation-plugin [data-block="current-section"] a[data-is-leaf] {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    margin: 2px;
    background-color: #F0EBD6;
    color: #4A5542;
    border-radius: 4px;
    font-size: 13px;
    font-weight: normal;
    text-decoration: none !important;
    white-space: nowrap;
    transform: none !important;
    line-height: 1;
}

/* Эффект при наведении на квадратики */
#navigation-plugin [data-block="current-section"] a[data-is-leaf]:hover {
    background-color: #E8E1C9;
    color: #384232;
    transform: scale(1.05) !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    text-decoration: none !important;
}

/* Текущая страница для квадратиков */
#navigation-plugin [data-block="current-section"] a[data-is-leaf].current {
    background-color: #4A5542;
    color: white;
}

#navigation-plugin [data-block="current-section"] a[data-is-leaf].current:hover {
    background-color: #5a684f;
    color: white;
}

/* === УБРАНО ПОДЧЕРКИВАНИЕ ДЛЯ ВСЕХ ССЫЛОК === */
#navigation-plugin a {
    text-decoration: none;
}

/* Эффекты при наведении для обычных ссылок */
#navigation-plugin [data-block="current-section"] a:not([data-is-leaf]):hover,
#navigation-plugin [data-block="recent"] a:hover,
#navigation-plugin [data-block="sections"] a:hover,
#navigation-plugin [data-block="current-section"] .group > span:hover {
    background-color: #E8E1C9;
    color: #384232;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Текущая страница для обычных ссылок */
#navigation-plugin [data-block="current-section"] a.current {
    background-color: #4A5542;
    color: white;
}

#navigation-plugin [data-block="current-section"] a.current:hover {
    background-color: #5a684f;
    color: white;
}

/* === УПРАВЛЕНИЕ ВИДИМОСТЬЮ ЧЕРЕЗ КЛАССЫ === */

/* Скрытые подразделы */
#navigation-plugin .group:not(.expanded) > ul {
    display: none !important;
}

/* Раскрытые подразделы */
#navigation-plugin .group.expanded > ul {
    display: block !important;
    margin: 4px 0 4px 15px !important;
}

/* === FLEX-КОНТЕЙНЕР ДЛЯ КОНЕЧНЫХ ЭЛЕМЕНТОВ === */
#navigation-plugin .group.expanded > ul.has-leaf-items {
    display: flex !important;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0 12px 0 !important;
    padding: 0 !important;
    list-style: none;
}

/* Ссылки с data-span (широкие элементы) */
#navigation-plugin a[data-span="2"] { width: calc(2 * 32px + 2 * 4px); }
#navigation-plugin a[data-span="3"] { width: calc(3 * 32px + 3 * 4px); }
#navigation-plugin a[data-span="4"] { width: calc(4 * 32px + 4 * 4px); }
#navigation-plugin a[data-span="5"] { width: calc(5 * 32px + 5 * 4px); }
#navigation-plugin a[data-span="6"] { width: calc(6 * 32px + 6 * 4px); }

/* === ФОКУС ДЛЯ ДОСТУПНОСТИ === */
#navigation-plugin .collapsible-header:focus,
#navigation-plugin .group > span:focus,
#navigation-plugin a:focus {
    outline: none;
    outline-offset: 0;
}

/* === АДАПТИВНОСТЬ === */

@media (max-width: 1400px) {
    #nav-container {
        margin-top: 40px;
        margin-bottom: 40px;
        width: 100%;
    }
    
    #navigation-plugin {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        max-height: none;
        padding: 24px 16px;
        background-color: #F8F4E9;
    }
    
    #navigation-plugin a:hover,
    #navigation-plugin .group > span:hover,
    #navigation-plugin .collapsible-header:hover {
        transform: none;
    }
    
    #navigation-plugin a[data-is-leaf]:hover {
        transform: scale(1.05) !important;
    }
}

/* === СБРОС СТИЛЕЙ ТЕМЫ ДЛЯ НАВИГАЦИИ === */
/* Перебиваем глобальные стили темы .single-content ul { padding-left: 2em } */

/* Сбрасываем padding для всех списков внутри плагина */
#navigation-plugin ul {
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* Задаём отступы для вложенных списков */
#navigation-plugin ul ul {
    margin-left: 15px !important;
    padding-left: 0 !important;
}

#navigation-plugin ul ul ul {
    margin-left: 30px !important;
    padding-left: 0 !important;
}

#navigation-plugin ul ul ul ul {
    margin-left: 45px !important;
    padding-left: 0 !important;
}

/* Для библиографии/архива */
.bibl-arh-toc-list .toc-h3 {
    padding-left: 15px !important;
    margin-left: 10px !important;
}
.bibl-arh-toc-list .toc-h4 {
    padding-left: 30px !important;
    margin-left: 25px !important;
}
.bibl-arh-toc-list .toc-h5 {
    padding-left: 45px !important;
    margin-left: 40px !important;
}