/* Fixed left sidebar TOC - Lark doc style */
.toc-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height, 60px);
    width: 240px;
    height: calc(100vh - var(--header-height, 60px));
    padding: 24px 16px;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.25s ease;
}

.toc-sidebar .toc {
    margin-bottom: 0;
    border: none;
    background: transparent;
    padding: 0;
    font-size: 13px;
}

[data-theme="dark"] .toc-sidebar .toc {
    background: transparent;
}

.toc-sidebar .toc details summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-inline-start: 0;
}

.toc-sidebar .toc .inner {
    margin: 8px 0;
    padding: 0;
}

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

.toc-sidebar .toc li {
    line-height: 1.5;
    margin: 2px 0;
}

.toc-sidebar .toc li ul {
    padding-left: 14px;
    margin: 0;
}

.toc-sidebar .toc a {
    color: var(--secondary);
    font-size: 13px;
    text-decoration: none;
    display: block;
    padding: 3px 8px;
    border-radius: 4px;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
}

.toc-sidebar .toc a:hover {
    color: var(--primary);
    background: var(--code-bg);
    border-left-color: var(--primary);
    box-shadow: none;
}

.toc-sidebar .toc a.toc-active {
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
    background: var(--code-bg);
}

/* Scrollbar */
.toc-sidebar::-webkit-scrollbar {
    width: 3px;
}

.toc-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Toggle button */
.toc-toggle {
    display: none;
    position: fixed;
    left: 12px;
    top: calc(var(--header-height, 60px) + 12px);
    z-index: 101;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--theme);
    color: var(--secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: background 0.15s ease;
}

.toc-toggle:hover {
    background: var(--code-bg);
    color: var(--primary);
}

/* Overlay for mobile */
.toc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.25s ease;
}

/* Narrow screens: hide sidebar, show toggle button */
@media screen and (max-width: 1280px) {
    .toc-toggle {
        display: flex;
    }

    .toc-sidebar {
        transform: translateX(-100%);
        background: var(--theme);
        border-right: 1px solid var(--border);
        box-shadow: 2px 0 12px rgba(0,0,0,0.1);
    }

    .toc-sidebar.open {
        transform: translateX(0);
    }

    .toc-overlay.open {
        display: block;
        opacity: 1;
    }
}
