/* 侧边栏目录 */
.sidebar {
    width: 260px;
    position: sticky;
    top: 80px;
    height: fit-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 16px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-right: 30px;
    flex-shrink: 0;
    font-size: 0.9em;
}

.sidebar h2 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 1.1em;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
}

.sidebar ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.sidebar ul ul {
    padding-left: 16px;
}

.sidebar li {
    margin: 0;
}

.sidebar .toc-level-1 {
    /* H1 — 现在也正常渲染了 */
}

.sidebar .toc-level-2 {
    /* H2 */
}

.sidebar .toc-level-3 {
    /* H3 */
}

.sidebar a {
    display: block;
    padding: 4px 8px;
    color: #555;
    text-decoration: none;
    border-radius: 4px;
    line-height: 1.4;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}

.sidebar a:hover {
    background: #e9ecef;
    color: #000;
    border-left-color: #14867d;
}

.sidebar a:visited {
    color: #555;
}

/* H1 已在模板中跳过，不渲染 */

/* 滚动高亮 */
.sidebar a.active {
    background: #14867d;
    color: white !important;
    border-left-color: #14867d;
    font-weight: 500;
}

/* 小屏隐藏侧边栏 */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
}
