/* Loaded after legacy responsive rules. Keep overrides scoped to the viewer. */
.feed-preferences {
  box-sizing: border-box;
  width: 100%;
  max-width: 800px;
  margin: 24px auto;
  padding: 16px;
  border: 1px solid #737373;
  border-radius: 12px;
  background: #fff;
  color: #222;
  overflow-wrap: anywhere;
}
.feed-preferences summary { cursor: pointer; padding: 8px; }
.feed-preferences p { line-height: 1.6; }
.feed-preferences form { margin: 12px 0; }
.feed-preferences button { min-height: 44px; max-width: 100%; padding: 12px; white-space: normal; overflow-wrap: anywhere; }
.feed-preferences :focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
[data-theme="dark"] .feed-preferences { background: #1e1e1e; color: #f5f5f5; }
[data-theme="dark"] .feed-preferences :focus-visible { outline-color: #93c5fd; }
.meme-share-panel {
  box-sizing: border-box;
  width: 100%;
  max-width: 800px;
  margin: 16px auto;
  padding: 16px;
  border: 1px solid #737373;
  border-radius: 12px;
  background: #fff;
  color: #222;
  overflow-wrap: anywhere;
}
.meme-share-panel summary { cursor: pointer; padding: 8px; }
.meme-share-panel .share-bar { display: flex; flex-wrap: wrap; gap: 12px; }
.meme-share-panel button, .meme-share-panel a { min-height: 44px; padding: 12px; }
.meme-share-panel [role="status"] { flex-basis: 100%; }
.meme-share-panel .share-guidance { flex-basis: 100%; line-height: 1.6; }
.meme-share-panel button { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
.meme-share-panel :focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
[data-theme="dark"] .meme-share-panel { background: #1e1e1e; color: #f5f5f5; }
[data-theme="dark"] .meme-share-panel a { color: #a8c7fa; }
.gallery-dot {
  box-sizing: content-box;
  border: 0;
  padding: 0;
  margin: 12px;
  position: relative;
}

/* Preserve the small visual dot while giving touch a 44px target. */
.gallery-dot::after {
  content: '';
  position: absolute;
  width: 44px;
  height: 44px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.gallery-carousel button:focus-visible,
.meme-gallery button:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 4px;
}

.meme-gallery {
  touch-action: pan-y pinch-zoom;
}

.more-from-sub-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  margin-left: 6px;
  border-radius: 999px;
  border: 1px solid #737373;
  background: var(--card-bg, #f8fafc);
  color: var(--text-color, #1e293b);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.more-from-sub-btn:focus-visible,
.permalink-cta-card a:focus-visible,
.sponsor-slot-card a:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

[data-theme="dark"] .more-from-sub-btn {
  background: #262626;
  color: #f5f5f5;
  border-color: #9ca3af;
}

.permalink-cta-card,
.sponsor-slot-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 800px;
  margin: 24px auto;
  padding: 16px;
  border: 1px solid #737373;
  border-radius: 12px;
  background: var(--card-bg, #fff);
  color: var(--text-color, #222);
  text-align: center;
  overflow-wrap: anywhere;
}

.permalink-cta-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.permalink-cta-btn,
.permalink-cta-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.permalink-cta-btn {
  background: #b91c50;
  color: #fff !important;
}

.permalink-cta-secondary {
  border: 1px solid #737373;
  color: inherit;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-slide { transition: none !important; }
}

/* Unlike hidden, clip does not create a scrolling ancestor for sticky controls. */
@supports (overflow: clip) {
  html, body {
    overflow-x: clip !important;
  }
}

.viewer-navigation {
  position: sticky;
  top: 0;
  z-index: 110;
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 800px;
  box-sizing: border-box;
  padding: 8px;
  background: var(--card-bg, #fff);
  border-bottom: 1px solid var(--border-color, #ddd);
}

.viewer-navigation .control-btn {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  white-space: normal !important;
  overflow-wrap: anywhere;
  flex-direction: row !important;
  font-size: 1rem !important;
  background: var(--card-bg, #fff) !important;
  color: var(--text-color, #222) !important;
  border: 1px solid var(--border-color, #aaa) !important;
}

.viewer-navigation #next-btn {
  background: #b91c50 !important;
  color: #fff !important;
  font-weight: 700;
}

.viewer-navigation button:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

.viewer-navigation button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

[data-theme="dark"] .viewer-navigation {
  --card-bg: #1e1e1e;
  --text-color: #f5f5f5;
  --border-color: #737373;
}

[data-theme="dark"] .viewer-navigation button:focus-visible {
  outline-color: #93c5fd;
}

@media (max-width: 768px) {
  header {
    padding: 0 !important;
    gap: 0 !important;
  }

  nav.main-nav {
    flex-wrap: wrap !important;
    overflow: visible !important;
    box-sizing: border-box;
    padding: 4px 8px !important;
    gap: 4px !important;
  }

  nav.main-nav .logo {
    font-size: 1.1rem !important;
    padding: 4px 6px !important;
    min-height: 44px !important;
  }

  nav.viewer-navigation {
    overflow: visible !important;
    padding: 6px 8px !important;
    gap: 8px !important;
  }

  nav.main-nav .nav-items {
    width: auto !important;
    flex: 1 1 auto;
    justify-content: flex-end;
    min-width: 0;
    gap: 2px !important;
  }

  nav.main-nav .nav-items a,
  nav.main-nav .nav-items button {
    padding: 6px 8px !important;
    font-size: 0.85rem !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .page-wrapper.simplified-mode,
  .simplified-mode .meme-container {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
}

.viewer-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.simplified-mode #meme-display {
  box-sizing: border-box;
  display: block !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible;
}

.simplified-mode #meme-display .meme-display-content,
.simplified-mode #meme-display .meme-image-container,
.simplified-mode #meme-display .gallery-container {
  width: 100%;
  min-width: 0;
}

.simplified-mode #meme-display img {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: none !important;
  aspect-ratio: auto;
  object-fit: contain;
}

/* AJAX images must size their wrapper, not overflow an absolute square slot. */
.simplified-mode #meme-display .meme-image-container {
  aspect-ratio: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

.simplified-mode #meme-display .meme-image-container img {
  position: static !important;
}

.simplified-mode #meme-display video {
  display: block;
  max-width: 100% !important;
  max-height: 75vh !important;
  width: auto !important;
  height: auto !important;
  margin-inline: auto;
  object-fit: contain;
}

.simplified-mode .meme-controls {
  box-sizing: border-box;
}

.simplified-mode .meme-controls .control-btn {
  min-height: 44px;
}

@media (max-width: 768px) {
  .simplified-mode .meme-controls {
    position: static !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 8px !important;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .simplified-mode .meme-controls .control-btn {
    min-width: 0 !important;
    min-height: 48px !important;
    font-size: 1rem !important;
    line-height: 1.3;
    overflow-wrap: anywhere;
    grid-column: span 2;
  }

  .simplified-mode .meme-controls #prev-btn,
  .simplified-mode .meme-controls #next-btn {
    grid-column: span 3;
    flex-direction: row !important;
  }

  .simplified-mode .meme-controls #next-btn {
    background: #e52e71 !important;
    color: #fff !important;
    font-weight: 700;
  }

  .simplified-mode .meme-controls #download-btn {
    grid-column: 1 / -1;
    flex-direction: row !important;
    min-height: 44px !important;
  }

  .simplified-mode .meme-controls .control-count {
    font-size: 0.875rem !important;
    text-transform: none !important;
  }
}