@layer checkbox {
  .checkbox-stage {
    align-items: stretch;
  }

  .checkbox-showcase {
    width: min(100%, 600px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .checkbox-example {
    min-width: 0;
    margin: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    box-shadow: var(--shadow-xs);
  }

  .checkbox-example-heading {
    display: grid;
    gap: 2px;
    margin-bottom: 20px;
  }

  .checkbox-example-heading h2,
  .checkbox-group > legend {
    color: var(--foreground);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.375;
  }

  .checkbox-example-heading p,
  .checkbox-group-description {
    color: var(--muted-foreground);
    font-size: 13px;
    line-height: 1.5;
  }

  .checkbox-list {
    display: grid;
    gap: 12px;
  }

  .checkbox-field {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--foreground);
    cursor: pointer;
    user-select: none;
  }

  .checkbox-field-start {
    align-items: flex-start;
  }

  .checkbox-control {
    position: relative;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    display: grid;
    place-items: center;
    border: 1px solid var(--input);
    border-radius: 4px;
    background: transparent;
    color: var(--primary-foreground);
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
  }

  .checkbox-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: inherit;
    appearance: none;
    opacity: 0;
    cursor: inherit;
  }

  .checkbox-control svg {
    width: 14px;
    height: 14px;
    opacity: 0;
    pointer-events: none;
  }

  .checkbox-control svg path {
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .checkbox-control:has(.checkbox-input:checked) {
    border-color: var(--primary);
    background: var(--primary);
  }

  .checkbox-control:has(.checkbox-input:checked) svg {
    opacity: 1;
  }

  .checkbox-control:has(.checkbox-input:focus-visible) {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
  }

  .checkbox-input:focus-visible {
    outline: none;
  }

  .checkbox-field-invalid {
    color: var(--destructive);
  }

  .checkbox-field-invalid .checkbox-control {
    border-color: var(--destructive);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 20%, transparent);
  }

  .checkbox-field:has(.checkbox-input:disabled) {
    cursor: not-allowed;
  }

  .checkbox-field:has(.checkbox-input:disabled) .checkbox-control,
  .checkbox-field:has(.checkbox-input:disabled) .checkbox-label {
    opacity: 0.5;
  }

  .checkbox-label {
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.375;
  }

  .checkbox-content {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
  }

  .checkbox-description {
    color: var(--muted-foreground);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    user-select: text;
  }

  .checkbox-group {
    grid-column: 1 / -1;
  }

  .checkbox-group > legend {
    padding: 0;
  }

  .checkbox-group-description {
    margin-top: 2px;
    margin-bottom: 16px;
  }

  @media (prefers-color-scheme: dark) {
    .checkbox-control {
      background: color-mix(in srgb, var(--input) 30%, transparent);
    }

    .checkbox-control:has(.checkbox-input:checked) {
      background: var(--primary);
    }

    .checkbox-field-invalid .checkbox-control {
      border-color: color-mix(in srgb, var(--destructive) 50%, transparent);
      box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 40%, transparent);
    }
  }

  @media (max-width: 680px) {
    .checkbox-showcase {
      grid-template-columns: minmax(0, 1fr);
    }

    .checkbox-group {
      grid-column: auto;
    }
  }

  @media (max-width: 400px) {
    .checkbox-example {
      padding: 16px;
    }
  }
}
