@layer components {
  /* The picker sits in the composer's foot without a box: its button is one of the tools, its window floats over the field. */
  .gif-picker { display: contents; }
  .composer-attach.composer-gif { margin-left: 0; }
  .gif-picker-window {
    position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 6; width: 400px; max-width: calc(100vw - 32px);
    padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--popover); color: var(--popover-foreground);
    box-shadow: var(--shadow-sm);
  }
  .gif-picker-window[hidden] { display: none; }
  .gif-picker-body { display: flex; flex-direction: column; gap: 8px; }
  .gif-picker-search { width: 100%; }

  .gif-picker-chips-slot:empty { display: none; }
  .gif-picker-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .gif-picker-chip {
    padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: inherit;
    font: inherit; font-size: 13px; cursor: pointer;
  }
  .gif-picker-chip:hover { background: var(--accent); }
  .gif-picker-chip[aria-pressed="true"] { background: var(--jx-accent-soft); border-color: var(--jx-accent); }

  .gif-picker-results { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; overscroll-behavior: contain; }
  .gif-picker-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .gif-picker-item {
    display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; overflow: hidden; border: 1px solid var(--border);
    border-radius: 8px; background: var(--muted); cursor: pointer;
  }
  .gif-picker-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .gif-picker-item:focus-visible { outline: 2px solid var(--jx-accent); outline-offset: 2px; }
  .gif-picker-empty { margin: 0; padding: 12px 4px; color: var(--muted-foreground); text-align: center; }
  .gif-picker-more { align-self: center; }
  .gif-picker-manage { align-self: flex-start; font-size: 13px; }
  .gif-picker-error { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 4px; text-align: center; }
  .gif-picker-notice { margin: 0; color: var(--destructive); font-size: 13px; }
  .gif-picker-notice[hidden] { display: none; }
  .gif-picker-error[hidden] { display: none; }
  .gif-picker-error p { margin: 0; color: var(--muted-foreground); }

  /* Below 1100 px the picker is the inline sheet's dialog: the window is no box, the sheet draws itself. */
  @media (max-width: 1099px) {
    .gif-picker-window, .gif-picker-window[hidden] { display: contents; }
    .gif-picker-results { max-height: none; overflow: visible; }
    /* An inline sheet's body has no padding: the picker lines up with the sheet's title. */
    .gif-picker-body { padding: 0 var(--gutter) 12px; }
  }
}
