.nav #themeToggle.celestial-theme-switch {
    --toggle-width: 60px;
    --toggle-height: 34px;
    position: relative;
    display: inline-block;
    flex: 0 0 var(--toggle-width);
    width: var(--toggle-width);
    height: var(--toggle-height);
    min-width: var(--toggle-width);
    margin: 0;
    padding: 0;
    border: 0;
    cursor: pointer;
    isolation: isolate;
}

.nav #themeToggle::before,
.nav #themeToggle::after {
    content: none !important;
}

.celestial-theme-switch__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.celestial-theme-switch__track {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border: 1px solid rgba(125, 184, 225, 0.62);
    border-radius: 999px;
    background: linear-gradient(180deg, #72cfff 0%, #2999ed 100%);
    box-shadow: inset 0 -7px 12px rgba(0, 87, 170, 0.18), 0 8px 20px rgba(35, 127, 194, 0.18);
    transition: background 420ms ease, border-color 420ms ease, box-shadow 420ms ease;
}

.celestial-theme-switch__orb {
    position: absolute;
    left: 4px;
    bottom: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffd94f;
    box-shadow: 0 0 12px rgba(255, 222, 83, 0.85);
    transition: transform 430ms cubic-bezier(0.22, 1, 0.36, 1), background 420ms ease, box-shadow 420ms ease;
    z-index: 3;
}

.celestial-theme-switch__ray,
.celestial-theme-switch__crater,
.celestial-theme-switch__star,
.celestial-theme-switch__cloud {
    position: absolute;
    display: block;
    border-radius: 50%;
}

.celestial-theme-switch__ray {
    inset: 50%;
    border: 1px solid rgba(255, 255, 255, 0.36);
    transform: translate(-50%, -50%);
    transition: opacity 320ms ease;
}

.celestial-theme-switch__ray--one { width: 36px; height: 36px; }
.celestial-theme-switch__ray--two { width: 46px; height: 46px; opacity: 0.58; }
.celestial-theme-switch__ray--three { width: 56px; height: 56px; opacity: 0.32; }

.celestial-theme-switch__crater {
    opacity: 0;
    background: #aab5c2;
    transition: opacity 320ms ease;
}

.celestial-theme-switch__crater--one { width: 6px; height: 6px; left: 10px; top: 4px; }
.celestial-theme-switch__crater--two { width: 9px; height: 9px; left: 4px; top: 11px; }
.celestial-theme-switch__crater--three { width: 4px; height: 4px; right: 6px; bottom: 4px; }

.celestial-theme-switch__stars {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 360ms ease, transform 420ms ease;
}

.celestial-theme-switch__star {
    width: 3px;
    height: 3px;
    background: #fff;
    box-shadow: 0 0 5px #fff;
    animation: cecil-star-twinkle 2s ease-in-out infinite;
}

.celestial-theme-switch__star--one { left: 7px; top: 7px; }
.celestial-theme-switch__star--two { left: 18px; top: 18px; width: 2px; height: 2px; animation-delay: 0.5s; }
.celestial-theme-switch__star--three { left: 28px; top: 6px; width: 4px; height: 4px; animation-delay: 1s; }
.celestial-theme-switch__star--four { left: 9px; bottom: 6px; width: 2px; height: 2px; animation-delay: 1.4s; }

.celestial-theme-switch__cloud {
    right: -5px;
    bottom: 3px;
    background: rgba(248, 252, 255, 0.82);
    transition: transform 420ms ease, opacity 320ms ease;
    animation: cecil-cloud-drift 5s ease-in-out infinite;
}

.celestial-theme-switch__cloud--one { width: 28px; height: 12px; }
.celestial-theme-switch__cloud--two { width: 17px; height: 17px; right: 4px; bottom: 5px; animation-delay: 0.6s; }
.celestial-theme-switch__cloud--three { width: 14px; height: 14px; right: 18px; bottom: 2px; animation-delay: 1.1s; }

.celestial-theme-switch__input:checked + .celestial-theme-switch__track {
    border-color: rgba(103, 137, 196, 0.58);
    background: linear-gradient(180deg, #10182e 0%, #050914 100%);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.66), 0 8px 22px rgba(0, 18, 42, 0.3);
}

.celestial-theme-switch__input:checked + .celestial-theme-switch__track .celestial-theme-switch__orb {
    transform: translateX(26px) rotate(180deg);
    background: #f5f7fb;
    box-shadow: 0 0 10px rgba(220, 234, 255, 0.78);
}

.celestial-theme-switch__input:checked + .celestial-theme-switch__track .celestial-theme-switch__crater { opacity: 1; }
.celestial-theme-switch__input:checked + .celestial-theme-switch__track .celestial-theme-switch__ray { opacity: 0; }
.celestial-theme-switch__input:checked + .celestial-theme-switch__track .celestial-theme-switch__stars { opacity: 1; transform: translateY(0); }
.celestial-theme-switch__input:checked + .celestial-theme-switch__track .celestial-theme-switch__cloud { opacity: 0; transform: translateX(16px); }

.celestial-theme-switch__input:focus-visible + .celestial-theme-switch__track,
.nav #themeToggle:hover .celestial-theme-switch__track {
    border-color: rgba(64, 198, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(22, 140, 245, 0.16), 0 0 18px rgba(64, 198, 255, 0.25);
}

@keyframes cecil-cloud-drift {
    50% { transform: translateX(-3px); }
}

@keyframes cecil-star-twinkle {
    50% { opacity: 0.45; transform: scale(0.72); }
}

@media (max-width: 900px) {
    .nav #themeToggle.celestial-theme-switch {
        display: block;
        flex: 0 0 auto;
        width: var(--toggle-width) !important;
        min-width: var(--toggle-width) !important;
        min-height: var(--toggle-height) !important;
        height: var(--toggle-height) !important;
        margin: 0.25rem auto;
        padding: 0 !important;
        border-radius: 999px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .celestial-theme-switch__orb,
    .celestial-theme-switch__track,
    .celestial-theme-switch__stars,
    .celestial-theme-switch__cloud,
    .celestial-theme-switch__star { transition: none; animation: none; }
}
