.media-message {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.media-message__preview {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #f7f9fa;
}

.media-message__preview img,
.media-message__preview video {
  display: block;
  width: 100%;
  height: auto;
}

.media-message__preview audio {
  width: 100%;
}

.media-message__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.media-message__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: #ffffff;
  color: #2563eb;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 4px 12px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.media-message__action:hover,
.media-message__action:focus {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  text-decoration: none;
}

.media-message__status {
  font-size: 0.82rem;
  color: #54656f;
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-message__status--error {
  color: #c0392b;
}

.media-message__status--expired {
  color: #b26a00;
}

.media-message__spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(84, 101, 111, 0.25);
  border-top-color: rgba(84, 101, 111, 0.65);
  animation: media-message-spin 0.7s linear infinite;
}

@keyframes media-message-spin {
  to {
    transform: rotate(360deg);
  }
}

.media-message--status {
  background: rgba(84, 101, 111, 0.08);
  border-radius: 8px;
  padding: 12px;
}

.document-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.document-name {
  font-weight: 600;
  color: #1f2933;
}

.document-size {
  font-size: 0.78rem;
  color: #54656f;
}

.audio-message {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.12), rgba(255, 255, 255, 0.95));
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: inset 0 0 0 1px rgba(37, 211, 102, 0.12);
}

.audio-message__player {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audio-message__toggle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #25d366;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.25);
}

.audio-message__toggle:hover,
.audio-message__toggle:focus {
  background: #20bd5a;
  outline: none;
}

.audio-message__toggle--playing,
.audio-message--playing .audio-message__toggle {
  background: #128c7e;
  box-shadow: 0 4px 14px rgba(18, 140, 126, 0.3);
}

.audio-message__icon {
  position: relative;
  display: block;
}

.audio-message__icon::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-40%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 0 8px 12px;
  border-color: transparent transparent transparent #ffffff;
}

.audio-message__toggle--playing .audio-message__icon::before,
.audio-message--playing .audio-message__icon::before {
  content: '';
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: none;
  background: none;
}

.audio-message__toggle--playing .audio-message__icon::after,
.audio-message--playing .audio-message__icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: block;
  width: 12px;
  height: 12px;
  background: linear-gradient(90deg, #ffffff 0 45%, transparent 45% 55%, #ffffff 55% 100%);
}

.audio-message__timeline {
  position: relative;
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(18, 140, 126, 0.18);
  overflow: hidden;
}

.audio-message__progress {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: #25d366;
  border-radius: inherit;
  transition: width 0.12s linear;
}

.audio-message__time {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: #54656f;
  min-width: 76px;
  justify-content: flex-end;
}

.audio-message__time-divider {
  color: rgba(84, 101, 111, 0.6);
}

.audio-message__time-current {
  font-variant-numeric: tabular-nums;
}

.audio-message__time-duration {
  font-variant-numeric: tabular-nums;
  color: rgba(84, 101, 111, 0.85);
}

.message--media-refreshing .message-content {
  opacity: 0.85;
}

.message--media-error .media-message__preview {
  box-shadow: inset 0 0 0 1px rgba(192, 57, 43, 0.35);
}

.message--media-expired .media-message__preview {
  filter: grayscale(0.4);
}

@media (prefers-color-scheme: dark) {
  .media-message__preview {
    background: rgba(255, 255, 255, 0.06);
  }

  .media-message__action {
    border-color: rgba(147, 197, 253, 0.4);
    background: rgba(13, 17, 23, 0.6);
    color: #93c5fd;
  }

  .media-message__action:hover,
  .media-message__action:focus {
    background: rgba(59, 130, 246, 0.2);
    color: #bfdbfe;
  }

  .media-message__status {
    color: rgba(236, 239, 241, 0.8);
  }

  .media-message__status--error {
    color: #ff6b6b;
  }

  .media-message__status--expired {
    color: #f0b429;
  }

  .media-message--status {
    background: rgba(255, 255, 255, 0.08);
  }

  .document-name {
    color: #f0f4f8;
  }

  .document-size {
    color: rgba(236, 239, 241, 0.7);
  }

  .audio-message {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.16), rgba(17, 27, 33, 0.95));
    box-shadow: inset 0 0 0 1px rgba(37, 211, 102, 0.22);
  }

  .audio-message__toggle {
    background: #1da87e;
    box-shadow: 0 6px 18px rgba(0, 198, 111, 0.25);
  }

  .audio-message__toggle:hover,
  .audio-message__toggle:focus,
  .audio-message__toggle--playing,
  .audio-message--playing .audio-message__toggle {
    background: #147a65;
  }

  .audio-message__timeline {
    background: rgba(37, 211, 102, 0.35);
  }

  .audio-message__progress {
    background: #00c66f;
  }

  .audio-message__time {
    color: rgba(236, 239, 241, 0.85);
  }

  .audio-message__time-divider,
  .audio-message__time-duration {
    color: rgba(236, 239, 241, 0.6);
  }
}

.quoted {
  border-left: 3px solid #cfd8dc;
  padding: 6px 8px;
  margin: 0 0 6px 0;
  border-radius: 4px;
  background: #f7f7f7;
  color: #555;
}

.quoted__sender {
  margin-bottom: 4px;
  color: #37474f;
}

.quoted__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
}

.quoted__icon {
  font-size: 0.9rem;
}

.quoted__summary-text-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quoted__summary-type {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #607d8b;
}

.quoted__summary-detail,
.quoted__summary-text {
  font-size: 0.85rem;
  color: inherit;
  word-break: break-word;
}

.theme-dark .quoted {
  background: rgba(236, 239, 241, 0.08);
  border-left-color: rgba(236, 239, 241, 0.25);
  color: rgba(236, 239, 241, 0.8);
}

.theme-dark .quoted__sender {
  color: rgba(236, 239, 241, 0.85);
}

.theme-dark .quoted__summary-type {
  color: rgba(236, 239, 241, 0.6);
}

