.message-image {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  border-radius: 13px;
  background: #eadde4;
  box-shadow: inset 0 0 0 1px #ffffff25;
}

.message-image img {
  display: block;
  width: min(190px, 62vw);
  max-height: 240px;
  margin: 0;
  border-radius: inherit;
  object-fit: cover;
  transition: transform .22s ease, filter .22s ease;
}

.message-image > span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #241b20dc;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 5px 14px #241b2040;
  backdrop-filter: blur(8px);
}

.message-image:active img { transform: scale(1.025); filter: brightness(.88); }
.message-image:focus-visible { outline: 3px solid #d17caa; outline-offset: 3px; }
.message-image.is-broken { min-width: 150px; min-height: 90px; }

.photo-viewer {
  z-index: 80;
  align-items: stretch;
  padding: 0;
  background: #130e11f5;
  backdrop-filter: blur(18px);
}

.photo-viewer.is-open { display: flex; }

.photo-viewer-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  min-height: 100dvh;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
  color: #fff;
}

.photo-viewer-stage header { padding: 4px 54px 14px 4px; }
.photo-viewer-stage header span,
.photo-viewer-stage header small { display: block; }
.photo-viewer-stage header span { color: #e89bc4; font-size: 8px; font-weight: 800; letter-spacing: .16em; }
.photo-viewer-stage header small { margin-top: 5px; color: #ad9fa7; font-size: 8px; }

.photo-viewer-close {
  position: absolute;
  z-index: 2;
  top: calc(16px + env(safe-area-inset-top));
  right: 14px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff17;
  color: #fff;
  font-size: 25px;
  backdrop-filter: blur(12px);
}

.photo-viewer-canvas {
  display: grid;
  place-items: center;
  overflow: auto;
  min-height: 0;
  border-radius: 24px;
  background: #080607;
  overscroll-behavior: contain;
}

.photo-viewer-canvas img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 115px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  object-fit: contain;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transform: translate3d(var(--pan-x, 0), var(--pan-y, 0), 0) scale(var(--photo-zoom, 1));
  transition: transform .16s cubic-bezier(.2,.8,.2,1);
  will-change: transform;
}

.photo-viewer-canvas.is-gesturing img { transition: none; }

.photo-viewer-tools {
  display: grid;
  grid-template-columns: 52px minmax(76px, auto) 52px;
  justify-content: center;
  gap: 8px;
  padding: 13px 0 1px;
}

.photo-viewer-tools button {
  height: 46px;
  border-radius: 15px;
  background: #ffffff12;
  color: #fff;
  font-size: 19px;
  backdrop-filter: blur(10px);
}

.photo-viewer-tools #photoZoomReset {
  padding: 0 15px;
  color: #d7cbd1;
  font-size: 9px;
  font-weight: 800;
}

.photo-viewer-tools button:active { background: #ffffff25; }

@media (hover: hover) {
  .message-image:hover img { transform: scale(1.025); filter: brightness(.94); }
}
