.advanced-toc-container {
    position: relative;
    margin: 30px 0;
    background: linear-gradient(135deg, #6B46C1 0%, #9333EA 50%, #C026D3 100%);
    border-radius: 16px;
    padding: 2px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(107, 70, 193, 0.2);
}

.advanced-toc-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #8B5CF6, #EC4899, #F59E0B);
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.advanced-toc-container:hover::before {
    opacity: 0.1;
}

.advanced-toc-container.sticky {
    position: fixed !important;
    top: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 92% !important;
    max-width: 900px !important;
    z-index: 9999 !important;
    margin: 0 !important;
    box-shadow: 
        0 20px 60px rgba(107, 70, 193, 0.4),
        0 8px 16px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    background: linear-gradient(135deg, 
        rgba(107, 70, 193, 0.95) 0%, 
        rgba(147, 51, 234, 0.95) 50%, 
        rgba(192, 38, 211, 0.95) 100%) !important;
}

.advanced-toc-wrapper {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 14px;
    padding: 18px 24px;
    position: relative;
    overflow: hidden;
}

.advanced-toc-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.4), 
        transparent);
    transition: left 0.5s ease;
}

.advanced-toc-container:hover .advanced-toc-wrapper::before {
    left: 100%;
}

.advanced-toc-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 8px 4px;
    position: relative;
}

.advanced-toc-nav::-webkit-scrollbar {
    display: none;
}

.advanced-toc-item {
    flex-shrink: 0;
    padding: 12px 20px;
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    color: #475569;
    text-decoration: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    border: 2px solid #E2E8F0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    min-width: 80px;
    text-align: center;
    letter-spacing: 0.025em;
}

.advanced-toc-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #6B46C1, #9333EA, #C026D3);
    transition: left 0.3s ease;
    z-index: -1;
}

.advanced-toc-item:hover::before,
.advanced-toc-item.active::before {
    left: 0;
}

.advanced-toc-item:hover {
    color: white;
    border-color: #9333EA;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        0 12px 24px rgba(107, 70, 193, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}

.advanced-toc-item.active {
    color: white;
    border-color: #C026D3;
    box-shadow: 
        0 8px 32px rgba(192, 38, 211, 0.4),
        0 4px 16px rgba(107, 70, 193, 0.3);
    transform: translateY(-2px);
}

.advanced-toc-item:focus {
    outline: none;
    box-shadow: 
        0 0 0 3px rgba(147, 51, 234, 0.4),
        0 8px 16px rgba(107, 70, 193, 0.2);
}
.advanced-toc-container.sticky {
    animation: slideInSticky 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInSticky {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}
.advanced-toc-item.active {
    animation: activePulse 2s ease-in-out infinite;
}

@keyframes activePulse {
    0%, 100% {
        box-shadow: 
            0 8px 32px rgba(192, 38, 211, 0.4),
            0 4px 16px rgba(107, 70, 193, 0.3);
    }
    50% {
        box-shadow: 
            0 12px 40px rgba(192, 38, 211, 0.6),
            0 6px 20px rgba(107, 70, 193, 0.4);
    }
}

.advanced-toc-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #10B981, #3B82F6, #8B5CF6);
    border-radius: 0 0 14px 14px;
    transition: width 0.3s ease;
    width: var(--progress, 0%);
}

@media (max-width: 768px) {
    .advanced-toc-container.sticky {
        width: 96% !important;
        top: 15px !important;
        max-width: none !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        margin: 0 !important;
    }
    
    .advanced-toc-wrapper {
        padding: 14px 18px;
    }
    
    .advanced-toc-item {
        padding: 10px 16px;
        font-size: 14px;
        min-width: 70px;
        font-weight: 500;
    }
    
    .advanced-toc-nav {
        gap: 6px;
        padding: 6px 2px;
    }
}

@media (max-width: 480px) {
    .advanced-toc-container.sticky {
        width: 98% !important;
        top: 10px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        margin: 0 !important;
    }
    
    .advanced-toc-wrapper {
        padding: 12px 15px;
    }
    
    .advanced-toc-item {
        padding: 8px 14px;
        font-size: 13px;
        min-width: 60px;
        border-width: 1px;
    }
    
    .advanced-toc-nav {
        gap: 4px;
        padding: 4px 0;
    }
}

.advanced-toc-nav.scrolling {
    scroll-behavior: smooth;
}

@media (prefers-color-scheme: dark) {
    .advanced-toc-wrapper {
        background: rgba(15, 23, 42, 0.95);
    }
    
    .advanced-toc-item {
        background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
        color: #CBD5E1;
        border-color: #475569;
    }
    
    .advanced-toc-item:hover,
    .advanced-toc-item.active {
        color: white;
    }
}

.advanced-toc-item:focus-visible {
    outline: 3px solid #F59E0B;
    outline-offset: 2px;
}

.advanced-toc-container.loading .advanced-toc-item {
    animation: loadingShimmer 1.5s ease-in-out infinite;
}

@keyframes loadingShimmer {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.advanced-toc-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(107, 70, 193, 0.3);
}