:where(fieldset) {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  border: 0;
  position: relative;
  margin-block: 0.5lh;
  padding-inline: 0;
  padding-block-start: 0.5lh !important;
  /* the position of the legend has to be fixed */

  legend {
    position: relative;
    inset: 0.5lh 0;
    text-align: start;
    font-weight: 500;
    margin: 0 0 0.25lh;
    padding: 0;
  }

  .field-message {
    font-size: var(--font-size-xs);
  }

  &:has(:checked) legend {
    color: var(--gray-text);
  }

  &:has(:required) legend::after,
  legend.required::after {
    content: " *";
    color: var(--color-red);
  }

  & .field {
    margin-block: 0.25lh;
  }

  &.row {
    flex-direction: row;
    justify-content: flex-start;

    /* legend { margin-block-end: 0.25lh; } */

    .field:has([role=checkbox], [role=radio], [role=switch]) {
      padding-inline-end: 0.75rem;
      margin-block: 0 0.5lh;

      [role=radio] {
        align-self: center;
      }
    }

    &:has(.error) {
      legend,
      label,
      .error.message {
        color: var(--color-red);
      }

      :where(input, textarea, select) {
        border-color: var(--color-red);
      }

      .with-icon svg * {
        stroke: var(--color-red);
      }
    }

    .message {
      font-size: var(--font-size-xs);
      text-align: match-parent;
      text-align: inherit;
    }

  }
}
