html, body {
  margin: 0;
  overflow: hidden;
}

.stage {
  box-sizing: border-box;
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0;
  background: #ffffff;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
  padding: clamp(8px, 4vw, 24px);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: clamp(10px, 3vw, 14px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.switch__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch__track {
  position: relative;
  overflow: hidden;
  width: clamp(48px, 13vw, 56px);
  height: clamp(26px, 7vw, 30px);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(23, 20, 26, 0.1);
}

.switch__bg {
  position: absolute;
  inset: 0;
}

.switch__bg--off {
  background: rgba(23, 20, 26, 0.12);
  opacity: 1;
}

.switch__bg--on {
  background: #2f6df6;
  opacity: 0;
}

.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(20px, 5.5vw, 24px);
  height: clamp(20px, 5.5vw, 24px);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
  color: #17141a;
  transform: translateX(0);
  transition: transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch__icon {
  grid-area: 1/1;
  transition: opacity 220ms ease-out;
}

.switch__icon--x {
  opacity: 1;
}

.switch__icon--check {
  opacity: 0;
}

.switch__label {
  color: #17141a;
  font-weight: 600;
  font-size: clamp(14px, 4vw, 17px);
  line-height: 1;
  font-family: inherit;
}

.switch__input:checked ~ .switch__track .switch__bg--off {
  opacity: 0;
  transition: opacity 220ms ease-out;
}

.switch__input:checked ~ .switch__track .switch__bg--on {
  opacity: 1;
  transition: opacity 220ms ease-out;
}

.switch__input:checked ~ .switch__track .switch__knob {
  transform: translateX(clamp(22px, 6vw, 26px));
  color: #2f6df6;
}

.switch__input:checked ~ .switch__track .switch__icon--x {
  opacity: 0;
}

.switch__input:checked ~ .switch__track .switch__icon--check {
  opacity: 1;
}

.switch__input:focus-visible ~ .switch__track {
  outline: 2px solid #17141a;
  outline-offset: 3px;
}

.switch.is-demo .switch__bg--off {
  animation: bg-off-loop 2s ease-out infinite;
}

.switch.is-demo .switch__bg--on {
  animation: bg-on-loop 2s ease-out infinite;
}

.switch.is-demo .switch__knob {
  animation: knob-spring-loop 2s ease-out infinite;
}

.switch.is-demo .switch__track {
  animation: shadow-depth-loop 2s ease-out infinite;
}

.switch.is-demo .switch__icon--x {
  animation: icon-x-loop 2s ease-out infinite;
}

.switch.is-demo .switch__icon--check {
  animation: icon-check-loop 2s ease-out infinite;
}

@keyframes bg-off-loop {
  0%, 15% {
    opacity: 1;
  }
  40%, 60% {
    opacity: 0;
  }
  85%, 100% {
    opacity: 1;
  }
}
@keyframes bg-on-loop {
  0%, 15% {
    opacity: 0;
  }
  40%, 60% {
    opacity: 1;
  }
  85%, 100% {
    opacity: 0;
  }
}
@keyframes knob-loop {
  0%, 15% {
    transform: translateX(0);
  }
  40%, 60% {
    transform: translateX(26px);
  }
  85%, 100% {
    transform: translateX(0);
  }
}
@keyframes knob-spring-loop {
  0%, 15% {
    transform: translateX(0) scaleX(1) scaleY(1);
  }
  38% {
    transform: translateX(29px) scaleX(1.25) scaleY(0.85);
  }
  43% {
    transform: translateX(25px) scaleX(1.08) scaleY(0.94);
  }
  47%, 60% {
    transform: translateX(26px) scaleX(1) scaleY(1);
  }
  84% {
    transform: translateX(-2px) scaleX(0.92) scaleY(1.06);
  }
  85%, 100% {
    transform: translateX(0) scaleX(1) scaleY(1);
  }
}
@keyframes shadow-depth-loop {
  0%, 15% {
    box-shadow: inset 0 0 0 1px rgba(23, 20, 26, 0.1), inset 0 1px 3px rgba(0, 0, 0, 0.15);
  }
  38% {
    box-shadow: inset 0 0 0 2px rgba(23, 20, 26, 0.1), inset 0 3px 8px rgba(0, 0, 0, 0.28);
  }
  40%, 60% {
    box-shadow: inset 0 0 0 2px rgba(23, 20, 26, 0.1), inset 0 3px 8px rgba(0, 0, 0, 0.28);
  }
  85%, 100% {
    box-shadow: inset 0 0 0 1px rgba(23, 20, 26, 0.1), inset 0 1px 3px rgba(0, 0, 0, 0.15);
  }
}
@keyframes icon-x-loop {
  0%, 15% {
    opacity: 1;
  }
  40%, 60% {
    opacity: 0;
  }
  85%, 100% {
    opacity: 1;
  }
}
@keyframes icon-check-loop {
  0%, 15% {
    opacity: 0;
  }
  40%, 60% {
    opacity: 1;
  }
  85%, 100% {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .switch.is-demo .switch__bg--off, .switch.is-demo .switch__bg--on,
  .switch.is-demo .switch__knob, .switch.is-demo .switch__icon--x, .switch.is-demo .switch__icon--check,
  .switch.is-demo .switch__track {
    animation: none !important;
  }
  .switch__knob, .switch__bg--off, .switch__bg--on, .switch__icon {
    transition: none;
  }
}
