.bp-content :is(h1, h2, h3)[id] {
    scroll-margin-top: 96px;
}

.bp-toc {
    margin: 0 0 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    counter-reset: toc;
}

.bp-toc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 0 18px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.bp-toc-head::-webkit-details-marker {
    display: none;
}

.bp-toc-title {
    font-size: 15px;
    font-weight: 640;
    letter-spacing: -0.01em;
    color: var(--text);
}

.bp-toc-chevron {
    flex-shrink: 0;
    color: var(--text-3);
    transition: transform 0.22s ease;
}

.bp-toc[open] .bp-toc-chevron {
    transform: rotate(180deg);
}

.bp-toc-head:hover .bp-toc-chevron {
    color: var(--text);
}

.bp-toc-nav {
    padding: 2px 18px 16px;
    border-top: 1px solid var(--border);
}

.bp-toc-list,
.bp-toc-sub {
    margin: 0;
    padding: 0;
    list-style: none;
}

.bp-toc-list > li {
    counter-increment: toc;
    counter-reset: tocsub;
}

.bp-toc-sub > li {
    counter-increment: tocsub;
}

.bp-toc a {
    display: grid;
    grid-template-columns: 2.2em 1fr;
    align-items: baseline;
    padding: 7px 8px;
    margin: 0 -8px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-2);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.bp-toc-list > li > a {
    margin-top: 10px;
    font-weight: 560;
    color: var(--text);
}

.bp-toc-list > li > a::before {
    content: counter(toc);
    font-variant-numeric: tabular-nums;
    color: var(--text-3);
}

.bp-toc-sub {
    margin-left: 2.2em;
}

.bp-toc-sub a {
    grid-template-columns: 2.6em 1fr;
    padding-top: 5px;
    padding-bottom: 5px;
    font-size: 13.5px;
}

.bp-toc-sub a::before {
    content: counter(toc) "." counter(tocsub);
    font-variant-numeric: tabular-nums;
    color: var(--text-3);
}

.bp-toc a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.bp-toc a.is-active {
    background: var(--accent-soft);
    color: var(--text);
}

.bp-toc a.is-active::before {
    color: var(--text);
}

@media (max-width: 720px) {
    .bp-toc-head {
        padding: 0 14px;
    }

    .bp-toc-nav {
        padding: 2px 14px 12px;
    }
}

@media (prefers-reduced-motion: no-preference) {
    html:has(.bp-toc) {
        scroll-behavior: smooth;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bp-toc-chevron,
    .bp-toc a {
        transition: none;
    }
}
