@layer components {
  /* The space's emoji page: drop zone, one row per file waiting (with its verdict), the catalogue table, who may add. */
  .emoji-dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px;
    border: 1px dashed var(--border); border-radius: var(--radius-md); text-align: center;
  }
  .emoji-dropzone p { margin: 0; color: var(--muted-foreground); }
  .emoji-dropzone--over { border-color: var(--jx-accent); background: var(--jx-accent-soft); }
  .emoji-dropzone:has(input:focus-visible) label { outline: 2px solid var(--jx-accent); outline-offset: 2px; }
  .emoji-upload .card-footer[hidden], .emoji-plain[hidden], .emoji-upload [data-emoji-upload-target=fallback][hidden] { display: none; }

  .emoji-upload-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
  .emoji-upload-row {
    display: grid; grid-template-columns: 56px 200px 1fr 200px auto; gap: 6px 14px; align-items: start; padding: 12px;
    border: 1px solid var(--border); border-radius: var(--radius-md);
  }
  .emoji-upload-row.is-bad { border-color: color-mix(in oklch, var(--jx-no) 40%, var(--border)); }
  .emoji-upload-thumb { grid-row: span 2; width: 56px; height: 56px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--muted); }
  .emoji-upload-thumb img { width: 44px; height: 44px; object-fit: contain; }
  .emoji-upload-file { grid-column: 2 / -1; font-weight: 600; overflow-wrap: anywhere; }
  .emoji-upload-row .field-error, .emoji-upload-row .ok-line { grid-column: 2 / -1; margin: 0; }
  .emoji-upload-discard { margin-top: 26px; }
  .ok-line { font-size: 13px; color: var(--jx-ok); display: flex; align-items: center; gap: 4px; }
  .ok-line[hidden] { display: none; }
  .ok-line svg { width: 14px; height: 14px; }

  .name-input { position: relative; }
  .name-input .input { font-family: var(--font-mono); font-size: 13px; padding-inline: 18px; }
  .name-input::before, .name-input::after { content: ":"; position: absolute; top: 7px; font-family: var(--font-mono); color: var(--muted-foreground); }
  .name-input::before { left: 9px; }
  .name-input::after { right: 9px; }

  /* The picture at 20 px on a light and on a dark ground, whatever the theme: the real test of an emoji. */
  .emoji-upload-preview { display: flex; gap: 6px; }
  .emoji-upload-preview-chip { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px; border: 1px solid; border-radius: 8px; font-size: 13px; line-height: 1; }
  .emoji-upload-preview-chip.on-light { background: oklch(1 0 0); color: oklch(0.3 0 0); border-color: oklch(0.9 0 0); }
  .emoji-upload-preview-chip.on-dark { background: oklch(0.205 0 0); color: oklch(0.85 0 0); border-color: oklch(1 0 0 / 0.14); }
  .emoji-upload-preview-img { width: 20px; height: 20px; object-fit: contain; }

  .catalog-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .emojis-admin-search { display: flex; flex: 1; gap: 8px; min-width: 200px; }
  .emojis-admin-search .input { flex: 1; min-width: 200px; }
  .emoji-filters { display: flex; gap: 8px; }
  .filter-chip {
    display: inline-flex; align-items: center; height: 36px; padding: 0 12px; border: 1px solid var(--input); border-radius: var(--radius-md);
    background: var(--background); color: var(--foreground); font: inherit; font-size: 13px; text-decoration: none; cursor: pointer;
  }
  .filter-chip[aria-current="true"] { background: var(--jx-accent-soft); border-color: var(--jx-accent-line); color: var(--jx-accent); font-weight: 600; }

  .emoji-table .cell-img { width: 44px; }
  .emoji-table .emoji-thumb { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; }
  .emoji-table .emoji-thumb--empty { display: inline-block; border-radius: var(--radius-sm); background: var(--muted); }
  .emoji-table code { white-space: nowrap; }
  .emoji-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .emoji-actions { display: flex; justify-content: flex-end; gap: 6px; min-height: 32px; }
  .emoji-actions form { display: contents; }
  .emoji-table tr.is-retired .emoji-thumb { filter: grayscale(1); opacity: 0.6; }
  .emojis-admin-pages { display: flex; gap: 8px; justify-content: center; }

  .emoji-access .button { align-self: flex-start; }
  .who-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .who-choice { display: grid; gap: 4px; padding: 12px 14px; cursor: pointer; border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); }
  .who-choice:has(input:checked) { border-color: var(--jx-accent-line); background: var(--jx-accent-soft); }
  .who-choice:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--jx-accent); }
  .who-title { display: flex; gap: 8px; align-items: center; font-weight: 600; }
  .who-title input { margin: 0; accent-color: var(--primary); }

  @media (max-width: 767px) {
    .who-choices { grid-template-columns: 1fr; }
    .emoji-upload-row { grid-template-columns: 1fr; }
    .emoji-upload-thumb { grid-row: auto; }
    .emoji-upload-file, .emoji-upload-row .field-error, .emoji-upload-row .ok-line { grid-column: auto; }
    .emoji-upload-discard { margin-top: 0; justify-self: start; }

    /* The table becomes a list: picture, name and who, then the actions on their own line (nothing scrolls sideways). */
    .emoji-table, .emoji-table tbody { display: block; }
    .emoji-table thead { display: none; }
    .emoji-table tr { display: grid; grid-template-columns: 44px 1fr; align-items: center; column-gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
    .emoji-table td { display: block; padding: 0; border: 0; }
    .emoji-table .cell-img { grid-row: span 3; }
    .emoji-table .emoji-words { display: none; }
    .emoji-table .num { text-align: left; color: var(--muted-foreground); font-size: 13px; }
    .emoji-table td:has(.emoji-actions) { grid-column: 1 / -1; padding-top: 6px; }
    .emoji-actions { flex-wrap: wrap; }
  }
}
