/* The attachment look agreed with Felix on 4 Nov 2026 (2:15 PM SGT).
   Pictures: small same-height thumbnails that wrap, sit to the right, above the message. Everything else: one compact chip.
   Annotations: a small chip with a pen and a count; hovering it shows each selected text and comment with edit and delete.
   The message box and the sent message use the same rules. Phone sizes are the :root values in the media block. */
:root {
  --attach-thumb-h: 56px;
  --attach-chip-h: 28px;
  --attach-chip-max: 190px;
  --attach-gap: 6px;
}
@media (max-width: 600px) {
  :root {
    --attach-thumb-h: 44px;
    --attach-chip-max: 150px;
    --attach-gap: 4px;
  }
}

/* The row of attachments above a message, aligned to the left (Felix, 4 Nov 3:14 PM SGT). */
.attachment-list, .msg-wrapper > .attachment-list {
  display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: flex-start;
  gap: var(--attach-gap); width: 100%; max-width: 100%; box-sizing: border-box; margin: 0 0 6px;
}
.team-msg:not(.team-user) .attachment-list { justify-content: flex-start; }
#image-preview { gap: var(--attach-gap); align-items: flex-end; }
#image-preview .pending-file-preview { min-width: 0; min-height: 0; }

/* Picture thumbnail */
.attachment-card-thumb, #image-preview .attachment-card-thumb {
  display: inline-flex; flex-direction: row; width: auto; max-width: none; height: var(--attach-thumb-h);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden; box-sizing: content-box;
}
.attachment-card.attachment-card-thumb .attachment-media, #image-preview .attachment-card.attachment-card-thumb .attachment-media {
  display: block; width: auto; height: var(--attach-thumb-h); max-height: var(--attach-thumb-h);
  max-width: calc(var(--attach-thumb-h) * 1.5); min-width: calc(var(--attach-thumb-h) * 0.6);
  object-fit: cover; border: 0; border-radius: 0; cursor: zoom-in;
}

/* Compact chip: icon, name, size or length */
.attachment-card-chip, #image-preview .attachment-card-chip {
  display: inline-flex; flex-direction: row; align-items: center; width: auto; max-width: var(--attach-chip-max); min-width: 0;
}
.attachment-card-chip .pdf-attachment, #image-preview .attachment-card-chip .pdf-attachment {
  display: inline-flex; align-items: center; gap: 6px; width: auto; max-width: var(--attach-chip-max); min-width: 0;
  height: var(--attach-chip-h); padding: 0 10px 0 6px; box-sizing: border-box; border-radius: calc(var(--attach-chip-h) / 2); font-size: 12px;
}
.attachment-card-chip .pdf-attachment-icon, #image-preview .attachment-card-chip .pdf-attachment-icon {
  flex: 0 0 16px; width: 16px; height: 16px; background: transparent; border-radius: 0; font-size: 0;
}
.attachment-card-chip .pdf-attachment-icon svg, #image-preview .attachment-card-chip .pdf-attachment-icon svg { width: 14px; height: 14px; }
.attachment-card-chip .pdf-attachment-name, #image-preview .attachment-card-chip .pdf-attachment-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; opacity: 1;
}
.attachment-card-chip .pdf-attachment-size { flex: none; font-size: 11px; opacity: 0.55; }
.attachment-card .attachment-media[hidden], .attachment-card audio.attachment-media[hidden], .attachment-card video.attachment-media[hidden] { display: none; }
/* A voice note or video opens its player under the chip when the chip is tapped */
.attachment-card-chip.attachment-card-playing { flex-direction: column; align-items: stretch; max-width: min(300px, 100%); }
.attachment-card-chip.attachment-card-playing .attachment-media { width: 100%; max-height: 160px; }
.attachment-card-chip .attachment-unavailable { display: none; }
.attachment-card-chip .pdf-attachment[aria-label^="File unavailable"] { border-color: var(--pc07-preserved-paint-1); }

/* Pasted-text card in a sent message: the same chip */
.sent-paste-card { height: var(--attach-chip-h); padding: 0 10px; margin: 0 2px; border-radius: calc(var(--attach-chip-h) / 2); max-width: var(--attach-chip-max); box-sizing: border-box; font-size: 12px; }
.sent-paste-card .sent-paste-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chips in the queue list */
#durable-conversation-queue .queue-attachment-chip { height: var(--attach-chip-h); box-sizing: border-box; border-radius: calc(var(--attach-chip-h) / 2); max-width: var(--attach-chip-max); }

/* Annotation chip: small, a pen and a count; the quoted text is in the hover card */
.response-annotation-pending, .response-annotation-sent,
#image-preview .response-annotation-pending, .msg.user .response-annotation-sent, .msg.user .response-annotation-sent:first-child {
  position: relative; display: inline-flex; width: auto; max-width: var(--attach-chip-max); margin: 0; padding: 0; background: none; border: 0; box-shadow: none;
}
.response-annotation-pending .response-annotation-pending__open, #image-preview .response-annotation-pending .response-annotation-pending__open,
.response-annotation-sent .response-annotation-sent__open, .msg.user .response-annotation-sent .response-annotation-sent__open {
  display: inline-flex; align-items: center; flex-wrap: nowrap; gap: 6px; width: auto; max-width: 100%; height: var(--attach-chip-h);
  padding: 0 10px 0 6px; box-sizing: border-box; border-radius: calc(var(--attach-chip-h) / 2); white-space: nowrap; font-size: 12px;
}
.response-annotation-pending .response-annotation-pending__icon, #image-preview .response-annotation-pending .response-annotation-pending__icon,
.response-annotation-sent .response-annotation-sent__icon, .msg.user .response-annotation-sent .response-annotation-sent__icon {
  flex: 0 0 16px; width: 16px; height: 16px; background: transparent; border-radius: 0;
}
.response-annotation-pending__icon svg, .response-annotation-sent__icon svg { width: 14px; height: 14px; }
.response-annotation-pending .response-annotation-pending__preview, #image-preview .response-annotation-pending .response-annotation-pending__preview,
.response-annotation-sent .response-annotation-sent__preview, .msg.user .response-annotation-sent .response-annotation-sent__preview { display: none; }
.response-annotation-pending .pdf-attachment-name, .response-annotation-sent .pdf-attachment-name { font-size: 12px; max-width: none; }

/* The hover card */
.annotation-hover-card {
  display: none; position: absolute; bottom: 100%; left: 0; z-index: 60; width: max-content; max-width: min(290px, calc(100vw - 24px));
  box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-raised, var(--pc07-preserved-paint-2));
  color: var(--text, var(--pc07-preserved-paint-3)); font-size: 12px; line-height: 1.4; text-align: left; white-space: normal; box-shadow: 0 6px 18px var(--pc07-preserved-paint-4);
}
/* the hover card opens from the left edge of its chip */
.response-annotation-pending:hover .annotation-hover-card, .response-annotation-pending:focus-within .annotation-hover-card,
.response-annotation-sent:hover .annotation-hover-card, .response-annotation-sent:focus-within .annotation-hover-card { display: block; }
.annotation-hover-item + .annotation-hover-item { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.annotation-hover-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.annotation-hover-card b { display: block; font-weight: 500; opacity: 0.6; }
.annotation-hover-quote, .annotation-hover-comment { overflow-wrap: anywhere; margin-bottom: 4px; }
.annotation-hover-actions { display: inline-flex; gap: 2px; }
.annotation-hover-actions button { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
.annotation-hover-actions button:hover, .annotation-hover-actions button:focus-visible { background: var(--pc07-preserved-paint-5); }
.annotation-hover-actions svg { width: 14px; height: 14px; }

/* The sent annotation chip sits above its message, left aligned, like the picture row (the chip stays inside the bubble in the DOM) */
.msg.user:has(> .response-annotation-sent) { position: relative; margin-top: calc(var(--attach-chip-h) + 8px); }
.msg.user > .response-annotation-sent, .msg.user > .response-annotation-sent:first-child { position: absolute; left: 0; bottom: 100%; margin: 0 0 4px; }
/* Opened by a tap or click on the chip (a phone has no hover) */
.response-annotation-pending.is-open .annotation-hover-card, .response-annotation-sent.is-open .annotation-hover-card { display: block; }
