/* Unified result modal — tall cover card, image-first overlay chips. */

.rm-modal {
  position: fixed;
  inset: 0;
  z-index: 10070;
  background: rgba(5, 5, 7, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
}

.rm-modal.is-open { display: flex; }

.rm-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  max-height: calc(100vh - 32px);
  background: var(--bg-elev-1, #15151a);
  border: 1px solid var(--border-soft, rgba(255, 255, 255, 0.08));
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rm-modal-in 0.26s cubic-bezier(.4, 0, .2, 1);
}

@keyframes rm-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Light top row: centered, Gallery word is the affordance ─────────── */
.rm-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 14px 6px;
  flex-shrink: 0;
}

/* Author display:flex beats UA [hidden]; slim Plan L relies on this. */
.rm-top[hidden] {
  display: none !important;
}

.rm-top__link[hidden] {
  display: none !important;
}

.rm-top__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, rgba(255, 255, 255, 0.55));
  letter-spacing: -0.01em;
  text-decoration: none;
  text-align: center;
  line-height: 1.3;
}

.rm-top__icon {
  flex-shrink: 0;
  color: var(--pink, #ff4d8a);
  opacity: 0.95;
}

.rm-top__link:hover .rm-top__icon {
  color: #ff8caa;
}

.rm-top__link:hover .rm-top__em {
  color: #ff8caa;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rm-top__em {
  color: var(--pink, #ff4d8a);
  font-weight: 800;
  font-size: 0.86rem;
}

.rm-top__retain {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, rgba(255, 255, 255, 0.42));
  letter-spacing: -0.01em;
}

/* ── Media stage: media + remix overlay ──────────────────────────────── */
.rm-stage {
  position: relative;
  margin: 4px 8px 0;
  flex-shrink: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.rm-media-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 1;
  min-height: 0;
  background: #0a0a0c;
}

.rm-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 6;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.rm-close:hover { background: var(--pink, #ff4d8a); }

.rm-media {
  position: relative;
  width: 100%;
  max-height: min(62vh, 520px);
  background: #0a0a0c;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  line-height: 0;
}

/* Before <video> metadata loads, browsers paint a ~300×150 default box
   (looks like a widescreen player). Hold a tall placeholder instead and
   keep the element invisible until natural dimensions are known. */
.rm-media.is-awaiting-meta {
  aspect-ratio: 3 / 4;
  width: min(100%, 280px);
  margin: 0 auto;
  max-height: min(62vh, 520px);
}

.rm-media.is-awaiting-meta::after {
  content: '';
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--pink, #ff4d8a);
  animation: rm-spin 0.7s linear infinite;
}

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

.rm-media.is-awaiting-meta video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.rm-media--wide { /* kept for template compat; always natural ratio */ }

.rm-media img,
.rm-media video {
  max-width: 100%;
  max-height: min(62vh, 520px);
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  background: #0a0a0c;
  display: block;
}

.rm-media-wrap.is-blurred .rm-media img,
.rm-media-wrap.is-blurred .rm-media video {
  filter: blur(18px) saturate(0.85);
  transform: scale(1.06);
}

.rm-media-wrap.is-blurred .rm-overlay {
  opacity: 0.72;
}

.rm-blur-veil {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 14, 0.28);
  pointer-events: none;
}

.rm-blur-veil[hidden] { display: none; }

.rm-blur-veil__label {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

/* ── Image-bottom glass overlay chips ────────────────────────────────── */
.rm-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 28px 8px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
  pointer-events: none;
  border-radius: 0 0 14px 14px;
}
.rm-overlay[hidden] {
  display: none !important;
}

.rm-overlay .rm-chips,
.rm-overlay .rm-more {
  pointer-events: auto;
}

.rm-chips {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.rm-chip {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 2px 5px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 20, 26, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  text-align: center;
  box-shadow: none;
}

.rm-chip:hover {
  background: rgba(30, 30, 38, 0.62);
  border-color: rgba(255, 77, 138, 0.55);
}
.rm-chip:active { transform: scale(0.97); }
.rm-chip[hidden] { display: none; }
.rm-chip.is-active {
  border-color: var(--pink, #ff4d8a);
  background: rgba(255, 77, 138, 0.28);
}

.rm-chip__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: currentColor;
  stroke: none;
  opacity: 0.95;
}

.rm-chip__4k {
  width: 24px;
  height: 13px;
  border-radius: 3px;
  background: linear-gradient(135deg, #ff5e8b, #b45cff);
  color: #fff;
  font-size: 0.52rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

.rm-chip__more {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.85);
}

.rm-chip__label {
  font-size: 0.62rem;
  line-height: 1.1;
  display: block;
  opacity: 0.92;
}

/* More panel sits above the chip row, still on the image */
.rm-more {
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 18, 24, 0.28);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 180px;
  overflow-y: auto;
}
.rm-more[hidden] { display: none; }

.rm-more__label {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 6px;
  padding-left: 2px;
}

.rm-more__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rm-more__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.rm-more__item:hover {
  border-color: rgba(255, 77, 138, 0.65);
  background: rgba(255, 77, 138, 0.2);
  transform: translateY(-1px);
}
.rm-more__item:active { transform: scale(0.97); }
.rm-more__item[hidden] { display: none; }

.rm-overlay.is-empty {
  display: none;
}

/* Video: flat Face Swap / Dance / Eraser below player, above Download. No More. */
.rm-overlay.is-video {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  max-width: none;
  margin-top: 8px;
  padding: 0;
  background: none;
  border-radius: 0;
  align-items: stretch;
  gap: 0;
  pointer-events: auto;
}

.rm-overlay.is-video .rm-more {
  display: none !important;
}

.rm-overlay.is-video .rm-chips {
  justify-content: stretch;
  gap: 6px;
}

.rm-overlay.is-video .rm-chip--image,
.rm-overlay.is-video #resultChipMore {
  display: none !important;
}

.rm-overlay.is-video .rm-chip--video {
  flex: 1 1 0;
  flex-direction: row;
  gap: 6px;
  padding: 9px 8px;
  border-radius: 999px;
  background: var(--bg-elev-2, #1f1f25);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.rm-overlay.is-video .rm-chip--video .rm-chip__label {
  font-size: 0.78rem;
  font-weight: 800;
}

.rm-overlay.is-video .rm-chip--video .rm-chip__icon {
  width: 16px;
  height: 16px;
}

.rm-more__group[hidden] {
  display: none;
}

.rm-retry[hidden] {
  display: none !important;
}

/* ── Actions (sole solid CTA) ────────────────────────────────────────── */
.rm-actions {
  padding: 12px 12px 10px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.rm-actions--single { padding: 12px 12px 10px; }
.rm-actions--single .rm-btn { flex: 1 1 100%; padding: 11px 16px; font-size: 0.9rem; }

.rm-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 8px;
  border-radius: 999px;
  border: none;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.1s ease, background 0.15s ease;
  text-decoration: none;
  color: var(--text-primary, #fff);
  background: var(--bg-elev-3, #2a2a31);
}

.rm-btn:active { transform: scale(0.97); }
.rm-btn:disabled { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.3); }
.rm-btn:not(:disabled):hover { background: rgba(255, 255, 255, 0.12); }

.rm-btn--primary {
  background-image: var(--grad-warm, linear-gradient(135deg, #ffb347 0%, #ff5e8b 50%, #b45cff 100%));
  color: #fff;
  box-shadow: 0 6px 14px rgba(255, 94, 139, 0.28);
}
.rm-btn--primary:not(:disabled):hover {
  filter: brightness(1.06);
  background-image: var(--grad-warm, linear-gradient(135deg, #ffb347 0%, #ff5e8b 50%, #b45cff 100%));
}

.rm-btn__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

.rm-btn[hidden] { display: none !important; }

/* ── Retry ───────────────────────────────────────────────────────────── */
.rm-retry {
  padding: 0 12px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.55));
  flex-shrink: 0;
}
.rm-retry__lead { line-height: 1.4; }
.rm-retry__link {
  background: none;
  border: none;
  padding: 2px 4px;
  margin: 0;
  font: inherit;
  color: var(--pink, #ff4d8a);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rm-retry__link:hover:not(:disabled) { color: #ff8caa; }
.rm-retry__link:disabled {
  color: var(--text-muted, rgba(255, 255, 255, 0.4));
  cursor: not-allowed;
  text-decoration: none;
}
.rm-retry__hint { font-size: 0.72rem; opacity: 0.8; }

@media (min-width: 720px) {
  .rm-card { max-width: 360px; }
}

@media (max-width: 360px) {
  .rm-card { max-width: 100%; }
  .rm-chip__label { font-size: 0.58rem; }
  .rm-top__link { font-size: 0.74rem; }
  .rm-top__em { font-size: 0.8rem; }
}
