@layer components {
  .search-form { display: flex; flex-wrap: wrap; gap: 8px; }
  .search-form input[type="search"] { flex: 1 1 260px; min-width: 0; }
  .search-form select { flex: 0 1 240px; min-width: 0; }
  .search-summary { margin: 0; }
  .search-results {
    list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg, 12px);
    background: var(--background); overflow: hidden;
  }
  .search-result + .search-result { border-top: 1px solid var(--border); }
  .search-result-link {
    display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; color: var(--foreground); text-decoration: none;
  }
  .search-result-link:is(:hover, :active) { background: var(--surface); text-decoration: none; }
  .search-result-link:focus-visible { outline: 2px solid var(--jx-accent); outline-offset: -2px; }
  .search-result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; }
  .search-result-conversation { font-weight: 600; }
  .search-result-author, .search-result-head time { color: var(--muted-foreground); }
  .search-result-excerpt { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted-foreground); overflow-wrap: anywhere; }
  .search-result mark { background: var(--jx-accent-soft); color: var(--foreground); border-radius: 3px; padding: 0 2px; font-weight: 500; }

  /* The filter's chips belong to the mobile shell; the desktop keeps the list beside the field. */
  .search-shortcuts { display: none; }

  @media (max-width: 1099px) {
    .search-form input[type="search"] { flex-basis: 100%; }
    .search-form .search-filter--covered { display: none; }
    .search-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; }
    .search-shortcut {
      max-width: 100%;
      position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
      border: 1px solid var(--border); border-radius: 999px; background: var(--background);
      color: var(--foreground); font-size: var(--text-meta); text-decoration: none;
    }
    .search-shortcut:is(:hover, :active) { background: var(--accent); text-decoration: none; }
    .search-shortcut[aria-current="true"] {
      border-color: var(--jx-accent-line); background: var(--jx-accent-soft); font-weight: 600;
    }
    .search-shortcut-place { display: inline-flex; min-width: 0; }
    .search-shortcut-project { flex-shrink: 1000; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* pre keeps the leading space of the tail, which a flex item would otherwise drop; it shrinks last. */
    .search-shortcut-channel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; }
    .search-shortcut-count { color: var(--muted-foreground); }
  }

  /* On a phone the results run edge to edge, at the body's text size. */
  @media (max-width: 767px) {
    .search-results { margin-inline: calc(-1 * var(--gutter)); border-inline: 0; border-radius: 0; }
    .search-result-link { padding-inline: var(--gutter); }
    .search-result-excerpt { font-size: var(--text-body); }
  }

  .search-cancel { display: none; }

  /* The phone's header is the field and Annuler: the title stays for assistive technology, the button is the keyboard's. */
  @media (max-width: 767px) {
    .search-page > .page-header { display: contents; }
    .search-page-title {
      position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
      overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
    }
    .search-form { flex-wrap: wrap; align-items: center; }
    .search-form input[type="search"] { flex: 1 1 0; height: 44px; font-size: 16px; }
    .search-form .button { display: none; }
    .search-form .search-filter { flex-basis: 100%; }
    .search-cancel {
      display: inline-flex; align-items: center; min-height: 44px; font-size: 16px; color: var(--jx-accent); text-decoration: none;
    }
    /* No floating bar here: its reserve of space goes too. */
    body.search-screen .tab-bar { display: none; }
    body.search-screen .app-main { padding-bottom: 20px; }
  }

  /* A chip is drawn 36 px tall and answers a finger on --tap. */
  @media (pointer: coarse) {
    .search-shortcut::after { content: ""; position: absolute; inset: min(0px, calc((100% - var(--tap)) / 2)); }
  }
}
