/* ===== Modern Table of Contents ===== */
.post-toc-container {
    --toc-accent: #6366f1;
    --toc-bg: #ffffff;
    --toc-border: #e5e7eb;
    --toc-text: #1e293b;
    --toc-link: #475569;

    border: 1px solid var(--toc-border);
    border-radius: 14px;
    background: var(--toc-bg);
    margin: 1.75em 0;
    overflow: hidden;
    font-family: inherit;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.post-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--toc-accent), #818cf8);
    font-weight: 600;
    font-size: 1.05em;
    color: #ffffff;
    cursor: pointer;
    user-select: none;
}

.post-toc-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-toc-icon {
    font-size: 1.1em;
}

.post-toc-arrow {
    transition: transform 0.25s ease;
    font-size: 0.9em;
}

.post-toc-container.collapsed .post-toc-arrow {
    transform: rotate(-90deg);
}

.post-toc-list {
    list-style: none;
    margin: 0;
    padding: 14px 22px 18px 22px;
    max-height: 420px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.post-toc-container.collapsed .post-toc-list {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.post-toc-list li {
    margin: 4px 0;
    line-height: 1.5;
    border-left: 2px solid transparent;
    padding-left: 10px;
    transition: border-color 0.2s ease, background 0.2s ease;
    border-radius: 4px;
}

.post-toc-list li:hover {
    border-left-color: var(--toc-accent);
    background: #f5f5ff;
}

.post-toc-list a {
    text-decoration: none;
    color: var(--toc-link);
    font-size: 0.96em;
    display: block;
    padding: 4px 0;
}

.post-toc-list a:hover {
    color: var(--toc-accent);
}

.toc-level-3 {
    padding-left: 24px;
    font-size: 0.93em;
}

.toc-level-3 a::before {
    content: "—";
    margin-right: 6px;
    color: #cbd5e1;
}

.post-toc-list::-webkit-scrollbar {
    width: 6px;
}
.post-toc-list::-webkit-scrollbar-thumb {
    background: var(--toc-border);
    border-radius: 10px;
}

/* ===== Show/hide logic: sidebar (desktop) vs inline (mobile) ===== */

/* Hide the sidebar-widget TOC on mobile/tablet */
@media (max-width: 768px) {
    .post-toc-sidebar {
        display: none !important;
    }
    .post-toc-container {
        border-radius: 10px;
        margin: 1.25em 0;
    }
    .post-toc-header {
        padding: 13px 16px;
        font-size: 0.98em;
    }
    .post-toc-list {
        padding: 10px 16px 16px 16px;
        max-height: 320px;
    }
    .toc-level-3 {
        padding-left: 18px;
    }
}

/* Hide the inline (content-inserted) TOC on desktop */
@media (min-width: 769px) {
    .post-toc-inline {
        display: none !important;
    }
}