.switch {
  cursor: pointer;
}

.switch input {
  display: none;
}

.switch input + span {
  width: calc(48px * var(--scale));
  height: calc(28px * var(--scale));
  border-radius: calc(14px * var(--scale));
  transition: all 0.3s ease;
  display: block;
  position: relative;
  background: #000;
  outline: calc(1px * var(--scale)) solid #555;
}

.switch input + span:before,
.switch input + span:after {
  content: '';
  display: block;
  position: absolute;
  transition: all 0.3s ease;
}

.switch input + span:before {
  top: calc(5px * var(--scale));
  left: calc(5px * var(--scale));
  width: calc(18px * var(--scale));
  height: calc(18px * var(--scale));
  border-radius: calc(9px * var(--scale));
  border: calc(5px * var(--scale)) solid #555;
  transition: all 350ms ease;
}

.switch input + span:after {
  top: calc(5px * var(--scale));
  left: calc(32px * var(--scale));
  width: calc(6px * var(--scale));
  height: calc(18px * var(--scale));
  border-radius: 40%;
  transform-origin: 50% 50%;
  background: #555;
  opacity: 0;
}

.switch input + span:active {
  transform: scale(0.92);
}

.switch input:checked + span {
  background: #777;
  outline-color: transparent;
}

.switch input:checked + span:before {
  width: 0;
  border-radius: calc(3px * var(--scale));
  margin-left: calc(27px * var(--scale));
  border-width: calc(3px * var(--scale));
}

.switch input:checked + span:before {
  border-color: #000;
}

.switch input:checked + span:after {
  background: #000;
  -webkit-animation: blobChecked 0.35s linear forwards 0.2s;
  animation: blobChecked 0.35s linear forwards 0.2s;
}

.switch input:not(:checked) + span:before {
  -webkit-animation: blob 0.85s linear forwards 0.2s;
  animation: blob 0.85s linear forwards 0.2s;
}

@keyframes blob {
  0%,
  100% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.12, 0.94);
  }
  60% {
    transform: scale(0.96, 1.06);
  }
}

@keyframes blobChecked {
  0% {
    opacity: 1;
    transform: scaleX(1);
  }
  30% {
    transform: scaleX(1.44);
  }
  70% {
    transform: scaleX(1.18);
  }
  50%,
  99% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}
