.media-stage {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.stage-image,
.stage-video {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
  object-fit: contain;
  object-position: center;
  flex: 0 1 auto;
}

.comments-visible .media-stage .stage-image,
.comments-visible .media-stage .stage-video {
  max-width: 100% !important;
  max-height: 100% !important;
}

.edit-hint {
  position: absolute;
  z-index: 9;
  top: max(58px, calc(env(safe-area-inset-top) + 50px));
  right: max(12px, env(safe-area-inset-right));
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  background: rgba(18,18,18,.62);
  color: rgba(255,255,255,.92);
  font-size: 1rem;
  line-height: 1;
  box-shadow: 0 3px 14px rgba(0,0,0,.28);
  backdrop-filter: blur(8px);
}

.upload-indicator {
  position: fixed;
  z-index: 30;
  top: max(72px, calc(env(safe-area-inset-top) + 64px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(18,18,18,.84);
  color: #fff;
  font-size: .92rem;
  box-shadow: 0 4px 18px rgba(0,0,0,.32);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.upload-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: showpic-spin .8s linear infinite;
}

@keyframes showpic-spin { to { transform: rotate(360deg); } }

.thumb-toggle.gallery-toggle {
  width: auto;
  min-width: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.thumb-toggle .gallery-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.thumb-toggle .gallery-label {
  font-size: .8rem;
  font-weight: 650;
}

/* Statusmeddelanden efter t.ex. bulkuppladdning ska inte ligga kvar och
   blockera redigeringskontroller. De visas tydligt en stund och tonar sedan bort. */
.presenter-shell .toast {
  max-width: min(88vw, 720px);
  max-height: 32vh;
  overflow: auto;
  pointer-events: none;
  animation: showpic-toast-dismiss 10s ease forwards;
}

@keyframes showpic-toast-dismiss {
  0%, 72% { opacity: 1; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}

@supports not (height: 100dvh) {
  .stage-image,
  .stage-video { max-height: 100vh !important; }
}

@media (max-width: 699px) {
  .comments-visible .media-stage { bottom: 76px !important; }
  .presenter-shell .toast {
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 64px));
    font-size: .86rem;
  }
  .thumb-toggle .gallery-label { display: none; }
  .thumb-toggle.gallery-toggle { width: 44px; min-width: 44px; padding: 0; }
  .upload-indicator { font-size: .84rem; top: max(64px, calc(env(safe-area-inset-top) + 56px)); }
}

@media (orientation: landscape) and (max-height: 560px) {
  .comments-visible .media-stage { bottom: 58px !important; }
  .edit-hint { top: max(48px, calc(env(safe-area-inset-top) + 42px)); }
  .presenter-shell .toast { max-height: 24vh; }
  .upload-indicator { top: max(48px, calc(env(safe-area-inset-top) + 42px)); }
}
