.attachment-preview:has(.attachment-video-poster) {
  position: relative;
  background: #071015;
}
.attachment-preview .attachment-video-poster {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
.attachment-preview:has(.attachment-video-poster) .attachment-number {
  left: 4px;
  top: 4px;
}
.attachment-preview > span.attachment-video-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #000b;
  color: #fff;
  font-size: 12px;
  pointer-events: none;
}
.attachment-preview > span.attachment-video-fallback {
  padding: 8px;
  color: #dce8e5;
  font-size: 12px;
  text-align: center;
}

/* Decoded chat previews bridge the original media request without another fetch. */
.video-preview-frame,
.viewer-photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.video-preview-frame[hidden],
.viewer-photo-preview[hidden],
.viewer-loading[hidden] {
  display: none;
}
.viewer-photo:not([data-load-state="ready"]) .viewer-image {
  opacity: 0;
}
.viewer-loading {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  max-width: 90%;
  border-radius: 20px;
  background: #101718db;
  color: #f1f5f4;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.video-viewer,
.media-viewer {
  background: #080c0e;
}
.video-viewer:focus,
.media-viewer:focus {
  outline: none;
}
.video-header,
.media-viewer .viewer-header {
  min-height: 64px;
  padding-inline: 16px;
  background: #101719;
  border-bottom: 1px solid #ffffff0d;
}
.video-viewer button,
.media-viewer .viewer-close {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.video-viewer button svg {
  display: block;
  width: 24px;
  height: 24px;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.video-viewer .video-close,
.media-viewer .viewer-close {
  width: 44px;
  height: 44px;
  padding: 0;
  background: #ffffff0c;
  border: 0;
  border-radius: 50%;
}
.video-sender {
  font-size: 15px;
  font-weight: 600;
}
.video-date {
  font-size: 12px;
  color: #9eadaf;
}
.video-notice {
  bottom: 18px;
  border-radius: 20px;
  padding: 9px 15px;
  background: #101718db;
}
.video-timeline {
  gap: 12px;
  padding: 8px 22px 0;
  background: #101719;
  font-size: 12px;
}
.video-seek {
  accent-color: #83e4c2;
  box-shadow: none;
}
.video-controls {
  padding: 4px 22px 18px;
  background: #101719;
}
.video-viewer .video-play {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e8f4ef;
  color: #12201c;
}
.video-viewer .video-play:hover {
  background: #d2e9de;
}
.video-viewer .video-mute {
  right: 20px;
}
.video-viewer .video-rate {
  font-size: 13px;
  font-weight: 600;
}
.media-viewer .viewer-footer {
  color: #c5d0d0;
}
.media-viewer[data-single-photo="true"] .viewer-gallery {
  display: flex;
  flex-direction: column;
}
.media-viewer[data-single-photo="true"] .viewer-photo {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  margin-bottom: 0;
}
.media-viewer[data-single-photo="true"] .viewer-photo-stage {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 120px;
}
.media-viewer[data-single-photo="true"] .viewer-image {
  position: absolute;
  inset: auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: auto;
}
.media-viewer[data-single-photo="true"] .viewer-footer {
  flex-shrink: 0;
  max-height: 24dvh;
  overflow: auto;
  padding: 8px 18px 12px;
  background: #101719;
}
.media-viewer .viewer-status {
  font-size: 11px;
  color: #9eadaf;
}
@media (max-width: 720px) {
  .video-header,
  .media-viewer .viewer-header {
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-bottom: 8px;
  }
  .video-controls {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .media-viewer[data-single-photo="true"] .viewer-gallery {
    padding-bottom: 0;
  }
  .media-viewer[data-single-photo="true"] .viewer-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
