.message-attachments {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.message-attachments__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.message-attachments__toolbar > span {
  color: var(--ink-soft, #64717c);
  font-size: 12px;
}

.message-attachments__button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid #bdc3c5;
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #102131);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.message-attachments__button:hover,
.message-attachments__button:focus-within {
  border-color: var(--red, #f16023);
  box-shadow: 0 0 0 3px rgba(241, 96, 35, .13);
}

.message-attachments__button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.message-attachments__button span {
  color: var(--red, #f16023);
  font-size: 20px;
  line-height: 1;
}

.message-attachments__preview {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.message-attachments__preview[hidden] { display: none; }

.message-attachments__preview-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #e8e6df;
}

.message-attachments__preview-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.message-attachments__preview-item button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 28px;
  height: 28px;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 33, 49, .88);
  color: transparent;
  cursor: pointer;
}

.message-attachments__preview-item button::before,
.message-attachments__preview-item button::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 7px;
  width: 14px;
  height: 2px;
  background: #fff;
  transform: rotate(45deg);
}

.message-attachments__preview-item button::after { transform: rotate(-45deg); }

.message-attachments__status {
  min-height: 18px;
  margin: -2px 0 0;
  color: #326a55;
  font-size: 12px;
  line-height: 1.45;
}

.message-attachments__status[data-state="error"] { color: #8b2f12; }

.message-image-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: 9px;
}

.message-image-gallery--1 { grid-template-columns: 1fr; }

.message-image-gallery__item {
  min-width: 0;
  min-height: 118px;
  max-height: 280px;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #d9d8d2;
  color: #53616b;
  cursor: zoom-in;
}

.message-image-gallery__item img {
  width: 100%;
  height: 100%;
  min-height: 118px;
  max-height: 280px;
  display: block;
  object-fit: cover;
}

.message-image-gallery__item--retry {
  padding: 18px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
}

.message-image-lightbox {
  width: min(94vw, 1100px);
  max-width: none;
  height: min(92vh, 900px);
  max-height: none;
  padding: 46px 14px 14px;
  border: 0;
  border-radius: 12px;
  background: #101820;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
}

.message-image-lightbox::backdrop { background: rgba(0, 0, 0, .78); }

.message-image-lightbox img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.message-image-lightbox button {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 800px) {
  .message-attachments__toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .message-attachments__preview { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .message-image-gallery__item,
  .message-image-gallery__item img { min-height: 105px; }
}

@media (prefers-reduced-motion: reduce) {
  .message-image-lightbox { scroll-behavior: auto; }
}
