

.switch {
    position: fixed;
    top: 20px;
    right: 20px;
    overflow: hidden;
    width: 7.5rem;
    height: 4rem;
    z-index: 1000;
}

.switch input {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

.switch label {
    cursor: pointer;
}

.background {
    z-index: 1;
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 2.5rem;
    border: 0.25rem solid #202020;
    background: linear-gradient(to right, #484848 0%, #202020 100%);
    transition: all 0.3s;
}

.stars1,
.stars2 {
    position: absolute;
    height: 0.4rem;
    width: 0.4rem;
    background: #FFFFFF;
    border-radius: 50%;
    transition: 0.3s all ease;
}

.stars1 {
    top: 6px;
    right: 23px;
}

.stars2 {
    top: 40px;
    right: 48px;
}

.stars1:after,
.stars1:before,
.stars2:after,
.stars2:before {
    position: absolute;
    content: "";
    display: block;
    height: 0.25rem;
    width: 0.25rem;
    background: #FFFFFF;
    border-radius: 50%;
    transition: 0.2s all ease;
}

.stars1:after {
    top: 8px;
    right: 20px;
}

.stars1:before {
    top: 18px;
    right: -12px;
}

.stars2:after {
    top: -8px;
    right: -16px;
}

.stars2:before {
    top: 6px;
    right: -26px;
}

.sun-moon {
    z-index: 2;
    position: absolute;
    left: 0;
    display: inline-block;
    height: 3rem;
    width: 3rem;
    margin: 0.5rem;
    background: #FFFDF2;
    border-radius: 50%;
    transition: all 0.5s ease;
    border: 0.25rem solid #DEE2C6;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.sun-moon .dots {
    position: absolute;
    top: 3px;
    left: 23px;
    height: 1rem;
    width: 1rem;
    background: #EFEEDB;
    border: 0.25rem solid #DEE2C6;
    border-radius: 50%;
    transition: 0.4s all ease;
}

.sun-moon .dots:after,
.sun-moon .dots:before {
    position: absolute;
    content: "";
    display: block;
    height: 0.25rem;
    width: 0.25rem;
    background: #EFEEDB;
    border: 0.25rem solid #DEE2C6;
    border-radius: 50%;
    transition: 0.4s all ease;
}

.sun-moon .dots:after {
    top: -4px;
    left: -26px;
}

.sun-moon .dots:before {
    top: 18px;
    left: -10px;
}

.switch input:checked~.sun-moon {
    left: calc(100% - 4rem);
    background: #F5EC59;
    border-color: #E7C65C;
    transform: rotate(-25deg);
    box-shadow: 0 0 10px #F5EC59, 0 0 15px #F5EC59, 0 0 20px #F5EC59;
    border-radius: 50%;
}

.switch input:checked~.sun-moon .dots,
.switch input:checked~.sun-moon .dots:after,
.switch input:checked~.sun-moon .dots:before {
    background: #FFFFFF;
    border-color: #FFFFFF;
}

.switch input:checked~.sun-moon .dots {
    height: 1.5rem;
    width: 1.5rem;
    top: 0px;
    left: -20px;
    transform: rotate(25deg);
}

.switch input:checked~.sun-moon .dots:after {
    height: 0.65rem;
    width: 0.65rem;
    top: 2px;
    left: -12px;
}

.switch input:checked~.sun-moon .dots:before {
    height: 0.4rem;
    width: 0.4rem;
    top: 6px;
    left: 14px;
}

.switch input:checked~.background .stars1,
.switch input:checked~.background .stars2 {
    opacity: 0;
    transform: translateY(2rem);
}

.switch input:checked~.background {
    border: 0.25rem solid #78C1D5;
    background: linear-gradient(to right, #78C1D5 0%, #BBE7F5 100%);
}

@media screen and (max-width: 768px) {
    .switch {
        width: 5rem;
        height: 2.5rem;
        top: 10px;
        right: 10px;
    }

    .sun-moon {
        height: 1.8rem;
        width: 1.8rem;
        margin: 0.35rem;
    }

    .sun-moon .dots {
        height: 0.6rem;
        width: 0.6rem;
        top: 2px;
        left: 14px;
    }

    .stars1,
    .stars2 {
        height: 0.25rem;
        width: 0.25rem;
    }

    .stars1 {
        top: 4px;
        right: 15px;
    }

    .stars2 {
        top: 25px;
        right: 30px;
    }

    .stars1:after,
    .stars1:before,
    .stars2:after,
    .stars2:before {
        height: 0.15rem;
        width: 0.15rem;
    }

    .sun-moon .dots:after,
    .sun-moon .dots:before {
        height: 0.15rem;
        width: 0.15rem;
    }

    .switch input:checked~.sun-moon {
        left: calc(100% - 2.5rem);
    }
}