.toc-wrapper {
    font-family: 'Anek Bangla', sans-serif;
    font-size: 1.1rem;
    word-spacing: 0.5em;
    letter-spacing: 0.05em;
    line-height: 1.8;
    background-color: #f8f9fa;
    border: 2px solid #2d2d2d;
    border-radius: 1rem;
    margin: 0.5rem 0 1rem;
    box-shadow: 0 4px 6px rgba(26, 26, 26, 0.1);
    overflow: hidden;
}

.toc-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 2px solid #4a4a4a;
    background-color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toc-title {
    color: rgb(0, 0, 0);
    font-weight: 600;
    font-size: 1.1rem;
}

.toc-content {
    padding: 1rem;
    transition: height 0.3s ease-in-out;
    max-height: 1000px;
    overflow: hidden;
    position: relative; /* allow fade overlays */
    opacity: 1;
}

.toc-content.collapsed {
    height: 0;
    overflow: hidden;
    padding: 0;
}

.toc-content.expanded {
    height: auto;
    padding: 0.5rem 0;
}

.toc-list {
    display: block; /* single column by default */
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Visible scrollbar styling */
.toc-content {
    scrollbar-width: thin;                 /* Firefox */
    scrollbar-color: rgba(0,0,0,0.35) transparent;
}
.toc-content::-webkit-scrollbar {          /* WebKit */
    width: 8px;
}
.toc-content::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.35);
    border-radius: 9999px;
}
.toc-content::-webkit-scrollbar-track {
    background: transparent;
}
/* Hide WebKit scrollbar arrows */
.toc-content::-webkit-scrollbar-button {
    width: 0;
    height: 0;
    display: none;
}

/* Bottom/Top fade indicators to hint scrollability */
.toc-content::after,
.toc-content::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 24px;
    pointer-events: none;
    display: none; /* shown via state classes */
}
.toc-content.has-more:not(.at-bottom)::after {
    display: block;
    bottom: 0;
    /* match wrapper bg (#f8f9fa) to blend */
    background: linear-gradient(to bottom, rgba(248,249,250,0), #f8f9fa);
}
.toc-content.has-more:not(.at-top)::before {
    display: block;
    top: 0;
    background: linear-gradient(to top, rgba(248,249,250,0), #f8f9fa);
}

.toc-column {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #4a4a4a;
}

.toc-h2 > a, .toc-h3 > a {
    display: block;
    padding: 0.375rem 0.625rem;
    color: #1a1a1a;
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    margin-bottom: 0.25rem;
}

.toc-h2 > a {
    font-weight: 500;
    background-color: rgba(74, 74, 74, 0.1);
    margin-bottom: 0.75rem;
}

.toc-h3 > a {
    font-size: 1rem;
    color: #2d2d2d;
    margin: 0.25rem 0;
    line-height: 1.8;

}

/* Hover states */
.toc-h2 > a:hover, .toc-h3 > a:hover {
    background-color: #2d2d2d;
    color: white;
    transform: translateX(5px);
    box-shadow: 0 2px 4px rgba(26, 26, 26, 0.2);
}

.toc-h2 > a:hover::before, .toc-h3 > a:hover::before {
    background-color: white;
    opacity: 1;
}

/* Active states */
.toc-h2 > a.active, .toc-h3 > a.active {
    background-color: #1a1a1a;
    color: white;
    border: 1px solid #1a1a1a;
    box-shadow: 0 2px 4px rgba(26, 26, 26, 0.2);
}

/* Dot indicators */
.toc-h2 > a::before, .toc-h3 > a::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #4a4a4a;
    border-radius: 50%;
    margin-right: 8px;
    transition: all 0.2s ease;
    opacity: 0.7;
}

/* Active dot indicators */
.toc-h2 > a.active::before, .toc-h3 > a.active::before {
    background-color: white;
    opacity: 1;
}

/* Mobile styles */
@media (max-width: 768px) {
    .toc-list {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .toc-column {
        background-color: transparent;
        padding: 0;
        border: none;
        border-radius: 0;
    }

    .toc-content.collapsed {
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        opacity: 0;
    }

    .toc-content.expanded {
        max-height: 1000px;
        padding: 1rem;
        opacity: 1;
    }

    .toc-wrapper {
        margin: 0.5rem -0.5rem;
    }

    .toc-content.expanded {
        padding: 0.25rem 1rem;
    }

    .toc-h2 > a {
        padding: 0.25rem 0.5rem;
    }

    .toc-h3 > a {
        padding: 0.125rem 0.375rem;
    }
}

/* Toggle button */
.toc-toggle {
    color: #2d2d2d;
    transition: transform 0.3s ease-in-out;
}

.toc-toggle.rotated {
    transform: rotate(180deg);
}

.toc-sub-list {
    list-style: none;
    padding-left: 1.25rem;
    margin-top: 0.25rem;
    border-left: 2px solid #4a4a4a;
} 

/* Force-remove scrollbar arrows and fade overlays */
.toc-content::-webkit-scrollbar-button,
.toc-content::-webkit-scrollbar-button:single-button,
.toc-content::-webkit-scrollbar-button:increment,
.toc-content::-webkit-scrollbar-button:decrement {
    width: 0;
    height: 0;
    display: none;
}
.toc-content::before,
.toc-content::after {
    display: none !important;
}

/* Extra WebKit variants (Safari/Chrome) to hide any arrow buttons */
.toc-content::-webkit-scrollbar-button:start:decrement,
.toc-content::-webkit-scrollbar-button:end:increment,
.toc-content::-webkit-scrollbar-button:vertical:increment,
.toc-content::-webkit-scrollbar-button:vertical:decrement,
.toc-content::-webkit-scrollbar-button:single-button:start:decrement,
.toc-content::-webkit-scrollbar-button:single-button:end:increment,
.toc-content::-webkit-scrollbar-button:single-button:vertical:increment,
.toc-content::-webkit-scrollbar-button:single-button:vertical:decrement {
    display: none;
    width: 0;
    height: 0;
}