.pf-dark-mode-wrapper {
    display: inline-block;
}

/* Ensure the span icons align correctly with the labels */
.pf-dark-mode-wrapper .material-symbols-rounded {
    font-size: 16px;
    vertical-align: middle;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.pf-dark-mode-wrapper .toggle-group {
    border: 1px solid #FFFFFF;
    border-radius: 39px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    gap: 4px; /* Added 4px gap between icons */
    max-width: max-content;
    background-color: transparent;
    position: relative; /* Added to contain the sliding circle */
    z-index: 1;
}

/* 1. COMPLETELY HIDE NATIVE RADIO BUTTONS AND THEME INJECTIONS */
.pf-dark-mode-wrapper input[type="radio"],
.pf-dark-mode-wrapper .ttr_radio {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    pointer-events: none !important;
}

/* 2. THE NEW SLIDING CIRCLE ANIMATION */
.pf-dark-mode-wrapper .toggle-group::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 5px;
    width: 26px; /* 16px icon + 10px label padding */
    height: 26px;
    background-color: #FFFFFF;
    border-radius: 50%;
    z-index: -1; /* Keeps the circle behind the white icons */
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); /* Smooth slide effect */
}

/* Slide the circle left, center, or right based on which radio is checked. Math includes the new 4px gap. */
.pf-dark-mode-wrapper .toggle-group:has(#pf_light:checked)::before {
    transform: translateX(0);
}
.pf-dark-mode-wrapper .toggle-group:has(#pf_auto:checked)::before {
    transform: translateX(calc(100% + 4px)); /* Moves 1 position right + 1 gap */
}
.pf-dark-mode-wrapper .toggle-group:has(#pf_dark:checked)::before {
    transform: translateX(calc(200% + 8px)); /* Moves 2 positions right + 2 gaps */
}

/* 3. Style our icon labels (Default state: #FFFFFF) */
.pf-dark-mode-wrapper .toggle-group label[for^="pf_"] {
    cursor: pointer;
    padding: 5px 5px;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0 !important;
    color: #FFFFFF;
}

/* 4. Keep the active text color #662D91 to stand out against the orange circle */
.pf-dark-mode-wrapper .toggle-group:has(#pf_light:checked) label[for="pf_light"],
.pf-dark-mode-wrapper .toggle-group:has(#pf_auto:checked) label[for="pf_auto"],
.pf-dark-mode-wrapper .toggle-group:has(#pf_dark:checked) label[for="pf_dark"] {
    color: #662D91 !important;
}