/* Fullscreen media viewer — Telegram style */
.tx-viewer {
  position: fixed; inset: 0; z-index: 80; color: #fff;
  display: flex; flex-direction: column; user-select: none; touch-action: none;
}
.tx-viewer-bg { position: absolute; inset: 0; background: #000; z-index: 0; }
.tx-viewer.is-morphing .tx-viewer-stage { opacity: 0; }
.tx-viewer-ghost { position: fixed; z-index: 81; overflow: hidden; pointer-events: none; will-change: left, top, width, height; }
.tx-viewer-ghost img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tx-viewer-top, .tx-viewer-bottom { position: absolute; left: 0; right: 0; z-index: 3; transition: opacity 0.2s ease, transform 0.25s ease; }
.tx-viewer.is-chrome-hidden .tx-viewer-top { transform: translateY(-12px); }
.tx-viewer.is-chrome-hidden .tx-viewer-bottom { transform: translateY(12px); }
.tx-viewer.is-chrome-hidden .tx-viewer-top, .tx-viewer.is-chrome-hidden .tx-viewer-bottom { opacity: 0; pointer-events: none; }
.tx-viewer-top {
  top: 0; display: flex; align-items: center; gap: 6px; padding: calc(8px + var(--tx-safe-top)) 6px 24px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent);
}
.tx-viewer-title { flex: 1; min-width: 0; padding-left: 8px; }
.tx-viewer-title b { display: block; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-viewer-title span { display: block; font-size: 14.5px; opacity: 0.8; }
.tx-viewer-counter { position: absolute; top: calc(70px + var(--tx-safe-top)); left: 0; right: 0; text-align: center; font-size: 16px; font-weight: 600; z-index: 3; transition: opacity 0.2s; }
.tx-viewer.is-chrome-hidden .tx-viewer-counter { opacity: 0; }
.tx-viewer-stage { flex: 1; position: relative; z-index: 1; touch-action: none; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tx-viewer-stage img, .tx-viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; transition: transform 0.2s ease; }
.tx-viewer-bottom { bottom: 0; padding: 30px 16px calc(14px + var(--tx-safe-bottom)); background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent); }
.tx-viewer-caption { font-size: 16px; line-height: 1.38; max-height: 30vh; overflow-y: auto; margin-bottom: 10px; }
.tx-viewer-caption .emoji { width: 1.25em !important; height: 1.25em !important; vertical-align: -0.25em !important; }
.tx-seek-row { display: flex; align-items: center; gap: 14px; }
.tx-seek { flex: 1; position: relative; height: 24px; cursor: pointer; display: flex; align-items: center; }
.tx-seek-track { position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); overflow: hidden; }
.tx-seek-buf { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.45); width: 0; }
.tx-seek-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #fff; width: 0; }
.tx-seek-thumb { position: absolute; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #fff; left: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
.tx-seek-time { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-viewer-big-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  width: 66px; height: 66px; border-radius: 50%; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center; color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity 0.2s;
}
.tx-viewer-big-play .icon { font-size: 34px; }
.tx-viewer-big-play.is-playing { opacity: 0; pointer-events: none; }
.tx-viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 48px; height: 48px; border-radius: 50%; background: rgba(0, 0, 0, 0.4); display: none; align-items: center; justify-content: center; }
.tx-viewer-nav .icon { font-size: 26px; }
@media (hover: hover) { .tx-viewer-nav { display: flex; } }
.tx-viewer-nav.prev { left: 14px; } .tx-viewer-nav.next { right: 14px; }
.tx-viewer-spinner { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.25); border-top-color: #fff; animation: tx-spin 0.9s linear infinite; z-index: 1; }
@keyframes tx-spin { to { transform: rotate(360deg); } }

/* The viewer is always dark: the caption must not take the (dark) text colour of the day theme */
.tx-viewer-caption.post-text, .tx-viewer-caption.post-text * { color: #fff !important; }
div.tx-viewer-caption.post-text a { color: #8ab4ff !important; }
