/* === Floating Island Navigation / Ethereal Glass === */
.toc-compact {
    position: fixed;
    top: var(--space-6);
    left: 50%;
    z-index: 100;
    width: min(calc(100vw - 11rem), 860px);
    max-width: none;
    padding: 4px;
    color: var(--color-text);
    background: rgba(7, 8, 12, 0.68);
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-2xl);
    box-shadow:
        0 18px 54px rgba(0, 0, 0, 0.28),
        inset 0 1px 1px rgba(255, 255, 255, 0.09);
    backdrop-filter: blur(26px) saturate(145%);
    -webkit-backdrop-filter: blur(26px) saturate(145%);
    transform: translateX(-50%);
    transition:
        border-color 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.toc-compact:hover {
    background-color: rgba(7, 8, 12, 0.78);
    border-color: rgba(139, 163, 255, 0.26);
    box-shadow:
        0 22px 64px rgba(0, 0, 0, 0.34),
        0 0 30px rgba(106, 130, 251, 0.08),
        inset 0 1px 1px rgba(255, 255, 255, 0.11);
}

.toc-shell {
    display: grid;
    grid-template-columns: 156px minmax(0, 1fr);
    align-items: stretch;
    min-height: 58px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.018);
    border-radius: calc(var(--radius-2xl) - 4px);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.035);
}

.toc-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    padding: var(--space-3) var(--space-4);
    color: var(--color-text);
    text-decoration: none;
    border-right: 0.5px solid rgba(255, 255, 255, 0.08);
}

.toc-brand-mark {
    flex: 0 0 auto;
    color: var(--color-primary-light);
    font-size: 0.9rem;
    filter: drop-shadow(0 0 9px rgba(139, 163, 255, 0.6));
    transition: color 0.35s cubic-bezier(0.22, 1, 0.36, 1), transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toc-brand:hover .toc-brand-mark {
    color: var(--color-accent-1);
    transform: rotate(18deg) scale(1.1);
}

.toc-brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}

.toc-brand-text {
    overflow: hidden;
    color: var(--color-text);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toc-brand-sub {
    color: var(--color-text-tertiary);
    font-family: var(--font-body);
    font-size: 0.56rem;
    font-weight: 500;
    letter-spacing: 0.13em;
    line-height: 1;
    white-space: nowrap;
}

.toc-links {
    display: flex;
    align-items: stretch;
    gap: 2px;
    min-width: 0;
    margin: 0;
    padding: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    list-style: none;
}

.toc-links::-webkit-scrollbar {
    display: none;
}

.toc-links li {
    flex: 0 0 104px;
}

.toc-links a {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    min-height: 48px;
    padding: 0 var(--space-2);
    overflow: hidden;
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: var(--radius-md);
    transition:
        color 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toc-links a::after {
    content: '';
    position: absolute;
    right: 22%;
    bottom: 4px;
    left: 22%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-primary-light), transparent);
    border-radius: var(--radius-full);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toc-links a:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.055);
    transform: translateY(-1px);
}

.toc-links a.active {
    color: var(--color-primary-light);
    background: rgba(106, 130, 251, 0.11);
}

.toc-links a:hover::after,
.toc-links a.active::after {
    transform: scaleX(1);
}

.toc-links a:focus-visible,
.toc-brand:focus-visible,
.toc-menu-toggle:focus-visible,
.toc-menu-close:focus-visible,
.toc-mobile-links a:focus-visible {
    outline: 2px solid var(--color-primary-light);
    outline-offset: 3px;
}

.toc-menu-toggle,
.toc-mobile-menu {
    display: none;
}

.light-theme .toc-compact {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(0, 0, 0, 0.09);
    box-shadow:
        0 18px 54px rgba(34, 38, 60, 0.13),
        inset 0 1px 1px rgba(255, 255, 255, 0.9);
}

.light-theme .toc-compact:hover {
    background: rgba(255, 255, 255, 0.86);
    border-color: rgba(106, 130, 251, 0.22);
}

.light-theme .toc-shell {
    background: rgba(0, 0, 0, 0.018);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.85);
}

.light-theme .toc-brand {
    border-color: rgba(0, 0, 0, 0.07);
}

.light-theme .toc-links a:hover {
    background: rgba(0, 0, 0, 0.045);
}

/* 仅手机端折叠；电脑端始终保持单行导航。 */
@media (max-width: 768px) {
    .toc-compact {
        top: var(--space-4);
        left: var(--space-4);
        width: auto;
        min-width: 190px;
        max-width: calc(100vw - 7rem);
        transform: none;
    }

    .toc-shell {
        display: flex;
        min-height: 48px;
    }

    .toc-brand {
        flex: 1;
        border-right: none;
    }

    .toc-links {
        display: none;
    }

    .toc-menu-toggle {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 38px;
        width: 38px;
        height: 38px;
        margin: 5px;
        padding: 0;
        cursor: pointer;
        background: rgba(255, 255, 255, 0.05);
        border: 0.5px solid rgba(255, 255, 255, 0.08);
        border-radius: 50%;
    }

    .toc-menu-toggle span {
        position: absolute;
        width: 15px;
        height: 1.5px;
        background: var(--color-text-secondary);
        border-radius: var(--radius-full);
        transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1), background-color 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .toc-menu-toggle span:first-child {
        transform: translateY(-4px);
    }

    .toc-menu-toggle span:last-child {
        transform: translateY(4px);
    }

    .toc-menu-toggle[aria-expanded="true"] span:first-child {
        transform: rotate(45deg);
    }

    .toc-menu-toggle[aria-expanded="true"] span:last-child {
        transform: rotate(-45deg);
    }

    .toc-mobile-menu {
        position: fixed;
        inset: 0;
        z-index: 90;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: var(--space-8);
        visibility: hidden;
        background: rgba(5, 5, 8, 0.92);
        opacity: 0;
        pointer-events: none;
        backdrop-filter: blur(34px) saturate(140%);
        -webkit-backdrop-filter: blur(34px) saturate(140%);
        transform: translateY(-16px);
        transition:
            opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
            visibility 0.55s cubic-bezier(0.22, 1, 0.36, 1),
            transform 0.65s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .toc-mobile-menu.is-open {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    .toc-menu-close {
        position: absolute;
        top: var(--space-6);
        right: var(--space-6);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        padding: 0;
        color: var(--color-text-secondary);
        font-family: var(--font-body);
        font-size: 1.5rem;
        font-weight: 300;
        cursor: pointer;
        background: rgba(255, 255, 255, 0.05);
        border: 0.5px solid rgba(255, 255, 255, 0.09);
        border-radius: 50%;
        transition: color 0.35s cubic-bezier(0.22, 1, 0.36, 1), transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    }

    .toc-menu-close:hover {
        color: var(--color-text);
        background: rgba(255, 255, 255, 0.09);
        transform: rotate(90deg);
    }

    .toc-mobile-eyebrow {
        margin-bottom: var(--space-8);
        color: var(--color-primary-light);
        font-family: var(--font-body);
        font-size: var(--text-xs);
        font-weight: 600;
        letter-spacing: 0.2em;
    }

    .toc-mobile-links {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    .toc-mobile-links a {
        display: inline-flex;
        align-items: baseline;
        gap: var(--space-4);
        color: var(--color-text-secondary);
        font-family: var(--font-display);
        font-size: clamp(1.8rem, 7vw, 3rem);
        font-weight: 600;
        letter-spacing: -0.03em;
        line-height: 1.15;
        text-decoration: none;
        opacity: 0;
        transform: translateY(28px);
        transition:
            color 0.35s cubic-bezier(0.22, 1, 0.36, 1),
            opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
            transform 0.65s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .toc-mobile-menu.is-open .toc-mobile-links a {
        opacity: 1;
        transform: translateY(0);
    }

    .toc-mobile-menu.is-open .toc-mobile-links a:nth-child(1) { transition-delay: 0.08s; }
    .toc-mobile-menu.is-open .toc-mobile-links a:nth-child(2) { transition-delay: 0.13s; }
    .toc-mobile-menu.is-open .toc-mobile-links a:nth-child(3) { transition-delay: 0.18s; }
    .toc-mobile-menu.is-open .toc-mobile-links a:nth-child(4) { transition-delay: 0.23s; }
    .toc-mobile-menu.is-open .toc-mobile-links a:nth-child(5) { transition-delay: 0.28s; }
    .toc-mobile-menu.is-open .toc-mobile-links a:nth-child(6) { transition-delay: 0.33s; }

    .toc-mobile-links a span {
        color: var(--color-primary-light);
        font-family: var(--font-body);
        font-size: var(--text-xs);
        font-weight: 600;
        letter-spacing: 0.14em;
    }

    .toc-mobile-links a:hover,
    .toc-mobile-links a.active {
        color: var(--color-text);
    }

    .toc-mobile-links a.active span {
        color: var(--color-accent-1);
    }

    body.toc-menu-open {
        overflow: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toc-compact,
    .toc-brand-mark,
    .toc-links a,
    .toc-links a::after,
    .toc-menu-toggle span,
    .toc-mobile-menu,
    .toc-mobile-links a,
    .toc-menu-close {
        transition: none;
    }
}
