@layer components {
  /* A message's files under its text, one card each; the documents panel lists the same cards, compact. */
  .message-attachments-frame { display: block; }
  .message-attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 7px; max-width: 460px; }
  .file-card {
    margin: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--card); overflow: hidden;
    font-size: 13px;
  }
  .file-card-preview { position: relative; border-bottom: 1px solid var(--border); }
  .file-card-thumbnail {
    display: block; width: 100%; padding: 0; border: 0; border-radius: 0; appearance: none; font: inherit;
    color: inherit; background: var(--muted); line-height: 0; cursor: zoom-in;
  }
  .file-card-thumbnail:active { opacity: 0.85; }
  .file-card-thumbnail:focus-visible { outline-offset: -2px; }
  /* Never wider than the picture: enlarging a small one blurs it. */
  .file-card-thumbnail img { display: block; max-width: 100%; margin-inline: auto; height: auto; max-height: 280px; object-fit: contain; }
  /* A GIF fills its card: its tag and its play button sit on the picture. */
  .file-card-thumbnail img[data-gif-player-target] { width: 100%; }
  /* A thumbnail that could not be served leaves the card with its kind icon. */
  .file-card--no-thumbnail .file-card-preview { display: none; }
  .file-card-main { display: flex; gap: 10px; padding: 9px 11px; }
  .file-card-icon {
    width: 28px; height: 28px; flex: none; border-radius: 7px; background: var(--muted);
    display: inline-flex; align-items: center; justify-content: center; color: var(--muted-foreground);
  }
  .file-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  .file-card-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; color: var(--foreground); }
  .file-card-meta { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
  /* A file a service handed over says where it came from, in words. */
  .file-card-origin {
    display: inline-flex; align-items: center; gap: 4px;
    width: max-content; max-width: 100%; padding: 0 8px; border-radius: 99px; font-size: 13px;
    color: var(--jx-wait); background: var(--jx-wait-soft); overflow-wrap: anywhere;
  }
  .file-card-origin-logo { display: inline-flex; }
  .file-card-foot {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 7px 11px;
    border-top: 1px solid var(--border); background: var(--surface);
  }
  .file-card-state { flex: 1; margin: 0; min-width: 0; color: var(--muted-foreground); }
  .file-card-state strong { font-weight: 600; color: var(--foreground); }
  .file-card-state[data-state="ready"] strong { color: var(--jx-ok); }
  .file-card-state[data-state="failed"] strong, .file-card-state[data-state="too_large"] strong { color: var(--jx-no); }
  /* Why a file stayed a file or could not become a document: a line of its own under the read state. */
  .file-card-conversion { flex: 1 1 100%; margin: 0; color: var(--muted-foreground); }
  .file-card-actions { display: inline-flex; gap: 12px; margin-left: auto; }
  .file-card-action {
    background: none; border: 0; padding: 0; font: inherit; font-weight: 500; color: var(--foreground);
    text-decoration: none; cursor: pointer;
  }
  .file-card-action:hover { text-decoration: underline; }
  .file-card-action:active { opacity: 0.7; }
  /* The download icon sits on the thumbnail: shown on hover or keyboard focus, always on a touch screen. */
  .file-card-download {
    position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; display: inline-flex; align-items: center;
    justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--card); color: var(--foreground); box-shadow: var(--shadow-sm); opacity: 0;
  }
  .file-card-preview:focus-within .file-card-download { opacity: 1; }
  /* A real hover only: a tap hovers too, and iOS Safari then drops its click. */
  @media (hover: hover) { .file-card-preview:hover .file-card-download { opacity: 1; } }
  .file-card-download:hover { background: var(--muted); }
  .file-card-download:active { background: var(--accent); }
  @media (hover: none), (pointer: coarse) { .file-card-download { opacity: 1; } }
  @media (pointer: coarse) { .file-card-download { top: 8px; right: 8px; } }
  /* While the thumbnail shows, the icon and the thumbnail replace the foot's links; they come back if it fails. */
  .file-card--image:not(.file-card--no-thumbnail) .file-card-foot { display: none; }

  /* A page shown from its offline copy offers nothing that would fail. */
  html[data-offline-copy] .file-card-preview,
  html[data-offline-copy] .file-card-foot { display: none; }
  .file-card > .offline-unavailable { padding: 0 11px 9px; margin: 0; }
  .file-card--compact > .offline-unavailable { padding: 0 9px 7px; }

  .file-card--compact { border-radius: 8px; }
  .file-card--compact .file-card-main { padding: 7px 9px; gap: 8px; }
  .file-card--compact .file-card-text { gap: 4px; }
  .file-card--compact .file-card-name { text-decoration: none; }
  .file-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
  .file-card-kind {
    font-family: var(--font-mono); font-size: 13px; font-weight: 400; padding: 0 5px;
    border: 1px solid var(--border); border-radius: 4px; color: var(--muted-foreground);
  }
  .file-card--compact a.file-card-name:hover { text-decoration: underline; }
  .file-card--compact .file-card-foot { padding: 5px 9px; }
  /* In the panel the thumbnail, kept at the top, replaces the icon, name and badge; they return if it fails. */
  .file-card--compact .file-card-thumbnail img { max-height: 180px; }
  html:not([data-offline-copy]) .file-card--compact.file-card--image:not(.file-card--no-thumbnail) .file-card-icon { display: none; }
  /* Compact meta wraps between segments, never inside "déposé par X". */
  .file-card--compact .file-card-meta { display: flex; flex-wrap: wrap; column-gap: 5px; }
  .file-card--compact .file-card-meta-part { display: inline-flex; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .file-card--compact .file-card-meta-sep { white-space: normal; }
  /* An image card in the panel: name and meta form one caption under the thumbnail, no rule between them. */
  .file-card--compact.file-card--image:not(.file-card--no-thumbnail) .file-card-preview { border-bottom: 0; }
  .file-card--compact.file-card--image:not(.file-card--no-thumbnail) .file-card-head { flex-wrap: nowrap; }
  .file-card--compact.file-card--image:not(.file-card--no-thumbnail) .file-card-name {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal;
  }

  /* A GIF in a message: its label top left, its play or pause bottom left, both on their own dark ground. */
  .file-card-gif-tag, .file-card-gif-toggle {
    position: absolute; left: 8px; display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
    border: 0; border-radius: 6px; font: inherit; font-size: 13px; font-weight: 600; line-height: 1.5;
    color: white; background: color-mix(in oklch, black 68%, transparent);
  }
  .file-card-gif-tag { top: 8px; pointer-events: none; letter-spacing: .04em; }
  .file-card-gif-toggle { bottom: 8px; min-height: 28px; cursor: pointer; }
  .file-card-gif-toggle:hover { background: color-mix(in oklch, black 82%, transparent); }
  .file-card-gif-toggle:focus-visible { outline: 2px solid white; outline-offset: 2px; box-shadow: 0 0 0 4px black; }
  .file-card-gif-toggle [hidden] { display: none; }
  /* Inline, the icon would sit on the text's baseline, above the label's middle. */
  .file-card-gif-toggle svg { display: block; }
  @media (pointer: coarse) { .file-card-gif-toggle { min-height: 44px; min-width: 44px; justify-content: center; } }
}
