/* ===== Floating TOC Button & Panel ===== */
.toc-float-button {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--border-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    color: var(--color-text-secondary);
    transition: all var(--transition-base);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
}

.toc-float-button.visible {
    opacity: 1;
    visibility: visible;
}

.toc-float-button:hover {
    background: var(--color-accent);
    color: white;
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

.toc-float-button.active {
    background: var(--color-accent);
    color: white;
}

.toc-panel {
    position: fixed;
    bottom: 7.5rem;
    right: 2rem;
    width: 280px;
    max-height: 60vh;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(20px);
    transform-origin: bottom right;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toc-panel.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.toc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-light);
}

.toc-panel-title {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
}

.toc-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-tertiary);
    padding: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.toc-panel-close:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.toc-panel-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    font-size: var(--font-size-xs);
}

.toc-panel-nav ul {
    list-style: none;
    padding-left: 0;
    counter-reset: toc-counter;
}

.toc-panel-nav ul ul {
    padding-left: var(--spacing-md);
    margin-top: var(--spacing-xs);
    counter-reset: toc-counter;
}

.toc-panel-nav li {
    margin-bottom: var(--spacing-xs);
    counter-increment: toc-counter;
    border-radius: var(--border-radius-sm);
}

.toc-panel-nav a {
    display: block;
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    color: var(--color-text-secondary);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    border-left: 2px solid transparent;
    position: relative;
}

.toc-panel-nav a::before {
    content: counters(toc-counter, ".") ". ";
    color: var(--color-text-tertiary);
    font-weight: 500;
    margin-right: var(--spacing-xs);
}

.toc-panel-nav a:hover {
    color: var(--color-accent);
    background: rgba(0, 122, 255, 0.06);
    border-left-color: var(--color-accent);
}

.toc-panel-nav a:hover::before {
    color: var(--color-accent);
}

.toc-panel-nav a.active {
    color: var(--color-accent);
    background: rgba(0, 122, 255, 0.12);
    font-weight: 500;
    border-left-color: var(--color-accent);
}

.toc-panel-nav a.active::before {
    color: var(--color-accent);
    font-weight: 600;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .toc-panel {
        right: 5%;
        width: 90%;
        max-width: 320px;
    }
    
    .toc-panel.active {
        right: 5%;
    }
    
    .toc-float-button {
        bottom: 70px;
        right: 1rem;
    }
}
