.theme-toggle {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 64px;
    height: 34px;
    border-radius: 999px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    font-size: 0;
    transition: var(--transition);
    z-index: 100;
}

/* When toggle is moved into header controls */
.theme-toggle.in-header {
    position: static;
    width: 64px;
    height: 34px;
    box-shadow: none;
    margin-right: 0;
    bottom: auto;
    right: auto;
}

/* Inner track */
.theme-toggle-track {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

/* Thumb */
.theme-toggle-thumb {
    position: absolute;
    top: 50%;
    left: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface-0);
    transform: translateY(-50%);
    transition: transform 0.25s ease, background 0.25s ease;
}

/* Icons */
.theme-toggle-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text);
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.25s ease;
    width: 18px;
    height: 18px;
}

.theme-toggle-icon--sun {
    left: 8px;
}

.theme-toggle-icon--moon {
    right: 8px;
}

.theme-toggle-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: currentColor;
}

/* Light theme visuals */
[data-theme="light"] .theme-toggle {
    background: var(--surface-3);
}

[data-theme="light"] .theme-toggle-thumb {
    background: var(--surface-1);
    transform: translate(0, -50%);
}

[data-theme="light"] .theme-toggle-icon--sun {
    opacity: 1;
}

[data-theme="light"] .theme-toggle-icon--moon {
    opacity: 0.1;
}

/* Dark theme visuals */
[data-theme="dark"] .theme-toggle {
    background: var(--surface-3);
}

[data-theme="dark"] .theme-toggle-thumb {
    background: var(--surface-1);
    transform: translate(26px, -50%);
}

[data-theme="dark"] .theme-toggle-icon--sun {
    opacity: 0.1;
}

[data-theme="dark"] .theme-toggle-icon--moon {
    opacity: 1;
}

/* Base ring */
.theme-toggle-icon::after {
    content: "";
    position: absolute;
    width: 26px;                 
    height: 26px;                
    border-radius: 50%;
    border: 1px solid transparent;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition: border-color 0.25s ease;
}

/* Light mode → sun active */
[data-theme="light"] .theme-toggle-icon--sun::after {
    border-color: var(--border-color);
}

/* Dark mode → moon active */
[data-theme="dark"] .theme-toggle-icon--moon::after {
    border-color: var(--border-color);
}
