/* 大图查看器 (image-viewer.js). Full screen, dark, the picture moved only by a transform. */
.iv { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; overflow: hidden; color: #eef2f4; background: transparent; touch-action: none; overscroll-behavior: contain; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.iv[open] { display: block; animation: ivIn 180ms cubic-bezier(.2, .8, .2, 1) both; }
.iv::backdrop { background: transparent; }
.iv-backdrop { position: absolute; inset: 0; background: #05070a; opacity: var(--iv-dim, 1); }
.iv.is-closing { animation: ivOut 160ms ease-in both; }
.iv-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: default; }
.iv.is-zoomed .iv-stage { cursor: grab; }
.iv.is-dragging .iv-stage, .iv.is-dragging.is-zoomed .iv-stage { cursor: grabbing; }

/* The picture: real box size set by the script, scaled from its top-left corner. */
.iv .iv-img { position: absolute; left: 0; top: 0; display: block; max-width: none; max-height: none; margin: 0; border-radius: 0; transform-origin: 0 0; image-rendering: auto; -webkit-user-drag: none; -webkit-touch-callout: default; pointer-events: auto; }
.iv-fade-in { animation: ivFade 180ms ease-out both; }
.iv-from-right { animation: ivFade 200ms ease-out both; }
.iv-from-left { animation: ivFade 200ms ease-out both; }

.iv-status { position: absolute; left: 50%; top: 50%; display: grid; justify-items: center; gap: 12px; width: min(320px, calc(100vw - 48px)); transform: translate(-50%, -50%); color: #aeb9c1; font-size: 14px; text-align: center; pointer-events: none; }
.iv-status[hidden] { display: none; }
.iv-status-text::before { content: ""; display: block; width: 28px; height: 28px; margin: 0 auto 10px; border: 2px solid #ffffff24; border-top-color: #d8ff4f; border-radius: 50%; animation: ivSpin .8s linear infinite; }
.iv-status.is-failed .iv-status-text::before { display: none; }
.iv .iv-retry { min-height: 40px; padding: 0 18px; border: 1px solid #d8ff4f55; border-radius: 10px; background: #d8ff4f14; color: #d8ff4f; font: inherit; font-size: 13px; pointer-events: auto; }
.iv .iv-retry[hidden] { display: none; }

/* Top bar: counter, file name, close. */
.iv-top { position: absolute; z-index: 2; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); background: linear-gradient(180deg, #05070acc, #05070a00); opacity: var(--iv-dim, 1); pointer-events: none; }
.iv-top > * { pointer-events: auto; }
.iv-count { flex: none; min-width: 52px; padding: 5px 10px; border-radius: 999px; background: #ffffff14; font-size: 13px; font-variant-numeric: tabular-nums; text-align: center; }
.iv-count[hidden] { display: none; }
.iv-name { min-width: 0; overflow: hidden; color: #c9d2d8; font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.iv-loading { flex: none; color: #8f9ba3; font-size: 12px; }
.iv-loading[hidden] { display: none; }
.iv .iv-close { flex: none; display: grid; place-items: center; width: 44px; height: 44px; min-height: 0; margin-left: auto; padding: 0; border: 1px solid #ffffff1f; border-radius: 50%; background: #11171ccc; color: #eef2f4; }
.iv .iv-close:hover { background: #1c242b; }
.iv svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Previous / next. */
.iv .iv-nav { position: absolute; z-index: 2; top: calc(50% - 26px); display: grid; place-items: center; width: 52px; height: 52px; min-height: 0; padding: 0; border: 1px solid #ffffff1f; border-radius: 50%; background: #11171cb3; color: #eef2f4; opacity: var(--iv-dim, 1); }
.iv .iv-nav:hover:not(:disabled) { background: #1c242b; border-color: #d8ff4f55; }
.iv .iv-nav:disabled { opacity: .3; cursor: default; }
.iv .iv-nav[hidden] { display: none; }
.iv .iv-prev { left: max(14px, env(safe-area-inset-left)); }
.iv .iv-next { right: max(14px, env(safe-area-inset-right)); }
.iv .iv-nav svg { width: 24px; height: 24px; }

/* Bottom toolbar: zoom out, percent (fit / real size), zoom in, download. */
.iv-bar { position: absolute; z-index: 2; left: 50%; bottom: max(14px, calc(env(safe-area-inset-bottom) + 8px)); display: flex; align-items: center; gap: 6px; padding: 6px; border: 1px solid #ffffff1a; border-radius: 16px; background: #11171ceb; box-shadow: 0 12px 40px #0009; transform: translateX(-50%); opacity: var(--iv-dim, 1); white-space: nowrap; }
.iv .iv-bar button, .iv .iv-download { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 42px; height: 42px; min-height: 0; padding: 0 10px; border: 1px solid transparent; border-radius: 11px; background: #ffffff0d; color: #eef2f4; font: inherit; font-size: 13px; text-decoration: none; }
.iv .iv-bar button:hover:not(:disabled) { background: #ffffff1a; }
.iv .iv-bar button:disabled { opacity: .35; cursor: default; }
.iv .iv-scale { min-width: 64px; font-variant-numeric: tabular-nums; }
.iv .iv-download { padding: 0 14px; border-color: #d8ff4f40; background: #d8ff4f14; color: #d8ff4f; font-weight: 600; }
.iv .iv-download:hover { background: #d8ff4f24; }
.iv .iv-download[hidden] { display: none; }
.iv .iv-download svg { width: 18px; height: 18px; }
.iv.is-video .iv-zoom-out, .iv.is-video .iv-zoom-in, .iv.is-video .iv-scale { display: none; }
.iv-bar[hidden] { display: none; }

/* Short notes above the toolbar (long-press save, preview fallback). */
.iv-hint { position: absolute; z-index: 3; left: 50%; bottom: calc(max(14px, calc(env(safe-area-inset-bottom) + 8px)) + 68px); width: max-content; max-width: min(460px, calc(100vw - 32px)); margin: 0; padding: 10px 14px; border: 1px solid #d8ff4f40; border-radius: 12px; background: #161c22f2; color: #eef2f4; font-size: 13px; line-height: 1.55; text-align: center; box-shadow: 0 12px 40px #0009; opacity: 0; transform: translate(-50%, 8px); transition: opacity 180ms ease, transform 180ms ease; pointer-events: none; }
.iv-hint.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* Videos keep the site's own player, centred, no zoom. */
.iv-video { position: absolute; left: 50%; top: 50%; width: min(960px, calc(100vw - 32px)); transform: translate(-50%, -50%); }
.iv-video > .video-player { border-radius: 16px; }
.iv-video > .video-player .video-player-stage { height: max(140px, calc(100dvh - 230px)); min-height: 0; aspect-ratio: auto !important; border-radius: 16px 16px 0 0; clip-path: inset(0 round 16px 16px 0 0); }
.iv-video > .video-player video { display: block; width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
.iv-video > video { display: block; width: 100%; max-height: calc(100dvh - 160px); }

@media (max-width: 619px) {
  .iv-top { min-height: 52px; gap: 10px; padding-left: max(12px, env(safe-area-inset-left)); }
  .iv-name { font-size: 12px; }
  .iv .iv-nav { display: none; }
  .iv .iv-bar button, .iv .iv-download { height: 44px; }
  .iv .iv-bar button { min-width: 44px; padding: 0 8px; }
  .iv .iv-scale { min-width: 58px; }
  .iv-video { width: 100vw; }
  .iv-video > .video-player, .iv-video > .video-player .video-player-stage { border-radius: 0; clip-path: none; }
  .iv-video > .video-player .video-player-stage { height: auto; max-height: calc(100dvh - 220px); aspect-ratio: 16 / 9 !important; }
}

@media (prefers-reduced-motion: reduce) {
  .iv[open], .iv.is-closing, .iv-fade-in, .iv-from-left, .iv-from-right { animation: none; }
  .iv-hint { transition: none; }
}

@keyframes ivIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ivOut { to { opacity: 0; } }
@keyframes ivFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ivSpin { to { transform: rotate(360deg); } }

/* Where pictures open large. */
.gallery-detail-media { position: relative; }
.gallery-detail-media img { cursor: zoom-in; }
.gallery-detail-zoom { position: absolute; right: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid #ffffff24; border-radius: 999px; background: #0d1115cc; color: #eef2f4; font: inherit; font-size: 12px; cursor: zoom-in; }
.gallery-detail-zoom svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.history-library-image:not(video) { cursor: zoom-in; }

/* Pay sheet: where a download link cannot save the code, say to long-press it instead. */
.pay-qr-save.is-hint { color: var(--v2-muted, #9aa6ae); text-decoration: none; cursor: default; }
html.ui-v2 .pay-waiting > .pay-qr-save.is-hint { border-color: transparent; background: transparent; color: var(--v2-muted, #9aa6ae); }
