 1; i >= 0; i--) {
                const heading = headings[i];
                const rect = heading.getBoundingClientRect();

                if (rect.top <= 100) {
                    // 移除所有活动状态
                    tocLinks.forEach(link => link.classList.remove('active'));
                    
                    // 高亮当前标题
                    const activeLink = document.querySelector(`.toc-nav a[href="#${heading.id}"]`);
                    if (activeLink) {
                  