/* Face Swap CSS - Adapted from edits.css */

.unauth-generate-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.unauth-generate-modal.active {
  opacity: 1;
  visibility: visible;
}

.unauth-generate-modal-content {
  background: linear-gradient(135deg, rgba(26, 26, 26, 0.98) 0%, rgba(42, 42, 42, 0.98) 100%);
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.18), 0 0 60px rgba(255, 215, 0, 0.08);
  max-width: 460px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(30px) scale(0.95);
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 215, 0, 0.3);
}

.unauth-generate-modal.active .unauth-generate-modal-content {
  transform: translateY(0) scale(1);
}

.unauth-generate-modal-header {
  display: flex;
  justify-content: flex-end;
  padding: 20px 20px 0 20px;
}

.unauth-generate-modal-close {
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: #FFD700;
  transition: all 0.2s ease;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.25);
}

.unauth-generate-modal-close:hover {
  background: rgba(255, 215, 0, 0.2);
  color: #1a1a1a;
  transform: scale(1.1);
}

.unauth-generate-modal-body {
  padding: 0 30px 30px 30px;
  text-align: center;
}

.unauth-generate-modal-icon {
  margin: 0 auto 20px auto;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1a;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.unauth-generate-modal-title {
  color: #FFD700;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 12px 0;
  line-height: 1.3;
}

.unauth-generate-modal-message {
  color: #e5e7eb;
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 30px 0;
  opacity: 0.9;
}

.unauth-generate-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.unauth-generate-modal-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
}

.unauth-generate-modal-login {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #1a1a1a;
  box-shadow: 0 8px 24px rgba(255, 215, 0, 0.35);
}

.unauth-generate-modal-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 215, 0, 0.5);
  color: #1a1a1a;
}

.unauth-generate-modal-signup {
  background: transparent;
  color: #FFD700;
  border-color: rgba(255, 215, 0, 0.35);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.15);
}

.unauth-generate-modal-signup:hover {
  background: rgba(255, 215, 0, 0.1);
  border-color: rgba(255, 215, 0, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.25);
  color: #FFD700;
}

/* Credit Balance Pill */
.credit-balance-pill {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: linear-gradient(135deg, #facc15 0%, #fbbf24 100%);
    color: #1f2937;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Generation modal */
.generation-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.generation-modal.active {
  opacity: 1;
  visibility: visible;
}

.generation-modal-content {
  text-align: center;
  transform: scale(0.8) rotate(-5deg);
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: 90vw;
  padding: 2rem;
}

.generation-modal.active .generation-modal-content {
  transform: scale(1) rotate(0deg);
}

.generation-loader {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 2rem;
}

.loader-ring {
  position: absolute;
  border: 3px solid transparent;
  border-radius: 50%;
  animation: spin 2s linear infinite;
}

.loader-ring:nth-child(1) {
  width: 120px;
  height: 120px;
  border-top: 3px solid #FFD700;
  border-right: 3px solid #FFD700;
  animation-duration: 2s;
}

.loader-ring:nth-child(2) {
  width: 90px;
  height: 90px;
  top: 15px;
  left: 15px;
  border-bottom: 3px solid #FFA500;
  border-left: 3px solid #FFA500;
  animation-duration: 1.5s;
  animation-direction: reverse;
}

.loader-ring:nth-child(3) {
  width: 60px;
  height: 60px;
  top: 30px;
  left: 30px;
  border-top: 3px solid #FFD700;
  border-right: 3px solid #FFD700;
  animation-duration: 1s;
}

.loader-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1.5s ease-in-out infinite alternate;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

.loader-icon {
  width: 20px;
  height: 20px;
  color: #1a1a1a;
  animation: iconBounce 2s ease-in-out infinite;
}

.loader-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #FFD700;
  border-radius: 50%;
  animation: float 3s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.loader-particle:nth-child(4) { top: 10px; left: 50%; animation-delay: 0s; }
.loader-particle:nth-child(5) { top: 50%; right: 10px; animation-delay: 0.5s; }
.loader-particle:nth-child(6) { bottom: 10px; left: 50%; animation-delay: 1s; }
.loader-particle:nth-child(7) { top: 50%; left: 10px; animation-delay: 1.5s; }

.generation-message {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FFD700 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2s ease-in-out infinite;
}

.generation-subtitle {
  color: #ccc;
  font-size: 1.1rem;
  font-weight: 400;
  opacity: 0.9;
  animation: fadeInOut 2s ease-in-out infinite;
}

.generation-progress-container {
  width: 100%;
  max-width: 300px;
  margin: 1.5rem auto;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 20px;
  padding: 4px;
  border: 1px solid rgba(34, 197, 94, 0.3);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
  position: relative;
  overflow: hidden;
}

.generation-progress-bar {
  height: 8px;
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 25%, #15803d 50%, #166534 75%, #14532d 100%);
  border-radius: 16px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.6), 0 0 20px rgba(34, 197, 94, 0.4), 0 0 30px rgba(34, 197, 94, 0.2);
}

.generation-progress-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
  border-radius: 16px;
  animation: progressGlow 2s ease-in-out infinite;
}

.generation-progress-bar.submitted { width: 25%; }
.generation-progress-bar.pending { width: 50%; }
.generation-progress-bar.processing { width: 75%; }
.generation-progress-bar.completed { width: 100%; }

.generation-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: #22c55e;
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.generation-progress-text.show {
  opacity: 1;
}

.generation-progress-stage {
  position: absolute;
  top: -25px;
  font-size: 0.7rem;
  color: #22c55e;
  font-weight: 500;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.generation-progress-stage.active {
  opacity: 1;
  color: #22c55e;
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  font-weight: 600;
}

.generation-progress-stage.completed {
  opacity: 1;
  color: #16a34a;
}

.generation-progress-stage.submitted { left: 0%; }
.generation-progress-stage.pending { left: 25%; }
.generation-progress-stage.processing { left: 50%; }
.generation-progress-stage.completed { left: 75%; }

.queue-details {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: rgba(255, 215, 0, 0.08);
  border-radius: 1rem;
  border: 1px solid rgba(255, 215, 0, 0.3);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.1);
}

.queue-apology {
  color: #fbbf24;
  font-size: 0.9rem;
  font-weight: 400;
  opacity: 0.9;
  margin-top: 0.75rem;
  font-style: italic;
  text-align: center;
}

.queue-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  text-align: center;
}

.queue-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
}

.queue-label {
  font-size: 0.8rem;
  color: #ccc;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.queue-value {
  font-size: 1rem;
  color: #FFD700;
  font-weight: 600;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* Validation overlay */
.validation-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.validation-loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.validation-loading-content {
  background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(42, 42, 42, 0.95) 100%);
  border: 2px solid rgba(255, 215, 0, 0.35);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.18), 0 0 60px rgba(255, 215, 0, 0.08);
  transform: scale(0.8);
  transition: transform 0.3s ease;
  max-width: 320px;
  width: 90%;
}

.validation-loading-overlay.active .validation-loading-content {
  transform: scale(1);
}

.validation-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.validation-spinner {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: validationSpin 2s linear infinite;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.45), 0 0 50px rgba(255, 215, 0, 0.25);
}

.validation-spinner svg {
  width: 20px;
  height: 20px;
  color: #1f2937;
  animation: validationPulse 1.5s ease-in-out infinite;
}

.validation-message {
  font-size: 18px;
  font-weight: 600;
  color: #FFD700;
  margin: 0;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.validation-submessage {
  font-size: 14px;
  color: #e5e7eb;
  margin: 0;
  opacity: 0.9;
}

/* Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes validationSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes validationPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.8);
  }
}

@keyframes iconBounce { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-5px);} }
@keyframes float { 0%,100% { transform: translateY(0) scale(1); opacity:1;} 50% { transform: translateY(-20px) scale(1.2); opacity:.7;} }
@keyframes shimmer { 0% { background-position: -200% 0;} 100% { background-position: 200% 0;} }
@keyframes fadeInOut { 0%,100% { opacity:.9;} 50% { opacity:.6;} }
@keyframes progressGlow {
  0%, 100% { opacity: 0.3; transform: translateX(-100%); }
  50% { opacity: 0.6; transform: translateX(100%); }
}

/* Fixed footer positioning for face-swap mode */
.face-swap-mode .input-bar {
    position: fixed;
    bottom: 0;
    left: 260px;
    right: 0;
    z-index: 50;
    margin: 0;
    padding: 0.75rem 1.5rem;
}

/* Desktop layout for face-swap footer */
.face-swap-mode .input-container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 0rem 1.5rem;
  align-items: start;
  grid-template-areas:
    "mode mode mode"
    "upload textarea generate";
}

/* Hide mobile source face section on desktop */
.face-swap-mode .source-face-section-mobile {
  display: none;
}

.face-swap-mode .mode-dropdown-section { grid-area: mode; justify-self: center; }
.face-swap-mode .file-upload-section { grid-area: upload; }
.face-swap-mode .text-input-section { grid-area: textarea; }
.face-swap-mode .generate-section { grid-area: generate; }

/* Generate section now contains both source face upload and generate button */
.face-swap-mode .generate-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  justify-content: space-between;
}

/* Adjust chat area to account for fixed footer */
.face-swap-mode .chat-area {
    padding-bottom: 250px;
    height: calc(100vh - 250px);
    overflow-y: auto;
}

/* Enhanced file upload styling for face-swap mode */
.face-swap-mode .file-upload-btn,
.face-swap-mode .upload-link-btn,
.face-swap-mode .generate-btn {
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 1rem;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
    min-height: 50px; /* Compact height for desktop */
    min-width: 120px;
    padding: 0.6rem 1rem; /* Tighter padding */
    display: flex;
    flex-direction: row; /* Horizontal layout for compact design */
    align-items: center;
    justify-content: center;
    gap: 0.4rem; /* Smaller gap */
    font-size: 0.85rem; /* Smaller font */
    color: #FFD700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.face-swap-mode .file-upload-btn,
.face-swap-mode .upload-link-btn {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 215, 0, 0.05) 100%);
}

.face-swap-mode .upload-link-btn:hover,
.face-swap-mode .file-upload-btn:hover {
    border-color: #FFD700;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.1) 100%);
}

/* Enhanced textarea styling for face-swap mode */
.face-swap-mode .message-textarea {
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.9) 0%, rgba(42, 42, 42, 0.9) 100%);
    border: 2px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.1);
    min-height: 90px; /* Back to original height */
    padding: 1rem;
}

.face-swap-mode .message-textarea:focus {
    border-color: #FFD700;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
}

/* Enhanced generate button for face-swap mode */
.face-swap-mode .generate-btn { 
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    animation: faceSwapButtonGlow 2s ease-in-out infinite alternate;
    color: #1a1a1a;
    font-weight: 800;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.face-swap-mode .generate-btn .generate-top {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1.1;
}

.face-swap-mode .generate-btn .credits-inline {
    display: block;
    margin-top: 1px;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
    color: #1a1a1a;
    opacity: 0.95;
}

.face-swap-mode .generate-btn:hover {
    border-color: #FFD700;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, #FFA500 0%, #FFD700 100%);
}

/* Special welcome message styling for face-swap mode */
.face-swap-mode .welcome-message .message-text {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(255, 215, 0, 0.06) 100%);
    border: 2px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.25);
}

/* Welcome text styling to match edits */
.face-swap-mode .welcome-main-text {
  font-size: 1.1rem;
  line-height: 1.6;
  font-weight: 600;
  color: #ffec7e;
  margin-bottom: 0.3rem;
  margin-top: 0.3rem;
}

.face-swap-mode .welcome-sub-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #ededca;
  margin-left: 1rem;
  margin-bottom: 0.3rem;
}

/* Face-swap-specific animations */
@keyframes faceSwapButtonGlow {
    0% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    }
    100% {
        box-shadow: 0 0 40px rgba(255, 215, 0, 0.4);
    }
}

/* Mode dropdown styling for face-swap mode */
.mode-dropdown-section {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.mode-dropdown {
    position: relative;
    display: inline-block;
}

.mode-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    min-width: 120px;
    min-height: 50px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.1) 100%);
    border: 2px solid #FFD700;
    border-radius: 0.75rem;
    color: #FFD700;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    animation: modeGlow 2s ease-in-out infinite alternate;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-dropdown-btn:hover {
    border-color: #FFD700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.15) 100%);
}

.mode-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(42, 42, 42, 0.95) 100%);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 1rem;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    margin-bottom: 0.5rem;
    backdrop-filter: blur(10px);
    display: none;
    z-index: 100;
    min-width: 150px;
}

.mode-dropdown-menu.show {
    display: block;
    animation: dropdownSlideUp 0.3s ease-out;
}

.mode-option {
    padding: 1rem 1.5rem;
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    font-weight: 500;
}

.mode-option:last-child {
    border-bottom: none;
    border-radius: 0 0 1rem 1rem;
}

.mode-option:first-child {
    border-radius: 1rem 1rem 0 0;
}

.mode-option:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 215, 0, 0.05) 100%);
    color: #FFD700;
}

.mode-option.selected {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.1) 100%);
    color: #FFD700;
    font-weight: 600;
    border-left: 4px solid #FFD700;
    box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.2);
}

@keyframes modeGlow {
    0% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    }
    100% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
    }
}

@keyframes dropdownSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stack the remaining buttons vertically (upload link and target image) */
.face-swap-mode .file-upload-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Image preview styles for face-swap mode (matching edits page) */
.face-swap-mode .image-preview-container {
  position: relative;
  display: none;
  align-self: flex-start; /* Prevent flex container from stretching this element */
}

.face-swap-mode .image-preview-container.show {
  display: inline-block;
}

.face-swap-mode .preview-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(255, 215, 0, 0.4);
}

.face-swap-mode .remove-image-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ff4444;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.face-swap-mode .remove-image-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

/* Chat image message styling */
.uploaded-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.08) 0%, rgba(255, 215, 0, 0.03) 100%);
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-radius: 1rem;
    margin: 0.5rem 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* User Request Card styling (match edits page) */
.user-message .user-request-card {
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.9) 0%, rgba(42, 42, 42, 0.9) 100%);
    border: 1.5px solid rgba(255, 215, 0, 0.35);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    box-shadow: 0 6px 24px rgba(255, 215, 0, 0.12), inset 0 0 0 1px rgba(255, 215, 0, 0.12);
}

.user-request-card .request-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.user-request-card .request-title {
    color: #ffec7e;
    font-weight: 800;
    letter-spacing: 0.2px;
    text-align: center;
}

.user-request-card .request-badges {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
}

.user-request-card .badge {
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-gold {
    color: #1a1a1a;
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.badge-slate {
    color: #e5e7eb;
    background: rgba(148, 163, 184, 0.15);
    border-color: rgba(148, 163, 184, 0.25);
}

.badge-cost {
    color: #1a1a1a;
    background: linear-gradient(135deg, #fde68a, #fbbf24);
}

.user-request-card .request-body .row {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 0.6rem;
    align-items: center;
    padding: 0.35rem 0;
    border-top: 1px dashed rgba(255, 215, 0, 0.18);
}

.user-request-card .request-body .row:first-child {
    border-top: 0;
}

.user-request-card .label {
    color: #fcd34d;
    font-size: 0.9rem;
    font-weight: 600;
}

.user-request-card .value {
    color: #f3f4f6;
}

.user-request-card .desc {
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.18);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    line-height: 1.45;
    color: #ededca;
    display: flex;
    align-items: center;
    min-height: 38px;
    font-size: 0.9rem;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.uploaded-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    border-radius: 0.75rem;
    object-fit: contain;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.image-filename {
    font-size: 0.875rem;
    color: #FFD700;
    font-weight: 500;
    text-align: center;
    padding: 0.25rem 0.75rem;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 215, 0, 0.3);
    margin-top: 0.5rem;
}

/* Generated image responsive sizing */
.generated-result { width: 100%; }
.generated-image-container { max-width: 100%; }
.generated-result .generated-image { display: block; margin: 0 auto; }

/* Landscape 16:9 */
.generated-result.aspect-16-9 .generated-image {
  width: 100%;
  height: auto;
}

/* Portrait 9:16 (tall) */
.generated-result.aspect-9-16 .generated-image {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 90vh;
  object-fit: contain;
}

/* Square 1:1 */
.generated-result.aspect-1-1 .generated-image {
  width: 70%;
  height: auto;
}

/* Portrait 4:5 */
.generated-result.aspect-4-5 .generated-image {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

/* Responsive adjustments for face-swap mode */
/* <= 1024px */
@media (max-width: 1024px) {
  .face-swap-mode .input-bar {
    left: 260px; /* Account for sidebar being open on tablet - sidebar is 260px wide */
    right: 0; /* Constrain the width */
    width: calc(100vw - 260px); /* Explicitly set width to available space */
    padding: 1rem;
  }
  .face-swap-mode .chat-area {
    padding-bottom: 350px;
    height: calc(100vh - 350px);
    overflow-y: auto;
  }
  
  /* Override large minimum widths for tablet layout */
  .face-swap-mode .file-upload-btn,
  .face-swap-mode .upload-link-btn { min-width: 80px !important; }
  .face-swap-mode .generate-btn { min-width: 70px !important; }
  .face-swap-mode .mode-dropdown-btn { min-width: 80px !important; }
  
  /* Set minimum width for description input box */
  .face-swap-mode .message-textarea { min-width: 200px; }
}

/* <= 768px */
@media (max-width: 768px) {
  /* Unauth modal */
  .unauth-generate-modal-content {
    max-width: 350px;
    margin: 20px;
  }
  .unauth-generate-modal-body {
    padding: 0 20px 25px 20px;
  }
  .unauth-generate-modal-title {
    font-size: 20px;
  }
  .unauth-generate-modal-message {
    font-size: 15px;
  }
  .unauth-generate-modal-buttons {
    flex-direction: column;
    gap: 10px;
  }
  .unauth-generate-modal-btn {
    width: 100%;
  }

  /* Layout */
  .face-swap-mode .input-bar {
    left: 0; /* No sidebar offset on mobile */
    right: 0; /* Use full width */
    width: 100vw; /* Use full viewport width on mobile */
    padding: 1rem;
  }
  .face-swap-mode .chat-area {
    padding-bottom: 400px;
    height: calc(100vh - 400px);
  }
  
  /* Mobile layout: Row 1 - Mode & Source Face, Row 2 - Textarea, Row 3 - Link, Target, Generate */
  .face-swap-mode .input-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 1rem;
    grid-template-areas:
      "mode source ."
      "textarea textarea textarea"
      "upload upload generate";
  }
  
  .face-swap-mode .mode-dropdown-section {
    grid-area: mode;
    justify-self: center;
  }
  
  .face-swap-mode .text-input-section {
    grid-area: textarea;
    width: 100%;
  }
  
  .face-swap-mode .file-upload-section {
    grid-area: upload;
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
  }
  

  
  /* Mobile-only source face section */
  .face-swap-mode .source-face-section-mobile {
    grid-area: source;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  
  /* Hide desktop source face button on mobile */
  .face-swap-mode .generate-section .file-upload-btn {
    display: none;
  }
  

  
  .face-swap-mode .generate-section {
    grid-area: generate;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  
  /* Mobile-specific grid areas for individual buttons */
  .face-swap-mode .file-upload-section .upload-link-btn {
    grid-area: link;
  }
  
  .face-swap-mode .file-upload-section .file-upload-btn {
    grid-area: target;
  }
  

  
  /* Generate button gets its own grid area on mobile */
  .face-swap-mode .generate-section .generate-btn {
    grid-area: generate;
  }

  /* Controls sizing - all buttons equal width in their rows */
  .face-swap-mode .upload-link-btn,
  .face-swap-mode .file-upload-btn,
  .face-swap-mode .generate-btn {
    width: 100%;
    min-width: auto;
    min-height: 70px;
    padding: 0.75rem;
    font-size: 0.8rem;
    gap: 0.3rem;
  }
  
  /* Row 1 buttons (Mode and Source Face) - equal width */
  .face-swap-mode .mode-dropdown-btn,
  .face-swap-mode .source-face-section-mobile .file-upload-btn {
    width: 100%;
    min-height: 70px;
    padding: 0.75rem;
    font-size: 0.8rem;
  }
  
  /* Ensure source face button matches mode button height and alignment */
  .face-swap-mode .source-face-section-mobile .file-upload-btn {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Row 3 buttons (Link, Target, Generate) - each takes 33% width */
  .face-swap-mode .file-upload-section .upload-link-btn,
  .face-swap-mode .file-upload-section .file-upload-btn,
  .face-swap-mode .generate-section .generate-btn {
    width: 100%;
    min-height: 70px;
    padding: 0.75rem;
    font-size: 0.8rem;
  }
  .face-swap-mode .message-textarea {
    min-height: 80px;
    padding: 1rem;
    font-size: 0.875rem;
  }
  .mode-dropdown-btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
  }
  .face-swap-mode .welcome-message .message-text h3 {
    font-size: 1rem;
  }
  .face-swap-mode .welcome-main-text { font-size: 1rem; margin-top: 0.25rem; }
  .face-swap-mode .welcome-sub-text { font-size: 0.9rem; }
  .mode-dropdown-menu {
    left: 0%;
    right: -50%;
    min-width: 150px;
  }
}

/* <= 480px */
@media (max-width: 480px) {
  /* Unauth modal */
  .unauth-generate-modal-content {
    max-width: 90%;
    border-radius: 16px;
  }
  .unauth-generate-modal-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
  }
  .unauth-generate-modal-icon svg {
    width: 32px;
    height: 32px;
  }
  .unauth-generate-modal-title {
    font-size: 18px;
  }
  .unauth-generate-modal-message {
    font-size: 14px;
    margin-bottom: 24px;
  }

  /* Layout: tighter spacing between mode and textarea */
  .face-swap-mode .input-bar {
    padding: 0.75rem;
  }
  .face-swap-mode .chat-area {
    padding-bottom: 450px;
    height: calc(100vh - 450px);
  }
  .face-swap-mode .input-container {
    gap: 0.5rem;
    grid-template-areas:
      "mode source source"
      "textarea textarea textarea"
      "upload upload generate";
  }
  .mode-dropdown-section {
    margin-bottom: 0.3rem;
  }

  /* Controls sizing */
  .face-swap-mode .upload-link-btn,
  .face-swap-mode .file-upload-btn,
  .face-swap-mode .generate-btn {
    min-height: 60px;
    padding: 0.75rem;
    font-size: 0.75rem;
  }
  
  /* Specific button font sizes to match recreate.css */
  .face-swap-mode .file-upload-section .upload-link-btn {
    font-size: 0.75rem;
  }
  
  .face-swap-mode .file-upload-section .file-upload-btn {
    font-size: 0.75rem;
  }
  
  .face-swap-mode .source-face-section-mobile .file-upload-btn {
    font-size: 0.75rem;
  }
  
  .face-swap-mode .generate-section .generate-btn {
    font-size: 0.75rem;
  }
  
  /* Reset height constraints for smallest mobile */
  .face-swap-mode .generate-section .file-upload-btn,
  .face-swap-mode .generate-btn {
    min-height: 60px;
    height: auto;
  }
  .face-swap-mode .mode-dropdown-btn {
    min-height: 30px;
    padding: 0.6rem;
    font-size: 0.75rem;
  }
  
  /* Ensure source face button matches mode button height on 480px */
  .face-swap-mode .source-face-section-mobile .file-upload-btn {
    min-height: 30px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .face-swap-mode .message-textarea {
    min-height: 50px;
    padding: 0.75rem;
    font-size: 0.8rem;
  }

  /* Credit pill parity */
  .credit-balance-pill {
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 14px;
    gap: 4px;
  }

  /* Welcome message parity */
  .face-swap-mode .welcome-message .message-text h3 {
    font-size: 0.85rem;
  }
  .face-swap-mode .welcome-main-text { font-size: 0.95rem; }
  .face-swap-mode .welcome-sub-text { font-size: 0.85rem; }

  /* Media content */
  .uploaded-image-container {
    padding: 0.5rem;
    gap: 0.4rem;
  }
  .uploaded-image {
    max-height: 150px;
  }
}

/* Small screens: relax caps for generated images */
@media (max-width: 640px) {
  .generated-result.aspect-16-9 .generated-image { max-width: 100%; }
  .generated-result.aspect-1-1 .generated-image { max-width: 92vw; }
  .generated-result.aspect-9-16 .generated-image { max-height: 65vh; }
  .generated-result.aspect-4-5 .generated-image { max-height: 75vh; }
}

/* Download modal (parity with edits) */
.download-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.download-modal.active {
  opacity: 1;
  visibility: visible;
}

.download-modal-content {
  text-align: center;
  transform: scale(0.7) translateY(30px);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90vw;
  padding: 2rem;
}

.download-modal.active .download-modal-content {
  transform: scale(1) translateY(0);
}

.download-loader {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 2rem;
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid #10b981;
  border-radius: 50%;
  animation: pulseRing 2s ease-out infinite;
}

.pulse-ring:nth-child(1) { animation-delay: 0s; }
.pulse-ring:nth-child(2) { animation-delay: 0.4s; }
.pulse-ring:nth-child(3) { animation-delay: 0.8s; }

.download-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  animation: downloadIconBounce 2s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.download-icon svg {
  width: 16px;
  height: 16px;
}

.download-message {
  color: #fff;
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  background: linear-gradient(135deg, #10b981 0%, #34d399 50%, #10b981 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: downloadShimmer 2.5s ease-in-out infinite;
}

.download-subtitle {
  color: #d1d5db;
  font-size: 1rem;
  font-weight: 400;
  opacity: 0.9;
  animation: downloadFadeInOut 2s ease-in-out infinite;
}

.download-dots {
  display: inline-block;
  margin-left: 0.5rem;
}
.download-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  margin: 0 2px;
  animation: downloadDotPulse 1.2s ease-in-out infinite both;
}
.download-dots span:nth-child(1) { animation-delay: -0.24s; }
.download-dots span:nth-child(2) { animation-delay: -0.12s; }
.download-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes pulseRing {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

@keyframes downloadIconBounce {
  0%, 100% { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 20px rgba(16, 185, 129, 0.4); }
  50% { transform: translate(-50%, -50%) scale(1.1); box-shadow: 0 0 30px rgba(16, 185, 129, 0.6); }
}

@keyframes downloadShimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes downloadFadeInOut { 0%, 100% { opacity: 0.9; } 50% { opacity: 0.6; } }
@keyframes downloadDotPulse {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.3); opacity: 1; }
}

/* Mask Editor Modal */
.mask-editor-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mask-editor-modal.active {
  opacity: 1;
  visibility: visible;
}

.mask-editor-content {
  background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(42, 42, 42, 0.95) 100%);
  border: 2px solid rgba(255, 215, 0, 0.4);
  border-radius: 16px;
  padding: 1rem;
  max-width: 98vw;
  max-height: 98vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.2);
  overflow-y: auto;
  overflow-x: hidden;
}

.mask-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.mask-editor-title {
  color: #FFD700;
  font-size: 1.2rem;
  font-weight: 600;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.mask-editor-close {
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #FFD700;
  font-size: 18px;
  transition: all 0.2s ease;
}

.mask-editor-close:hover {
  background: rgba(255, 215, 0, 0.2);
  transform: scale(1.1);
}

.mask-canvas-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255, 215, 0, 0.2);
  flex: 3;
  min-height: 60vh;
  height: 60vh;
}

.mask-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: crosshair;
  touch-action: none;
}

/* Custom brush cursor styles */
.mask-canvas.brush-cursor {
  cursor: none; /* Hide default cursor when using custom brush cursor */
}

.brush-cursor-preview {
  position: fixed;
  pointer-events: none;
  z-index: 10002;
  transform: translate(-50%, -50%);
  transition: opacity 0.1s ease;
  opacity: 0.8;
}

.brush-cursor-preview.hidden {
  opacity: 0;
}

.mask-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(255, 215, 0, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.2);
  flex-shrink: 0;
}

.mask-control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.mask-control-label {
  font-size: 0.8rem;
  color: #ccc;
  font-weight: 500;
}

.brush-color-toggle {
  display: flex;
  background: rgba(255, 215, 0, 0.1);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  overflow: hidden;
}

.brush-color-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: #ccc;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 0.9rem;
}

.brush-color-btn.active {
  background: rgba(255, 215, 0, 0.2);
  color: #FFD700;
}

.brush-color-btn:hover {
  background: rgba(255, 215, 0, 0.1);
}

.brush-size-slider {
  width: 100px;
  height: 6px;
  background: rgba(255, 215, 0, 0.2);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.brush-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #FFD700;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.brush-size-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #FFD700;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.brush-size-value {
  color: #FFD700;
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 30px;
  text-align: center;
}

.mask-action-btn {
  padding: 0.6rem 1.2rem;
  border: 2px solid rgba(255, 215, 0, 0.4);
  border-radius: 8px;
  background: rgba(255, 215, 0, 0.1);
  color: #FFD700;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.mask-action-btn:hover {
  background: rgba(255, 215, 0, 0.2);
  border-color: #FFD700;
  transform: translateY(-1px);
}

.mask-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.mask-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.mask-save-btn {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #1a1a1a;
  border: none;
}

.mask-save-btn:hover {
  background: linear-gradient(135deg, #FFA500 0%, #FFD700 100%);
  color: #1a1a1a;
  border: none;
}

.mask-cancel-btn {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.mask-cancel-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}

.mask-instructions {
  text-align: center;
  color: #ccc;
  font-size: 0.85rem;
  opacity: 0.8;
  line-height: 1.4;
  flex-shrink: 0;
}

/* Mobile responsive adjustments for uploaded image container */
@media (max-width: 768px) {
  .uploaded-image-container {
    padding: 0.75rem;
    gap: 0.5rem;
    max-width: 100%;
    box-sizing: border-box;
  }
  .uploaded-image {
    max-height: 200px;
    max-width: 100%;
  }
  .image-filename {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .uploaded-image-container {
    padding: 0.5rem;
    gap: 0.4rem;
    max-width: 100%;
    box-sizing: border-box;
  }
  .uploaded-image {
    max-height: 150px;
    max-width: 100%;
  }
  .image-filename {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
  }
}



/* Mobile responsiveness for mask editor */
/* Upload from Link modal (copied from edits.css) */
.upload-link-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-link-modal.active {
  opacity: 1;
  visibility: visible;
}

.upload-link-modal-content {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 20px;
  padding: 2rem;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(59, 130, 246, 0.3),
              0 0 20px rgba(59, 130, 246, 0.2);
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.upload-link-modal.active .upload-link-modal-content {
  transform: scale(1) translateY(0);
}

.upload-link-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.upload-link-modal-title {
  color: #f1f5f9;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.upload-link-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.upload-link-close-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.upload-link-input-group {
  margin-bottom: 1.5rem;
}

.upload-link-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid #334155;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.8);
  color: #f1f5f9;
  font-size: 1rem;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.upload-link-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.upload-link-input::placeholder {
  color: #64748b;
}

.upload-link-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.upload-link-fetch-btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.upload-link-fetch-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

.upload-link-fetch-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.upload-link-cancel-btn {
  padding: 0.875rem 1.5rem;
  background: rgba(71, 85, 105, 0.5);
  border: 2px solid #475569;
  border-radius: 12px;
  color: #cbd5e1;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-link-cancel-btn:hover {
  background: rgba(71, 85, 105, 0.8);
  border-color: #64748b;
}

.upload-link-loading {
  display: none;
  text-align: center;
  color: #94a3b8;
  margin: 1rem 0;
}

.upload-link-loading.show {
  display: block;
}

.upload-link-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #334155;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 0.5rem;
}

.upload-link-preview {
  display: none;
  text-align: center;
  margin-bottom: 1.5rem;
}

.upload-link-preview.show {
  display: block;
}

.upload-link-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  margin-bottom: 1rem;
}

.upload-link-use-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.upload-link-use-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.upload-link-error {
  display: none;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 1rem;
  color: #fca5a5;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.upload-link-error.show {
  display: block;
}

@media (max-width: 768px) {
  .mask-editor-content {
    padding: 1rem;
    margin: 0.5rem;
    max-width: 98vw;
    max-height: 80vh;
  }

  .mask-canvas-container {
    min-height: 50vh; /* Keep it reasonably sized */
    height: 50vh; /* Keep it reasonably sized */
  }
  
  .mask-canvas {
    max-width: 100%;
    max-height: 100%;
  }
  
  .mask-controls {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .brush-size-slider {
    width: 80px;
  }
  
  .mask-actions {
    flex-direction: column;
  }
  
  .mask-action-btn {
    width: 100%;
    justify-content: center;
  }
}
