@layer components {
  .switch-control {
    --switch-track: #d1d9d6;
    --switch-track-checked: var(--form-accent-color, #0e7490);
    --switch-knob: #ffffff;
    --switch-focus-ring: color-mix(in srgb, var(--switch-track-checked), white 35%);
    --switch-width: 2.55rem;
    --switch-height: 1.45rem;
    --switch-knob-size: 1.08rem;
    --switch-knob-offset: 0.18rem;
    --switch-knob-translate: 1.05rem;
    position: relative;
    display: inline-flex;
    align-items: center;
    width: var(--switch-width);
    height: var(--switch-height);
    cursor: pointer;
  }

  .switch-control input[type="checkbox"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }

  .switch-control__track {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    border: 1px solid color-mix(in srgb, var(--switch-track), #6b7280 18%);
    border-radius: 999px;
    background: var(--switch-track);
    transition: background-color 0.15s ease, border-color 0.15s ease;
  }

  .switch-control__track::after {
    content: "";
    position: absolute;
    top: var(--switch-knob-offset);
    left: calc(var(--switch-knob-offset) + 0.02rem);
    width: var(--switch-knob-size);
    height: var(--switch-knob-size);
    border-radius: 50%;
    background: var(--switch-knob);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.28);
    transition: transform 0.15s ease;
  }

  .switch-control input[type="checkbox"]:checked + .switch-control__track {
    border-color: var(--switch-track-checked);
    background: var(--switch-track-checked);
  }

  .switch-control input[type="checkbox"]:checked + .switch-control__track::after {
    transform: translateX(var(--switch-knob-translate));
  }

  .switch-control input[type="checkbox"]:focus-visible + .switch-control__track {
    outline: 2px solid var(--switch-focus-ring);
    outline-offset: 3px;
  }

  .switch-control input[type="checkbox"]:disabled {
    cursor: not-allowed;
  }

  .switch-control:has(input[type="checkbox"]:disabled) {
    cursor: not-allowed;
    opacity: 0.6;
  }

  .switch-control__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
}
