/* Elements + components. Cue register + cascade rules: docs/design/design-review-law.md.
   Load order: tokens.css (which declares the @layer order) first, then this file.
   .c-sig / .c-sig-code are the register's own selector names — pinned by it, not renameable. */

/* ============================================================
   ELEMENTS — semantic HTML styled directly (law C1).
   ============================================================ */
@layer elements {
  *,
  ::before,
  ::after {
    box-sizing: border-box;
  }

  /* form controls do not inherit by browser default; reset once, so parts never restate it */
  :where(input, select, textarea, button) {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
  }
  ::placeholder {
    color: var(--ink-2);
    opacity: 1;
  }

  /* focus: the one global interaction invariant */
  :focus-visible {
    outline: var(--focus-width) solid var(--ink);
    outline-offset: var(--focus-width);
  }

  /* links are underlined ink (register row 20) */
  a {
    color: inherit;
    text-underline-offset: var(--underline-offset);
  }

  /* disclosure headings (the custom bag) share the one label treatment */
  :where(summary) {
    cursor: pointer;
    font: var(--type-label);
    color: var(--ink-2);
  }

  /* Default = outline (the native file chooser's button too); .primary = inversion (register row
     3), and every button inverts under the pointer — in light; dark never fills with ink (DESIGN.md
     Buttons). The tokens sit on the button, not on :root, so they resolve against its surface (the
     band). Declared in :where() (law C13) so .primary, button.link and every component outrank it
     without a contest. */
  :where(button, a.button),
  ::file-selector-button {
    --button-fill: light-dark(var(--ink), var(--ground));
    --button-fill-ink: light-dark(var(--ground), var(--ink));
    --button-hover: light-dark(var(--ink), var(--page-lift));
    --button-hover-ink: light-dark(var(--ground), var(--ink));
    --button-primary-hover: light-dark(var(--ground), var(--page-lift));
    display: inline-block;
    /* a <button> centers its content natively; the min-height knob (below) stretches an
       inline-block a.button PAST its line box, so the shared set centers explicitly —
       one geometry for both elements. */
    align-content: center;
    font: var(--type-meta);
    padding: var(--space-1) var(--space-3);
    background: var(--ground);
    color: var(--ink); /* bound to the role, so a context (.danger) can re-point it */
    border: var(--line-width) solid var(--ink);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
  }
  :where(button, a.button):hover,
  ::file-selector-button:hover {
    background: var(--button-hover);
    color: var(--button-hover-ink);
  }
  :where(button, a.button).primary {
    background: var(--button-fill);
    color: var(--button-fill-ink);
  }
  :where(button, a.button).primary:hover {
    background: var(--button-primary-hover);
    color: var(--ink);
  }
  /* a button that reads as inline text — or, in a toolbar slot, an icon control (the shared
     icon-control rule below gives it the hit area; this one takes the chrome away) */
  button.link {
    background: none;
    border: none;
    padding: var(--space-1) 0;
    font: var(--type-meta);
    color: var(--ink);
  }
  button.link:hover {
    text-decoration: underline;
  }
  button.link:disabled {
    color: var(--ink-2);
    cursor: default;
    text-decoration: none;
  }

  /* Checkboxes/radios keep their native rendering, but on role ink: a retint must be able to
     reach every visible color. */
  input:is([type="checkbox"], [type="radio"]) {
    /* biome-ignore lint/nursery/useBaseline: decoration (law F); without it, the browser's default control color */
    accent-color: var(--ink);
  }
  /* Knob: --field-font — the control type, set on an ancestor and inherited, so every STATE rule
     below still holds. Restating the chrome from a later layer would beat them whatever its
     specificity (C13). */
  textarea,
  select,
  input:not([type="checkbox"], [type="radio"], [type="file"]) {
    --_field-font: var(--field-font, var(--type-meta));
    font: var(--_field-font);
    background: var(--ground);
    border: var(--line-width) solid var(--edge);
    padding: var(--space-1) var(--space-2);
  }
  input[type="file"] {
    font: var(--type-meta);
  }
  /* focus turns the edge to ink in addition to the ring */
  :is(textarea, select, input):focus-visible {
    border-color: var(--ink);
  }

  /* the stored value under a field an edit conflict touches: in ink, it is what to decide on */
  .was {
    font: var(--type-meta);
    white-space: pre-line; /* a stored value of lines (Schlagworte) shows as lines */
  }
  /* one source for the message and a field's error border: the .error node's presence */
  .error {
    font: var(--type-meta);
    color: var(--error);
  }
  /* ---- hint — a quiet message: a field's hint, the index lag notice ---- */
  .hint {
    font: var(--type-meta);
    color: var(--ink-2);
  }
}

/* ============================================================
   COMPONENTS — named structures (atoms/molecules with real anatomy).
   ============================================================ */
@layer components {
  /* ---- control rows (law C8): a row sets --control-height once and every interactive child
     consumes it, so equal heights hold by construction. Outside a row --hit-fallback decides, and
     outside that the control keeps its content height. A bare <a> or <p> in a row cannot use
     min-height (it is an inline box) — layouts.css gives those the row's line box. ---- */
  :is(button, a.button, summary, input, select) {
    --_control-height: var(--control-height, var(--hit-fallback, auto));
    min-height: var(--_control-height);
  }

  /* ---- visually hidden — a family (component rule 4): screen-reader-only text, the skip link until
     it takes focus, and the file input an upload hides once it uploads on choosing. ---- */
  .visually-hidden,
  .skip:not(:focus),
  [data-upload-on-choose] .upload input[type="file"] {
    position: absolute;
    width: 1px; /* the sr-only clip box — no dimension token applies to an off-screen rect */
    height: 1px; /* (same) */
    padding: 0;
    margin: -1px; /* (same) */
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  /* ---- skip link — "Zum Inhalt springen", the page's first stop; until it takes focus it is
     visually hidden. It belongs to no control row, so it names its own hit floor (C8's out-of-row
     mechanism). ---- */
  .skip {
    --hit-fallback: var(--touch-target);
  }
  /* focused it lands ON the page rather than in the flow, so nothing below it shifts */
  .skip:focus {
    position: absolute;
    inset-block-start: var(--space-2);
    inset-inline-start: var(--space-2);
    z-index: var(--z-banner);
  }

  /* ---- field (workbench/_field.html, every form; inline in the Feld chooser, the
     file-row's caption and the pairs): the label over its control, then its hint and error. Knob:
     --field-display, plus the control type knob (elements layer).
     A MESSAGE (.error/.hint) inside a label element would join the control's accessible name, so a
     field carrying one is a <div> with an explicit <label for>, or its control names itself via
     aria-labelledby (_field.html). ---- */
  .field {
    --_field-display: var(--field-display, inline-flex);
    --_field-rows: var(--field-rows, none);
    display: var(--_field-display);
    flex-direction: column;
    grid-template-rows: var(--_field-rows);
    gap: var(--space-1);
  }
  /* its help popover hangs from its own ⓘ (overlay placement) */
  @supports (anchor-name: --anchor-probe) and
    (inset-block-start: anchor(end)) and
    (justify-self: anchor-center) {
    .field {
      anchor-scope: --help;
    }
  }
  .field > :is(label, span):first-child {
    font: var(--type-label);
    color: var(--ink-2);
  }
  /* a checkbox field: the box leads its label on one line */
  .field > label:has(> input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }
  /* the edge doubled (register row 5): a 1px red line alone does not stand out from the gray edge */
  .field :is(input, select, textarea)[aria-invalid="true"] {
    border-color: var(--error);
    box-shadow: inset 0 0 0 var(--line-width) var(--error);
  }

  /* ---- action rows: ONE pattern for a row of related actions. [role=toolbar] is the named,
     extensible slot flavor; its icons come from the one vendored set (register row 9).
     Knobs: --toolbar-opacity (its controls' resting opacity). ---- */
  .actions,
  [role="toolbar"] {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }
  /* its panels hang from its own triggers (overlay placement) */
  @supports (anchor-name: --anchor-probe) and
    (inset-block-start: anchor(end)) and
    (justify-self: anchor-center) {
    .actions,
    [role="toolbar"] {
      anchor-scope: --menu-button;
    }
  }
  /* A toolbar declares its FALLBACK hit size, never the row knob: it cannot know whether it IS the
     control row or sits inside one, and inside one the row owns the height (C8). */
  [role="toolbar"] {
    --hit-fallback: var(--touch-target-compact);
    --_toolbar-justify: var(--toolbar-justify, normal);
    justify-content: var(--_toolbar-justify);
  }
  [role="toolbar"] > * {
    --_toolbar-opacity: var(--toolbar-opacity, 1);
    opacity: var(--_toolbar-opacity);
  }
  /* a mutating action is its own <form> (Enter never fires it) but sits inline in an .actions row.
     A form inside a PANEL is a list line instead — `.menu-form` owns that. */
  .actions form:not([popover]) {
    display: inline;
    margin: 0;
  }
  /* a toolbar's text link (the list's "Papierkorb") takes the meta type its buttons set */
  [role="toolbar"] > a:not(.button) {
    font: var(--type-meta);
  }

  /* ---- icon control — a family (component rule 4): a quiet control as large as its hit area, a
     row's control height or else its fallback (C8), in the toolbar's ink. Toolbar controls are its
     DIRECT children: a toolbar may own a disclosure, and its dropped panel's links are overlay
     contents. `a:not(.button)` is load-bearing: a toolbar's `a.button` takes its look from @layer
     elements and this layer outranks that one, so a bare `a` here overrode the button even from
     :where() — 14.98:1 down to 2.24:1. ---- */
  [role="toolbar"] > :is(a:not(.button), button.link),
  .actions > a:not(.button),
  .theme-toggle,
  .remove,
  .pane header > a,
  [role="toolbar"] > .bulk > a {
    --_icon-hit: var(--control-height, var(--hit-fallback, var(--touch-target)));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--_icon-hit);
    min-height: var(--_icon-hit);
  }
  /* the ink, the same three states, once. Quiet until the pointer is on it; a disabled control
     keeps a visibly non-interactive ink, so a dead-end arrow is no false affordance (Q6). Declared
     in :where() per law C13, so every per-site delta outranks it in this same layer. */
  :where(
    [role="toolbar"] > :is(a:not(.button), button.link),
    .pane header > a,
    [role="toolbar"] > .bulk > a
  ) {
    color: var(--ink-2);
  }
  [role="toolbar"] > :is(a:not(.button), button.link):hover:not(:disabled),
  .pane header > a:hover:not(:disabled),
  [role="toolbar"] > .bulk > a:hover:not(:disabled) {
    color: var(--ink);
    text-decoration: none;
  }
  [role="toolbar"] > button.link:disabled {
    color: var(--faint);
  }

  /* ---- mark — a state in words, never a box (Entwurf, Titelbild, the dirty register) ---- */
  .mark {
    font: var(--type-label);
    color: var(--ink-2);
    --_mark-wrap: var(--mark-wrap, nowrap);
    white-space: var(--_mark-wrap);
  }

  /* ---- remove — the one × for every removal (DESIGN.md Remove); it carries .danger, so the ink it
     takes on hover, press and focus is red. Hit area: the icon control's. ---- */
  .remove {
    padding: 0;
    background: none;
    border: 0;
    color: var(--ink-2);
  }
  .remove:is(:hover, :active, :focus-visible) {
    color: var(--ink);
  }

  /* ---- theme toggle — the light/dark toggle in the page footer: a quiet glyph, in ink while
     pointed at. Hit area: the icon control's. ---- */
  .theme-toggle {
    padding: 0;
    background: none;
    border: 0;
    color: var(--ink-2);
    cursor: pointer;
  }
  .theme-toggle:is(:hover, :active, :focus-visible) {
    color: var(--ink);
  }

  /* ---- add — "+ …" adds one more of its kind, the header's "+ Neu …" voice: text, no frame. A
     button, or the label over a file input. ---- */
  .add {
    align-self: start; /* one more row of its kind, not a bar: it keeps its own width in a stack */
    padding: var(--space-1) 0;
    font: var(--type-meta);
    background: none;
    border: 0;
    color: var(--ink);
    cursor: pointer;
  }
  .add:hover {
    text-decoration: underline;
    text-underline-offset: var(--underline-offset);
  }

  /* ---- register — a list of rows. Its one-ended rows (a file-row) draw no line (register row
     14). ---- */
  ul.register {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* ---- register-row — one entry of a list that leads somewhere: the label, its figure (a count)
     at the end edge. The whole row is the link; only the label underlines, on hover (row 20; no
     mark on the figure, row 6). Parts: .register-label, .register-figure or .register-aside. ---- */
  .register-row {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
    padding-block: var(--space-2);
    text-decoration: none;
  }
  .register-label {
    flex: 1 1 auto;
    font: var(--type-entry);
  }
  a.register-row:hover .register-label {
    text-decoration: underline;
  }
  /* the menu's count (.menu li > a > span) in a row of its own: the same face, kept per component
     because a shared `data` element rule would also restyle the pager and the byline */
  .register-figure {
    font: var(--type-mono-meta);
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
  }

  /* a name at the end edge where a count would stand (the Collection in Zuletzt hinzugefügt): words,
     so the meta face, not the data face */
  .register-aside {
    font: var(--type-meta);
    color: var(--ink-2);
  }
  /* the aside follows its label, not the far edge: a name belongs to what it names */
  .register-label:has(+ .register-aside) {
    flex-grow: 0;
  }

  /* the entry of a dated list: its date before the label (Zuletzt hinzugefügt) */
  .register-lead {
    flex: 0 0 var(--measure-date);
    font: var(--type-mono-meta);
    color: var(--ink-2);
  }
  /* a narrow list keeps only the titles: the date and the aside would squeeze them */
  @container tiles (width < 40rem) /* S (DESIGN.md space budget) */ {
    .register-lead,
    .register-aside {
      display: none;
    }
  }
  /* a row with a bar (the Zeitleiste): label, then the bar between it and the figure. The bar is a
     <meter> (a style attribute is blocked by the CSP): its value out of its max, never thinner
     than the bar is thick. Browsers draw a meter through vendor pseudo-elements only. */
  .register-row:has(> .register-bar) {
    align-items: center;
    padding-block: var(--space-1);
  }
  .register-label:has(+ .register-bar) {
    flex: 0 0 var(--measure-decade);
    font: var(--type-mono);
  }
  .register-bar {
    flex: 1 1 auto;
    block-size: var(--bar-weight);
    appearance: none;
    border: 0;
    background: transparent;
  }
  .register-bar::-webkit-meter-bar {
    background: transparent;
    border: 0;
    block-size: var(--bar-weight);
  }
  .register-bar::-webkit-meter-optimum-value {
    background: var(--ink);
    min-inline-size: var(--bar-weight);
  }
  .register-bar::-moz-meter-bar {
    background: var(--ink);
  }
  /* an entry in quieter ink (a context: it re-points the ink its parts read); the list sets it apart */
  .register-apart {
    --ink: var(--ink-2);
  }

  /* ---- expandable list — a ranked list's first rows, the rest behind "Mehr …" / "Weniger"
     (DESIGN.md). Parts: .expandable-rest (a folded row), .expandable-more, .expandable-less. ---- */
  .expandable:has(details:not([open])) .expandable-rest,
  .expandable [open] .expandable-more,
  .expandable details:not([open]) .expandable-less {
    display: none;
  }
  /* the row's line is the entry face's, so it stands exactly as tall as a register row; its words
     are in the meta face. A block (not flex): a flex row would drop that line. */
  .expandable summary {
    display: block; /* no list-item, so no disclosure triangle */
    padding-block: var(--space-2); /* a register row's */
    font: var(--type-entry);
  }
  .expandable summary span {
    font: var(--type-meta);
  }
  .expandable summary::-webkit-details-marker {
    display: none;
  }
  .expandable summary:hover {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: var(--underline-offset);
  }

  /* ---- resume — "Weiter bearbeiten:" and its links as one running line ---- */
  .resume {
    color: var(--ink-2);
  }
  .resume > h2 {
    display: inline;
    margin: 0 var(--space-2) 0 0;
    font: inherit;
  }
  .resume > ul {
    display: inline;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .resume li {
    display: inline;
  }
  .resume li + li::before {
    content: " \00B7 ";
  }
  /* biome-ignore lint/style/noDescendingSpecificity: never a toolbar's link */
  .resume a {
    font: var(--type-entry);
    color: var(--ink);
  }

  /* ---- media tile — one file as one link to its original, shown by its best stand-in
     (contract: design-system/components/media-tile.md). The container sets the box on the root (an
     inline size); the stand-in fills it in its own shape up to its own pixels
     (the placeholder's are a thumbnail's square). Parts: -thumb, -placeholder (where no thumbnail
     exists), -face (over the placeholder: the glyph of the file's kind, then -label, its kind and
     name at the foot). ---- */
  .media-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    inline-size: fit-content;
    max-inline-size: 100%;
  }
  /* sizes="auto" keeps the picture from sizing itself (the browser contains its size): its width
     is the box's, up to the width attribute, its largest version's own pixels */
  .media-tile-thumb {
    display: block;
    max-inline-size: 100%;
    block-size: auto;
    border: var(--line-width) solid var(--edge);
  }
  .media-tile-placeholder > svg {
    display: block;
    inline-size: auto;
    block-size: auto;
    max-inline-size: 100%;
  }
  .media-tile-placeholder {
    position: relative;
    display: flex;
    max-inline-size: 100%;
    overflow: hidden;
    border: var(--line-width) solid var(--faint);
  }
  .media-tile-face {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    place-items: center;
    padding: var(--space-2);
    container-type: size; /* the glyph scales with the placeholder's short side */
    color: var(--ink-3); /* the glyph: a default, not the owner's pick */
  }
  .media-tile-face > .icon {
    inline-size: clamp(24px, 30cqmin, 48px); /* a default, not the owner's pick */
    block-size: auto;
  }
  .media-tile-label {
    justify-self: start;
    max-inline-size: 100%;
    padding: var(--space-1);
    font: var(--type-meta);
    color: var(--ink-2);
    /* a name wraps at the <wbr> after its separators; only a segment wider than the tile breaks */
    overflow-wrap: break-word;
  }

  /* ---- file-row — one medium in a register: its media tile, then one column of the name (size
     and marks on its line) over the caption field, the tools level with the caption input right
     after it. The column stops at the query measure. Parts: -name, -tools. Knob:
     --file-row-thumb (the tile's width). S: the tools under the caption. ---- */
  .file-row {
    --file-row-thumb: 8rem; /* the mock's --measure-thumb */
    display: grid;
    grid-template-columns: var(--file-row-thumb) minmax(0, var(--measure-query)) auto;
    grid-template-rows: auto auto 1fr;
    align-items: start;
    gap: var(--space-2) var(--space-5);
    padding-block: var(--space-3);
  }
  .file-row > .media-tile {
    grid-row: 1 / -1;
    inline-size: 100%;
  }
  .file-row > .field {
    grid-column: 2;
  }
  .file-row-name {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-3);
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }
  .file-row-name small {
    font: var(--type-meta);
    color: var(--ink-2);
  }
  .file-row-tools {
    grid-column: 3;
    grid-row: 2;
    align-self: end;
  }
  @container (width < 40rem) /* S (DESIGN.md space budget); no token names a container width */ {
    .file-row {
      --file-row-thumb: 5.5rem; /* the mock's --space-10 */
      grid-template-columns: var(--file-row-thumb) minmax(0, 1fr);
      grid-template-rows: auto;
    }
    .file-row > .media-tile {
      grid-row: 1 / span 3;
    }
    .file-row-tools {
      grid-column: 2;
      grid-row: auto;
    }
  }

  /* ---- upload — "+ Dateien hinzufügen" over the file input. Once catalog_form.js marks the root
     the chosen files upload at once, so the input hides and the submit goes; without it both
     stay. While files go up, a .mark beside it says how far ("2/3 · 40 %"). ---- */
  .upload {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }
  .upload label:has(:focus-visible) {
    outline: var(--focus-width) solid var(--ink);
    outline-offset: var(--focus-width);
  }
  [data-upload-on-choose] .upload button {
    display: none;
  }
  /* biome-ignore lint/style/noDescendingSpecificity: hidden, the input takes the clip's margin */
  .upload input[type="file"] {
    margin-inline-start: var(--space-2);
  }
  .upload ::file-selector-button {
    margin-inline-end: var(--space-2);
  }

  /* ---- note — a quiet annotation touching its label or heading ("intern") ---- */
  .note {
    font: var(--type-note);
    color: var(--ink-3);
  }

  /* ---- help — the ⓘ at the end of a hint (register row 16); it opens a .popover. Everything
     comes from the hint it sits in, which also owns the space before it (law C4). ---- */
  .help {
    padding: 0;
    font: inherit;
    background: none;
    color: inherit;
    border: 0;
  }
  /* its popover hangs from it (overlay placement) */
  @supports (anchor-name: --anchor-probe) and
    (inset-block-start: anchor(end)) and
    (justify-self: anchor-center) {
    .help {
      anchor-name: --help;
    }
  }
  .hint > .help {
    margin-inline-start: var(--space-2);
  }

  /* ---- title-field — the page heading is the record's Titel, editable in place (DESIGN.md). Root
     is the h1; its one textarea shows the placeholder while empty. No frame: an edge shows under it
     on hover, and focus thickens that edge to the focus width — the underline is the focus
     signal. ---- */
  .title-field {
    font: var(--type-page-title);
  }
  .title-field > textarea {
    display: block;
    width: 100%;
    margin: 0;
    /* the glyphs reach past a tight line box: a hair of padding keeps them in */
    padding: 0.06em 0;
    min-height: calc(1lh + 0.12em);
    /* biome-ignore lint/nursery/useBaseline: decoration (law F); without it, a resize handle */
    resize: none;
    /* biome-ignore lint/nursery/useBaseline: limited-availability enhancement with an @supports fallback (law F) */
    field-sizing: content;
    font: inherit;
    background: transparent;
    border: 0;
    border-block-end: var(--line-width) solid transparent;
  }
  @supports (field-sizing: content) {
    .title-field > textarea {
      overflow: hidden; /* the box grows with its text, so nothing is left to scroll */
    }
  }
  .title-field > textarea:hover {
    border-block-end-color: var(--edge);
  }
  .title-field > textarea:focus-visible {
    outline: 0;
    border-block-end: var(--focus-width) solid var(--ink);
  }
  /* invalid: the edge it has is its only one, so the error doubles that edge (register row 5) */
  .title-field > textarea[aria-invalid="true"] {
    border-block-end: calc(2 * var(--line-width)) solid var(--error);
  }
  .title-field > textarea[aria-invalid="true"]:focus-visible {
    border-block-end-width: var(--focus-width);
  }

  /* ---- crumbs — the place, not the path: "Archiv", then the Collection chain, each step opening the
     scoped list (design-system.md, navigation). ---- */
  .crumbs {
    font: var(--type-meta);
    color: var(--ink-2);
  }
  .crumbs a:hover {
    color: var(--ink);
  }
  .crumbs a + a::before {
    content: "›" / "";
    display: inline-block;
    margin-inline: var(--space-2);
  }

  /* ---- section-head — a section's rank: its heading over the section's content, then at most
     one aside (.section-head-aside, a link or note) that touches the heading. Knob:
     --section-head-type (the h2's role; the form's sections set the Subhead). ---- */
  .section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2) var(--space-5);
  }
  .section-head-aside {
    font: var(--type-meta);
    color: var(--ink-2);
    white-space: nowrap;
  }
  a.section-head-aside:hover {
    color: var(--ink);
  }
  .section-head > :is(h1, h2) {
    margin: 0;
    --_head-type: var(--section-head-type, var(--type-title));
    font: var(--_head-type);
  }

  /* ---- conflict notice (components/conflict_notice.html) — someone saved the record while it was
     open. It outranks everything around it: the heavy rule and a red subhead (rows 5, 15), then a
     quiet sentence. ---- */
  .conflict-notice {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding-block-start: var(--space-3);
    border-block-start: var(--state-border) solid var(--error);
    font: var(--type-meta);
    color: var(--ink-2);
  }
  .conflict-notice > p {
    margin: 0;
  }
  .conflict-notice-head {
    font: var(--type-subhead);
    color: var(--error);
  }

  /* ---- record-meta — the form's margin: the conflict notice, the record's Status and audience,
     then the actions. Parts: .record-meta-state (the page's state in words, the create step),
     .record-meta-line (a quiet sentence), .record-meta-actions (Speichern first). ---- */
  .record-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }
  .record-meta > p {
    margin: 0;
  }
  /* Gruppen means something only at the GROUPS rung */
  .record-meta:not(:has(option[value="groups"]:checked)) > .field[data-shows-with="groups"] {
    --field-display: none;
  }
  .record-meta-line {
    font: var(--type-meta);
    color: var(--ink-2);
  }
  .record-meta-actions {
    /* a CONTROL ROW (law C8): Speichern and "Mehr …" share one height */
    --control-height: var(--touch-target-compact);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-5);
  }
  /* its menu hangs from its own button (overlay placement) */
  @supports (anchor-name: --anchor-probe) and
    (inset-block-start: anchor(end)) and
    (justify-self: anchor-center) {
    .record-meta-actions {
      anchor-scope: --menu-button;
    }
  }

  /* ---- Signatur mark: the plain mono code wherever it appears — repetition dilutes a mark. ---- */
  .c-sig {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
    max-width: 100%;
    font: var(--type-mono);
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
  }
  .c-sig-code {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ---- floating panel — a family (component rule 4): every dropped panel (register row 12) is page
     surface with the full-ink edge, even when its trigger sits in the band. Knob: --panel-padding.
     ---- */
  ul.menu[popover],
  .popover,
  .toolpanel,
  .autocomplete-list {
    /* A panel is not part of the row it hangs from, so the row's knob must not reach into it:
       RE-DECLARED here, to a real value — the compact one, as every page action row (owner
       2026-10-05: one control height across rows and panels). Never `initial` — for a custom
       property that is the guaranteed-invalid value, so each consumer falls back to its OWN default
       and one knob resolves to two things. */
    --control-height: var(--touch-target-compact);
    /* re-declared too, so a panel nested in another starts from this default, not its host's knob;
       a panel's own section sets it later in this file */
    --panel-padding: var(--space-2);
    --ground: var(--page-ground);
    --ink: var(--page-ink);
    --ink-2: var(--page-ink-2);
    padding: var(--panel-padding);
    list-style: none;
    background: var(--ground);
    color: var(--ink);
    border: var(--line-width) solid var(--ink);
  }

  /* ---- panel entry — a family (component rule 4): one entry of a floating panel is the panel's
     hit floor in the meta type; the set entry is bold, a count quiet tabular figures at the end
     edge. ---- */
  /* biome-ignore lint/style/noDescendingSpecificity: never a toolbar's link */
  .menu li > a,
  :is(.menu li > button.link, .menu li > form > button.link),
  .autocomplete-list [role="option"],
  .toolpanel > ul:not(.menu) a {
    --_entry-height: var(--control-height, auto);
    min-height: var(--_entry-height);
    font: var(--type-meta);
    text-decoration: none;
  }
  :is(.menu li > a, .menu li > button.link, .menu li > form > button.link):hover,
  .autocomplete-list [role="option"]:hover {
    text-decoration: underline;
  }
  .menu li > a[aria-current],
  .toolpanel > ul a[aria-current] {
    font-weight: 600;
  }
  .menu li > a > span,
  .toolpanel > ul:not(.menu) a > span,
  .autocomplete-list [role="option"] > .autocomplete-count {
    margin-inline-start: auto;
    font: var(--type-mono-meta);
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
  }

  /* the list scrolls past the viewport; where it hangs from its field, the room under it caps it */
  .autocomplete-list {
    max-block-size: calc(100dvh - 2 * var(--space-2));
  }

  /* ---- overlay placement — PROGRESSIVE ENHANCEMENT (law F, pre-Baseline tier, never
     load-bearing): where anchor positioning exists a panel drops from its OWN trigger; where it
     does not, the browser centres it. Each container's anchor-scope (in its own section) keeps a
     disclosure resolving its own trigger, not a later sibling's. anchor() + anchor-center, never
     position-area or position-try. `--anchor-probe` is also the e2e hook: the
     containment walker serves this stylesheet with that condition falsified, so the FALLBACK tier
     gets its own computed proof. ---- */
  @supports (anchor-name: --anchor-probe) and
    (inset-block-start: anchor(end)) and
    (justify-self: anchor-center) {
    /* the popover menu lives in the top layer, so no row contains it: the viewport is its
       containing block. Under its button, right edges aligned; a panel that would overflow shifts
       back inside the viewport (default overflow alignment). Without anchor positioning the
       browser centres it (UA margin: auto). The scope keeps each list on its own button when a
       page holds two menus: named containers, never an unqualified :has(); a menu outside them
       fails the e2e "panel under its own trigger" fact. A panel opened from a menu entry
       ("Löschen …") follows the menu, so it hangs from the menu's button (menu.js closes the
       menu). */
    body > header {
      anchor-scope: --menu-button;
    }
    [popovertarget]:has(+ .toolpanel) {
      anchor-name: --menu-button;
    }
    ul.menu[popover],
    .toolpanel {
      position-anchor: --menu-button;
      inset: auto;
      inset-block-start: anchor(end);
      margin: var(--space-1) 0 0;
    }
    /* a toolpanel's inline placement is its own knobs' (its section) */
    ul.menu[popover] {
      inset-inline: 0 anchor(end);
      justify-self: end;
    }
    /* a help popover hangs under its ⓘ, centred on it as far as the viewport allows */
    .popover {
      position-anchor: --help;
      inset: auto;
      inset-block-start: anchor(end);
      inset-inline: 0;
      justify-self: anchor-center;
      margin: var(--space-1) 0 0;
    }
    /* a suggestion list hangs under its field, as wide as the field */
    [data-suggest] {
      anchor-name: --suggest;
    }
    .autocomplete-list {
      position-anchor: --suggest;
      inset: auto;
      inset-block: anchor(end) var(--space-2);
      inset-inline: anchor(start) anchor(end);
      inline-size: auto;
      /* auto fills the room under the field, fit-content shrinks it to the options: the list
         scrolls where the room is short */
      block-size: auto;
      max-block-size: fit-content;
      margin: var(--space-1) 0 0;
    }
  }

  /* ---- menu: a button that opens a list of actions, a native popover (button.menu-button +
     ul.menu[popover]) — the form margin's "Mehr …". ---- */
  /* the button is text, not a framed button (DESIGN.md "Menu"). Its ink binds to the role,
     because the elements layer's button hover would otherwise invert it. */
  .menu-button {
    padding-inline: 0;
    background: none;
    color: var(--ink);
    border: 0;
    text-underline-offset: var(--underline-offset);
  }
  .menu-button:hover {
    text-decoration: underline;
  }
  /* its menu hangs from it (overlay placement) */
  @supports (anchor-name: --anchor-probe) and
    (inset-block-start: anchor(end)) and
    (justify-self: anchor-center) {
    .menu-button {
      anchor-name: --menu-button;
    }
  }
  /* in a sentence it reads in the sentence's type */
  .search-sentence .menu-button {
    font: inherit;
  }
  /* a split button's chevron: framed like the action beside it, whose end edge is the divider */
  .split-button > .menu-button {
    display: inline-grid;
    place-items: center;
    padding: 0 var(--space-1); /* the 24px icon plus a block padding would outgrow the compact row */
    border: var(--line-width) solid var(--ink);
    border-inline-start-width: 0;
  }
  .split-button > .menu-button:hover {
    background: var(--button-hover);
    color: var(--button-hover-ink);
    text-decoration: none;
  }
  ul.menu[popover] {
    min-width: 12rem; /* the panel's reading width — one structural size, no token fits */
  }
  /* menu delta: a fixed label neither wraps nor ellipsizes, so the entry's own box pads and centers
     it — link or submit button alike (Kopieren mutates, so it cannot be a link), or the button
     that opens an entry's own tool panel ("Löschen …"). */
  /* biome-ignore lint/style/noDescendingSpecificity: never a check-list link (ul:not(.menu)) */
  .menu li > a,
  :is(.menu li > button.link, .menu li > form > button.link) {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: start;
    padding: var(--space-1) var(--space-2);
    white-space: nowrap;
    color: var(--ink); /* bound to the role, so a context (.danger) can re-point it */
  }
  /* an entry that POSTs is a line, even in an .actions row */
  .menu li > form.menu-form {
    display: block;
    margin: 0;
  }
  /* an entry with a count (a filter slot's value): the words, then the count at the end edge */
  /* biome-ignore lint/style/noDescendingSpecificity: never a check-list link (ul:not(.menu)) */
  .menu li > a {
    justify-content: space-between;
    gap: var(--space-4);
  }

  /* ---- split-button — one action and its rarer siblings in one frame: a .button (the frequent
     action), then a button.menu-button holding the chevron (named "Weitere Aktionen") that opens a
     ul.menu[popover]. The chevron draws no start edge, so the action's end edge is the divider; it
     inverts on hover like a button. ---- */
  .split-button {
    display: inline-flex;
    align-items: stretch;
  }
  /* its menu hangs from its own chevron (overlay placement) */
  @supports (anchor-name: --anchor-probe) and
    (inset-block-start: anchor(end)) and
    (justify-self: anchor-center) {
    .split-button {
      anchor-scope: --menu-button;
    }
  }

  /* ---- byline — one line of facts, separated by a middle dot: self-evident values as spans,
     <time> or <data>; a value that cannot speak for itself as a <div><dt><dd> pair of a <dl>. Every
     item carries its dot in a fixed slot before it, hanging in the item's own start padding; the
     line is shifted one slot back and clipped there, so no line, the first or a wrapped one, begins
     with a dot, and a long value that wraps inside its item keeps its first letters. The clip
     leaves room around the other edges for a link's focus ring. ---- */
  .byline {
    --_byline-font: var(--byline-font, var(--type-body));
    --byline-sep: 1.6em;
    font: var(--_byline-font);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    translate: calc(-1 * var(--byline-sep));
    clip-path: inset(-1em -1em -1em var(--byline-sep));
  }
  .byline > * {
    padding-inline-start: var(--byline-sep);
  }
  .byline > *::before {
    content: "·" / "";
    display: inline-block;
    width: var(--byline-sep);
    margin-inline-start: calc(-1 * var(--byline-sep));
    text-align: center;
    color: var(--ink-2);
  }
  .byline a:not(:hover, :focus-visible) {
    text-decoration: none;
  }
  .byline :is(dt, dd) {
    display: inline;
    margin: 0;
  }
  .byline dt {
    margin-inline-end: var(--space-2);
    color: var(--ink-2);
  }
  /* a value that is a run of links (byline_links): the pair, and the links and a last "+n" inside
     its value, are flex lines, so source whitespace never renders. Every item but the last holds a
     tighter dot in its end margin: a wrapped line ends with one, never begins with one. The run
     wraps beside its label while its widest item fits there, else below it; the pair's own dot
     must not shrink, or the label slides into the line's clip. */
  .byline-links {
    --byline-link-sep: 0.82em;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
  }
  .byline-links::before,
  .byline-links > dt {
    flex: none;
  }
  .byline-links > dd {
    flex: 1 1 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
  }
  .byline-links > dd > :not(:last-child) {
    margin-inline-end: var(--byline-link-sep);
  }
  .byline-links > dd > :not(:last-child)::after {
    content: "·" / "";
    display: inline-block;
    width: var(--byline-link-sep);
    margin-inline-end: calc(-1 * var(--byline-link-sep));
    text-align: center;
    color: var(--ink-2);
    pointer-events: none; /* the dot hangs past its link; a click on it opens nothing */
  }

  /* ---- autocomplete-list — the values a field suggests for what is typed (combobox.js): a
     native [popover] listbox, its surface the floating panel's (register row 12). The option the
     arrow keys reach inverts. Unanchored the browser centres it. ---- */
  .autocomplete-list [role="option"] {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    overflow-wrap: anywhere;
    cursor: pointer;
  }
  /* what follows the words (a date, a count) keeps its width: only the words give way */
  /* biome-ignore lint/style/noDescendingSpecificity: never a toolpanel's span */
  .autocomplete-list [role="option"] > span + span {
    flex: none;
  }
  /* a quiet note in it re-points --ink to --ink-2, so that role follows the inversion too */
  .autocomplete-list [aria-selected="true"] {
    --ink-2: var(--ground);
    color: var(--ground);
    background: var(--ink);
  }
  .autocomplete-list mark {
    background: none;
    color: inherit;
    font-weight: 700;
  }
  /* parts of a grouped list (the search field's): each group's kind hangs in a start column; where
     the list is too narrow for both, the options wrap under it */
  .autocomplete-group {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline; /* the kind sits on its first option's baseline */
    column-gap: var(--space-3);
  }
  .autocomplete-group + .autocomplete-group,
  .autocomplete-all {
    margin-block-start: var(--space-2);
  }
  .autocomplete-kind {
    flex: 0 0 6rem; /* the kind column: "Schlagworte" in the label type, one structural size */
    padding-inline-start: var(--space-2); /* on the options' text edge */
    font: var(--type-label);
    color: var(--ink-2);
  }
  .autocomplete-group > ul {
    flex: 1 1 20rem; /* below this the options wrap under their kind: a title keeps its width */
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* ---- popover — the surface a help button opens: a native [popover] holding a <dl> of
     example · meaning. Its surface is the floating panel's (register row 12); only the reading
     width, padding and type differ. Unanchored the browser centres it. ---- */
  .popover {
    --panel-padding: var(--space-4) var(--space-5);
    max-inline-size: 28rem; /* the panel's reading width — one structural size, no token fits */
    font: var(--type-meta);
  }
  .popover dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-1) var(--space-5);
    margin: 0;
  }
  .popover dt {
    font: var(--type-mono);
  }
  .popover dd {
    margin: 0;
  }

  /* ---- toolpanel — one action's own small panel, a native [popover] opened by its button: a
     sentence (or labelled controls), then its one action beside "Abbrechen"
     (components/toolpanel_cancel; a3: the Veröffentlichen confirmation).
     Its surface is the floating panel's (register row 12); it hangs under its button like a
     menu. Light dismiss and Esc cancel; without popover support it shows inline.
     Knobs: --toolpanel-inset-inline and --toolpanel-justify-self, its anchored placement (a
     selection tool's panel opens start-aligned under its tool, a2 round 2). ---- */
  .toolpanel {
    --_toolpanel-inset: var(
      --toolpanel-inset-inline,
      var(--gutter) max(var(--gutter), anchor(end))
    );
    /* safe: a panel wider than the room left of its trigger starts at the gutter; the default
       overflow alignment would shift it to the viewport edge */
    --_toolpanel-justify: var(--toolpanel-justify-self, safe end);
    --panel-padding: var(--space-5);
    inline-size: var(--measure-query);
    max-inline-size: min(100%, 100vw - 2 * var(--gutter)); /* the page gutter, also on S */
  }
  /* anchored, it keeps the page gutter clear on both sides, on S too (overlay placement) */
  @supports (anchor-name: --anchor-probe) and
    (inset-block-start: anchor(end)) and
    (justify-self: anchor-center) {
    .toolpanel {
      inset-inline: var(--_toolpanel-inset);
      justify-self: var(--_toolpanel-justify);
    }
  }
  .toolpanel > * {
    margin: 0;
  }
  .toolpanel > * + * {
    margin-block-start: var(--space-5);
  }
  /* a form's fields stack, each the panel's width ("Neuer Eintrag …") */
  .toolpanel > .field {
    --field-display: flex;
  }
  /* a check list (the ledger's "Spalten …") is as wide as its longest entry */
  .toolpanel:has(> ul) {
    inline-size: auto;
    min-inline-size: 12rem; /* the panel's reading width — one structural size, no token fits */
  }
  .toolpanel > ul {
    padding: 0;
    list-style: none;
  }
  /* an entry is the panel's hit height (its checkbox consumes the panel's --control-height) in a
     panel entry's type */
  .toolpanel > ul label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font: var(--type-meta);
  }
  /* a check list of links ("+ Filter"): the box before each entry is filled when it is set */
  .toolpanel > ul:not(.menu) a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--ink);
  }
  .toolpanel > ul:not(.menu) a::before {
    content: "";
    inline-size: 1em;
    block-size: 1em;
    border: var(--line-width) solid currentColor;
  }
  .toolpanel > ul:not(.menu) a[aria-current]::before {
    background: currentColor;
  }
  /* the head over one list of the phone's "Filter" fold: which slot its entries set */
  .toolpanel > .toolpanel-head {
    margin-block-start: var(--space-3);
    font: var(--type-label);
    color: var(--ink-2);
  }
  .toolpanel > .toolpanel-head:first-child {
    margin-block-start: 0;
  }
  .toolpanel > .toolpanel-head + ul {
    margin-block-start: var(--space-1);
  }
  /* the checkbox's UA margin would stand the entry taller than the panel's other controls (C8) */
  .toolpanel > ul label > input {
    margin-block: 0;
  }

  /* ---- ledger: the result table in hairlines (DESIGN.md "Register and Ledger"). One lead per
     row, the Titel; every other cell one tier quieter, on one line, ending in "…" when it does not
     fit (round 10). A rule runs only between rows (register row 14). The last column shrinks to its
     content, so the rules end where the content ends (round 2). The root is a size container and
     the last-resort scroll box: the page body never scrolls sideways. ---- */
  .ledger {
    container-type: inline-size;
    /* the containing block of the sr-only texts, so the scroll box clips them */
    position: relative;
    overflow-x: auto;
  }
  .ledger > table {
    width: 100%;
    border-collapse: collapse;
  }
  .ledger th {
    padding: 0 var(--space-5) var(--space-3) 0;
    font: var(--type-label);
    color: var(--ink-2);
    text-align: start;
    white-space: nowrap;
  }
  .ledger td {
    padding: var(--space-3) var(--space-5) var(--space-3) 0;
    vertical-align: baseline;
  }
  .ledger tbody tr + tr td {
    border-block-start: var(--line-width) solid var(--rule);
  }
  /* the sort lives on the head (register row 13): the active direction shows; another sortable
     head shows its ↕ on hover or focus */
  /* biome-ignore lint/style/noDescendingSpecificity: never a tool row's link */
  .ledger th > a {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-1);
    text-decoration: none;
  }
  .ledger th > a::after {
    content: "↕" / "";
    opacity: 0;
  }
  .ledger th > a:is(:hover, :focus-visible)::after {
    opacity: 1;
  }
  .ledger th[aria-sort="ascending"] > a::after {
    content: "↑" / "";
    opacity: 1;
  }
  .ledger th[aria-sort="descending"] > a::after {
    content: "↓" / "";
    opacity: 1;
  }

  .ledger td.title > a:first-child {
    font: var(--type-entry);
    color: var(--ink);
    text-decoration: none;
  }
  .ledger td.title > a:first-child:hover {
    text-decoration: underline;
  }
  /* the matching pages under the title; the margin also drops the dl's own */
  .ledger td.title > .byline {
    --byline-font: var(--type-meta);
    margin: var(--space-1) 0 0;
  }
  .ledger td:not(.title, .select) {
    font: var(--type-meta);
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* mono aligns a column of values (DESIGN.md "The Mono Column Rule"); their ch counts in it */
  .ledger td:is(.date, .ref-code) {
    font: var(--type-mono);
    font-variant-numeric: tabular-nums;
  }
  /* the column sizes, in :where() so the fold at S outranks them (law C13) */
  .ledger :where(td.date) {
    width: var(--measure-date);
  }
  .ledger :where(td.ref-code) {
    width: var(--measure-ref-code);
  }
  /* the word cells keep one width on every page, so the columns do not jump between results */
  .ledger :where(td.type, td.digital, td.collection) {
    width: var(--measure-word);
    max-width: var(--measure-word);
  }
  .ledger :where(th, td):where(.select, :last-child) {
    width: 1%;
  }
  .ledger :is(th, td):last-child {
    padding-inline-end: 0;
  }
  /* a cell that sets its filter reads like the others until hovered (round 11); the link is the
     ellipsizing box, so the cell never clips its focus ring */
  .ledger td:not(.title):has(> a) {
    overflow: visible;
  }
  .ledger td:not(.title) > a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
  }
  .ledger td:not(.title) > a:hover {
    color: var(--ink);
    text-decoration: underline;
  }

  /* S: the heads go, and a row is its title over one line of its facts, "1866-11-20 · Lagerheft ·
     PDF · BA 1842", in sans: one line is no column (round 10). The tools and the selection are
     absent (bulk work is L/M). A dot prints only between two present values. */
  @container (width < 40rem) /* S (DESIGN.md space budget); no token names a container width */ {
    .ledger thead {
      display: none;
    }
    .ledger :is(table, tbody) {
      display: block;
    }
    .ledger tr {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      padding-block: var(--space-3);
    }
    .ledger tbody tr + tr {
      border-block-start: var(--line-width) solid var(--rule);
    }
    .ledger tbody tr td,
    .ledger tbody tr + tr td {
      width: auto;
      max-width: none;
      padding: 0;
      border: 0;
    }
    .ledger td.title {
      flex-basis: 100%;
      padding-block-end: var(--space-1);
    }
    .ledger td:not(.title, .select) {
      flex: 0 1 auto;
      min-width: 0;
      font: var(--type-meta);
    }
    .ledger td:not(.title) > a {
      display: inline;
    }
    .ledger td:not(.title, .select):not(:empty) ~ td:not(:empty)::before {
      content: "·" / "";
      margin-inline: var(--space-2);
    }
    .ledger td.select {
      display: none;
    }
  }

  /* ---- affected — the records an action touches, one quiet row each (the consequence disclosure,
     design-system.md). The Titel leads with its Signatur; .affected-old is the value the action
     removes, one tier quieter. Values wrap: the disclosure never cuts what is lost. ---- */
  .affected {
    width: 100%;
    border-collapse: collapse;
  }
  .affected th {
    padding: 0 var(--space-5) var(--space-3) 0;
    font: var(--type-label);
    color: var(--ink-2);
    text-align: start;
  }
  /* biome-ignore lint/style/noDescendingSpecificity: never a ledger cell */
  .affected td {
    padding: var(--space-3) var(--space-5) var(--space-3) 0;
    vertical-align: baseline;
  }
  .affected :is(th, td):last-child {
    padding-inline-end: 0;
  }
  .affected tbody tr + tr td {
    border-block-start: var(--line-width) solid var(--rule);
  }
  .affected-old {
    color: var(--ink-2);
  }

  /* ---- pager: the result range between its steps, one group at the end edge (a2 round 10). A
     step that cannot move yet stays, in Faint (DESIGN.md), and in the same type so nothing moves
     when it becomes active. ---- */
  .pager {
    container-type: inline-size;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: var(--space-2) var(--space-5);
    font: var(--type-meta);
    color: var(--ink-2);
  }
  .pager data {
    color: var(--ink);
  }
  /* the steps and the range: one group, so the row wraps between its two parts only */
  .pager-steps {
    display: flex;
    align-items: baseline;
    gap: var(--space-5);
  }
  /* biome-ignore lint/style/noDescendingSpecificity: never a ledger cell's link */
  .pager-steps > a {
    font: var(--type-control);
    color: var(--ink);
    text-decoration: none;
  }
  .pager-steps > a[href]:hover {
    text-decoration: underline;
  }
  .pager-steps > a[aria-disabled] {
    color: var(--faint);
  }
  @container (width < 40rem) /* S (DESIGN.md space budget); no token names a container width */ {
    /* the arrows alone, in a narrow pager (it is its own container); each step keeps its name
       in aria-label */
    .pager-steps > a > span {
      display: none;
    }
    /* a thumb-sized hit area that leaves the text where it was: padding grows the box, the
       negative margin takes the growth back out of the row. No two areas overlap, wrapped or not:
       a size grows up and only in height, a step grows down and over the range beside it. */
    .pager-steps > a,
    .pager-sizes > a {
      --_hit-grow: calc(var(--touch-target) - 1lh);
    }
    .pager-sizes > a {
      padding-block-start: var(--_hit-grow);
      margin-block-start: calc(-1 * var(--_hit-grow));
    }
    .pager-steps > a {
      padding-block-end: var(--_hit-grow);
      margin-block-end: calc(-1 * var(--_hit-grow));
    }
    .pager-steps > a:first-child {
      padding-inline-end: var(--touch-target);
      margin-inline-end: calc(-1 * var(--touch-target));
    }
    .pager-steps > a:last-child {
      padding-inline-start: var(--touch-target);
      margin-inline-start: calc(-1 * var(--touch-target));
    }
  }
  /* the page-size chooser leads the row; the size on screen in ink and no link, as the view
     switch marks its view */
  .pager-sizes {
    display: flex;
    gap: var(--space-4);
  }
  /* biome-ignore lint/style/noDescendingSpecificity: never inside a panel */
  .pager-sizes > a {
    color: inherit;
  }
  .pager-sizes > [aria-current] {
    color: var(--ink);
  }

  /* ---- honest empty state: words, no frame (row 6: a dashed edge marks only what reacts) ---- */
  .empty-state {
    padding: var(--space-6);
    text-align: center;
  }
  .empty-state > p {
    margin: 0 0 var(--space-1);
    font: var(--type-title);
  }
  .empty-state > p + p {
    margin: 0;
    font: var(--type-body);
    color: var(--ink-2);
  }

  /* ---- reading — the Lesesaal (components/reading): one hit per row, read top to bottom: the
     title as the entry, then meta lines one tier quieter — the why line (its matched words in ink),
     the matching pages, the facts. Rows part by air, no rule. Knob: --reading-measure. ---- */
  ol.reading {
    --_reading-measure: var(--reading-measure, 48rem);
    margin: 0;
    padding: 0;
    list-style: none;
    max-inline-size: var(--_reading-measure);
  }
  .reading > li {
    --byline-font: var(--type-meta);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }
  .reading > li > p {
    margin: 0;
  }
  .reading > li + li {
    margin-block-start: var(--space-6);
  }
  .reading-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-3);
  }
  /* biome-ignore lint/style/noDescendingSpecificity: never inside a panel or the ledger */
  .reading-title > a {
    font: var(--type-entry);
    color: var(--ink);
    text-decoration: none;
  }
  /* biome-ignore lint/style/noDescendingSpecificity: never inside a panel or the ledger */
  .reading-title > a:hover {
    text-decoration: underline;
  }
  .reading-why {
    font: var(--type-meta);
    color: var(--ink-2);
  }
  .reading-why mark {
    background: none;
    color: var(--ink);
    font-weight: 600;
  }

  /* ---- view-switch — the hit count and the two views of one search, "Lesesaal · Tabelle"
     (components/view_switch): words in the meta type. ---- */
  .view-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-5);
    font: var(--type-meta);
    color: var(--ink-2);
  }
  /* in the list's tool row it holds the start, whatever follows it, and the tool that follows
     sits as far from it as the switch's own parts sit from each other */
  [role="toolbar"] > .view-switch {
    margin-inline-end: auto;
    padding-inline-end: calc(var(--space-5) - var(--space-2));
  }
  .view-switch > nav {
    display: flex;
    gap: var(--space-4);
  }
  /* biome-ignore lint/style/noDescendingSpecificity: never inside a panel or the ledger */
  .view-switch a {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target-compact);
    color: inherit;
  }
  /* the view on screen in ink and without the link's underline; one weight, as every control
     in a row (law C8) */
  /* biome-ignore lint/style/noDescendingSpecificity: never inside a panel or the ledger */
  .view-switch a[aria-current] {
    color: var(--ink);
    text-decoration: none;
  }

  /* ---- danger — a context, not a variant (law C2): an action that deletes for good re-points
     --ink to --error while it is about to act. Whatever reads --ink (text, edge, fill) turns
     red; it sets no property itself. ---- */
  .danger:is(:hover, :active, :focus-visible) {
    --ink: var(--error);
  }

  /* ---- quiet — a context, not a variant (law C2): one tier quieter. Its own text follows by
     inheritance, every part that reads --ink by the role. ---- */
  .quiet {
    --ink: var(--ink-2);
    color: var(--ink);
  }
}

/* ============================================================
   MODES — deliberate global overrides + future mode remaps.
   ============================================================ */
@layer modes {
  /* The one sanctioned !important (legacy-blacklist carve-out: "deliberate @layer override"):
     no author display rule may ever un-hide a [hidden] element again. Kills the recorded
     regression class — a fixed-position element whose display rule overrode [hidden] and
     intercepted clicks. JS reveals by REMOVING the attribute, so enhancement still works. */
  [hidden] {
    /* biome-ignore lint/complexity/noImportantStyles: the deliberate @layer override (law F) */
    display: none !important;
  }
}
