/* Chat
/* -------------------------------------------------------------------------- */

.chat {
  --chat-radius: 12px;

  background: var(--color-canvas);
  border: var(--border);
  border-radius: var(--chat-radius);
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  height: calc(100dvh - 3.25rem - 5rem);
  min-height: 24rem;
  overflow: hidden;
}

/* Sidebar */

.chat-sidebar {
  background: var(--color-ink-lightest);
  border-right: var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-sidebar-header {
  align-items: center;
  border-bottom: var(--border);
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}

.chat-sidebar-title { font-size: 0.95rem; font-weight: 600; margin: 0; }

.chat-sidebar-scroll { flex: 1; overflow-y: auto; padding: 0.25rem 0.5rem 1rem; }

.chat-sidebar-label {
  color: var(--color-ink-medium);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 1rem 0.5rem 0.35rem;
  text-transform: uppercase;
}

.chat-sidebar-empty { color: var(--color-ink-medium); font-size: 0.8rem; margin: 0 0.5rem; }

.chat-room-list { display: grid; gap: 1px; }

.chat-room-form { margin: 0; }

.chat-room-link {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--color-ink-dark);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 0.85rem;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.chat-room-link:hover { background: var(--color-ink-lighter); color: var(--color-ink); }
.chat-room-link--current { background: var(--color-theme-lightest); color: var(--color-theme); }
.chat-room-link--unread { color: var(--color-ink); font-weight: 600; }

.chat-room-icon { color: var(--color-ink-medium); flex-shrink: 0; height: 1rem; width: 1rem; }

.chat-room-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-unread-dot { background: var(--color-theme); border-radius: 50%; flex-shrink: 0; height: 0.5rem; width: 0.5rem; }

.chat-icon-btn {
  align-items: center;
  border-radius: 50%;
  color: var(--color-ink-medium);
  display: flex;
  height: 1.75rem;
  justify-content: center;
  width: 1.75rem;
}

.chat-icon-btn:hover { background: var(--color-ink-lighter); color: var(--color-ink); }
.chat-icon-btn svg { height: 1rem; width: 1rem; }

/* Badge on the dashboard sidebar link */

.chat-badge-slot { margin-left: auto; }

.chat-badge {
  background: var(--color-negative);
  border-radius: 999px;
  color: var(--color-white);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.2rem 0.4rem;
}

/* Room */

.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.chat-main--empty {
  align-items: center;
  color: var(--color-ink-medium);
  font-size: 0.9rem;
  justify-content: center;
}

.chat-header {
  align-items: center;
  border-bottom: var(--border);
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
}

.chat-header form { margin: 0; }

.chat-header-title { flex: 1; min-width: 0; }
.chat-header-title h2 { font-size: 0.95rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-title span { color: var(--color-ink-medium); display: block; font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-header-action {
  background: none;
  border: 0;
  color: var(--color-ink-medium);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  text-decoration: none;
}

.chat-header-action:hover { color: var(--color-ink); text-decoration: underline; }
.chat-header-action--danger:hover { color: var(--color-negative); }

.chat-back { color: var(--color-ink-medium); display: none; }
.chat-back svg { height: 1.25rem; width: 1.25rem; }

/* Messages: avatar beside a soft bubble with the name and time
   inside it; yours mirrored to the right; runs from one person thread together. */

.chat-messages {
  --message-gap: 0.75ch;
  --message-space: 1.1rem;
  --bubble-radius: 0.9em;
  --avatar-col: 2rem;

  display: grid;
  flex: 1;
  grid-auto-rows: min-content;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem clamp(0.75rem, 2vw, 1.5rem) 1.75rem;
  row-gap: var(--message-space);
}

.chat-message {
  column-gap: var(--message-gap);
  display: grid;
  grid-template-areas:
    "sep sep"
    "avatar body";
  grid-template-columns: var(--avatar-col) minmax(0, 1fr);
  position: relative;
}

.chat-message--threaded { margin-block-start: calc(var(--message-space) * -1 + 0.2rem); }
.chat-message--threaded .chat-message-avatar { visibility: hidden; }
.chat-message--threaded .chat-bubble-author { display: none; }

.chat-message-avatar { align-self: start; display: flex; grid-area: avatar; }
.chat-message-avatar > * { height: 2rem; width: 2rem; }

.chat-message-frame { display: block; grid-area: body; justify-self: start; max-width: min(42rem, 85%); min-width: 0; }

/* Day separator */

.chat-day-separator {
  align-items: center;
  color: var(--color-ink-medium);
  display: none;
  font-size: 0.7rem;
  font-weight: 600;
  gap: 0.75rem;
  grid-area: sep;
  grid-template-columns: 1fr auto 1fr;
  letter-spacing: 0.04em;
  margin-block: 0.5rem 0.25rem;
  text-transform: uppercase;
}

.chat-day-separator::before,
.chat-day-separator::after { border-top: 1px solid var(--color-ink-lighter); content: ""; }

.chat-day-separator span { background: var(--color-ink-lightest); border-radius: 3em; padding: 0.35em 1.1em; }

.chat-message--first-of-day .chat-day-separator { display: grid; }

/* Bubble */

.chat-bubble {
  background: var(--message-background, var(--color-ink-lightest));
  border-radius: var(--bubble-radius);
  color: var(--color-ink);
  max-width: 100%;
  padding: 0.55rem 0.9rem 0.6rem;
  position: relative;
  width: fit-content;
}

.chat-bubble-meta {
  align-items: baseline;
  display: flex;
  font-size: 0.75rem;
  gap: 0.5ch;
  line-height: 1.4;
}

.chat-bubble-author { color: var(--color-ink); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-bubble-time { color: var(--color-ink-medium); white-space: nowrap; }

.chat-bubble-body { font-size: 0.92rem; line-height: 1.45; overflow-wrap: anywhere; }
.chat-bubble-body > :first-child { margin-top: 0.1rem; }
.chat-bubble-body > :last-child { margin-bottom: 0; }

/* Threaded messages lose their header, so the time waits beside the bubble until hover. */
.chat-message--threaded .chat-bubble-meta {
  inset-block-start: 50%;
  inset-inline-start: calc(100% + 0.5rem);
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transform: translateY(-50%);
  transition: opacity 120ms;
}

.chat-message--threaded:hover .chat-bubble-meta { opacity: 1; }

/* Hover actions perch on the bubble's top corner. */
.chat-bubble-actions {
  align-items: center;
  background: var(--color-canvas);
  border: var(--border);
  border-radius: 999px;
  box-shadow: 0 2px 6px oklch(0 0 0 / 0.08);
  display: flex;
  gap: 0.1rem;
  inset-block-start: -0.9rem;
  inset-inline-end: -0.5rem;
  opacity: 0;
  padding: 0.1rem;
  pointer-events: none;
  position: absolute;
  transition: opacity 120ms;
  z-index: 2;
}

.chat-message:hover .chat-bubble-actions,
.chat-bubble-actions:focus-within { opacity: 1; pointer-events: auto; }

.chat-bubble-action-form { display: flex; margin: 0; }

.chat-bubble-action {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--color-ink-medium);
  cursor: pointer;
  display: flex;
  height: 1.6rem;
  justify-content: center;
  padding: 0;
  width: 1.6rem;
}

.chat-bubble-action svg { height: 0.9rem; width: 0.9rem; }
.chat-bubble-action:hover { background: var(--color-ink-lightest); color: var(--color-ink); }
.chat-bubble-action--delete:hover { color: var(--color-negative); }

/* Yours to edit and delete, or anyone's for an admin. A customer's
   own words, and files, can only be deleted. Nothing left to offer, no toolbar. */
.chat-messages:not(.chat-messages--admin) .chat-message:not(.chat-message--me) .chat-bubble-actions,
.chat-message--inbound .chat-bubble-action--edit,
.chat-message--attachment .chat-bubble-action--edit,
.chat-message--pending .chat-bubble-actions { display: none; }

/* Yours, mirrored onto the right in the theme colour. */
.chat-message:is(.chat-message--me, .chat-message--outbound) {
  grid-template-areas:
    "sep sep"
    "body avatar";
  grid-template-columns: minmax(0, 1fr) var(--avatar-col);
}

:is(.chat-message--me, .chat-message--outbound) .chat-message-frame { justify-self: end; }
:is(.chat-message--me, .chat-message--outbound) .chat-bubble { --message-background: var(--color-theme-lightest); margin-inline-start: auto; }
:is(.chat-message--me, .chat-message--outbound) .chat-bubble-meta { flex-direction: row-reverse; justify-content: flex-start; }
:is(.chat-message--me, .chat-message--outbound) .chat-bubble-actions { inset-inline-end: auto; inset-inline-start: -0.5rem; }
.chat-message:is(.chat-message--me, .chat-message--outbound).chat-message--threaded .chat-bubble-meta { inset-inline-end: calc(100% + 0.5rem); inset-inline-start: auto; }

/* The assistant answers in its own colour, so nobody mistakes it for a teammate. */
.chat-message--assistant .chat-bubble { --message-background: oklch(var(--lch-blue-medium) / 0.12); }

.chat-assistant-avatar {
  align-items: center;
  background: var(--color-ink);
  border-radius: 50%;
  color: var(--color-canvas);
  display: flex;
  justify-content: center;
}

.chat-assistant-avatar svg { height: 1rem; width: 1rem; }

/* Sending, and what didn't make it */
.chat-message--pending .chat-bubble { opacity: 0.6; }

.chat-message--failed .chat-bubble {
  animation: chat-wiggle 0.4s both;
  opacity: 0.6;
  outline: 1px dashed var(--color-negative);
}

.chat-message--failed .chat-bubble-time { color: var(--color-negative); }
.chat-message--failed .chat-bubble-time::after { content: " · Not sent"; }

@keyframes chat-wiggle {
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}

/* Editing in place */
.chat-bubble--editing { display: grid; gap: 0.5rem; min-width: min(32rem, 70vw); width: 100%; }
.chat-bubble--editing form { margin: 0; }
.chat-bubble--editing lexxy-editor { background: var(--color-canvas); border: 1px solid var(--color-theme); border-radius: 0.6rem; box-shadow: 0 0 0 3px var(--color-theme-lightest); max-height: 16rem; padding: 0.4rem 0.65rem; }
.chat-bubble-edit-actions { align-items: center; display: flex; gap: 0.5rem; justify-content: flex-end; }
.chat-bubble--editing .chat-edit-delete { margin: 0 auto 0 0; }
.chat-edit-hint { color: var(--color-ink-medium); font-size: 0.7rem; }
.chat-edit-error { color: var(--color-negative); font-size: 0.78rem; margin: 0 0 0.35rem; }

@media (max-width: 768px) { .chat-edit-hint { display: none; } }

.chat-edit-btn {
  background: none;
  border: var(--border);
  border-radius: 999px;
  color: var(--color-ink-dark);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.8rem;
  text-decoration: none;
}

.chat-edit-btn--primary { background: var(--color-theme); border-color: var(--color-theme); color: var(--color-theme-ink); }

.chat-edit-btn--danger { align-items: center; color: var(--color-ink-medium); display: flex; padding: 0.3rem; }
.chat-edit-btn--danger svg { height: 0.95rem; width: 0.95rem; }
.chat-edit-btn--danger:hover { border-color: var(--color-negative); color: var(--color-negative); }

/* Composer: a rounded pill with the send button inside it, and
   who's typing floating just above. */

.chat-composer-wrap { padding: 0 clamp(0.75rem, 2vw, 1.5rem) 0.9rem; position: relative; }

.chat-composer { margin: 0; }

.chat-composer-input-wrap {
  align-items: flex-end;
  background: var(--color-canvas);
  border: 1px solid var(--color-ink-lighter);
  border-radius: 1.4rem;
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
  transition: border-color 120ms, box-shadow 120ms;
}

.chat-composer-input-wrap:focus-within {
  border-color: var(--color-theme);
  box-shadow: 0 0 0 3px var(--color-theme-lightest);
}

.chat-composer-hint {
  color: var(--color-ink-medium);
  flex-shrink: 0;
  height: 1.25rem;
  margin-block-end: 0.4rem;
  width: 1.25rem;
}

.chat-composer-input {
  align-self: center;
  flex: 1;
  font-size: 0.92rem;
  max-height: 12rem;
  min-width: 0;
  overflow-y: auto;
  padding-block: 0.35rem;
}

/* One line to start, growing as you write. */
.chat-composer-input .lexxy-editor__content,
.chat-bubble--editing .lexxy-editor__content { margin: 0; min-block-size: 1lh; }

.chat-composer-input .lexxy-editor__content > p,
.chat-bubble--editing .lexxy-editor__content > p { margin: 0; }

.chat-composer-send {
  align-items: center;
  background: var(--color-theme);
  border: 0;
  border-radius: 50%;
  color: var(--color-theme-ink);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 2.1rem;
  justify-content: center;
  transition: background 120ms, transform 80ms;
  width: 2.1rem;
}

.chat-composer-send:hover { background: var(--color-theme-hover); }
.chat-composer-send:active { transform: scale(0.94); }
.chat-composer-send svg { height: 1.05rem; width: 1.05rem; }

@media (max-width: 768px) {
  .chat-composer-wrap:focus-within .chat-composer-hint { display: none; }
}

/* Typing indicator */

.chat-typing {
  align-items: center;
  color: var(--color-ink-medium);
  display: flex;
  font-size: 0.75rem;
  gap: 0.5rem;
  inset-block-end: calc(100% - 0.35rem);
  inset-inline-start: calc(clamp(0.75rem, 2vw, 1.5rem) + 0.9rem);
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transform: translateY(0.35rem);
  transition: opacity 200ms ease, transform 200ms ease;
}

.chat-typing--active { opacity: 1; transform: translateY(0); }

.chat-typing-dots { display: inline-flex; gap: 3px; }

.chat-typing-dots i {
  animation: chat-typing-bounce 1.2s infinite ease-in-out;
  background: currentColor;
  border-radius: 50%;
  display: block;
  height: 5px;
  width: 5px;
}

.chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-typing-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing-dots i, .chat-message--failed .chat-bubble { animation: none; }
}

/* Room form */

.chat-room-form-page { display: grid; gap: 1.25rem; max-width: 32rem; }
.chat-room-form-page fieldset { border: 0; margin: 0; padding: 0; }
.chat-room-form-page fieldset[hidden] { display: none; }

.chat-choice { align-items: center; display: flex; font-size: 0.9rem; gap: 0.5rem; padding: 0.3rem 0; }

.chat-hint { color: var(--color-ink-medium); font-size: 0.8rem; margin: 0.25rem 0 0; }

.chat-form-actions { align-items: center; display: flex; gap: 1rem; }

/* One pane at a time on small screens: the list, or the room you opened. */
@media (max-width: 768px) {
  .chat { grid-template-columns: 1fr; height: calc(100dvh - 3.25rem - 3rem); }
  .chat--room .chat-sidebar { display: none; }
  .chat:not(.chat--room) .chat-main { display: none; }
  .chat-back { display: flex; }
  .chat-message-frame { max-width: 92%; }
}

/* WhatsApp */

/* The customer's side of the conversation, marked out from teammates. */
/* WhatsApp rooms: the customer on the left in a plain bubble, the team on the right in
   WhatsApp green, and the time with its ticks tucked into each bubble's corner. */
.chat-messages--relayed {
  --whatsapp-green: #25d366;
  --whatsapp-outbound: color-mix(in srgb, var(--whatsapp-green) 16%, var(--color-canvas));
}

.chat-messages--relayed .chat-message--inbound .chat-bubble { --message-background: var(--color-canvas); border: var(--border); }
.chat-messages--relayed .chat-message--outbound .chat-bubble { --message-background: var(--whatsapp-outbound); }
.chat-messages--relayed .chat-message--assistant .chat-bubble { --message-background: oklch(var(--lch-blue-medium) / 0.12); }

/* The time and ticks sit in the bubble's bottom corner, as in WhatsApp. An invisible
   gap at the end of the text keeps the last line from running under them, so the
   bubble stays as narrow as its words. */
.chat-messages--relayed .chat-bubble { --footer-space: 4.4rem; }
.chat-messages--relayed .chat-message--outbound .chat-bubble { --footer-space: 5.6rem; }

.chat-messages--relayed .chat-bubble-meta .chat-bubble-time { display: none; }
.chat-messages--relayed .chat-message--threaded .chat-bubble-meta { display: none; }

.chat-messages--relayed .chat-bubble-body p:last-of-type::after {
  content: "";
  display: inline-block;
  width: var(--footer-space);
}

.chat-bubble-footer {
  align-items: center;
  color: var(--color-ink-medium);
  display: inline-flex;
  font-size: 0.68rem;
  gap: 0.25rem;
  inset-block-end: 0.45rem;
  inset-inline-end: 0.7rem;
  line-height: 1;
  position: absolute;
  white-space: nowrap;
}

/* Files: a caption sits under the file; without one the time needs a line of its own,
   except on a photo, where it sits on the picture. */
.chat-messages--relayed .chat-message--attachment .chat-bubble-body { padding: 0.35rem 0.4rem 0.1rem; }
.chat-messages--relayed .chat-message--attachment .chat-bubble:not(:has(.chat-bubble-body)) { padding-block-end: 1.45rem; }

.chat-messages--relayed .chat-bubble:has(> .chat-attachment--image):not(:has(.chat-bubble-body)) { padding-block-end: 0.35rem; }
.chat-messages--relayed .chat-bubble:has(> .chat-attachment--image):not(:has(.chat-bubble-body)) .chat-bubble-footer {
  background: oklch(0 0 0 / 0.35);
  border-radius: 999px;
  color: #fff;
  inset-block-end: 0.75rem;
  inset-inline-end: 0.85rem;
  padding: 0.2rem 0.45rem;
}

.chat-messages--relayed .chat-bubble:has(> .chat-attachment--image):not(:has(.chat-bubble-body)) .chat-delivery:not(.chat-delivery--read, .chat-delivery--failed) { color: #fff; }

.chat-attachment--audio { display: block; max-width: 100%; width: 18rem; }

/* A failed message spells out why, with the time beneath. */
.chat-messages--relayed .chat-bubble:has(.chat-delivery-error) { padding-block-end: 1.5rem; }

.chat-delivery-error {
  color: var(--color-negative);
  font-size: 0.72rem;
  margin: 0.35rem 0 0;
}

.chat-message--outbound:has(.chat-delivery--failed) .chat-bubble { outline: 1px dashed var(--color-negative); }

/* What went out over WhatsApp can't be changed on the customer's phone. */
.chat-messages--relayed .chat-bubble-action--edit { display: none; }

.chat-delivery { color: var(--color-ink-medium); display: inline-flex; }
.chat-delivery svg { height: 0.95rem; width: 0.95rem; }
.chat-delivery--pending svg { height: 0.8rem; width: 0.8rem; }
.chat-delivery--read { color: #34b7f1; }
.chat-delivery--failed { color: var(--color-negative); }

.chat-window-closed {
  background: var(--color-ink-lightest);
  border-radius: 1rem;
  color: var(--color-ink-dark);
  font-size: 0.82rem;
  margin: 0 clamp(0.75rem, 2vw, 1.5rem) 0.9rem;
  padding: 0.85rem 1rem;
}

.whatsapp-setup { display: grid; gap: 0.5rem; }
.whatsapp-setup ol { margin: 0; padding-left: 1.25rem; }
.whatsapp-setup li { font-size: 0.85rem; margin-bottom: 0.35rem; }
.whatsapp-copy { font-family: ui-monospace, monospace; font-size: 0.8rem; }

.chat-involvement { display: contents; }

.chat-involvement__button {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  cursor: pointer;
}

.chat-involvement__button svg { width: 1rem; height: 1rem; }
.chat-involvement__button--on { color: var(--color-theme); }

@media (max-width: 640px) {
  .chat-involvement__button span { display: none; }
}

/* Attachments: a file is its own message. Images and video sit in
   the bubble edge to edge, under the name and time; other files are a download card. */

.chat-message--attachment .chat-bubble { padding: 0.35rem; }
.chat-message--attachment .chat-bubble-meta { padding: 0.15rem 0.5rem 0.35rem; }
.chat-message--attachment.chat-message--threaded .chat-bubble-meta { padding: 0; }

.chat-attachment { display: block; }

.chat-attachment--image,
.chat-attachment--video {
  border-radius: calc(var(--bubble-radius) - 0.3rem);
  max-height: 22rem;
  max-width: min(100%, 28rem);
  overflow: hidden;
}

.chat-attachment--image { cursor: zoom-in; }

/* Capped in absolute units so the bubble shrinks to the picture, not its pixel size. */
.chat-attachment--image img {
  display: block;
  height: auto;
  max-height: 22rem;
  max-width: min(28rem, 70vw);
  object-fit: contain;
  width: auto;
}

.chat-attachment--video { background: #000; width: min(28rem, 70vw); }

.chat-attachment--file {
  align-items: center;
  background: var(--color-canvas);
  border: var(--border);
  border-radius: calc(var(--bubble-radius) - 0.3rem);
  color: var(--color-ink);
  display: flex;
  gap: 0.65rem;
  max-width: 22rem;
  padding: 0.55rem 0.75rem;
  text-decoration: none;
}

.chat-attachment--file:hover { border-color: var(--color-theme); }

.chat-attachment-icon {
  align-items: center;
  background: var(--color-theme-lightest);
  border-radius: 0.4rem;
  color: var(--color-theme);
  display: flex;
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 700;
  height: 2.25rem;
  justify-content: center;
  letter-spacing: 0.03em;
  width: 2.25rem;
}

.chat-attachment-details { display: grid; min-width: 0; }
.chat-attachment-details strong { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attachment-details span { color: var(--color-ink-medium); font-size: 0.72rem; }

/* Waiting to send */

.chat-composer-files { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chat-composer-files:not(:empty) { padding-block-end: 0.6rem; }

.chat-composer-file {
  align-items: center;
  background: var(--color-canvas);
  border: var(--border);
  border-radius: 0.75rem;
  color: var(--color-ink);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 0.78rem;
  gap: 0.5rem;
  max-width: 14rem;
  padding: 0.3rem 0.6rem 0.3rem 0.3rem;
  position: relative;
}

.chat-composer-file img { border-radius: 0.5rem; flex-shrink: 0; height: 2.25rem; object-fit: cover; width: 2.25rem; }
.chat-composer-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-composer-file::after {
  align-items: center;
  background: var(--color-ink);
  border-radius: 50%;
  color: var(--color-canvas);
  content: "×";
  display: flex;
  font-size: 0.8rem;
  height: 1.1rem;
  inset-block-start: -0.4rem;
  inset-inline-end: -0.4rem;
  justify-content: center;
  line-height: 1;
  opacity: 0;
  position: absolute;
  transition: opacity 120ms;
  width: 1.1rem;
}

.chat-composer-file:hover::after,
.chat-composer-file:focus-visible::after { opacity: 1; }
.chat-composer-file:hover { border-color: var(--color-negative); }

@media (hover: none) { .chat-composer-file::after { opacity: 1; } }

.chat-composer-attach {
  align-items: center;
  border-radius: 50%;
  color: var(--color-ink-medium);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 2.1rem;
  justify-content: center;
  margin-inline-start: -0.5rem;
  width: 2.1rem;
}

.chat-composer-attach:hover { background: var(--color-ink-lightest); color: var(--color-ink); }
.chat-composer-attach:focus-within { outline: 2px solid var(--color-theme); }
.chat-composer-attach svg { height: 1.2rem; width: 1.2rem; }

/* Uploading */

.chat-upload {
  --progress: 0%;

  align-items: center;
  border-radius: calc(var(--bubble-radius) - 0.3rem);
  display: flex;
  font-size: 0.82rem;
  gap: 0.6rem;
  isolation: isolate;
  min-width: 14rem;
  overflow: hidden;
  padding: 0.5rem 0.75rem 0.5rem 0.5rem;
  position: relative;
}

.chat-upload::before {
  background: var(--color-theme-lightest);
  content: "";
  inset: 0 auto 0 0;
  position: absolute;
  transition: width 150ms linear;
  width: var(--progress);
  z-index: -1;
}

.chat-upload-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-upload-percent { color: var(--color-ink-medium); font-variant-numeric: tabular-nums; }
.chat-message--pending .chat-upload { opacity: 1; }

/* Dropping files anywhere on the room */

.chat-main { position: relative; }

.chat-drop-hint {
  align-items: center;
  background: oklch(from var(--color-canvas) l c h / 0.85);
  border: 2px dashed var(--color-theme);
  border-radius: var(--chat-radius);
  color: var(--color-theme);
  display: none;
  font-weight: 600;
  inset: 0.5rem;
  justify-content: center;
  pointer-events: none;
  position: absolute;
  z-index: 5;
}

.chat--dropping .chat-drop-hint { display: flex; }
