[data-ck-toc-region] {
    --ck-post-toc-width: 260px;
    --ck-post-toc-gap: 2rem;
    --ck-post-toc-panel-width: min(360px, calc(100vw - 2rem));
}

.ck-post-toc-region {
    position: relative;
}

.ck-post-toc-region--left,
.ck-post-toc-region--right {
    display: block;
}

.ck-post-toc-desktop-wrap {
    background: var(--bg-tertiary, #f8f9fa);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.ck-post-toc-region--inline .ck-post-toc-desktop-wrap {
    margin-bottom: 1.5rem;
}

.ck-post-toc-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary, #6c757d);
    font-weight: 700;
    margin-bottom: 0.9rem;
}

.ck-post-toc-nav ul,
.ck-post-toc-nav ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ck-post-toc-nav li + li {
    margin-top: 0.3rem;
}

.ck-post-toc-link {
    display: block;
    color: var(--text-secondary, #6c757d);
    text-decoration: none;
    padding: 0.2rem 0;
    line-height: 1.45;
    font-size: 0.95rem;
}

.ck-post-toc-link:hover {
    color: var(--color-primary, var(--primary-color, #0d6efd));
}

.ck-post-toc-link--h3 {
    padding-left: 0.9rem;
    font-size: 0.9rem;
}

.ck-post-toc-link--h4 {
    padding-left: 1.8rem;
    font-size: 0.85rem;
}

.ck-post-toc-native-hidden {
    display: none !important;
}

.ck-post-toc-content > :last-child {
    margin-bottom: 0;
}

.ck-post-toc-drawer {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1040;
    display: none;
}

.ck-post-toc-region--floating-left .ck-post-toc-drawer {
    left: 1rem;
    right: auto;
    display: block;
}

.ck-post-toc-region--floating-right .ck-post-toc-drawer {
    display: block;
}

.ck-post-toc-toggle {
    border: none;
    border-radius: 999px;
    background: var(--text-primary, #212529);
    color: white;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.ck-post-toc-toggle:hover {
    opacity: 0.95;
}

.ck-post-toc-panel {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    right: 0;
    width: var(--ck-post-toc-panel-width);
    max-height: min(60vh, 520px);
    overflow-y: auto;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 1rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
    padding: 1rem;
}

.ck-post-toc-region--floating-left .ck-post-toc-panel {
    left: 0;
    right: auto;
}

.ck-post-toc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.ck-post-toc-close {
    border: none;
    background: transparent;
    color: var(--text-secondary, #6c757d);
    font-size: 1rem;
    line-height: 1;
}

@media (min-width: 992px) {
    .ck-post-toc-region--left,
    .ck-post-toc-region--right {
        display: grid;
        gap: var(--ck-post-toc-gap);
        align-items: start;
    }

    .ck-post-toc-region--left {
        grid-template-columns: minmax(220px, var(--ck-post-toc-width)) minmax(0, 1fr);
    }

    .ck-post-toc-region--right {
        grid-template-columns: minmax(0, 1fr) minmax(220px, var(--ck-post-toc-width));
    }

    .ck-post-toc-region--right .ck-post-toc-desktop-wrap {
        order: 2;
        margin-bottom: 0;
    }

    .ck-post-toc-region--right .ck-post-toc-content {
        order: 1;
    }

    .ck-post-toc-region--left .ck-post-toc-desktop-wrap,
    .ck-post-toc-region--right .ck-post-toc-desktop-wrap {
        position: sticky;
        top: 6rem;
        margin-bottom: 0;
    }

    .ck-post-toc-region--inline .ck-post-toc-drawer {
        display: none !important;
    }

    .ck-post-toc-region--left .ck-post-toc-drawer,
    .ck-post-toc-region--right .ck-post-toc-drawer {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    .ck-post-toc-desktop-wrap {
        display: none !important;
    }

    .ck-post-toc-ready .ck-post-toc-drawer {
        display: block;
    }

    .ck-post-toc-panel {
        position: fixed;
        right: 1rem;
        left: auto;
        bottom: 4.75rem;
    }

    .ck-post-toc-region--floating-left .ck-post-toc-panel {
        left: 1rem;
        right: auto;
    }
}
