:root {
    --md-default-fg-color: #333;
}

/* Стили для заголовков второго уровня */
.md-typeset h2 {
    color: #1976d2; /* Синий цвет для светлой темы */
    border-bottom: 2px solid #1976d2;
    padding-bottom: 0.3em;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    font-weight: 600;
}

/* Для тёмной темы */
[data-md-color-scheme="slate"] .md-typeset h2 {
    color: #42a5f5; /* Более светлый синий для тёмной темы */
    border-bottom-color: #42a5f5;
}

/* Стили для заголовков третьего уровня - БЕЗ вертикальной черты */
.md-typeset h3 {
    color: #2e7d32; /* Зелёный для светлой темы */
    padding: 0;
    margin: 1.2em 0 0.6em 0;
    font-weight: 500;
    border: none; /* Убираем все границы */
}

/* Для тёмной темы */
[data-md-color-scheme="slate"] .md-typeset h3 {
    color: #66bb6a; /* Более светлый зелёный для тёмной темы */
}

/* Стили для маркеров списка */
.list-marker {
    color: #666;
    margin-right: 6px;
    font-weight: bold;
    user-select: none;
}

/* Для тёмной темы */
[data-md-color-scheme="slate"] .list-marker {
    color: #aaa;
}

/* Стили для внешних ссылок */
.external-link {
    color: #1976d2;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.external-link:hover {
    color: #1565c0;
    text-decoration: none;
}

/* Для тёмной темы */
[data-md-color-scheme="slate"] .external-link {
    color: #42a5f5;
}

[data-md-color-scheme="slate"] .external-link:hover {
    color: #90caf9;
}

/* Заголовок — ультра-компактный */
.collapsible-header {
    color: var(--md-default-fg-color);
    cursor: pointer;
    padding: 1px 4px;                  /* ← МИНИМАЛЬНЫЕ ОТСТУПЫ */
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 0.95em;
    background: transparent;
    display: flex;
    align-items: center;
    font-weight: normal;
    text-decoration: none;
    transition: font-weight 0.3s ease;
    user-select: none;
}

/* Ховер */
.collapsible-header:hover .text {
    text-decoration: underline;
}

/* Активное */
.collapsible-header.active .text {
    font-weight: bold;
    text-decoration: underline;
}

/* Маркер — узкий */
.collapsible-header .marker {
    display: inline-block;
    width: 1em;
    min-width: 1em;
    margin-right: 0.15em;              /* ← УМЕНЬШЕНО */
    font-size: 1em;
    text-align: center;
    user-select: none;
}

.collapsible-header .marker::before {
    content: '▶';
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 0.8em;
}

.collapsible-header.active .marker::before {
    transform: rotate(90deg);
}

/* ЛИСТЫ */
.collapsible-header.no-children {
    cursor: default !important;
}

.collapsible-header.no-children:hover .text {
    text-decoration: none !important;
}

.collapsible-header.no-children .marker::before {
    content: '' !important;
}

.collapsible-header.no-children.active .text {
    font-weight: normal !important;
    text-decoration: none !important;
}

/* Текст */
.collapsible-header .text {
    flex-grow: 1;
    text-decoration: none;
}

/* Содержимое */
.content {
    padding: 0;
    height: auto;
    opacity: 1;
    transform: scaleY(1);
    transform-origin: top;
    overflow: hidden;
    background: transparent;
    color: var(--md-default-fg-color);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    will-change: opacity, transform;
}

.content.collapsed {
    height: 0;
    opacity: 0;
    transform: scaleY(0);
}

/* УЛЬТРА-МИНИМАЛЬНЫЕ ОТСТУПЫ ВЛОЖЕННОСТИ */
.content ul {
    margin: 0.1em 0;
    padding-left: 0.15em;      /* ← МАКСИМАЛЬНО УМЕНЬШЕНО */
    font-size: 1em;
    line-height: 1.3;
    color: inherit;
    list-style: none;
}

.content ul li {
    margin-bottom: 0;
    padding: 0;
}

.content ul ul {
    padding-left: 0.15em;      /* ← ЕЩЁ МЕНЬШЕ */
}

.content .collapsible-list {
    margin-left: 0.15em;       /* ← МИНИМАЛЬНО */
}

.content .collapsible-header {
    padding-left: 0;
}

/* НОВЫЕ СТИЛИ: Подсветка при переходе по якорной ссылке */
.collapsible-header.anchor-highlight {
    background-color: rgba(0, 123, 255, 0.08); /* Светло-синий фон как в MkDocs */
    box-shadow: 0 0 0 1px rgba(0, 123, 255, 0.2); /* Тонкая граница */
    border-radius: 2px;
    transition: background-color 0.6s ease, box-shadow 0.6s ease;
}

.collapsible-header.anchor-highlight .text {
    color: #1976d2; /* Цвет как в активных ссылках MkDocs */
    font-weight: 600;
}

/* Стили для якорных ссылок с Font Awesome иконкой */
.id-link {
    color: #1976d2;
    text-decoration: none;
    font-weight: 600;
    margin: 0 1px;
    padding: 0 2px;
    border-radius: 1px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    font-size: 0.85em;
}

.id-link::before {
    content: '\f0c1'; /* Font Awesome icon: fa-link */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.8em;
    margin-right: 2px;
    display: inline-block;
}

.id-link:hover {
    background-color: rgba(25, 118, 210, 0.1);
    text-decoration: none;
    transform: scale(1.1);
}

/* Альтернатива: если Font Awesome не загружается, используем Unicode */
@supports not (font-family: 'Font Awesome 5 Free') {
    .id-link::before {
        content: '🔗'; /* Unicode chain icon */
        font-family: inherit;
        font-weight: normal;
        font-size: 0.9em;
    }
}