@layer components {
  /* ——— The filter vocabulary (owner, 2026-11-03) ———
     Three shapes and one line, wherever a page narrows or orders what it
     shows. A MODE is where you are or how you read it: a quiet button, the
     chosen one in the selected voice (buttons.css) — modes, tabs, a folder's
     kinds, Mail's piles, a view switch. A CHIP is the answer to one
     question, inside a sentence ("Showing all projects by everyone"). The
     FIND is the field. A line holds what it has of them in one order:
     modes, the sentence and its ×, then the find, the order and the view —
     what narrows at the start, how it is drawn at the end. Layout is
     utilities, because that is all a line is; what lives here is what a
     utility cannot say. */

  /* ——— A chip ———
     The answer in ink, with a faint ⌄ that says it opens: a quiet button
     retuned (filters/_chip, and the combobox's sentence trigger). It wears
     the selected voice only while it narrows what you see — `aria-current`,
     or the combobox's ticked answer (buttons.css). An order changes what
     comes first, never what is there, so an order chip never wears it.

     The ⌄ is .input--select's "pick from a list", one size down because it
     trails a word instead of bounding a field, and faded by opacity rather
     than by ink so it follows the chip through the chosen wash. */
  .filter-chip {
    --btn-color: var(--color-ink);

    .icon {
      --icon-size: 0.75em;

      opacity: 0.6;
    }
  }

  /* The × undoes a narrowing, so it is there only once there is one. The bar
     can see its own state, which means no server-rendered condition and
     nothing to keep in sync behind a frame swap — the same reason every
     control in the bar carries its own state (filter_bar_controller).
     Stated as the exception, not the rule, so .btn's own display is never
     restated: revert-layer would go to the previous LAYER, not the previous
     rule, and both live in components. */
  .filter-bar:not(:has(.combobox [aria-checked="true"])) .filter-bar__clear {
    display: none;
  }

  /* The CRM rule's own fields, in reading order — attribute, operator, value,
     then the actions. .input fills its container by default, which here would
     push the button onto a line of its own; and each written line needs a
     little inline room, or the baselines run together into one long rule. */
  .filter-bar .input {
    inline-size: auto;
    max-inline-size: 100%;
    padding-inline: var(--inline-space-half);
  }

  /* ——— The find ———
     One line, three parts, one hairline under all of them: the glyph, the
     words, and the key that reaches the field (filters/_box draws every one
     of them). In a row it is as wide as its words; standing alone it takes
     the line. A control's size, not the sheet's: .btn's block padding and
     one size down, so its baseline agrees with the buttons beside it. */
  .filter-line {
    --icon-size: 0.9375rem;

    display: flex;
    align-items: center;
    gap: var(--inline-space-half);
    font-size: var(--text-small);
    color: var(--color-ink-faint);
    border-block-end: var(--border);
    cursor: text;

    .input.filter-box {
      flex: 1;
      inline-size: auto;
      min-inline-size: 0;
      padding: 0.25rem 0;
      font-size: inherit;
      border: none;
    }

    /* / says how to get here and esc, once you are here, how to get out;
       neither once the field holds words, where its own × takes the end.
       A touch screen shows neither (.hide-on-touch on both). */
    &:not(:focus-within) .filter-line__leave,
    &:focus-within .filter-line__reach,
    &:has(.filter-box:not(:placeholder-shown)) kbd {
      display: none;
    }
  }

  /* Where finding is the page itself — the finding page, a chat's search:
     the same line at display size (HANSHI, form treatment C). */
  .filter-line--large {
    --icon-size: 1.25rem;

    gap: var(--inline-space);
    font-size: var(--text-large);
  }
}

/* What a filter match looks like, wherever a filter paints one. A highlight
   pseudo-element styles painted ranges, not boxes, so this is the entire
   implementation of match highlighting — the registry lives in
   filter_controller.js. Unlayered: highlight pseudos take only a handful of
   properties and nothing else argues over them. */
::highlight(filter-match) {
  background-color: var(--color-highlight);
}
