/* Auto TOC */
.auto-toc {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 20px 24px;
    margin: 24px 0 32px;
    max-width: 720px;
}
.auto-toc summary {
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.auto-toc summary::before {
    content: "☰";
    font-size: 1.1em;
}
.auto-toc summary::marker { display: none; }
.auto-toc summary::-webkit-details-marker { display: none; }
.auto-toc ol {
    margin: 16px 0 0;
    padding-left: 20px;
    counter-reset: toc;
}
.auto-toc li {
    margin-bottom: 8px;
    counter-increment: toc;
    list-style: none;
}
.auto-toc li::before {
    content: counter(toc) ".";
    font-weight: 600;
    margin-right: 6px;
    opacity: 0.5;
}
.auto-toc a {
    text-decoration: none;
    opacity: 0.85;
    transition: opacity 0.2s;
}
.auto-toc a:hover { opacity: 1; text-decoration: underline; }
.auto-toc a.active { opacity: 1; font-weight: 600; }

/* Light theme variant */
body:not([class*="dark"]) .auto-toc {
    background: #f8f9fa;
    border-color: #e2e8f0;
}

/* Sticky sidebar TOC for desktop */
@media (min-width: 1200px) {
    .auto-toc-sidebar {
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        font-size: 0.85rem;
    }
}

/* Mobile: collapsible */
@media (max-width: 768px) {
    .auto-toc { margin: 16px 0 24px; padding: 16px; }
    .auto-toc[open] ol { max-height: 50vh; overflow-y: auto; }
}

/* H3 sub-items */
.auto-toc-sub {
    margin: 6px 0 2px 12px;
    padding-left: 12px;
    border-left: 2px solid rgba(128,128,128,0.15);
}
.auto-toc-sub li { font-size: 0.9em; margin-bottom: 4px; }
.auto-toc-sub li::before { content: "–"; margin-right: 6px; }
