:root {
    color-scheme: light;
}

body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    color-scheme: dark;
    --color-bg: #191d19;
    --color-surface: #252b25;
    --color-primary: #d27b55;
    --color-primary-dark: #b6532d;
    --color-secondary: #91a087;
    --color-tertiary: #111511;
    --color-text: #f5f5f7;
    --color-muted: #a1a1aa;
    --color-on-primary: #18181b;
}

.text-on-dark-muted {
    color: var(--color-on-dark-muted);
}

.theme-switch {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 46px;
    height: 26px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.theme-switch-input {
    position: absolute;
    inset: 0;
    z-index: 4;
    width: 46px;
    height: 26px;
    opacity: 0;
    cursor: pointer;
}

.theme-switch-track {
    position: absolute;
    top: 2px;
    left: 0;
    display: block;
    width: 54px;
    height: 26px;
    overflow: hidden;
    border: 1px solid rgba(32, 37, 33, 0.28);
    border-radius: 999px;
    background: linear-gradient(110deg, #d0e7f3, #91c2de);
    transform: scale(0.85);
    transform-origin: top left;
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.2s ease;
}

.theme-switch-input:focus-visible + .theme-switch-track {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}

.mobile-menu-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
}

.theme-switch-orb {
    position: absolute;
    z-index: 3;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffe08a;
    box-shadow: 0 1px 5px rgba(48, 42, 24, 0.2);
    transition: transform 0.45s cubic-bezier(0.2, 0.75, 0.25, 1), background-color 0.4s ease;
}

.theme-switch-moon-mark {
    position: absolute;
    top: 4px;
    left: 5px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #e6edf2;
    opacity: 0;
    transform: translate(4px, -2px);
    content: '';
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-switch-moon-mark::after {
    position: absolute;
    top: -2px;
    left: 5px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #526379;
    content: '';
}

.theme-switch-cloud {
    position: absolute;
    z-index: 2;
    bottom: -5px;
    width: 26px;
    height: 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.theme-switch-cloud::before,
.theme-switch-cloud::after {
    position: absolute;
    bottom: 4px;
    border-radius: 50%;
    background: inherit;
    content: '';
}

.theme-switch-cloud::before {
    left: 6px;
    width: 14px;
    height: 14px;
}

.theme-switch-cloud::after {
    right: 4px;
    width: 18px;
    height: 18px;
}

.theme-switch-cloud-one {
    left: 25px;
}

.theme-switch-cloud-two {
    left: 38px;
    transform: scale(0.72);
}

.theme-switch-star {
    position: absolute;
    z-index: 1;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #fff;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-switch-star-one { top: 5px; left: 31px; }
.theme-switch-star-two { top: 15px; left: 42px; width: 2px; height: 2px; }
.theme-switch-star-three { top: 5px; left: 48px; width: 2px; height: 2px; }

body.dark-mode .theme-switch-track {
    border-color: rgba(232, 238, 246, 0.42);
    background: linear-gradient(110deg, #172238, #34425d);
}

body.dark-mode .theme-switch-orb {
    background: #f1f3f5;
    transform: translateX(26px);
}

body.dark-mode .theme-switch-moon-mark {
    opacity: 1;
    transform: translate(0, 0);
}

body.dark-mode .theme-switch-cloud {
    opacity: 0;
    transform: translateY(8px);
}

body.dark-mode .theme-switch-star {
    opacity: 1;
    transform: scale(1);
}

body.dark-mode .theme-switch-star-two { transition-delay: 80ms; }
body.dark-mode .theme-switch-star-three { transition-delay: 150ms; }

@media (prefers-reduced-motion: reduce) {
    body,
    .theme-switch-track,
    .theme-switch-orb,
    .theme-switch-cloud,
    .theme-switch-star {
        transition-duration: 0.01ms !important;
    }
}