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

  .textarea-showcase {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 36px;
    width: min(100%, 676px);
  }

  .textarea-example {
    width: min(100%, 320px);
    min-width: 0;
    justify-self: center;
    display: grid;
    align-content: start;
    gap: 12px;
  }

  .textarea-example-title {
    color: var(--muted-foreground);
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .textarea-field,
  .textarea-action {
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .textarea-label {
    width: fit-content;
    color: var(--foreground);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.375;
    user-select: none;
  }

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

  .textarea-control {
    display: block;
    width: 100%;
    min-height: 64px;
    field-sizing: content;
    margin: 0;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    outline: none;
    background: transparent;
    color: var(--foreground);
    padding: 8px 10px;
    font-size: 14px;
    line-height: 20px;
    resize: vertical;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
  }

  .textarea-control::placeholder {
    color: var(--muted-foreground);
    opacity: 1;
  }

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

  .textarea-control:disabled {
    cursor: not-allowed;
    background: color-mix(in srgb, var(--input) 50%, transparent);
    opacity: 0.5;
  }

  .textarea-field-disabled .textarea-label {
    cursor: not-allowed;
    opacity: 0.5;
  }

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

  .textarea-control[aria-invalid="true"] {
    border-color: var(--destructive);
    color: var(--destructive);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 20%, transparent);
  }

  .textarea-control[aria-invalid="true"]:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 20%, transparent);
  }

  .textarea-button {
    display: inline-flex;
    width: 100%;
    height: 32px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    outline: none;
    background: var(--primary);
    color: var(--primary-foreground);
    padding-inline: 10px;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color 150ms ease, box-shadow 150ms ease, border-color 150ms ease, transform 100ms ease;
  }

  .textarea-button:hover {
    background: color-mix(in srgb, var(--primary) 80%, transparent);
  }

  .textarea-button:focus-visible {
    border-color: var(--ring);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
  }

  .textarea-button:active {
    transform: translateY(1px);
  }

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

    .textarea-control:disabled {
      background: color-mix(in srgb, var(--input) 80%, transparent);
    }

    .textarea-control[aria-invalid="true"] {
      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: 767px) {
    .textarea-control {
      font-size: 16px;
      line-height: 24px;
    }
  }

  @media (max-width: 640px) {
    .textarea-showcase {
      grid-template-columns: minmax(0, 1fr);
      gap: 28px;
    }
  }
}
