.attach-button {
  flex: 0 0 40px;
  align-self: flex-end;
  height: 44px;
  font-size: 26px;
}
.attachment-queue {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
  max-height: 180px;
  overflow: auto;
}
.queued-media {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--theme-line);
  border-radius: 10px;
  background: var(--theme-surface);
  padding: 8px;
}
.queued-media img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
}
.queued-media > div {
  flex: 1;
  min-width: 0;
}
.queued-media strong,
.queued-media span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.queued-media span,
.attachment-hint {
  color: var(--muted);
  font-size: 11px;
}
.attachment-hint {
  margin: 6px 0;
}
.composer-meta #cancelUpload {
  margin-left: auto;
}
#composer.dragging .compose-box {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}
.message-content {
  min-width: 0;
}
.message-media {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  margin-top: 7px;
  max-width: 100%;
}
.media-card {
  margin: 0;
  width: 360px;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--theme-line);
  border-radius: 10px;
  background: var(--theme-surface);
}
.media-card video {
  display: block;
  max-width: 100%;
  width: 100%;
  height: 240px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.08);
}
/* Let the image define the card's shape, without cropping or letterboxing. */
.media-card.image-card {
  width: fit-content;
  max-width: min(362px, 100%);
}
.image-preview {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: zoom-in;
  max-width: 100%;
  overflow: hidden;
}
.image-preview img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(360px, 100%);
  max-height: 320px;
}
.image-preview:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}
.image-card figcaption {
  box-sizing: border-box;
  width: 0;
  min-width: 100%;
}
.image-card figcaption a {
  min-width: 0;
}
.image-viewer {
  width: min(1240px, calc(100vw - 32px));
  height: calc(100dvh - 32px);
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
}
.image-viewer-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.image-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--theme-line);
  flex-shrink: 0;
}
.image-viewer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.image-viewer-toolbar a {
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}
.image-viewer-toolbar button {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  font-size: 24px;
}
.image-viewer-stage {
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: center;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
}
.image-viewer-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.image-viewer-stage img[hidden] {
  display: none;
}
.image-viewer-error {
  padding: 24px;
  color: var(--muted);
}
@media (max-width: 600px) {
  .image-viewer-toolbar {
    flex-wrap: wrap;
    gap: 8px 12px;
  }
  .image-viewer-name {
    flex-basis: calc(100% - 56px);
    order: -2;
  }
  .image-viewer-toolbar button {
    order: -1;
  }
}
@media (max-width: 700px), (pointer: coarse) {
  .image-viewer-toolbar button {
    width: 44px;
    height: 44px;
  }
}
.media-card audio {
  display: block;
  width: 100%;
  max-width: 100%;
}
.media-card figcaption {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  align-items: center;
  font-size: 12px;
}
.media-card figcaption a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
}
.media-card figcaption span {
  margin-left: auto;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}
.media-fallback {
  margin: 12px;
  color: var(--muted);
  font-size: 12px;
}
.msg {
  position: relative;
}
.delete-preview {
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}
@media (max-width: 600px) {
  .media-card video {
    height: 190px;
  }
  .attachment-queue {
    max-height: 140px;
  }
  .attach-button {
    flex-basis: 32px;
  }
}
