.trmv-root {
  --trmv-backdrop: rgba(4, 6, 10, 0.9);
  --trmv-surface: #0b0e15;
  --trmv-surface-soft: #121723;
  --trmv-border: rgba(239, 231, 220, 0.18);
  --trmv-text: #f7f1ea;
  --trmv-text-soft: #c7bdb4;
  --trmv-accent: #f0a7bf;
  --trmv-accent-strong: #ffd1df;
  --trmv-ring: rgba(240, 167, 191, 0.55);
  position: fixed;
  z-index: 99999;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 32px);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.trmv-root.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.trmv-backdrop {
  position: absolute;
  inset: 0;
  background: var(--trmv-backdrop);
  backdrop-filter: blur(10px);
}

.trmv-shell {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(1180px, 100%);
  height: min(92dvh, 900px);
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  color: var(--trmv-text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.trmv-shell.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.trmv-toolbar {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) repeat(7, 42px);
  gap: 6px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--trmv-border);
  border-radius: 16px;
  background: rgba(11, 14, 21, 0.94);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.trmv-title {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.trmv-count {
  min-width: 0;
  margin: 0 8px;
  overflow: hidden;
  color: var(--trmv-text-soft);
  font: 700 12px/1.3 var(--sans, Arial, sans-serif);
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trmv-btn {
  display: inline-flex;
  width: 42px;
  min-width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  appearance: none;
  border: 1px solid var(--trmv-border);
  border-radius: 11px;
  padding: 0;
  color: var(--trmv-text);
  background: rgba(18, 23, 35, 0.9);
  cursor: pointer;
  font: 700 16px/1 var(--sans, Arial, sans-serif);
  text-decoration: none;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.trmv-btn:hover {
  border-color: var(--trmv-accent);
  background: rgba(240, 167, 191, 0.14);
  transform: translateY(-1px);
}

.trmv-btn:focus-visible {
  border-color: var(--trmv-accent-strong);
  outline: 3px solid var(--trmv-ring);
  outline-offset: 2px;
}

.trmv-btn:active {
  transform: translateY(0);
}

.trmv-btn:disabled {
  cursor: default;
  opacity: .42;
}

.trmv-btn:disabled:hover {
  border-color: var(--trmv-border);
  background: rgba(18, 23, 35, 0.9);
  transform: none;
}

.trmv-close {
  color: var(--trmv-accent-strong);
}

.trmv-download {
  color: #c6efd4;
}

.trmv-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--trmv-border);
  border-radius: 18px;
  background: radial-gradient(circle at 50% 35%, rgba(240, 167, 191, 0.13), transparent 38%), linear-gradient(145deg, var(--trmv-surface-soft), var(--trmv-surface));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025), 0 24px 70px rgba(0, 0, 0, 0.42);
}

.trmv-image-wrap {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  cursor: default;
  touch-action: pan-y pinch-zoom;
}

.trmv-image-wrap.is-zoomable {
  cursor: zoom-in;
}

.trmv-image-wrap.is-zoomed {
  cursor: grab;
}

.trmv-image-wrap.is-panning {
  cursor: grabbing;
}

.trmv-media {
  display: block;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  transition: transform 120ms ease;
}

.trmv-caption {
  position: absolute;
  right: 14px;
  bottom: 14px;
  left: 14px;
  z-index: 1;
  width: fit-content;
  max-width: min(52rem, calc(100% - 28px));
  margin: 0 auto;
  border: 1px solid rgba(239, 231, 220, 0.16);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--trmv-text);
  background: rgba(6, 8, 12, 0.76);
  box-shadow: 0 7px 24px rgba(0, 0, 0, 0.28);
  font: 700 12px/1.25 var(--sans, Arial, sans-serif);
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  pointer-events: none;
  text-align: center;
}

img[data-tr-media-viewer="ready"] {
  cursor: zoom-in;
}

img[data-tr-media-viewer="ready"]:focus-visible {
  outline: 3px solid var(--trmv-accent-strong);
  outline-offset: 3px;
}

.trmv-media.is-failed,
.trmv-media[hidden],
.trmv-caption[hidden],
.trmv-error[hidden] {
  display: none !important;
}

.trmv-error {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(28rem, calc(100% - 32px));
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(240, 167, 191, 0.3);
  border-radius: 14px;
  color: var(--trmv-text-soft);
  background: rgba(8, 10, 15, 0.86);
  font: 600 14px/1.45 var(--sans, Arial, sans-serif);
  text-align: center;
  transform: translate(-50%, -50%);
}

@media (max-width: 720px) {
  .trmv-root {
    padding: 8px;
  }

  .trmv-shell {
    width: 100%;
    height: min(96dvh, 760px);
  }

  .trmv-toolbar {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    padding: 6px;
  }

  .trmv-count {
    grid-column: 1 / -1;
    margin: 2px 5px 4px;
  }

  .trmv-btn {
    width: 100%;
    min-width: 0;
    height: 40px;
  }

  .trmv-stage {
    border-radius: 14px;
  }
}

@media (max-width: 420px) {
  .trmv-shell {
    height: 100dvh;
  }

  .trmv-root {
    padding: 0;
  }

  .trmv-toolbar {
    border-radius: 0 0 14px 14px;
    border-top: 0;
  }

  .trmv-stage {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .trmv-root,
  .trmv-shell,
  .trmv-media,
  .trmv-btn {
    transition: none;
  }

  .trmv-btn:hover,
  .trmv-btn:active {
    transform: none;
  }
}
