/* ===================================
   MM Viewer Styles
   Dedicated styles for the media viewer overlay
   =================================== */

/* Disable text selection during A-B slider dragging */
#capsuleImageOverlay,
#capsuleImageOverlay *,
#capsuleOverlayStage,
#capsuleOverlayStage *,
#capsuleOverlaySlider,
#capsuleOverlaySlider * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -moz-user-drag: none;
  -ms-user-drag: none;
  user-drag: none;
}

/* Main viewer overlay */
.capsule-image-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: transparent; /* Phase 1: invisible backdrop */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: none;
  z-index: 10000000; /* ensure overlay above capsules panel */
  touch-action: auto;
  pointer-events: none; /* Allow clicks to pass through when not active */
}

.capsule-image-overlay.active {
  display: flex;
  pointer-events: auto; /* Enable interactions when active */
}

/* While overlay is active, disable/blur generations panel underneath (DOM order-agnostic) */
/* Only block generations panel when both overlay active and flag present */
body.capsule-overlay-active #generationsPanel.overlay-block {
  pointer-events: none !important;
  filter: blur(2px);
}

/* Ensure the viewer info panel is always above the capsules stripe */
body.capsule-overlay-active .viewer-desktop-info-panel-container {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  width: 320px !important;
  height: 100vh !important;
  z-index: 10000002 !important;
  pointer-events: auto !important;
}

/* ================= VIEWER CONFLICT FIXES ================= */
/* When the viewer overlay is active, fade/disable the main header so it doesn't block clicks */
body.capsule-overlay-active .main-header {
  pointer-events: none;
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Hide/disable the input bar for full immersion while overlay is open */
body.capsule-overlay-active .input-section {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Keep panel visible; viewer sits above */

/* Do not block the fixed header while overlay is open */
@media (min-width: 769px) {
  .capsule-image-overlay.active {
    pointer-events: auto;
  }
  .main-header,
  .header-user-section,
  .panel-toggle-arrow,
  .generations-close {
    position: relative;
    z-index: 60002 !important; /* Above overlay chrome */
    pointer-events: auto !important;
  }
}

/* Layout when info panel is visible - only on desktop */
@media (min-width: 769px) {
  .capsule-image-overlay:not(.zoomed) {
    padding-right: 320px; /* Reserve space for info panel */
  }

  .capsule-image-overlay.zoomed {
    padding-right: 0; /* Full width when zoomed */
  }
}

/* Mobile: no padding for overlay */
@media (max-width: 768px) {
  .capsule-image-overlay:not(.zoomed),
  .capsule-image-overlay.zoomed {
    padding-right: 0;
  }
}

/* Media container */
.capsule-overlay-media-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.capsule-overlay-media {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  border-radius: 0; /* remove rounded edge */
  box-shadow: none; /* remove thin pixel/shadow edge */
  background: transparent; /* no background plate */
  border: none; /* no borders */
  overflow: visible;
  cursor: pointer;
  user-select: none;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              position 0s 0.4s; /* Delay position change until after other transitions */
}

/* Focus Mode - Phase 2: JUST THE FUCKING IMAGE, REST IS BLACK */
.capsule-image-overlay.focus-mode {
  background: rgba(0,0,0,0.88) !important;
  backdrop-filter: blur(18px) saturate(110%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(110%) !important;
}

.capsule-image-overlay.focus-mode .capsule-overlay-media {
  max-width: 100vw !important;
  max-height: 100vh !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  position: relative !important;
}

/* Remove global cursor rules - let JavaScript handle cursor based on mouse position */
.capsule-image-overlay.focus-mode .capsule-overlay-media img,
.capsule-image-overlay.focus-mode .capsule-overlay-media video {
  /* Cursor will be set by JavaScript based on mouse position */
}

.capsule-image-overlay.focus-mode .capsule-overlay-media {
  /* Cursor will be set by JavaScript based on mouse position */
}

/* Black background area in focus mode has pointer cursor (clickable to go back) */
.capsule-image-overlay.focus-mode .capsule-overlay-media-container {
  cursor: pointer !important;
}

/* Smooth transition for media container positioning */
.capsule-overlay-media-container {
  transition: margin-right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Remove any overlay backgrounds and effects in focus mode */
.capsule-image-overlay.focus-mode::before,
.capsule-image-overlay.focus-mode::after {
  display: none !important;
}

.capsule-image-overlay.zoomed .capsule-overlay-media {
  /* Cursor will be set by JavaScript based on mouse position */
  max-width: none;
  max-height: none;
  border-radius: 0; /* keep square edge */
  box-shadow: none; /* no edge/glow */
  background: transparent;
}

.capsule-image-overlay.zoomed .capsule-overlay-media:active {
  /* Cursor will be set by JavaScript based on mouse position */
}

/* Media elements */
.capsule-overlay-media img,
.capsule-overlay-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 0 !important; /* do not inherit rounding */
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  will-change: transform;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3D Model specific styling for proper centering */
.capsule-overlay-media .capsule-overlay-model {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Ensure 3D model content is centered within its container */
.capsule-overlay-media .capsule-overlay-model > * {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Desktop: maximize 3D model space usage */
@media (min-width: 769px) {
  .capsule-overlay-media .capsule-overlay-model {
    /* Use maximum available space with proper margins */
    width: calc(100% - 40px);
    height: calc(100% - 40px);
    margin: 20px;
    margin-right: calc(360px + 20px); /* Account for info panel + margin */
  }
}

/* Mobile: ensure proper centering and margins */
@media (max-width: 768px) {
  .capsule-overlay-media .capsule-overlay-model {
    /* Center with smaller margins on mobile */
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    margin: 10px;
  }
}

.capsule-image-overlay.zoomed .capsule-overlay-media img,
.capsule-image-overlay.zoomed .capsule-overlay-media video {
  /* Cursor will be set by JavaScript based on mouse position */
}

.capsule-image-overlay.zoomed .capsule-overlay-media img:active,
.capsule-image-overlay.zoomed .capsule-overlay-media video:active {
  /* Cursor will be set by JavaScript based on mouse position */
}

/* Info Panel */
.capsule-overlay-info-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.capsule-image-overlay.zoomed .capsule-overlay-info-panel {
  transform: translateX(100%);
}

/* Info Panel Sections */
.info-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 4px;
}

/* Prompt Section */
.info-prompt {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  max-height: 120px;
  overflow-y: auto;
}

.info-prompt::-webkit-scrollbar {
  width: 4px;
}

.info-prompt::-webkit-scrollbar-track {
  background: transparent;
}

.info-prompt::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

/* Metadata */
.info-metadata {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-meta-item:last-child {
  border-bottom: none;
}

/* Metadata Grid - Compressed layout */
.metadata-grid {
  display: grid;
  gap: 8px;
}

.metadata-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metadata-label {
  font-size: 12px;
  color: #888;
}

.metadata-value {
  font-size: 12px;
  color: #fff;
  font-weight: 500;
}

.info-meta-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

.info-meta-value {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400;
  text-align: right;
}

/* Project Item Layout */
.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Project Pill Button */
.project-pill {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 20px;
  padding: 6px 12px;
  color: #60a5fa;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  max-width: 200px;
  margin-left: auto;
}

.project-pill:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  color: #93c5fd;
  text-decoration: none;
  transform: translateY(-1px);
}

.project-pill-image {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.project-pill-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Actions Section */
.info-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.info-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.info-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-1px);
}

.info-action-btn:active {
  transform: translateY(0);
}

.info-action-btn img {
  width: 16px;
  height: 16px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.info-action-btn:hover img {
  opacity: 1;
}

/* Close Button */
.capsule-overlay-close {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000050; /* ensure always on top */
  pointer-events: auto;
}

/* When panel is visible (Phase 1), move close button to the left of panel */
@media (min-width: 769px) {
  .capsule-image-overlay:not(.focus-mode):not(.zoomed) .capsule-overlay-close {
    right: calc(360px + 24px);
  }
}

.capsule-overlay-close:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.capsule-overlay-close::before,
.capsule-overlay-close::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 2px;
  background: #ffffff;
  border-radius: 1px;
}

.capsule-overlay-close::before {
  transform: rotate(45deg);
}

.capsule-overlay-close::after {
  transform: rotate(-45deg);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .capsule-image-overlay:not(.zoomed) {
    padding-right: 0;
  }
  
  .capsule-overlay-info-panel {
    width: 100vw;
    height: auto;
    top: auto;
    bottom: 0;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px 16px 0 0;
    padding: 24px;
  }
  
  .capsule-image-overlay.zoomed .capsule-overlay-info-panel {
    transform: translateY(100%);
  }
  
  .capsule-overlay-media {
    max-width: 95%;
    max-height: 70%;
  }
}

/* Parent Images Grid */
.parent-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 9px;
  margin-top: 9px;
}

.parent-image-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 7.2px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
}

.parent-image-item:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.parent-image-item.active {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: scale(1.02);
}

.parent-image-item.active:hover {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px rgba(147, 197, 253, 0.4), 0 6px 20px rgba(0, 0, 0, 0.4);
  transform: scale(1.07);
}

.parent-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 7.2px;
  background: transparent;
  box-shadow: none;
  border: none;
}

.parent-image-item .image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(0, 0, 0, 0.7));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 4.5px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.parent-image-item .image-overlay::before {
  content: '⚡';
  position: absolute;
  top: 4.5px;
  right: 4.5px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.parent-image-item.active .image-overlay::before {
  content: '✓';
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.2);
}

.parent-image-item:hover .image-overlay {
  opacity: 1;
}

.parent-image-item .image-info {
  color: white;
  font-size: 9.9px;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Parent image tooltip */
.parent-tooltip {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.parent-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

.parent-image-item:hover .parent-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* Reduce all text and element sizes by 10% */
.capsule-overlay-info-panel {
  font-size: 12.6px; /* was 14px */
  padding: 18px; /* was 20px */
  width: 324px; /* scaled-down width */
}

.info-section-title {
  font-size: 10.8px; /* was 12px */
  margin-bottom: 7.2px; /* was 8px */
}

.info-section {
  margin-bottom: 18px; /* was 20px */
}

.info-prompt {
  font-size: 12.6px; /* was 14px */
  padding: 10.8px; /* was 12px */
  border-radius: 7.2px; /* was 8px */
}

.info-meta-label {
  font-size: 10.8px; /* was 12px */
}

.info-meta-value {
  font-size: 11.7px; /* was 13px */
}

.info-meta-item {
  margin-bottom: 7.2px; /* was 8px */
}

.info-action-btn {
  font-size: 11.7px; /* was 13px */
  padding: 9px 13.5px; /* was 10px 15px */
  border-radius: 5.4px; /* was 6px */
  gap: 7.2px; /* was 8px */
}

.info-action-btn img {
  width: 14.4px; /* was 16px */
  height: 14.4px; /* was 16px */
}

.info-project-link {
  font-size: 12.6px; /* was 14px */
  padding: 9px; /* was 10px */
  border-radius: 5.4px; /* was 6px */
}

.capsule-overlay-close {
  width: 36px; /* was 40px */
  height: 36px; /* was 40px */
  font-size: 16.2px; /* was 18px */
}

@media (max-width: 768px) {
  .capsule-overlay-info-panel {
    padding: 20px;
    gap: 16px;
  }
  
  .info-prompt {
    font-size: 12px;
    padding: 12px;
  }
  
  .info-action-btn {
    padding: 10px 14px;
    font-size: 12px;
  }
  
  .capsule-overlay-close {
    top: 16px;
    left: 16px;
    width: 36px;
    height: 36px;
  }
}

/* Touch and interaction improvements */
@media (max-width: 768px) {
  .capsule-overlay-media {
    touch-action: pan-x pan-y pinch-zoom;
  }
  
  .capsule-image-overlay.zoomed .capsule-overlay-media {
    touch-action: pan-x pan-y;
  }
  
  .capsule-overlay-media img,
  .capsule-overlay-media video {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ================= MOBILE RESPONSIVE LAYOUT ================= */

/* Mobile Layout Container */
.viewer-layout-container {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
}

/* Desktop - keep original layout */
@media (min-width: 769px) {
  .viewer-layout-container {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    position: relative;
  }
  
  .capsule-overlay-media-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Account for desktop panel width - center in remaining space */
    margin-right: 360px;
    transition: margin-right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* When in focus mode, remove margin and expand container */
  .capsule-image-overlay.focus-mode .capsule-overlay-media-container {
    margin-right: 0;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1000002 !important;
  }
  
  .capsule-overlay-controls-panel {
    display: none; /* Hide mobile controls on desktop */
  }
  
  /* Show desktop info panel on desktop - IMPORTANT: Higher specificity */
  .capsule-image-overlay .viewer-desktop-info-panel-container {
    display: block !important;
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    height: 100vh;
    z-index: 1000001;
    pointer-events: auto;
    padding: 0; /* Remove default padding, let info panel handle it */
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  /* Extra specific rule for desktop viewer info panel */
  #capsuleImageOverlay .viewer-desktop-info-panel-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* FORCE SHOW - Ultra specific desktop rule */
  body #capsuleImageOverlay.capsule-image-overlay.active .viewer-desktop-info-panel-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    width: 360px !important;
    height: 100vh !important;
    z-index: 10000001 !important; /* ensure info panel above everything under overlay */
    background: rgba(20, 20, 20, 0.95) !important;
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateX(0) !important;
  }
  
  /* HIDE PANEL COMPLETELY IN FOCUS MODE */
body #capsuleImageOverlay.capsule-image-overlay.focus-mode .viewer-desktop-info-panel-container {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Alternative selector - HIDE PANEL */
.focus-mode .viewer-desktop-info-panel-container {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Mobile Focus Mode - Full screen image */
@media (max-width: 768px) {
  .capsule-image-overlay.focus-mode .viewer-layout-container {
    flex-direction: column;
    height: 100vh;
    padding: 0;
  }
  
  .capsule-image-overlay.focus-mode .capsule-overlay-media-container {
    flex: 1;
    width: 100vw;
    height: 100vh;
    padding: 0;
    background: transparent;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000002;
  }
  
  .capsule-image-overlay.focus-mode .capsule-overlay-controls-panel {
    display: none !important;
  }
  
  .capsule-image-overlay.focus-mode .capsule-overlay-media {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    position: relative;
  }
}
  
  /* Hide mobile-specific elements on desktop */
  .mobile-parent-column,
  .mobile-info-column,
  .mobile-actions-column,
  .mobile-parent-row,
  .mobile-info-row,
  .mobile-actions-row {
    display: none !important;
  }
  
  /* Desktop info panel - restore original positioning */
  .capsule-overlay-info-panel {
    position: relative;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    padding: 32px 24px;
    overflow-y: auto;
    z-index: 100;
  }
}

/* Mobile Portrait - 3 Column Layout */
@media (max-width: 768px) and (orientation: portrait) {
  .viewer-layout-container {
    flex-direction: column;
    height: 100vh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  
  .capsule-overlay-media-container {
    flex: 0 0 65%; /* 65% for media */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
  }
  
  .capsule-overlay-controls-panel {
    flex: 0 0 35%; /* 35% for controls */
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: 1fr 2fr 1fr; /* 3 columns: parent, info, actions */
    gap: 12px;
    padding: 16px;
    overflow: hidden;
  }
  
  /* Show column layout, hide row layout */
  .mobile-parent-column,
  .mobile-info-column,
  .mobile-actions-column {
    display: flex;
  }
  
  .mobile-parent-row,
  .mobile-info-row,
  .mobile-actions-row {
    display: none !important;
  }
  
  .mobile-parent-column {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  
  .mobile-info-column {
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
  }
  
  .mobile-actions-column {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  
  .capsule-overlay-info-panel {
    position: static;
    width: auto;
    background: transparent;
    padding: 0;
    overflow: visible;
    height: 100%;
  }
  
  /* Hide desktop info panel on mobile portrait */
  .capsule-image-overlay .viewer-desktop-info-panel-container {
    display: none !important;
  }
}

/* Mobile Landscape - 3 Row Layout */
@media (max-width: 768px) and (orientation: landscape) {
  .viewer-layout-container {
    flex-direction: row;
    height: 100vh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  
  .capsule-overlay-media-container {
    flex: 0 0 65%; /* 65% for media */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
  }
  
  .capsule-overlay-controls-panel {
    flex: 0 0 35%; /* 35% for controls */
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-rows: 1fr 2fr 1fr; /* 3 rows: parent, info, actions */
    gap: 12px;
    padding: 16px;
    overflow: hidden;
  }
  
  /* Hide column layout, show row layout */
  .mobile-parent-column,
  .mobile-info-column,
  .mobile-actions-column {
    display: none !important;
  }
  
  .mobile-parent-row,
  .mobile-info-row,
  .mobile-actions-row {
    display: flex;
  }
  
  .mobile-parent-row {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 0;
    overflow-x: auto;
  }
  
  .mobile-info-row {
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
  }
  
  .mobile-actions-row {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 0;
  }
  
  .capsule-overlay-info-panel {
    position: static;
    width: auto;
    background: transparent;
    padding: 0;
    overflow: visible;
    height: 100%;
  }
  
  /* Hide desktop info panel on mobile landscape */
  .capsule-image-overlay .viewer-desktop-info-panel-container {
    display: none !important;
  }
}

/* Mobile Column/Row Specific Styles */
.mobile-parent-column-title,
.mobile-info-column-title,
.mobile-actions-column-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  margin-bottom: 6px;
}

.mobile-parent-image {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid transparent;
  transition: border-color 0.2s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mobile-parent-image.active {
  border-color: #4a9eff;
}

.mobile-parent-image:focus-visible {
  outline: 2px solid #4a9eff;
  outline-offset: 2px;
}

/* Make mobile parent image strip comfortably scrollable */
#mobileParentImages,
#mobileParentImagesLandscape {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.mobile-info-compact {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  overflow: hidden;
}

.mobile-prompt-compact {
  font-size: 11px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
  border-radius: 6px;
  border-left: 2px solid #4a9eff;
  max-height: calc(1.3em * 4 + 16px); /* 4 lines + padding */
  min-height: calc(1.3em * 2 + 16px); /* Minimum 2 lines + padding */
  overflow-y: auto;
  position: relative;
  resize: vertical;
  flex-shrink: 0;
}

.mobile-prompt-compact::-webkit-scrollbar {
  width: 4px;
}

.mobile-prompt-compact::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.mobile-prompt-compact::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.mobile-prompt-compact::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.mobile-prompt-compact::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><path d="M2 8h8v2H2V8zm0-3h8v2H2V5zm0-3h8v2H2V2z" fill="%23ffffff" opacity="0.6"/></svg>') no-repeat center;
  background-size: contain;
  pointer-events: none;
  opacity: 0.7;
  z-index: 1;
}

.mobile-meta-compact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  flex: 1;
  overflow: hidden;
}

.mobile-meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(255, 255, 255, 0.7);
}

.mobile-meta-label {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
}

.mobile-action-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.mobile-action-btn:hover,
.mobile-action-btn:active {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.mobile-action-btn img {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

/* Landscape specific adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-parent-image {
    width: 50px;
    height: 50px;
  }
  
  .mobile-action-btn {
    width: 40px;
    height: 40px;
  }
  
  .mobile-action-btn img {
    width: 16px;
    height: 16px;
  }
  
  .mobile-prompt-compact {
    font-size: 10px;
    padding: 6px;
    -webkit-line-clamp: 2;
  }
  
  .mobile-meta-compact {
    font-size: 9px;
  }
}

/* Quick Actions Bar */
.quick-actions-bar {
  display: flex;
  justify-content: space-around;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.quick-action-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.quick-action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.quick-action-btn:active {
  /* No active state effects - just hover */
}

.quick-action-btn:focus {
  /* No focus outline - clean design */
  outline: none;
}

.quick-action-btn img {
  width: 20px;
  height: 20px;
  opacity: 0.9;
}

/* Desktop Info Panel Container */
.viewer-desktop-info-panel-container {
  display: none; /* Hidden by default, shown on desktop */
  flex: 1;
  overflow-y: auto;
  padding: 0;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================= DESKTOP PANEL STRUCTURE ================= */
@media (min-width: 769px) {
  .capsule-overlay-info-panel {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    gap: 0;
    background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%);
    border-left: 1px solid #333;
    width: 320px;
  }

  /* Panel Header */
  .panel-header {
    padding: 20px;
    border-bottom: 1px solid #333;
  }

  .panel-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
  }

  .panel-subtitle {
    font-size: 12px;
    color: #888;
  }

  /* Panel Content */
  .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
  }

  /* Info Sections */
  .info-section {
    padding: 20px;
    border-bottom: 1px solid #2a2a2a;
  }

  .info-section:last-child {
    border-bottom: none;
  }

  /* Scrollbar styling to match reference */
  .panel-content::-webkit-scrollbar {
    width: 4px;
  }

  .panel-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
  }

  .panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
  }

  .panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
  }

  /* Panel Sections - 3-part layout */
  .desktop-panel-section {
    flex-shrink: 0;
    margin-bottom: 20px;
  }

  .desktop-panel-top {
    flex: 0 0 25vh; /* Top quarter */
    max-height: 25vh;
    overflow: hidden;
  }

  .desktop-panel-middle {
    flex: 0 0 25vh; /* Second quarter */
    max-height: 25vh;
    overflow: hidden;
  }

  .desktop-panel-bottom {
    flex: 1; /* Bottom half - takes remaining space */
    min-height: 50vh;
    overflow: hidden;
  }

  /* Section Titles */
  .desktop-section-title,
  .section-title {
    font-size: 13px;
    font-weight: 500;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
  }

  /* Quick Actions - 5 icons in a row */
  .quick-actions {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 4px !important;
    margin-bottom: 12px;
    width: 100%;
    min-width: 0;
    /* Removed overflow: hidden to prevent hover clipping */
    /* Add padding to prevent hover clipping */
    padding: 2px;
  }

  .quick-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px 2px 6px 2px;
    color: #ddd;
    font-size: 4.5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 1px;
    min-width: 0;
    /* Removed overflow: hidden to prevent hover clipping */
    white-space: nowrap;
    text-overflow: ellipsis;
    /* Add margin to prevent hover clipping */
    margin: 2px;
    /* Ensure proper transform origin for hover effects */
    transform-origin: center center;
    /* Ensure proper positioning for loading states */
    position: relative;
  }

  .quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    /* Ensure hover effects are not clipped */
    z-index: 10;
    position: relative;
  }

  /* Love button states - these will be controlled by JavaScript */
  .quick-action-btn[data-action="love"] .action-icon {
    /* Default love icon is already set in HTML */
  }

  .quick-action-btn[data-action="love"].loved .action-icon {
    /* This class will be added by JavaScript to show loved.png */
  }

  /* Loading states handled by mm_viewer.css - no duplicate rules here */

  /* Loading states handled by mm_viewer.css - no duplicate rules here */

  /* Spin animation handled by mm_viewer.css - no duplicate here */

  /* Loading states handled by mm_viewer.css - no duplicate rules here */

  .quick-action-btn .action-icon {
    width: 14px;
    height: 14px;
    opacity: 0.8;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: all 0.3s ease;
    /* Ensure smooth opacity transitions */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    flex-shrink: 0;
  }

  /* Smooth icon transitions for state changes */
  .quick-action-btn .action-icon.transitioning {
    opacity: 0.3;
    transform: scale(0.8);
  }

  .quick-action-btn .action-icon.success {
    opacity: 1;
    transform: scale(1);
  }

  /* Loading states for quick action buttons */
  .quick-action-btn.loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
    /* Center the spinning wheel perfectly */
    justify-content: center !important;
    align-items: center !important;
    /* Maintain height for proper centering */
    min-height: 42px;
    /* Ensure perfect centering for the wheel */
    text-align: center;
  }

  .quick-action-btn.loading .action-icon {
    opacity: 0;
    visibility: hidden;
  }

  .quick-action-btn.loading .btn-text {
    opacity: 0;
    visibility: hidden;
  }

  /* Remove text-indent and overflow since we're using opacity now */
  .quick-action-btn.loading {
    /* Text maintains position, just fades out */
  }

  .quick-action-btn.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spinCentered 1s linear infinite;
  }

  /* Success states for quick action buttons */
  .quick-action-btn.success .action-icon {
    filter: brightness(0) invert(1) sepia(1) hue-rotate(120deg) saturate(2);
  }

  /* Success states for different actions - centered text, no icons */
  .quick-action-btn.success.copied .action-icon {
    display: none;
  }

  .quick-action-btn.success.copied .btn-text {
    display: none;
  }

  .quick-action-btn.success.copied::after {
    content: 'Copied';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4CAF50;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    z-index: 10;
  }

  .quick-action-btn.success.shared .action-icon {
    display: none;
  }

  .quick-action-btn.success.shared .btn-text {
    display: none;
  }

  .quick-action-btn.success.shared::after {
    content: 'Shared';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4CAF50;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    z-index: 10;
  }

  .quick-action-btn.success.saved .action-icon {
    display: none;
  }

  .quick-action-btn.success.saved .btn-text {
    display: none;
  }

  .quick-action-btn.success.saved::after {
    content: 'Saved';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4CAF50;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    z-index: 10;
  }

  /* Ensure loading state is completely removed when showing success */
  .quick-action-btn.success.loading::before {
    display: none;
  }

  /* Smooth transition between loading and success states */
  .quick-action-btn.success {
    transition: all 0.3s ease;
  }

  .quick-action-btn.success::after {
    animation: fadeInSuccess 0.3s ease-in;
  }

  @keyframes fadeInSuccess {
    from {
      opacity: 0;
      transform: translate(-50%, -50%) scale(0.8);
    }
    to {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
    }
  }

  /* Text transitions for different states */
  .quick-action-btn .btn-text {
    transition: all 0.3s ease;
    /* Ensure smooth opacity transitions */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  }

  .quick-action-btn.loading .btn-text {
    opacity: 0;
    transform: scale(0.8);
  }

  .quick-action-btn.success .btn-text {
    opacity: 1;
    transform: scale(1);
  }

  /* Primary Actions */
  .primary-actions {
    display: grid;
    gap: 8px;
  }

  .primary-action-btn {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .primary-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
  }

  .secondary-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 16px;
    color: #ddd;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .secondary-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
  }

  /* Generation Options */
  .generation-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .generation-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 8px;
    color: #ddd;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .generation-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
  }

  /* Parent Images Grid */
  .desktop-parent-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    height: calc(100% - 40px); /* Account for title */
    overflow-y: auto;
  }

  .parent-image-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
  }

  .parent-image-item:hover {
    border-color: rgba(74, 158, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .parent-image-item.active {
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
  }

  .parent-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
  }

  .parent-image-item:hover img {
    transform: scale(1.05);
  }

  /* Quick Actions */
  .desktop-quick-actions {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 4px;
    justify-content: center;
    align-items: center;
    height: calc(100% - 40px); /* Account for title */
    padding: 20px 0;
    width: 100%;
    /* Removed overflow: hidden to prevent hover clipping */
    min-width: 0;
    max-width: none;
  }

  .desktop-quick-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px 2px 6px 2px;
    color: #ddd;
    font-size: 4.5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 1px;
    min-width: 0;
    white-space: nowrap;
    text-overflow: ellipsis;
    /* Add margin to prevent hover clipping */
    margin: 2px;
    /* Ensure proper transform origin for hover effects */
    transform-origin: center center;
    /* Ensure proper positioning for loading states */
    position: relative;
  }

  .desktop-quick-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.1), rgba(74, 158, 255, 0.05));
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .desktop-quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    /* Ensure hover effects are not clipped */
    z-index: 10;
    position: relative;
  }

  .desktop-quick-action-btn:hover::before {
    opacity: 1;
  }

  .desktop-quick-action-btn:active {
    /* No active state effects - just hover */
  }

  .desktop-quick-action-btn:focus {
    /* No focus outline - clean design */
    outline: none;
  }

  .quick-action-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: all 0.3s ease;
    /* Ensure smooth opacity transitions */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
  }

  /* Smooth icon transitions for state changes */
  .desktop-quick-action-btn .quick-action-icon.transitioning {
    opacity: 0.3;
    transform: scale(0.8);
  }

  .desktop-quick-action-btn .quick-action-icon.success {
    opacity: 1;
    transform: scale(1);
  }

  /* Loading states for desktop quick action buttons */
  .desktop-quick-action-btn.loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
    /* Center the spinning wheel perfectly */
    justify-content: center !important;
    align-items: center !important;
    /* Maintain height for proper centering */
    min-height: 42px;
    /* Ensure perfect centering for the wheel */
    text-align: center;
  }

  .desktop-quick-action-btn.loading .btn-text {
    opacity: 0;
    visibility: hidden;
  }

  .desktop-quick-action-btn.loading .quick-action-icon {
    opacity: 0;
    visibility: hidden;
  }

  .desktop-quick-action-btn.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spinCentered 1s linear infinite;
  }

  /* Success states for desktop quick action buttons */
  .desktop-quick-action-btn.success .quick-action-icon {
    filter: brightness(0) invert(1) sepia(1) hue-rotate(120deg) saturate(2);
  }

  /* Success states for different actions - centered text, no icons */
  .desktop-quick-action-btn.success.copied .quick-action-icon {
    display: none;
  }

  .desktop-quick-action-btn.success.copied .btn-text {
    display: none;
  }

  .desktop-quick-action-btn.success.copied::after {
    content: 'Copied';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4CAF50;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    z-index: 10;
  }

  .desktop-quick-action-btn.success.shared .quick-action-icon {
    display: none;
  }

  .desktop-quick-action-btn.success.shared .btn-text {
    display: none;
  }

  .desktop-quick-action-btn.success.shared::after {
    content: 'Shared';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4CAF50;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    z-index: 10;
  }

  .desktop-quick-action-btn.success.saved .quick-action-icon {
    display: none;
  }

  .desktop-quick-action-btn.success.saved .btn-text {
    display: none;
  }

  .desktop-quick-action-btn.success.saved::after {
    content: 'Saved';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4CAF50;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    z-index: 10;
  }

  /* Ensure loading state is completely removed when showing success */
  .desktop-quick-action-btn.success.loading::before {
    display: none;
  }

  /* Smooth transition between loading and success states */
  .desktop-quick-action-btn.success {
    transition: all 0.3s ease;
  }

  .desktop-quick-action-btn.success::after {
    animation: fadeInSuccess 0.3s ease-in;
  }

  /* Text transitions for different states */
  .desktop-quick-action-btn .btn-text {
    transition: all 0.3s ease;
    /* Ensure smooth opacity transitions */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  }

  .desktop-quick-action-btn.loading .btn-text {
    opacity: 0;
    transform: scale(0.8);
  }

  .desktop-quick-action-btn.success .btn-text {
    opacity: 1;
    transform: scale(1);
  }

  /* Action icon styling for both images and text */
  .action-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
  }

  .desktop-quick-action-btn:hover .quick-action-icon {
    filter: brightness(0) invert(1);
    transform: scale(1.05);
  }

  /* Force horizontal layout - override any grid behavior */
  .desktop-quick-actions,
  .desktop-quick-actions * {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
  }

  .desktop-quick-action-btn {
    display: flex !important;
    flex-direction: column !important; /* Buttons themselves are vertical for icon + label */
  }

  /* Legacy styles for backward compatibility */
  .desktop-info-item {
    margin-bottom: 20px;
  }

  .desktop-info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
  }

  .desktop-info-prompt {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 8px;
    border-left: 3px solid #4a9eff;
    max-height: calc(1.5em * 4 + 32px); /* 4 lines + padding */
    min-height: calc(1.5em * 2 + 32px); /* Minimum 2 lines + padding */
    overflow-y: auto;
    word-wrap: break-word;
    position: relative;
    resize: vertical;
  }

  .desktop-info-prompt::-webkit-scrollbar {
    width: 6px;
  }

  .desktop-info-prompt::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
  }

  .desktop-info-prompt::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
  }

  .desktop-info-prompt::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
  }

  .desktop-info-prompt::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path d="M4 10h8v2H4v-2zm0-3h8v2H4V7zm0-3h8v2H4V4z" fill="%23ffffff" opacity="0.7"/></svg>') no-repeat center;
    background-size: contain;
    pointer-events: none;
    opacity: 0.6;
    z-index: 1;
  }

  .desktop-info-value {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    padding: 8px 0;
  }

  .desktop-project-link {
    display: inline-block;
    padding: 12px 16px;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 8px;
    color: #4a9eff;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.2s ease;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .desktop-project-link:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.2);
  }

  /* Actions Grid */
  .desktop-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    height: calc(100% - 40px); /* Account for title */
    overflow-y: auto;
  }

  .desktop-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 70px;
    position: relative;
    overflow: hidden;
  }

  .desktop-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.1), rgba(74, 158, 255, 0.05));
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .desktop-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }

  .desktop-action-btn:hover::before {
    opacity: 1;
  }

  .desktop-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }

  .action-icon {
    font-size: 16px;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
  }

  .action-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    text-align: center;
    position: relative;
    z-index: 1;
  }

  /* Generation button icon styling */
  .generation-btn .action-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: all 0.2s ease;
    flex-shrink: 0;
  }

  /* Primary Action Button - Use as Input */
  .desktop-primary-action-btn {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 8px;
  }

  .desktop-primary-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
  }

  /* Secondary Action Button - Edit Image */
  .desktop-secondary-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 16px;
    color: #ddd;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }

  .desktop-secondary-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
  }

  /* Primary and secondary action button icon styling */
  .primary-action-btn .action-icon,
  .secondary-action-btn .action-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: all 0.2s ease;
  }

  /* Scrollbar styling for desktop */
  .desktop-parent-images-grid::-webkit-scrollbar,
  .desktop-actions-grid::-webkit-scrollbar,
  .desktop-info-prompt::-webkit-scrollbar {
    width: 6px;
  }

  .desktop-parent-images-grid::-webkit-scrollbar-track,
  .desktop-actions-grid::-webkit-scrollbar-track,
  .desktop-info-prompt::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
  }

  .desktop-parent-images-grid::-webkit-scrollbar-thumb,
  .desktop-actions-grid::-webkit-scrollbar-thumb,
  .desktop-info-prompt::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
  }

  .desktop-parent-images-grid::-webkit-scrollbar-thumb:hover,
  .desktop-actions-grid::-webkit-scrollbar-thumb:hover,
  .desktop-info-prompt::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
  }

  /* Responsive adjustments for different desktop sizes */
  @media (min-width: 769px) and (max-width: 1200px) {
    .capsule-overlay-info-panel {
      padding: 20px;
    }
    
    .desktop-section-title {
      font-size: 11px;
      margin-bottom: 12px;
    }
    
    .desktop-action-btn {
      padding: 14px 10px;
      min-height: 70px;
    }
    
    .action-icon {
      font-size: 18px;
    }
    
    .action-label {
      font-size: 9px;
    }
  }

  @media (min-width: 1201px) {
    .capsule-overlay-info-panel {
      padding: 28px;
    }
    
    .desktop-section-title {
      font-size: 13px;
      margin-bottom: 20px;
    }
    
    .desktop-action-btn {
      padding: 18px 14px;
      min-height: 90px;
    }
    
    .action-icon {
      font-size: 22px;
    }
    
    .action-label {
      font-size: 11px;
    }
  }

  /* Ensure proper spacing and alignment */
  .desktop-panel-section:last-child {
    margin-bottom: 0;
  }

  /* Smooth transitions for all interactive elements */
  .desktop-action-btn,
  .desktop-project-link,
  .parent-image-item {
    will-change: transform, box-shadow;
  }

  /* Focus states for accessibility - removed blue outline */
  .desktop-action-btn:focus,
  .desktop-project-link:focus,
  .desktop-quick-action-btn:focus {
    /* No focus outline - clean design */
  }

  /* Loading states handled by mm_viewer.css - no duplicate rules here */

  /* Loading states handled by mm_viewer.css - no duplicate rules here */

  /* Quick action feedback */
  .quick-action-feedback {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* Spin animation handled by mm_viewer.css - no duplicate here */
}

/* Mobile Info Panel Adjustments */
@media (max-width: 768px) {
  .info-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .info-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
  }
  
  .info-section-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  .info-prompt {
    font-size: 14px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid #4a9eff;
  }
  
  .info-metadata {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .info-meta-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
  }
  
  .info-meta-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
  }
  
  .info-meta-value {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
  }
  
  .info-project-link {
    display: block;
    padding: 12px;
    background: rgba(74, 158, 255, 0.1);
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 8px;
    color: #4a9eff;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
  }
  
  .info-project-link:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
  }
  
  .parent-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
    margin-top: 8px;
  }
  
  .parent-image-item {
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
  }
  
  .parent-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  
  .parent-image-item.active {
    border-color: #4a9eff;
  }
}

/* Close Button Mobile Adjustments */
@media (max-width: 768px) {
  .capsule-overlay-close {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10000050; /* match desktop */
  }
}

/* Media Adjustments for Mobile */
@media (max-width: 768px) {
  .capsule-overlay-media {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  }
  
  .capsule-overlay-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0; /* no rounded edge */
    background: transparent; /* no grey background */
    box-shadow: none; /* ensure no shadow edge */
  }
  
  /* Ensure overlay takes full screen on mobile */
  .capsule-image-overlay {
    padding: 0;
  }
  
  /* Hide desktop quick actions on mobile */
  .quick-actions-bar {
    display: flex;
  }
}

/* Touch-friendly improvements */
@media (max-width: 768px) {
  /* Larger touch targets */
  .quick-action-btn {
    min-width: 48px;
    min-height: 48px;
    touch-action: manipulation;
  }
  
  /* Smooth scrolling for desktop info panel */
  .viewer-desktop-info-panel-container {
    scroll-behavior: smooth;
  }
  
  /* Better text readability */
  .info-prompt {
    font-size: 15px;
    line-height: 1.5;
  }
  
  /* Improved spacing for touch */
  .info-meta-item {
    min-height: 44px;
    padding: 12px 0;
  }
  
  .info-project-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* High DPI optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .capsule-overlay-media img,
  .capsule-overlay-media video {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .capsule-overlay-media img,
  .capsule-overlay-media video,
  .capsule-overlay-info-panel,
  .info-action-btn {
    transition: none;
  }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .capsule-overlay-info-panel {
    background: rgba(10, 10, 10, 0.95);
  }
  
  .info-prompt {
    background: rgba(255, 255, 255, 0.03);
  }
}

/* ================= DESKTOP INTERACTION SAFEGUARDS ================= */
@media (min-width: 769px) {
  /* Prevent the sidebar overlay from blocking clicks on desktop */
  .sidebar-overlay.active {
    pointer-events: none !important;
  }
}

/* ================= HEADER SPINNER FIX ================= */
/* Completely override all spinner rules with a working solution */
.dropbtn.loading .spinner {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 16px !important;
  height: 16px !important;
  margin: -8px 0 0 -8px !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  border-top: 2px solid #ffffff !important;
  border-radius: 50% !important;
  animation: headerSpinnerRotate 1s linear infinite !important;
  z-index: 10 !important;
}

/* Simple rotation animation */
@keyframes headerSpinnerRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Ensure the loading state properly centers the spinner */
.dropbtn.loading {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* ================= HEADER SHINE EFFECT ================= */
/* Professional shine effect for header dropdown updates */
@keyframes headerTextShine {
  0% {
    background-position: -200% center;
    opacity: 0.3;
  }
  25% {
    opacity: 0.6;
  }
  50% {
    background-position: 0% center;
    opacity: 1;
  }
  75% {
    opacity: 0.6;
  }
  100% {
    background-position: 200% center;
    opacity: 0.3;
  }
}

/* Shine effect for user info updates */
.dropbtn.updating .user-name,
.dropbtn.updating .credits-amount {
  position: relative;
  display: inline-block;
  background: linear-gradient(
    90deg,
    var(--text-secondary, #a0a0a0) 0%,
    var(--text-primary, #ffffff) 25%,
    var(--text-primary, #ffffff) 50%,
    var(--text-secondary, #a0a0a0) 75%,
    var(--text-secondary, #a0a0a0) 100%
  );
  background-size: 200% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: headerTextShine 2.5s ease-in-out infinite;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Shine effect for credits display */
.dropbtn.updating .credits-display {
  position: relative;
}

/* Enhanced shine effect for the entire button when updating */
.dropbtn.updating {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  backdrop-filter: blur(8px) !important;
  transition: all 0.3s ease !important;
}

/* Shine effect for different update states */
.dropbtn.updating.username .user-name {
  animation: headerTextShine 2s ease-in-out infinite;
}

.dropbtn.updating.credits .credits-amount {
  animation: headerTextShine 1.8s ease-in-out infinite;
}

.dropbtn.updating.both .user-name,
.dropbtn.updating.both .credits-amount {
  animation: headerTextShine 2.2s ease-in-out infinite;
}

/* When overlay is active, disable interactions on generations panel beneath */
#capsuleImageOverlay.capsule-image-overlay.active ~ #generationsPanel.overlay-block {
  pointer-events: none !important;
}

/* ================= INTERACTION FIXES - OVERRIDE ANY BLOCKING ================= */

/* Force clickability for all interactive elements - highest specificity */
.generations-search,
.generation-item,
.capsule-image,
.capsule-image img,
.capsule-image video,
.generations-close,
.generations-panel,
.generations-list {
  pointer-events: auto !important;
}

/* Ensure proper cursors */
.generation-item,
.capsule-image,
.capsule-image img,
.capsule-image video {
  cursor: pointer !important;
}

.generations-search {
  cursor: text !important;
}

/* Ensure overlays don't block when inactive */
.capsule-image-overlay:not(.active) {
  pointer-events: none !important;
}

.capsule-image-overlay.active {
  pointer-events: auto !important;
}

/* ================= ID-LEVEL OVERRIDES (beats old #capsuleImageOverlay rules elsewhere) ================= */
#capsuleImageOverlay {
  /* When not active, send overlay behind everything and make it non-interactive */
  z-index: -1 !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

#capsuleImageOverlay.active {
  /* When active, bring overlay to the very top and enable interactivity */
  z-index: 10000000 !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  display: flex !important;
}

/* Spinner animation that maintains centering */
@keyframes spinCentered {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
