html {
    scroll-behavior: smooth;
}

.ae-post-layout {
    display: grid;
    gap: 3rem;
}

.ae-post-toc-card {
    padding: 2rem;
    border: 1px solid rgb(31 41 55);
    border-radius: 1rem;
    background: rgb(249 250 251);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.ae-post-toc-card.is-sticky {
    position: sticky;
    top: 2rem;
    display: flex;
    max-height: calc(100vh - 4rem);
    max-height: calc(100dvh - 4rem);
    flex-direction: column;
}

.ae-post-toc-card.is-sticky nav {
    min-height: 0;
    padding-right: 0.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.ae-toc-title {
    color: #212605;
    letter-spacing: -0.025em;
}

.ae-toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: ae-toc-item;
}

.ae-toc-item {
    margin-top: 0.7rem;
    line-height: 1.45;
}

.ae-toc-list .ae-toc-list {
    margin-top: 0.35rem;
    padding-left: 1rem;
}

.ae-toc-list.is-numbered .ae-toc-item {
    counter-increment: ae-toc-item;
}

.ae-toc-list.is-numbered .ae-toc-link::before {
    content: counters(ae-toc-item, ".") ". ";
    color: #212605;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.ae-toc-link {
    display: block;
    padding: 0.55rem 0.75rem;
    border-left: 3px solid transparent;
    border-radius: 0.5rem;
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ae-toc-link:hover,
.ae-toc-link:focus-visible {
    border-left-color: var(--brand, #7DD532);
    background: rgb(125 213 50 / 0.14);
    color: #212605;
    box-shadow: 0 2px 10px rgb(125 213 50 / 0.18);
    outline: none;
    transform: translateX(3px);
}

.ae-toc-link.is-active {
    border-left-color: var(--brand, #7DD532);
    background: #212605;
    color: #fff;
    box-shadow: 0 4px 14px rgb(33 38 5 / 0.22);
    font-weight: 600;
}

.ae-toc-link.is-active::before {
    color: var(--brand, #7DD532) !important;
}

.ae-gutenberg-post-content :is(h2, h3, h4, h5, h6)[id] {
    scroll-margin-top: 2rem;
}

#ae-mobile-toc-container {
    display: none;
}

@media (min-width: 1024px) {
    .ae-post-layout.has-toc {
        grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr);
    }
}

@media (max-width: 1023px) {
    .ae-post-layout {
        display: block;
    }

    .ae-post-toc-desktop {
        display: none;
    }

    #ae-mobile-toc-container {
        position: fixed;
        z-index: 50;
        bottom: 1.5rem;
        left: 50%;
        display: block;
        width: min(90%, 28rem);
        transform: translateX(-50%);
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    #ae-mobile-toc-container.is-hidden-by-scroll {
        transform: translate(-50%, 7rem);
        opacity: 0;
        pointer-events: none;
    }

    #ae-mobile-toc-menu {
        max-height: 60vh;
        margin-bottom: 1rem;
        padding: 1.5rem;
        overflow-y: auto;
        border: 1px solid rgb(229 231 235);
        border-radius: 1rem;
        background: #fff;
        box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.15);
    }

    #ae-mobile-toc-menu[hidden] {
        display: none;
    }

    #ae-mobile-toc-toggle {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        padding: 1rem 1.25rem;
        border: 0;
        border-radius: 9999px;
        background: #000;
        color: #fff;
        font-weight: 700;
        box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.2);
        cursor: pointer;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    #ae-mobile-toc-container,
    .ae-toc-link {
        transition: none;
    }
}

.dark .ae-post-toc-card,
.dark #ae-mobile-toc-menu {
    border-color: rgb(55 65 81);
    background: #1c1917;
}

.dark .ae-toc-title {
    color: #fafaf9;
}

.dark .ae-toc-list.is-numbered .ae-toc-link::before {
    color: var(--brand, #7DD532);
}

.dark .ae-toc-link:hover,
.dark .ae-toc-link:focus-visible {
    border-left-color: var(--brand, #7DD532);
    background: rgb(125 213 50 / 0.16);
    color: #fff;
}

.dark .ae-toc-link.is-active {
    border-left-color: #fff;
    background: var(--brand, #7DD532);
    color: #212605;
    box-shadow: 0 4px 16px rgb(125 213 50 / 0.22);
}

.dark .ae-toc-link.is-active::before {
    color: #212605 !important;
}

.dark #ae-mobile-toc-toggle {
    background: #fff;
    color: #000;
}
