@layer components {
  .switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
  }

  .switch__track {
    --switch-width: 2.75rem;
    --switch-height: 1.5rem;
    --switch-knob: 1.25rem;
    --switch-inset: 2px;
    --switch-travel: calc(var(--switch-width) - var(--switch-knob) - var(--switch-inset) * 2);
    --switch-color: var(--color-gray-200);

    position: relative;
    width: var(--switch-width);
    height: var(--switch-height);
    border-radius: var(--radius-full);
    background: linear-gradient(to bottom, color-mix(in oklch, var(--switch-color), black 8%), var(--switch-color));
    box-shadow: var(--bevel-inset);
    transition: background var(--default-transition-duration) var(--default-transition-timing-function);

    &::after {
      content: "";
      position: absolute;
      top: var(--switch-inset);
      left: var(--switch-inset);
      width: var(--switch-knob);
      height: var(--switch-knob);
      border-radius: var(--radius-full);
      background: var(--gradient-card);
      box-shadow:
        inset 0 1px 0 0 var(--color-white-90),
        0 0 0 0.5px rgb(0 0 0 / 0.12),
        0 1px 2px rgb(0 0 0 / 0.18),
        0 2px 4px -1px rgb(0 0 0 / 0.12);
      transition: translate 0.2s var(--ease-out-overshoot-subtle);
    }

    .switch__input:focus-visible ~ & {
      --focus-ring-color: var(--color-indigo-300);
      outline: var(--focus-ring);
      outline-offset: var(--focus-ring-offset);
    }

    .switch__input:checked ~ & {
      --switch-color: var(--color-indigo-600);
    }

    .switch__input:checked ~ &::after {
      translate: var(--switch-travel) 0;
    }
  }
}
