/* --- TOC Layout & Styles --- */
.post-layout-container {
    display: grid;
    grid-template-columns: 2fr 6fr 2fr;
    gap: 30px;
    position: relative;
    align-items: start;
}

.toc-sidebar,
.related-sidebar {
    height: 100%;
}

.toc-widget,
.related-widget {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    transition: all 0.3s ease;
}

.related-widget h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.related-post-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.related-post-card:last-child {
    margin-bottom: 0;
}

.related-post-thumb img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
}

.related-post-title {
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0;
}

.related-post-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.related-post-title a:hover {
    color: var(--accent-primary);
}

.related-post-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.toc-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
}

.toc-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}

.toc-list::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: var(--border-color);
}

.toc-item {
    padding-left: 15px;
    margin-bottom: 10px;
    position: relative;
}

.toc-item.toc-h3 {
    padding-left: 30px;
}

.toc-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    display: block;
    transition: color 0.2s, padding-left 0.2s;
}

.toc-link:hover {
    color: var(--accent-primary);
}

.toc-link.active {
    color: var(--accent-primary);
    font-weight: 600;
}

.toc-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background 0.2s;
}

.toc-link.active::after {
    content: '';
    position: absolute;
    left: -2px;
    top: 6px;
    height: calc(100% - 12px);
    width: 2px;
    background: var(--accent-primary);
    border-radius: 2px;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 991px) {
    .post-layout-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .toc-sidebar {
        order: 1;
    }

    .post-main-column {
        order: 2;
    }

    .related-sidebar {
        order: 3;
    }

    .toc-widget {
        position: relative;
        top: 0;
        max-height: none;
        overflow: visible;
    }

    .related-widget {
        position: relative;
        top: 0;
    }

    .toc-toggle {
        display: block;
    }

    .toc-list {
        display: none;
        margin-top: 15px;
        padding-left: 10px;
    }

    .toc-widget.expanded .toc-list {
        display: block;
    }

    .toc-list::before {
        display: none;
    }

    .toc-item {
        border-left: 2px solid var(--border-color);
    }

    .toc-link.active::after {
        left: -2px;
    }
}
