.dx-viewer {
  z-index: calc(var(--dx-overlay-index) + 10);
}

/* 内容预览中触发登录时，认证弹窗及遮罩必须显示在预览层上方。 */
html.dx-viewer-open .modal-backdrop {
  z-index: calc(var(--dx-overlay-index) + 20);
}

html.dx-viewer-open .modal {
  z-index: calc(var(--dx-overlay-index) + 30);
}

/*
 * 多图 / 图+视频导向箭头：可点亮起（粉），禁用灰显；随 Swiper
 * .swiper-button-disabled 互相反馈（首张右亮左灰 → 中间双侧亮 → 末张左亮右灰）。
 */
.dx-viewer-prev,
.dx-viewer-next {
  cursor: pointer;
  touch-action: manipulation;
}

.dx-viewer-prev:not(.swiper-button-disabled),
.dx-viewer-prev:not(.swiper-button-disabled):hover,
.dx-viewer-prev:not(.swiper-button-disabled):active {
  background-image: url(/static/web91/images/viewer-prev-active.svg);
}

.dx-viewer-next:not(.swiper-button-disabled),
.dx-viewer-next:not(.swiper-button-disabled):hover,
.dx-viewer-next:not(.swiper-button-disabled):active {
  background-image: url(/static/web91/images/viewer-next-active.svg);
}

.dx-viewer-prev.swiper-button-disabled,
.dx-viewer-prev.swiper-button-disabled:hover,
.dx-viewer-prev.swiper-button-disabled:active {
  background-image: url(/static/web91/images/viewer-prev.svg);
  cursor: default;
  pointer-events: none;
}

.dx-viewer-next.swiper-button-disabled,
.dx-viewer-next.swiper-button-disabled:hover,
.dx-viewer-next.swiper-button-disabled:active {
  background-image: url(/static/web91/images/viewer-next.svg);
  cursor: default;
  pointer-events: none;
}

/* 手机端仅在视频播放时隐藏箭头，暂停、结束及图片状态保留箭头。 */
@media (max-width: 767px) {
  .dx-viewer.is-multi .dx-viewer-prev,
  .dx-viewer.is-multi .dx-viewer-next {
    display: flex !important;
    width: 40px;
    height: 40px;
  }

  .dx-viewer.is-multi .dx-viewer-prev {
    left: 8px;
  }

  .dx-viewer.is-multi .dx-viewer-next {
    right: 8px;
  }

  .dx-viewer.is-video-playing .dx-viewer-prev,
  .dx-viewer.is-video-playing .dx-viewer-next {
    display: none !important;
  }
}

/* 主图区与缩略图分区：缩略图在文档流底部，不再绝对叠在主图上 */
.dx-viewer-media {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
}

.dx-viewer-stage {
  position: relative;
  flex: 1 1 0%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  container-type: size;
}

.dx-viewer-swiper {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.dx-viewer-img {
  width: auto;
  height: auto;
  max-width: 82%;
  max-height: 100%;
  object-fit: contain;
}

/* 挂载点就是播放器根节点：铺满主舞台，视频由 contain 保持原比例。
 * 舞台已扣除缩略图高度，控制栏始终位于可见区域内。
 */
.dx-viewer-video.xgplayer,
.dx-viewer-video {
  box-sizing: border-box;
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  aspect-ratio: auto;
  padding-top: 0 !important;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.dx-viewer-video.xgplayer video,
.dx-viewer-video video {
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  object-fit: contain;
}

.dx-viewer-video.xgplayer .xgplayer-poster {
  background-size: contain;
  background-position: center;
}

/* 视频弹窗位于 Swiper 内，进度条需要独占横向拖动手势。 */
.dx-viewer-video .xgplayer-progress {
  pointer-events: auto !important;
  touch-action: none;
}

.dx-viewer-thumbs {
  position: relative;
  bottom: auto;
  left: auto;
  transform: none;
  flex-shrink: 0;
  justify-content: center;
  margin: 12px auto 16px;
  max-width: calc(100% - 32px);
  overflow-x: auto;
  scrollbar-width: none;
}

.dx-viewer-thumbs::-webkit-scrollbar {
  display: none;
}

@media (min-width: 768px) {
  .dx-viewer-side {
    width: clamp(430px, 30.52vw, 586px);
  }
}

.dx-viewer-comments {
  margin-top: 20px;
}

.dx-viewer-comment-state {
  display: block;
  width: 100%;
  padding: 34px 12px;
  color: #99a1af;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  cursor: default;
}

.dx-viewer-comment-state:disabled {
  opacity: 1;
}

.dx-viewer-comment-state.is-retry {
  color: var(--color-primary);
  cursor: pointer;
}

.dx-viewer-comments .dx-comment-list {
  display: flex;
  flex-direction: column;
}

.dx-viewer-comments .dx-load-comments {
  display: none;
  width: 100%;
  margin-top: 20px;
  padding: 10px;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.dx-viewer-input {
  min-height: 85px;
  padding: 14px 24px;
  gap: 15px;
  background: var(--color-card);
}

.dx-viewer-input .dx-comment-input {
  flex: 1;
  min-width: 0;
  height: 56px;
  padding: 0 18px;
  border: 0;
  border-radius: 28px;
  outline: 0;
  background: #171516;
  color: #fff;
  font-size: 14px;
  line-height: 56px;
}

.dx-viewer-input .dx-comment-input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.dx-viewer-input .dx-publish-comment {
  flex: 0 0 108px;
  width: 108px;
  height: 56px;
  border: 0;
  border-radius: 28px;
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.dx-viewer-input .dx-publish-comment:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dx-viewer-input .dx-publish-comment.is-success {
  background: #38b03f;
  opacity: 1;
}

.dx-viewer-input .dx-publish-comment.is-invalid {
  background: #d99116;
  opacity: 1;
}

@media (max-width: 767px) {
  .dx-viewer-close {
    top: calc(12px + env(safe-area-inset-top));
    left: 12px;
  }

  .dx-viewer-media {
    height: 52vh;
  }

  .dx-viewer-img {
    max-width: 94%;
    max-height: 100%;
  }

  .dx-viewer-thumbs {
    margin: 10px auto 12px;
  }

  .dx-viewer-side-scroll {
    padding: 18px 16px;
  }

  .dx-viewer-comments {
    margin-top: 16px;
  }

  .dx-viewer-input {
    min-height: 68px;
    padding: 10px 14px;
    gap: 10px;
  }

  .dx-viewer-input .dx-comment-input {
    height: 44px;
    line-height: 44px;
  }

  .dx-viewer-input .dx-publish-comment {
    flex-basis: 72px;
    width: 72px;
    height: 44px;
  }
}

/*
 * 安卓/窄屏 H5：xgplayer 左右栏默认 flex-wrap，超宽时第二行被
 * .xgplayer{overflow:hidden} 裁掉，表现为「没有时间 / 没有画中画」。
 */
.xgplayer-mobile .xg-left-grid,
.xgplayer-mobile .xg-right-grid {
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.xgplayer-mobile .xg-center-grid,
.xgplayer-mobile .xgplayer-progress {
  min-width: 0;
  flex: 1 1 auto;
}

.xgplayer-mobile .xg-inner-controls xg-icon {
  margin-left: 4px;
  margin-right: 4px;
  flex-shrink: 0;
}

.xgplayer-mobile .xgplayer-time {
  flex-shrink: 0;
  white-space: nowrap;
  min-width: auto;
  font-size: 11px;
}

.xgplayer-mobile .xgplayer-playbackrate {
  display: none;
}

/* 页内画中画浮动小窗（安卓 WebView 无系统 PiP 时的兜底） */
.xgplayer.dx-pip-floating {
  position: fixed !important;
  right: 12px !important;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  left: auto !important;
  top: auto !important;
  width: 42vw !important;
  max-width: 220px !important;
  min-width: 140px !important;
  height: auto !important;
  aspect-ratio: 16 / 9;
  padding-top: 0 !important;
  z-index: 100000 !important;
  border-radius: 10px !important;
  overflow: hidden !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45) !important;
  background: #000 !important;
}

.xgplayer.dx-pip-floating video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

.xgplayer.dx-pip-floating .dx-pip-float-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 100001;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  line-height: 28px;
  text-align: center;
  padding: 0;
  cursor: pointer;
}
