/* ── LIGHTBOX ────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--lb-chrome-bg, #000);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.lightbox.open { opacity: 1; pointer-events: all; }

/* ── Light mode lightbox — flip dark/white colors ─────────────────────────────
   Everything is the mirror of dark mode:
   - Text that was rgba(255,255,255,X) becomes rgba(0,0,0,X)
   - Borders that were rgba(255,255,255,X) become rgba(0,0,0,X)
   - Backgrounds that were rgba(255,255,255,X) become rgba(0,0,0,X)
   - The subreddit link stays accent red but hovers to #000 (flipped from hover-to-white)
   - Buttons that were white/muted become dark/muted
─────────────────────────────────────────────────────────────────────────── */
[data-theme="light"] .lightbox-header,
[data-theme="light"] .lightbox-footer { border-color: rgba(0,0,0,0.08); }

/* Home button */
[data-theme="light"] .lb-home-btn { color: rgba(0,0,0,0.55); }
[data-theme="light"] .lb-home-btn:hover { color: #000; }

/* Subreddit — stays accent red, hovers dark instead of light */
[data-theme="light"] .lb-browse-context { color: rgba(0,0,0,0.45); }
[data-theme="light"] .lb-browse-context[data-context-type="single"] { color: rgba(0,0,0,0.72); }
[data-theme="light"] .lightbox-subreddit { color: var(--accent); }
[data-theme="light"] .lightbox-subreddit:hover { opacity: 1; }
[data-theme="light"] #lbSubreddit:hover { opacity: 1; }
[data-theme="light"] #lbSubreddit:hover .lb-sub-name { color: #000; }
[data-theme="light"] #lbSubreddit:hover .lb-sub-prefix { opacity: 0.5; }

/* Close button */
[data-theme="light"] .lightbox-header .header-btn { color: rgba(0,0,0,0.7); }
[data-theme="light"] .lightbox-header .header-btn:hover { color: #000; }
[data-theme="light"] .lb-repeat-counter,
[data-theme="light"] #lbGalleryCounter,
[data-theme="light"] .lb-counter {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .lb-repeat-counter.is-default {
  color: rgba(0,0,0,0.45);
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
}

/* Title */
[data-theme="light"] .lightbox-title { color: rgba(0,0,0,0.85); }
[data-theme="light"] .lightbox-title:hover { color: #000; }

/* Meta row */
[data-theme="light"] .lightbox-meta { color: rgba(0,0,0,0.5); }
[data-theme="light"] .lightbox-meta a { color: rgba(0,0,0,0.6); }
[data-theme="light"] .lightbox-meta a:hover { color: var(--accent); }

/* Counter + countdown */
[data-theme="light"] .lb-counter { color: rgba(0,0,0,0.45); }
[data-theme="light"] .lb-head-counters { border-right-color: rgba(0,0,0,0.08); }
[data-theme="light"] .lb-header-left {
  border-right-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .lb-progress-countdown {
  color: rgba(0,0,0,0.75);        /* much stronger — dark text on light chrome */
  text-shadow: 0 1px 2px rgba(255,255,255,0.8); /* light shadow, exact opposite of dark mode */
}

/* Nav arrows — keep dark style in light mode: arrows always sit on the black #lbMedia background */
[data-theme="light"] .lb-nav { background: rgba(18,18,20,0.78); color: #fff; box-shadow: 0 8px 22px rgba(0,0,0,0.24); }
[data-theme="light"] .lb-nav:hover { background: rgba(18,18,20,0.94); }
[data-theme="light"] .lb-gal-prev,
[data-theme="light"] .lb-gal-next { background: rgba(18,18,20,0.44); color: rgba(68,204,255,0.68); box-shadow: 0 4px 12px rgba(0,0,0,0.14); opacity: 0.88; }
[data-theme="light"] .lb-gal-prev:hover,
[data-theme="light"] .lb-gal-next:hover { background: rgba(18,18,20,0.66); color: rgba(68,204,255,0.9); opacity: 1; }

/* Progress bar track */
[data-theme="light"] .lb-progress-bar { background: rgba(0,0,0,0.08); }

/* Slideshow control buttons */
[data-theme="light"] .lb-ss-btn {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.12);
  color: rgba(0,0,0,0.55);
}
[data-theme="light"] .lb-ss-btn:hover { background: rgba(0,0,0,0.1); color: #000; border-color: rgba(0,0,0,0.2); }
[data-theme="light"] .lb-ss-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }
[data-theme="light"] .lb-ss-btn.lb-ss-autoplay,
[data-theme="light"] .lb-ss-btn.lb-ss-autoplay:hover,
[data-theme="light"] .lb-ss-btn.lb-ss-autoplay.active {
  background: transparent;
  border-color: transparent;
  color: inherit;
}
[data-theme="light"] .lb-ss-autoplay-track {
  background: rgba(0,0,0,0.1);
  border-color: rgba(0,0,0,0.12);
}
[data-theme="light"] .lb-ss-autoplay-thumb {
  background: rgba(255,255,255,0.95);
  color: rgba(0,0,0,0.55);
  box-shadow: 0 4px 10px rgba(0,0,0,0.14);
}
[data-theme="light"] .lb-ss-btn.lb-ss-autoplay.active .lb-ss-autoplay-track {
  background: rgba(255,59,48,0.16);
  border-color: rgba(255,59,48,0.4);
}
[data-theme="light"] .lb-ss-btn.lb-ss-autoplay.active .lb-ss-autoplay-thumb {
  background: rgba(255,255,255,0.98);
  color: var(--accent);
}

.lightbox-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  height: var(--header-h);
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  margin-bottom: 8px;
}
.lb-header-left,
.lb-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.lb-header-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.lb-header-control-group--settings,
.lb-header-control-group--nav {
  margin-right: 2px;
  padding-right: 8px;
  border-right: 1px solid rgba(255,255,255,0.08);
}
.lb-header-left { justify-self: start; }
.lb-header-right { justify-self: end; }
.lb-header-center {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.lb-header-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.lb-head-counters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.lb-head-counters--rail {
  margin-right: 2px;
  padding-right: 6px;
  border-right: 1px solid rgba(255,255,255,0.08);
}
.lb-browse-context {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
}
.lb-browse-context[data-context-type="single"] {
  color: rgba(255,255,255,0.72);
}
.lightbox-subreddit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  transition: opacity var(--trans);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-sub-prefix {
  flex: 0 0 auto;
}
.lb-sub-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lightbox-subreddit:hover { opacity: 0.7; }

.lb-home-btn {
  display: flex;
  align-items: center;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  transition: color 0.15s;
  margin-right: 4px;
  flex-shrink: 0;
}
.lb-home-btn:hover { color: #fff; }
.lb-home-btn .material-icons { font-size: 20px; }
.lb-home-btn .svg-icon { width: 20px; height: 20px; }

.lb-logo {
  font-size: 26px;
  line-height: 1;
}
@media (min-width: 1101px) {
  .lb-header-left {
    padding-left: 8px;
  }
}
.lightbox-header .header-btn {
  background: transparent;
}
.lightbox-header .header-btn.lb-quick-reset-btn {
  width: auto;
  height: 36px;
  min-height: 36px;
  max-width: 0;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  justify-content: center;
  color: var(--accent);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.92);
  margin: 0;
  border-color: transparent;
  pointer-events: none;
  transition:
    max-width 0.18s ease,
    padding 0.18s ease,
    opacity 0.18s ease,
    transform 0.18s ease,
    border-color 0.15s ease,
    margin 0.18s ease,
    color 0.15s ease,
    background 0.15s ease;
}
.lightbox-header .header-btn.lb-quick-reset-btn.is-visible {
  max-width: 96px;
  padding: 0 12px;
  opacity: 1;
  transform: scale(1);
  border-color: var(--border);
  pointer-events: auto;
}
.lightbox-header .header-btn.lb-quick-reset-btn:hover {
  color: var(--accent-hover);
  border-color: var(--border-light);
  background: transparent;
}
.lightbox-header .header-btn.lb-quick-reset-btn.is-active {
  color: var(--accent);
  background: transparent;
  border-color: var(--border);
}
.lightbox-header .header-btn.lb-quick-reset-btn.is-active:hover {
  color: var(--accent-hover);
  background: transparent;
  border-color: var(--border-light);
}
.lb-header-btn .svg-icon { width: 18px; height: 18px; }
.lb-header-close { color: var(--text-muted); }
.lb-header-avatar {
  text-decoration: none;
  color: #fff;
}
.lb-avatar-wrap .header-avatar-menu {
  top: calc(100% + 10px);
  right: 0;
}
.lb-header-auth {
  min-width: 0;
}

/* lightbox-body: position:relative so side ad cols can be absolute.
   Always black — media looks best on pure black regardless of theme. */
.lightbox-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: #000;
}

/* Media fills full body — padding pushes content clear of absolute ad columns */
.lightbox-media {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 20px 70px;
  box-sizing: border-box;
  --media-feedback-circle-size: clamp(52px, 7vw, 74px);
  --media-feedback-halo-size: clamp(68px, 9vw, 96px);
}

/* 1366px+: right col 320px + 150px arrow buffer */
@media (min-width: 1366px) and (min-height: 380px) {
  .lightbox-media { padding-right: 470px; padding-left: 150px; }
}

/* 1600px+: left col 180px + 100px arrow, right col 320px + 100px arrow */
@media (min-width: 1600px) and (min-height: 380px) {
  .lightbox-media { padding-right: 470px; padding-left: 330px; }
}
.lightbox-media img,
.lightbox-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
.lightbox-media #lbContent {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}
.lightbox-media .embed-wrap {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: center;
}
.lightbox-media .embed-wrap iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 8px;
}
/* Direct iframes (redgifs and similar) — centered, not full-width */
.lightbox-media > iframe {
  display: block;
  border: none;
  border-radius: 8px;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lb-nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(18,18,20,0.78);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.24);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  pointer-events: auto;
  z-index: 20;
  isolation: isolate;
  will-change: transform, background-color;
}
.lb-nav:hover { background: rgba(18,18,20,0.94); box-shadow: 0 10px 26px rgba(0,0,0,0.3); }
.lb-nav:active { transform: translateY(-50%) scale(0.92); }
.lb-gal-prev,
.lb-gal-next {
  width: 44px;
  height: 44px;
  background: rgba(18,18,20,0.44);
  color: rgba(68,204,255,0.68);
  font-size: 19px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.14);
  opacity: 0.88;
}
.lb-gal-prev:hover,
.lb-gal-next:hover {
  background: rgba(18,18,20,0.66);
  color: rgba(68,204,255,0.9);
  box-shadow: 0 7px 18px rgba(0,0,0,0.22);
  opacity: 1;
}

.lb-no-media {
  color: rgba(255,255,255,0.35);
  font-size: 14px;
  letter-spacing: 0.05em;
  padding: 40px;
  text-align: center;
}
.lb-external-link {
  display: inline-block;
  padding: 14px 24px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  text-decoration: none;
  transition: background 0.15s;
}
.lb-external-link:hover { background: rgba(255,255,255,0.2); }
/* Arrow offsets — pushed inward when ad columns are present */
:root {
  --lb-arrow-left:  14px;
  --lb-arrow-right: 14px;
}
.lb-prev { left:  var(--lb-arrow-left);  }
.lb-next { right: var(--lb-arrow-right); }
.lb-prev::before,
.lb-next::before {
  content: "";
  position: absolute;
  inset: -8px;
}
.lb-nav:disabled { opacity: 0.2; pointer-events: none; }
.lb-skip-nav {
  top: calc(50% + 46px);
  width: 38px;
  height: 30px;
  font-size: 16px;
  border-radius: 999px;
  background: rgba(18,18,20,0.42);
  color: rgba(255,255,255,0.78);
  box-shadow: 0 4px 12px rgba(0,0,0,0.16);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-50%) translateY(0) scale(1);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s, background 0.15s ease, box-shadow 0.15s ease;
}
.lb-skip-nav.is-visible {
  opacity: 0.88;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(-50%) translateY(6px) scale(0.94);
  transition-delay: 0s, 0s, 0s, 0s, 0s;
}
.lb-skip-nav.is-visible:disabled {
  opacity: 0.2;
  pointer-events: none;
}
.lb-skip-nav:hover {
  background: rgba(18,18,20,0.62);
  color: #fff;
  box-shadow: 0 7px 18px rgba(0,0,0,0.22);
}
.lb-skip-nav:active {
  transform: translateY(-50%) translateY(6px) scale(0.86);
}
.lb-skip-nav .svg-icon {
  width: 17px;
  height: 17px;
}
.lb-skip-prev { left: calc(var(--lb-arrow-left) + 5px); }
.lb-skip-next { right: calc(var(--lb-arrow-right) + 5px); }

/* 1366px+: right col is 320px — push right arrow clear of it */
@media (min-width: 1366px) and (min-height: 380px) and (max-height: 500px) {
  .lb-next { right: 334px !important; }
}
@media (min-width: 1366px) and (min-height: 501px) {
  :root { --lb-arrow-right: 334px; }
}

/* 1600px+: left col is 180px, right col 320px — only above 380px */
@media (min-width: 1600px) and (min-height: 380px) {
  :root { --lb-arrow-left: 194px; --lb-arrow-right: 334px; }
}

.lightbox-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
  }

.lightbox.is-end-state .lightbox-footer,
.lightbox.is-end-state .lb-header-meta,
.lightbox.is-end-state .lb-head-counters,
.lightbox.is-end-state .lb-head-counters--rail,
.lightbox.is-end-state .lb-ad-leaderboard,
.lightbox.is-end-state .lb-ad-banner,
.lightbox.is-end-state .lb-ad-mobile {
  opacity: 0;
  pointer-events: none;
}

/* Progress bar — thin accent strip at top of footer, fills over slideshow interval */
.lb-progress-bar {
  height: 3px;
  background: rgba(255,255,255,0.08);
  width: 100%;
  overflow: hidden;
}
.lb-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  /* No CSS transition — the rAF loop drives width directly every frame.
     A transition here causes a ~250ms visual lag after pause because
     the bar coasts to its last-rendered position even after rAF stops. */
  border-radius: 0 2px 2px 0;
  transition: width 90ms linear;
  will-change: width;
}
.lb-progress-bar.lb-progress-instant .lb-progress-fill,
.lb-progress-bar.lb-scrubbing .lb-progress-fill {
  transition: none;
}

/* Footer row: title/meta left, controls right on desktop */
.lb-footer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px 12px;
}
.lb-footer-left {
  flex: 1;
  min-width: 0;
}

/* Slideshow controls */
.lb-ss-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.lb-ss-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lb-ss-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.lb-ss-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: rgba(255,255,255,0.55);
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  min-height: 34px;
  box-sizing: border-box;
}
.lb-ss-btn#lbSsSound {
  min-width: 34px;
  padding-inline: 8px;
}
.lb-ss-btn#lbSsRepeat {
  min-width: 54px;
  gap: 4px;
  padding-inline: 10px;
}
.lb-ss-btn .svg-icon,
.lb-ss-btn span .svg-icon { width: 18px; height: 18px; flex-shrink: 0; }
.lb-ss-btn:hover { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.2); }
.lb-ss-btn:active { transform: scale(0.93); }
.lb-ss-btn.lb-ss-play { padding: 6px 12px; }
.lb-ss-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }
.lb-ss-btn.lb-ss-autoplay,
.lb-ss-btn.lb-ss-autoplay:hover,
.lb-ss-btn.lb-ss-autoplay.active {
  padding: 0;
  min-width: 54px;
  border-color: transparent;
  background: transparent;
  color: inherit;
}
.lb-ss-autoplay-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 54px;
  height: 30px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  transition: background 0.18s ease, border-color 0.18s ease;
}
.lb-ss-autoplay-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.96);
  color: rgba(0,0,0,0.55);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transform: translateX(0);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
#lbSsAutoplayIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#lbSsAutoplayIcon .svg-icon {
  width: 14px;
  height: 14px;
}
.lb-ss-btn.lb-ss-autoplay.active .lb-ss-autoplay-track {
  background: rgba(255,59,48,0.18);
  border-color: rgba(255,59,48,0.36);
}
.lb-ss-btn.lb-ss-autoplay.active .lb-ss-autoplay-thumb {
  transform: translateX(24px);
  color: var(--accent);
  box-shadow: 0 4px 12px rgba(255,59,48,0.28);
}
.lb-ss-skip-n, .lb-ss-repeat-n { font-size: 11px; font-weight: 700; line-height: 1; }
.lb-repeat-counter,
.lb-counter {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}
#lbCounter,
#lbGalleryCounter {
  min-width: 0;
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  border-color: transparent;
  opacity: 0;
  overflow: hidden;
  transition:
    max-width 0.18s ease,
    padding 0.18s ease,
    opacity 0.18s ease,
    transform 0.18s ease,
    border-color 0.15s ease;
}
#lbCounter {
  transform: translateX(8px) scale(0.92);
}
#lbGalleryCounter {
  transform: scale(0.92);
}
#lbCounter.is-visible,
#lbGalleryCounter.is-visible {
  min-width: 56px;
  max-width: 108px;
  padding-left: 8px;
  padding-right: 8px;
  border-color: rgba(255,255,255,0.12);
  opacity: 1;
  transform: scale(1);
}
#lbGalleryCounter {
  color: #44ccff;
}
.lb-repeat-counter {
  min-width: 48px;
  justify-content: center;
  color: var(--accent);
}
.lb-counter {
  min-width: 56px;
  justify-content: center;
  color: rgba(255,255,255,0.5);
}
.lb-repeat-counter.is-default {
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.08);
}
/* Progress bar overlays: countdown (left) and loop counter (right) */
.lb-progress-bar { position: relative; }
.lb-progress-countdown,
.lb-progress-loops {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  transition: opacity 0.2s;
}
.lb-progress-countdown {
  left: 6px;
  color: rgba(255,255,255,0.75);
}

/* Volume control wrapper */
.lb-ss-vol-wrap {
  position: relative;
  display: flex;
  align-items: center;
  z-index: 2;
}
.lb-ss-vol-wrap::before {
  content: '';
  position: absolute;
  right: -4px;
  bottom: 100%;
  width: 44px;
  height: 16px;
}
.lb-ss-vol-slider-wrap {
  position: absolute;
  right: 0;
  bottom: calc(100% + 4px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 120px;
  padding: 12px 0;
  border-radius: 18px;
  background: rgba(14,14,16,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 16px 36px rgba(0,0,0,0.38);
  backdrop-filter: blur(10px);
  z-index: 3;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px) scale(0.96);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}
.lb-ss-vol-wrap:hover .lb-ss-vol-slider-wrap,
.lb-ss-vol-wrap:focus-within .lb-ss-vol-slider-wrap {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.lb-ss-vol-slider-wrap::after {
  content: '';
  position: absolute;
  right: 11px;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: rgba(14,14,16,0.92);
  border-right: 1px solid rgba(255,255,255,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  transform: rotate(45deg);
}
.lb-ss-vol-slider {
  width: 88px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transform: rotate(-90deg);
}
.lb-ss-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.lb-ss-vol-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* Mobile: stack controls below title/meta */
@media (max-width: 600px) {
  .lb-footer-row { flex-wrap: wrap; }
  .lb-ss-controls { width: 100%; justify-content: center; padding-bottom: 4px; gap: 6px; }
  .lb-ss-divider { display: none; }
  .lb-header-right { gap: 8px; }
}
.lightbox-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  transition: color 0.15s ease;
  cursor: pointer;
  margin-bottom: 6px;
  /* fit-content so the anchor only covers the text, not the full row width */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
}
@media (hover: hover) and (pointer: fine) {
  .lightbox-title:hover { color: #fff; }
}
/* On hover: whole element goes full opacity (restores name to full white),
   r/ prefix keeps its own dim so only the subreddit name hits true white. */
.lb-sub-prefix { opacity: 0.4; transition: opacity 0.15s ease; }
.lb-sub-name   { transition: color 0.15s ease; }
@media (hover: hover) and (pointer: fine) {
  #lbSubreddit:hover { opacity: 1; }
  #lbSubreddit:hover .lb-sub-name { color: #fff; }
  #lbSubreddit:hover .lb-sub-prefix { opacity: 0.7; } /* stays dim */
}
.lightbox-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  flex-wrap: wrap;
}
.lightbox-meta a { color: rgba(255,255,255,0.6); transition: color var(--trans); }
.lightbox-meta a:hover { color: var(--accent); }
.lightbox-meta .ups { color: var(--accent); font-weight: 600; }

/* Progress dots */
/* ── LIGHTBOX ADS ────────────────────────────────────────────── */
/*
  Tier by viewport:
    <480px          → 300x100 mobile banner
    480–767px       → 468x60 banner
    768–1279px      → 728x90 leaderboard
    1425–1599px     → 2x stacked 300x250 right col + 728x90 leaderboard
    1600px+         → 160x600 left sky + 2x stacked 300x250 right col
*/

/* ── Shared strip styles (below media body) — unified ad zone color via variable */
.lb-ad-leaderboard,
.lb-ad-banner,
.lb-ad-mobile {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--lb-ad-bg);
  border-top: 1px solid var(--lb-ad-border);
}
.lb-ad-leaderboard { padding: 8px 70px; }
@media (min-width: 1366px) { .lb-ad-leaderboard { padding: 8px 470px 8px 150px;  } }
@media (min-width: 1600px) { .lb-ad-leaderboard { padding: 8px 470px 8px 330px; } }
.lb-ad-banner      { padding: 8px 0;  }
.lb-ad-mobile      { padding: 6px 0;  }

/* ── Left skyscraper (160x600) — absolutely anchored to left edge */
.lb-ad-sky-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lb-ad-bg);
  border-right: 1px solid var(--lb-ad-border);
}

/* ── Right column: two stacked 300x250 — anchored to right edge */
.lb-ad-right-col {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--lb-ad-bg);
  border-left: 1px solid var(--lb-ad-border);
}
.lb-ad-right-unit {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Default: everything hidden, cascade up by breakpoint — no gaps */
.lb-ad-sky-left    { display: none; }
.lb-ad-right-col   { display: none; }
.lb-ad-leaderboard { display: none; }
.lb-ad-banner      { display: none; }
.lb-ad-mobile      { display: none; }

/* FIX 1: Cascade strip ads — mobile default, each breakpoint overrides, no boundary gaps */

/* <480px: mobile 300x100 — default, requires min-height 400px */
@media (min-height: 380px) {
  .lb-ad-mobile { display: flex; }
}

/* 480px+: 468x60 banner overrides mobile — exclude very short viewports */
@media (min-width: 480px) and (min-height: 380px) {
  .lb-ad-mobile      { display: none; }
  .lb-ad-banner      { display: flex; }
}

/* 768px+: leaderboard overrides banner — exclude landscape (max-height: 500px) */
@media (min-width: 768px) and (min-height: 501px) {
  .lb-ad-banner      { display: none; }
  .lb-ad-leaderboard { display: flex; }
}

/* 1366px+ height>=380px: show right col (single unit, second hidden by default) */
@media (min-width: 1366px) and (min-height: 380px) {
  .lb-ad-right-col { display: flex; }
  .lb-ad-right-col .lb-ad-right-unit:last-child { display: none; }
}

/* 1366px+ height>=770px: override — show both units (double stack) */
@media (min-width: 1366px) and (min-height: 770px) {
  .lb-ad-right-col .lb-ad-right-unit:last-child { display: flex; }
}

/* ── SHORT VIEWPORT RULES (height <= 500px) ──────────────────────────────
   One unified block. Strip ads never show. Only right col at 800px+ width.
   Below 380px height — nothing at all.
   ──────────────────────────────────────────────────────────────────────── */

/* Tighten header/footer in all short viewports */
@media (max-height: 500px) {
  .lightbox-header { padding: 0 16px; }
  .lightbox-footer { padding: 8px 20px; }
}

@media (max-width: 720px) {
  .lightbox-header {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    padding: 0 12px;
  }
  .lb-header-center { justify-content: flex-start; }
  .lb-header-meta { align-items: flex-start; gap: 2px; }
  .lb-header-right { gap: 6px; }
  .lb-header-control-group { gap: 6px; }
  .lb-head-counters { gap: 6px; }
  .lb-head-counters--rail {
    margin-right: 0;
    padding-right: 8px;
  }
  .lb-header-auth {
    padding-inline: 12px;
  }
}

@media (max-width: 500px) {
  .lightbox-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 0 10px;
  }
  .lb-header-left {
    min-width: 0;
  }
  .lb-logo {
    font-size: 23px;
  }
  .lb-header-center {
    min-width: 0;
    justify-content: flex-start;
  }
  .lb-header-meta {
    align-items: flex-start;
    width: 100%;
  }
  .lightbox-subreddit {
    justify-content: flex-start;
  }
  .lb-header-right {
    flex-shrink: 0;
    gap: 4px;
  }
  .lb-header-control-group {
    gap: 4px;
  }
  .lb-header-control-group--settings,
  .lb-header-control-group--nav {
    margin-right: 0;
    padding-right: 6px;
  }
  .lb-head-counters {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 4px;
  }
  .lb-head-counters--rail {
    width: max-content;
    max-width: none;
    align-self: flex-end;
    padding-top: 1px;
    padding-bottom: 1px;
    margin-right: 0;
    padding-right: 0;
    border-right: 0;
  }
  .lb-head-counters > * {
    width: auto;
    min-width: 0;
    min-height: 17px;
    padding: 0 6px;
    font-size: 10px;
    justify-content: center;
  }
  .lb-browse-context,
  .lightbox-subreddit {
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .lb-header-auth {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }
  .lb-header-auth-label {
    display: none;
  }
}

@media (max-width: 1360px) {
  .lightbox-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    height: auto;
    min-height: var(--header-h);
    padding-top: 6px;
    padding-bottom: 6px;
    align-items: center;
    gap: 10px;
  }
  .lb-header-left,
  .lb-header-center {
    min-height: calc(var(--header-h) - 12px);
    align-self: center;
  }
  .lb-header-left {
    margin-right: 0;
    padding-right: 12px;
    border-right: 1px solid rgba(255,255,255,0.08);
  }
  .lb-header-center {
    justify-content: flex-start;
  }
  .lb-header-meta {
    width: 100%;
    align-items: flex-start;
  }
  .lightbox-subreddit {
    justify-content: flex-start;
  }
  .lb-header-right {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    justify-content: end;
    justify-items: end;
    align-items: center;
    column-gap: 6px;
    row-gap: 4px;
    width: max-content;
    min-width: 0;
    max-width: none;
  }
  .lb-header-control-group {
    justify-self: end;
  }
  .lb-head-counters {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
  }
  .lb-head-counters--rail {
    grid-column: 1 / -1;
    justify-self: end;
    order: 5;
    width: max-content;
    max-width: none;
    align-self: center;
    justify-content: flex-end;
    margin-right: 0;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 6px;
    border-right: 1px solid rgba(255,255,255,0.08);
  }
}

@media (max-width: 720px) {
  .lightbox-header {
    gap: 8px;
  }
}

@media (max-width: 1099px) {
  .lb-gal-prev,
  .lb-gal-next {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }
  .lb-header-right {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    width: max-content;
    padding-bottom: 28px;
  }
  .lb-header-control-group--nav {
    margin-right: 0;
  }
  .lb-head-counters--rail {
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    width: max-content;
    padding-right: 0;
    border-right: 0;
  }
}

@media (max-width: 500px) {
  .lb-head-counters > * {
    width: auto;
    min-width: 0;
    min-height: 17px;
    padding: 0 6px;
    font-size: 10px;
    justify-content: center;
  }
}

/* Short + narrow (<800px): no side col, strips allowed, reset padding/arrows */
@media (max-width: 640px) {
  .header-sort-wrap {
    gap: 6px;
  }
  .header-quick-reset-btn,
  .lb-quick-reset-btn {
    min-height: 30px;
    padding: 0 10px;
    font-size: 11px;
  }
}
@media (max-height: 500px) and (max-width: 799px) {
  .lb-ad-leaderboard { display: none !important; }
  .lb-ad-right-col   { display: none !important; }
  .lightbox-media    { padding-right: 60px !important; padding-left: 60px !important; }
  .lb-next           { right: 14px !important; }
  .lb-prev           { left:  14px !important; }
}

/* Short + wide (800px+): kill strips, show right col if tall enough */
@media (max-height: 500px) and (min-width: 800px) {
  .lb-ad-leaderboard { display: none !important; }
  .lb-ad-banner      { display: none !important; }
  .lb-ad-mobile      { display: none !important; }
}

/* Short + wide (800px+) + tall enough (380px+): single 300x250 right col */
@media (min-height: 380px) and (max-height: 500px) and (min-width: 800px) {
  .lb-ad-right-col   { display: flex; }
  .lb-ad-right-col .lb-ad-right-unit:last-child { display: none; }
  .lightbox-media    { padding-right: 430px !important; padding-left: 60px !important; }
  .lb-next           { right: 334px !important; }
  .lb-prev           { left:  14px !important; }
}

/* Short + wide (380-500px) + 1600px+: left col 300x250 also shows — push left arrow */
@media (min-height: 380px) and (max-height: 500px) and (min-width: 1600px) {
  .lightbox-media    { padding-left: 430px !important; }
  .lb-prev           { left: 334px !important; }
}

/* Short + wide + too short (<380px): no right col, reset padding and arrows */
@media (max-height: 379px) and (min-width: 800px) {
  .lb-ad-right-col   { display: none !important; }
  .lightbox-media    { padding-right: 60px !important; padding-left: 60px !important; }
  .lb-next           { right: 14px !important; }
  .lb-prev           { left:  14px !important; }
}

/* Left col — sky-left units hidden by default, CSS toggles per height */
.lb-ad-sky-unit     { display: none; }
.lb-ad-sky-unit-250 { display: none; }

/* 1600px+ height>=860px: show 160x600 skyscraper, 180px col */
@media (min-width: 1600px) and (min-height: 860px) {
  .lb-ad-sky-left     { display: flex; width: 180px; }
  .lb-ad-sky-unit     { display: block; }
}

/* 1600px+ height 380-859px: if 160x600 won't fit, fall back to 300x250 on the left */
@media (min-width: 1600px) and (min-height: 380px) and (max-height: 859px) {
  .lb-ad-sky-left     { display: flex; width: 320px; }
  .lb-ad-sky-unit-250 { display: block; }
  /* Adjust left media padding to match wider left col */
  .lightbox-media     { padding-left: 430px; }
  .lb-ad-leaderboard  { padding-left: 430px; }
  :root { --lb-arrow-left: 334px; }
}

/* ── NATURAL IN-FEED AD CARDS ────────────────────────────────── */
.ad-card-natural {
  cursor: default;
  display: flex;
  flex-direction: column;
  align-self: stretch;      /* override post-card's start — match row height */
}
.ad-card-natural .ad-thumb {
  aspect-ratio: unset !important;
  height: auto !important;
  flex: 1;                  /* stretch to fill card height, ad centered inside */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-elevated);
  padding: 0;
}
.ad-real {
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-frame-crop {
  display: block;
  overflow: hidden;
  line-height: 0;
  background: var(--bg-elevated);
}
/* stacked ad container — two ads stacked vertically */
.ad-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 12px 0;
}
/* iframes/images: natural pixel size */
.ad-card-natural .ad-thumb iframe,
.ad-card-natural .ad-thumb ins,
.ad-card-natural .ad-thumb img {
  width: auto !important;
  max-width: 100% !important;
  display: block;
  flex-shrink: 0;
}
.ad-card-natural .ad-thumb iframe.ad-frame {
  width: min(var(--ad-frame-w, 100%), 100%) !important;
  height: var(--ad-frame-h, auto) !important;
  background: var(--bg-elevated);
}
.ad-card-natural .ad-thumb ins,
.ad-card-natural .ad-thumb img {
  height: auto !important;
}
/* placeholder divs have inline px dimensions — don't override */
.ad-card-natural .ad-thumb > div {
  display: block;
  flex-shrink: 0;
  max-width: 100%;
}
/* ad-stack must stay flex so gap works */
.ad-card-natural .ad-thumb > .ad-stack {
  display: flex;
  flex-shrink: 0;
  max-width: 100%;
}
/* Disable the hover lift on ad cards */
.ad-card-natural:hover {
  transform: none;
  box-shadow: var(--shadow-card);
}

/* ── BETWEEN-BATCH AD STRIP ──────────────────────────────────── */
/* Full-width row spanning all grid columns. JS injects only the
   correctly-sized unit for the current viewport — no hiding needed. */
.grid-spacer {
  visibility: hidden;
  pointer-events: none;
  height: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
}

.ad-strip-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 4px;
  margin: 4px 0;
}

/* ── INTERSTITIAL OVERLAY ────────────────────────────────────── */
.interstitial {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.interstitial.open { opacity: 1; pointer-events: all; }
.interstitial-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.interstitial-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.interstitial-ad iframe,
.interstitial-ad ins,
.interstitial-ad img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
}
.interstitial-premium-link {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.15s ease;
}
.interstitial-premium-link:hover {
  color: var(--accent);
}
.interstitial-premium-link strong {
  color: inherit;
  font-weight: 800;
}
.interstitial-divider {
  width: min(220px, 100%);
  height: 1px;
  background: var(--border-light);
  opacity: 0.45;
  margin: -2px 0;
}
.interstitial-skip {
  padding: 9px 24px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.interstitial-skip:hover:not(:disabled) { background: var(--border); }
.interstitial-skip:disabled { opacity: 0.35; cursor: not-allowed; }

