/* Form fields (FE-D4, FE-D5): label above, help and error below, 44 px controls. */
.field { display: grid; gap: var(--space-1); }
.field + .field { margin-top: var(--space-4); }
.field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.field__required { color: var(--color-text-muted); font-weight: var(--weight-regular); }
.field__control {
  width: 100%; min-height: var(--control-height); padding: 0 var(--space-3);
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-control);
  transition: border-color var(--duration-fast);
}
textarea.field__control { min-height: 7rem; padding: var(--space-3); resize: vertical; }
.field__control:hover { border-color: var(--color-text-muted); }
.field__control:focus-visible { border-color: var(--color-focus); }
/* A search field an open segment holds (U-0150): shown, not to be changed here. The text keeps its
   contrast; the dashed border and the cursor say that the field is locked. */
.field__control--held { border-style: dashed; cursor: not-allowed; }
.field__control--held:hover { border-color: var(--color-border); }
.field__help { font-size: var(--text-sm); color: var(--color-text-muted); }
.field__error { display: flex; gap: var(--space-1); align-items: flex-start; font-size: var(--text-sm); color: var(--color-danger); }
.field__error svg { width: 1rem; height: 1rem; margin-top: 0.15em; flex: none; }
.field--invalid .field__control { border-color: var(--color-danger); }

/* The rich-text editor (U-0224): a toolbar above an editable area that grows with its text. */
.rich__toolbar { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.rich__toolbar .button[aria-pressed="true"] { background: var(--color-surface-muted); color: var(--color-text); box-shadow: inset 0 0 0 1px var(--color-border); }
.rich__area { min-height: 12rem; padding: var(--space-3); overflow-wrap: anywhere; cursor: text; }

.check { display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--text-sm); }
.check input { width: 1.25rem; height: 1.25rem; margin-top: 0.1em; accent-color: var(--color-primary); flex: none; }

.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); }
/* The actions of a long form stay in view (U-0129): the bar sticks to the lower edge while the
   form is on screen. A focused field never hides under it (scroll-padding on the page). */
.form-actions--sticky {
  position: sticky; bottom: 0; z-index: 5; margin: var(--space-5) calc(-1 * var(--space-5)) calc(-1 * var(--space-5));
  padding: var(--space-3) var(--space-5); background: var(--color-surface);
  border-top: 1px solid var(--color-border); border-radius: 0 0 var(--radius-card) var(--radius-card);
}
html:has(.form-actions--sticky) { scroll-padding-bottom: calc(var(--control-height) + var(--space-8)); }
@media print { .form-actions--sticky { position: static; } }

/* Field grid (U-0129, FE-D16): short fields beside one another from 768px, one column below.
   The grid sets the distance itself — `.field + .field` would push the second field of a row down. */
.fields { display: grid; gap: var(--space-4); align-items: start; }
.fields > .field, .fields > .field + .field { margin-top: 0; }
.fields + .fields, .fields + .field, .field + .fields { margin-top: var(--space-4); }
@media (min-width: 768px) {
  .fields--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fields--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fields--1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
  .fields--2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .fields > .field--wide { grid-column: 1 / -1; }
}
/* A check box that stands in a row of fields sits on the controls' line, not on the labels'. */
.fields > .check { align-self: end; min-height: var(--control-height); align-items: center; }

/* One entry of a repeated group (an address, a contact detail, a role): a row, not a card. */
.entry { min-width: 0; margin: 0; padding: var(--space-4) 0; border: 0; border-top: 1px solid var(--color-border); }
.entry:first-of-type { border-top: 0; padding-top: 0; }
.entry__legend { padding: 0; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-muted); }
.entry > * + * { margin-top: var(--space-3); }
.entry--new { background: var(--color-surface-muted); padding: var(--space-4); border-radius: var(--radius-control); border-top: 0; margin-top: var(--space-4); }
/* The rows behind a disclosure of a creation form (U-0140): its button stands clear of the row above. */
.entry + .disclosure { margin-top: var(--space-4); }
/* Tags ticked from the stock (U-0141): the boxes wrap in the width they have. */
.tag-choice { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.entry__options { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }

/* Honeypot (FE-S4): off-screen, not display:none. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Folded on a phone (U-0117, generalised in U-0132; components/_filter.html): a <details> that is
   closed below 768px — its summary says what is inside — and stands open from 768px, where the
   summary is gone. A browser without ::details-content keeps the fold on every width: closed,
   and opened by a click or the keyboard like any <details>. The filter row of a list is one use
   (.filter-fold), a block of the start page another. */
.fold-narrow__summary { cursor: pointer; padding-block: var(--space-2); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.fold-narrow[open] > .fold-narrow__summary { margin-block-end: var(--space-3); }
@supports selector(::details-content) {
  @media (min-width: 768px) {
    .fold-narrow > .fold-narrow__summary { display: none; }
    .fold-narrow::details-content { content-visibility: visible; }
  }
}
/* Where the summary already is the title of the one card inside, the card's own title is not
   said twice on a phone: out of sight below 768px, still a heading for a screen reader's list
   of headings. Mobile first — the title comes back where the summary goes. */
.fold-narrow--titled > .card > .card__head .card__title {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
@media (min-width: 768px) {
  .fold-narrow--titled > .card > .card__head .card__title {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal;
  }
}

/* A search field with its own "x" (U-0144): the control and, when it is filled, a link that
   empties exactly this field — a 44px target beside the control. */
.field-clear { display: flex; align-items: center; gap: var(--space-1); }
.field-clear > .field__control { flex: 1 1 auto; min-width: 0; }
.field-clear__x { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; inline-size: var(--control-height); block-size: var(--control-height); border-radius: var(--radius-control); color: var(--color-text-muted); }
.field-clear__x:hover { color: var(--color-danger); background: var(--color-surface-muted); }
.search-mask > .muted { margin-block: var(--space-1) 0; }
.search-mask > .filter-more__fields { align-items: flex-start; }

/* The rarely used filters of a list (U-0132): behind "Weitere Filter" on every width, open when
   one of them is set; the summary counts the set ones. It takes a row of its own in the bar. */
.filter-more { flex: 1 1 100%; min-width: 0; }
.filter-more > summary { cursor: pointer; display: inline-block; padding-block: var(--space-2); color: var(--color-primary); font-weight: var(--weight-medium); }
.filter-more__fields { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; margin-block-start: var(--space-2); }
.filter-more__fields .field { flex: 1 1 14rem; }
.filter-more__fields .field + .field { margin-top: 0; }
/* The compact first row of such a bar: the search field takes the room, the rest keeps its width. */
.filter-bar--compact > .field { flex: 0 1 14rem; }
.filter-bar--compact > .field:first-child { flex: 1 1 16rem; }
.filter-bar--compact > .check { min-height: var(--control-height); align-items: center; }

/* A longer explanation behind "more about this" (U-0129): closed until asked for. */
.hint { margin-top: var(--space-3); font-size: var(--text-sm); }
.hint > summary { cursor: pointer; color: var(--color-text-muted); }
/* in a table cell (the audit log's content, U-0133): no gap above, the cell's own size */
.hint--cell { margin-top: 0; font-size: inherit; }
.hint--cell[open] > summary { margin-bottom: var(--space-2); }
.hint > p { margin-top: var(--space-2); max-width: var(--content-max); }

/* A file input (U-0130): the browser's own control, at the height of the others. */
.field__control--file { padding: var(--space-2) var(--space-3); height: auto; }

/* The stages of a pipeline (U-0132): one stage per row of the field grid. Mobile first: on a
   phone the name takes the row and the three short fields stand beside one another; from 768px
   the four fields stand in one row. Below 992px a line keeps the stages apart. */
.stage-row { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.stage-row > .field:first-of-type { grid-column: 1 / -1; }
.stage-row .field__control { min-width: 0; }
.stage-row + .stage-row { border-top: 1px solid var(--color-border); padding-top: var(--space-4); }
@media (min-width: 768px) {
  .stage-row { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
  .stage-row > .field:first-of-type { grid-column: auto; }
}
@media (min-width: 992px) { .stage-row + .stage-row { border-top: 0; padding-top: 0; } }

/* A radio or checkbox as a bordered row (U-0019; global since U-0212: portal forms use it too). */
.choice { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border-strong); border-radius: var(--radius-control); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--color-primary); }
.choice input { width: 1.1rem; height: 1.1rem; accent-color: var(--color-primary); flex: none; }

/* A colour with its picker beside the text field (U-0227, R-12): the picker works without
   JavaScript and sits level with the field's control, below its label. */
.colour-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-2); align-items: start; }
.colour-field__pick { margin-top: var(--space-6); inline-size: 3rem; block-size: 2.5rem; padding: var(--space-1); border: 1px solid var(--color-border-strong); border-radius: var(--radius-control); background: var(--color-surface); cursor: pointer; }
.colour-field__pick:focus-visible { outline: none; box-shadow: var(--focus-ring); }
