/* The box is the <input>, with its native look removed, and the check is its ::before. */
[data-slot='checkbox'] {
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin: 0;
  border: 1px solid var(--input);
  border-radius: 4px;
  background: light-dark(transparent, color-mix(in oklch, var(--input) 30%, transparent));
  color: var(--primary-foreground);
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: box-shadow 150ms;

  &::before {
    content: '';
    width: 0.875rem;
    height: 0.875rem;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")
      center / contain no-repeat;
    scale: 0;
  }
  &:checked,
  &:indeterminate {
    border-color: var(--primary);
    background: var(--primary);
  }
  &:checked::before {
    scale: 1;
  }
  &:indeterminate::before {
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");
    scale: 1;
  }
  &:focus-visible {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
  }
  &[aria-invalid='true'] {
    border-color: var(--destructive);
  }
  &:disabled {
    cursor: not-allowed;
    opacity: 0.5;
  }
}
