* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

:root {
    --color: #fff;
    --color2: #333;
}

body {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox {
    display: none;
}

.toggle {
    width: 40px;
    height: 21px;
    display: block;
    position: relative;
    background-color: var(--color);
    border-radius: 50px;
    box-shadow: inset 0 0 3px black;
    cursor: pointer;
    transform: scale(10);  /* scale remove  */  
}

/* use background img */
/* .toggle::after {
    content: '';
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: linear-gradient(to right, yellow, #fbffe4);
    position: absolute;
    border-radius: 50%;
    transition: 0.5s;
    box-shadow: inset 0 0 2px #ff7700, 0 0 2px grey;
}

.checkbox:checked~.toggle::after {
    left: 21px;
    background: linear-gradient(to right, white, grey);
    box-shadow: inset 0 0 2px #000000, 0 0 2px #303030;
} */

.checkbox:checked~.toggle {
    background-color: grey;
}

.background {
    width: 100vw;
    height: 100vh;
    background-color: var(--color);
    position: absolute;
    z-index: -1;
    transition: 0.5s;
}

.checkbox:checked~.background {
    background-color: var(--color2);
}

.toggle img {
    position: absolute;
    z-index: 1;
}

.toggle img.sun {
    width: 12px;
    transition: 0.5s;
    left: 5px;
    top: 4px;
}

.toggle img.moon {
    width: 12px;
    transform: scale(0);
    transition: 0.5s;
    left: 5px;
    top: 4px
}

.checkbox:checked~.toggle img.sun {
    left: 22px;
    transform: scale(0);
}

.checkbox:checked~.toggle img.moon {
    left: 22px;
    transform: scale(1);
}
