:root {
  --primary: #1DC53C;
  --primary-hover: #19a832;
  --dark: #010103;
  --text: #2C2C2D;
  --text-secondary: #6B7280;
  --text-muted: #99999A;
  --bg: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --border: #E5E7EB;
  --purple: #E7E2FF;
  --green: #BCF3DB;
  --orange: #FFE2C0;
  --error: #EF4444;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  /* Better mobile scrolling */
  -webkit-overflow-scrolling: touch;
  /* Prevent text size adjustment on mobile */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Better tap highlighting */
  -webkit-tap-highlight-color: rgba(29, 197, 60, 0.1);
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  z-index: 100;
}

.header-content {
  max-width: 100%;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: var(--dark);
  font-weight: 700;
  font-size: 1.125rem;
}

.logo svg {
  color: var(--primary);
}

.nav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.nav-link {
  padding: 0.5625rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-secondary);
}

.nav-link.active {
  color: var(--dark);
  background: var(--bg-secondary);
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Hero Section */
.hero {
  max-width: 800px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.hero-content {
  text-align: center;
  margin-bottom: 2rem;
}

.hero h1 {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--dark);
  line-height: 1.15;
  margin-bottom: 0.875rem;
}

.hero h1 .highlight {
  color: var(--primary);
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Upload Section */
.upload-section {
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.05);
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--bg-secondary);
  /* Prevent text selection during drag */
  user-select: none;
  -webkit-user-select: none;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: rgba(29, 197, 60, 0.04);
}

.upload-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.upload-icon svg {
  color: var(--primary);
  width: 40px;
  height: 40px;
}

.upload-text {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.375rem;
  font-weight: 500;
}

.upload-text span {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.upload-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.upload-hint::before {
  content: '📋 ';
  opacity: 0.7;
}

.preview-container {
  position: relative;
}

/* Multi-image preview grid */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.875rem;
  margin-bottom: 0.875rem;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item .preview-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.375rem 0.5rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  color: white;
  font-size: 0.6875rem;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.preview-remove-btn {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  width: 26px;
  height: 26px;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  opacity: 0;
}

.preview-remove-btn svg {
  width: 14px;
  height: 14px;
}

.preview-item:hover .preview-remove-btn {
  opacity: 1;
}

.preview-remove-btn:hover {
  background: var(--error);
}

.clear-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-all-btn:hover {
  background: #FEF2F2;
  border-color: #FECACA;
  color: var(--error);
}

/* Legacy single preview support */
.preview-container > img:not(.preview-grid img) {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius);
  object-fit: contain;
}

.remove-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.remove-btn:hover {
  background: var(--error);
}

/* Multi-results grid */
.multi-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.multi-result-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.multi-result-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.multi-result-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--bg-secondary);
}

.multi-result-info {
  padding: 0.875rem;
}

.multi-result-filename {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.625rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.875rem;
}

.multi-result-actions {
  display: flex;
  gap: 0.375rem;
}

.multi-result-actions button,
.multi-result-actions a {
  flex: 1;
  padding: 0.5rem 0.375rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.btn-copy-url {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-copy-url:hover {
  background: var(--border);
}

.btn-download-single {
  background: var(--primary);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-download-single:hover {
  background: var(--primary-hover);
}

/* Options Bar */
.options-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.875rem;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.option-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle-group {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  padding: 4px;
}

.toggle-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--dark);
  color: white;
}

/* Buttons */
.btn-primary {
  padding: 0.8125rem 2rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(29, 197, 60, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 0.625rem 1.25rem;
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-loading[hidden],
.btn-text[hidden] {
  display: none !important;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.large {
  width: 32px;
  height: 32px;
  border-color: var(--border);
  border-top-color: var(--primary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
  margin-top: 1.25rem;
  padding: 0.875rem 1.25rem;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  color: var(--error);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Results Section */
.results-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.result-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.result-header h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.75rem;
}

.url-box {
  display: flex;
  max-width: 500px;
  margin: 0 auto;
  gap: 0.5rem;
}

.url-box input {
  flex: 1;
  padding: 0.6875rem 0.875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: monospace;
  font-size: 0.8125rem;
  color: var(--text);
}

/* Before/After Slider */
.slider-container {
  max-width: 700px;
  margin: 0 auto;
}

.image-comparison {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: ew-resize;
  user-select: none;
  /* Aspect ratio set dynamically by JavaScript based on image */
}

.comparison-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  display: block;
}

.comparison-img--after {
  z-index: 1;
}

.comparison-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  overflow: hidden;
  z-index: 2;
}

.comparison-img--before {
  /* Width and height set by JavaScript to match container dimensions */
  /* This prevents the image from scaling with the overlay width */
}

.slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  transform: translateX(-50%);
  cursor: ew-resize;
  z-index: 10;
}

.slider-line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: white;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.slider-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}

.slider-button svg {
  width: 16px;
  height: 16px;
  color: var(--text);
}

.slider-handle:hover .slider-button,
.image-comparison.dragging .slider-button {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.comparison-label {
  position: absolute;
  top: 0.75rem;
  padding: 0.375rem 0.75rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: 5;
}

.comparison-label--before {
  left: 1rem;
}

.comparison-label--after {
  right: 1rem;
  background: var(--primary);
}

.slider-info {
  display: flex;
  justify-content: space-between;
  padding: 0.875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.slider-info-item {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.info-label {
  font-weight: 600;
  margin-right: 0.375rem;
}

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem;
  background: var(--primary);
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.btn-download:hover {
  background: var(--primary-hover);
}

.btn-download--full {
  margin-top: 1rem;
  border-radius: var(--radius);
}

/* Payment UI */
.download-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-purchase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

/* Ensure hidden attribute works even with display: flex */
.btn-purchase[hidden] {
  display: none !important;
}

.btn-purchase:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.watermark-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  color: #92400E;
  font-size: 0.85rem;
  text-align: center;
  justify-content: center;
}

/* Ensure hidden attribute works even with display: flex */
.watermark-notice[hidden] {
  display: none !important;
}

.watermark-notice svg {
  flex-shrink: 0;
}

.modal-watermark-notice {
  margin-top: 1rem;
}

/* History payment badges */
.filename-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.125rem;
}

.badge-paid {
  background: #D1FAE5;
  color: #065F46;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
}

.badge-watermarked {
  background: #FEF3C7;
  color: #92400E;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
}

.btn-buy {
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  color: white;
  border: none;
  padding: 0.4375rem 0.625rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-buy:hover {
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

/* Features Section */
.features {
  background: var(--bg-secondary);
  padding: 3rem 1.5rem;
  margin-top: 2.5rem;
}

.features-grid {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  padding: 2rem;
  border-radius: var(--radius-lg);
  text-align: center;
}

.feature-card.purple { background: var(--purple); }
.feature-card.green { background: var(--green); }
.feature-card.orange { background: var(--orange); }

.feature-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.25rem;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.feature-icon svg {
  color: var(--dark);
}

.feature-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.feature-card p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* History Tab */
.history-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.history-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.history-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.history-header p {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.history-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.upload-more-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.upload-more-link:hover {
  background: rgba(29, 197, 60, 0.1);
}

.loading-state,
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
}

.empty-state-content {
  margin-bottom: 1.25rem;
}

.empty-state-content svg {
  color: var(--border);
  margin-bottom: 0.75rem;
}

.empty-state-content h3 {
  font-size: 1.125rem;
  color: var(--text);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.empty-state-content p {
  font-size: 0.875rem;
}

.empty-upload-area {
  max-width: 560px;
  margin: 0 auto;
}

.empty-upload-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-secondary);
  /* Prevent text selection during drag */
  user-select: none;
  -webkit-user-select: none;
}

.empty-upload-box:hover {
  border-color: var(--primary);
  background: rgba(29, 197, 60, 0.05);
}

.empty-upload-box.dragover {
  border-color: var(--primary);
  background: rgba(29, 197, 60, 0.1);
}

.empty-upload-icon {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: center;
}

.empty-upload-icon svg {
  width: 36px;
  height: 36px;
}

.empty-upload-text {
  font-size: 0.9375rem;
  color: var(--text);
  margin-bottom: 0.375rem;
  font-weight: 500;
}

.empty-upload-text span {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

.empty-upload-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.empty-state svg {
  color: var(--border);
  margin-bottom: 1.5rem;
}

.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.history-item {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.history-item:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.history-item img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--bg-secondary);
  cursor: pointer;
  /* Better image rendering */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.history-item-info {
  padding: 0.875rem;
}

.history-item-info .filename {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.875rem;
}

.history-item-info .meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.history-item-actions {
  display: flex;
  gap: 0.375rem;
}

.history-item-actions button,
.history-item-actions a {
  flex: 1;
  padding: 0.5rem 0.375rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.btn-copy {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-copy:hover {
  background: var(--border);
}

.btn-hist-download {
  background: var(--primary);
  border: none;
  color: white;
}

.btn-hist-download:hover {
  background: var(--primary-hover);
}

.btn-delete {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--error);
}

.btn-delete:hover {
  background: #FEE2E2;
}

/* Footer */
.footer {
  background: var(--dark);
  color: white;
  padding: 2rem 1.5rem;
  margin-top: 2rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer p {
  font-size: 0.875rem;
  opacity: 0.9;
  line-height: 1.5;
}

.footer-note {
  margin-top: 0.375rem;
  font-size: 0.8rem !important;
  opacity: 0.6 !important;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.75rem 1.25rem;
  background: var(--dark);
  color: white;
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: 0.875rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Processing Overlay */
.processing-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
  overflow-y: auto;
}

.processing-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.processing-content {
  max-width: 800px;
  width: 90%;
  text-align: center;
  padding: 2rem;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.processing-header {
  margin-bottom: 1rem;
}

.processing-header h1 {
  font-family: 'Inter', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: white;
  margin-bottom: 0.75rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.processing-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.processing-preview {
  position: relative;
  margin: 2.5rem auto;
  width: 200px;
  height: 200px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.processing-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

.processing-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    var(--primary) 60deg,
    transparent 120deg
  );
  animation: rotateGlow 2s linear infinite;
  opacity: 0.6;
}

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

.processing-preview::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  background: #1a1a2e;
  border-radius: calc(var(--radius-lg) - 4px);
  z-index: 1;
}

.processing-preview img {
  position: relative;
  z-index: 2;
  border: 4px solid transparent;
}

/* Processing Grid for Multiple Images */
.processing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin: 2rem auto;
  max-width: 700px;
  width: 100%;
}

.processing-item {
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.3s ease;
}

.processing-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.processing-item-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
}

.processing-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.processing-item-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.processing-item-progress.complete {
  opacity: 0;
}

.processing-item-progress-ring {
  position: relative;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.processing-item-progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 2px 8px rgba(29, 197, 60, 0.3));
}

.processing-item-progress-ring circle {
  fill: none;
  stroke-width: 3.5;
}

.processing-item-progress-ring .ring-bg {
  stroke: rgba(255, 255, 255, 0.15);
}

.processing-item-progress-ring .ring-fill {
  stroke: var(--primary);
  stroke-dasharray: 157;
  stroke-dashoffset: 157;
  transition: stroke-dashoffset 0.35s ease;
  stroke-linecap: round;
}

.processing-item-progress-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  z-index: 1;
}

.processing-item-progress-icon svg {
  width: 26px;
  height: 26px;
  animation: pulse 2s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.processing-item-progress-icon.complete svg {
  animation: scaleIn 0.3s ease;
  color: var(--primary);
}

@keyframes scaleIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

.processing-item-status {
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 0.25rem;
  transition: color 0.3s ease;
}

.processing-item-status.processing {
  color: var(--primary);
  font-weight: 600;
}

.processing-item-status.complete {
  color: var(--primary);
  font-weight: 600;
}

.processing-item-status.error {
  color: #EF4444;
  font-weight: 600;
}

.processing-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin: 2rem 0;
}

.progress-ring {
  position: relative;
  width: 80px;
  height: 80px;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 6;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--primary);
  animation: pulse 1.5s ease-in-out infinite;
}

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

.progress-info {
  text-align: left;
}

.progress-step {
  font-size: 1.125rem;
  font-weight: 600;
  color: white;
  margin-bottom: 0.25rem;
}

.progress-detail {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.5);
}

.processing-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 2rem 0;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.4;
  transition: all 0.3s ease;
}

.step-item.active {
  opacity: 1;
}

.step-item.completed {
  opacity: 1;
}

.step-item.completed .step-icon {
  background: var(--primary);
  color: white;
}

.step-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  transition: all 0.3s ease;
}

.step-item.active .step-icon {
  background: rgba(29, 197, 60, 0.2);
  color: var(--primary);
  animation: stepPulse 1.5s ease-in-out infinite;
}

@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29, 197, 60, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(29, 197, 60, 0); }
}

.step-item span {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

.step-item.active span,
.step-item.completed span {
  color: white;
}

.step-connector {
  width: 30px;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  margin-bottom: 1.5rem;
}

.processing-tips {
  margin: 1.5rem auto;
  padding: 1rem 1.5rem;
  background: rgba(29, 197, 60, 0.12);
  border-radius: var(--radius);
  border: 1px solid rgba(29, 197, 60, 0.25);
  max-width: 600px;
}

.processing-tips p {
  font-size: 0.875rem;
  color: rgba(29, 197, 60, 1);
  margin: 0;
  transition: opacity 0.3s ease;
  line-height: 1.5;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-cancel {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 1rem;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
}

/* Gallery Comparison Modal */
.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.gallery-modal[hidden] {
  display: none;
}

.gallery-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
}

.gallery-modal-content {
  position: relative;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
  padding: 1.5rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.modal-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin-bottom: 0.375rem;
}

.modal-header p {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875rem;
}

.modal-slider-container {
  margin: 1.5rem 0;
}

.modal-image-comparison {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  cursor: ew-resize;
  user-select: none;
  /* Aspect ratio set dynamically by JavaScript based on image */
}

.modal-comparison-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  display: block;
}

.modal-comparison-img--after {
  z-index: 1;
}

.modal-comparison-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  overflow: hidden;
  z-index: 2;
}

.modal-comparison-img--before {
  /* Inherits styles from .modal-comparison-img */
}

.modal-slider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  transform: translateX(-50%);
  cursor: ew-resize;
  z-index: 10;
}

.modal-slider-line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: var(--primary);
  transform: translateX(-50%);
  box-shadow: 0 0 12px rgba(29, 197, 60, 0.6);
}

.modal-slider-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(29, 197, 60, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.modal-slider-button svg {
  width: 16px;
  height: 16px;
  color: white;
}

.modal-slider-handle:hover .modal-slider-button,
.modal-image-comparison.dragging .modal-slider-button {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 6px 24px rgba(29, 197, 60, 0.5);
}

.modal-comparison-label {
  position: absolute;
  top: 1rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: 5;
}

.modal-comparison-label--before {
  left: 1rem;
}

.modal-comparison-label--after {
  right: 1rem;
  background: var(--primary);
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions .btn-primary {
  padding: 0.8125rem 1.75rem;
}

/* ============================================
   RESPONSIVE DESIGN - Mobile First Approach
   ============================================ */

/* Safe area support for modern phones */
:root {
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
}

/* Touch-friendly minimum tap targets */
@media (pointer: coarse) {
  button,
  .btn-primary,
  .btn-secondary,
  .toggle-btn,
  .nav-link,
  .tab-btn {
    min-height: 44px;
  }
  
  /* Ensure touch targets are adequately sized */
  .history-item-actions button,
  .history-item-actions a,
  .multi-result-actions button,
  .multi-result-actions a {
    min-height: 44px;
  }
  
  /* Make remove buttons easier to tap on touch devices */
  .preview-remove-btn {
    opacity: 0.85;
  }
}

/* Large Tablets (1024px and below) */
@media (max-width: 1024px) {
  .hero {
    padding: 2rem 1rem;
  }

  .features-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
  }

  .history-container {
    padding: 1.25rem 1rem;
  }

  .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.875rem;
  }

  .slider-container {
    max-width: 100%;
  }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
  .header-content {
    padding: 0.875rem 1.25rem;
    padding-top: calc(0.875rem + var(--safe-area-top));
  }

  .header {
    position: fixed;
    width: 100%;
  }

  main {
    padding-top: 56px;
  }

  .logo {
    gap: 0.5rem;
  }

  .logo span {
    font-size: 1rem;
  }

  .logo svg {
    width: 28px;
    height: 28px;
  }

  .nav {
    gap: 0.25rem;
  }

  .nav-link {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
  }

  .hero {
    padding: 1.5rem 1rem;
  }

  .hero-content {
    margin-bottom: 1.5rem;
  }

  .hero h1 {
    font-size: 1.5rem;
    line-height: 1.25;
    margin-bottom: 0.625rem;
  }

  .hero-subtitle {
    font-size: 0.9375rem;
  }

  .upload-section {
    padding: 1rem;
    border-radius: var(--radius);
  }

  .upload-area {
    padding: 1.5rem 1rem;
  }

  .upload-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 0.875rem;
  }

  .upload-icon svg {
    width: 32px;
    height: 32px;
  }

  .upload-text {
    font-size: 0.9375rem;
  }

  .upload-hint {
    font-size: 0.75rem;
  }

  .options-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .option-group {
    justify-content: space-between;
    width: 100%;
  }

  .toggle-group {
    flex: 1;
    justify-content: flex-end;
  }

  .toggle-btn {
    padding: 0.625rem 1.5rem;
    font-size: 0.9rem;
  }

  .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 0.9375rem 1.5rem;
    font-size: 0.9375rem;
  }
  
  .btn-secondary {
    font-size: 0.8125rem;
    padding: 0.5625rem 1rem;
  }

  .result-header h2 {
    font-size: 1.25rem;
  }

  .url-box {
    flex-direction: column;
  }

  .url-box input {
    text-align: center;
  }

  .slider-info {
    flex-direction: column;
    gap: 0.375rem;
    text-align: center;
    padding: 0.75rem;
  }

  .slider-info-item {
    font-size: 0.75rem;
  }

  .toast {
    bottom: calc(1rem + var(--safe-area-bottom));
    font-size: 0.8125rem;
    padding: 0.625rem 1rem;
  }

  .btn-download--full {
    padding: 1rem;
  }

  .features {
    padding: 2rem 1rem;
    margin-top: 1.5rem;
  }

  .feature-card {
    padding: 1.25rem;
  }

  .feature-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 0.875rem;
  }

  .feature-card h3 {
    font-size: 0.9375rem;
  }

  .feature-card p {
    font-size: 0.8125rem;
  }

  .history-container {
    padding: 1rem 0.75rem;
  }

  .history-header {
    margin-bottom: 1rem;
  }

  .history-header h2 {
    font-size: 1.35rem;
  }

  .history-header p {
    font-size: 0.85rem;
  }

  .empty-state {
    padding: 1.5rem 1rem;
  }

  .empty-state-content svg {
    width: 56px;
    height: 56px;
    margin-bottom: 0.5rem;
  }

  .empty-upload-box {
    padding: 1.25rem 1rem;
  }

  .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
  }

  .history-item img {
    height: 150px;
  }

  .history-item-info {
    padding: 0.75rem;
  }

  .history-item-actions button,
  .history-item-actions a {
    min-height: 44px;
    padding: 0.625rem 0.5rem;
  }

  .footer {
    padding: 1.5rem 1rem;
    padding-bottom: calc(1.5rem + var(--safe-area-bottom));
    margin-top: 1.5rem;
  }

  .footer p {
    font-size: 0.8125rem;
  }

  /* Processing overlay mobile */
  .processing-content {
    padding: 1.5rem 1rem;
  }

  .processing-header h1 {
    font-size: 1.5rem;
  }

  .processing-preview {
    width: 150px;
    height: 150px;
    margin: 2rem auto;
  }

  .processing-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin: 1.5rem auto;
  }

  .processing-item {
    padding: 0.75rem;
  }

  .processing-item-progress-ring {
    width: 56px;
    height: 56px;
  }

  .processing-item-progress-icon svg {
    width: 22px;
    height: 22px;
  }

  .processing-item-status {
    font-size: 0.8rem;
  }

  .processing-status {
    flex-direction: column;
    gap: 1rem;
  }

  .progress-info {
    text-align: center;
  }

  .processing-steps {
    padding: 1rem;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .step-connector {
    width: 20px;
  }

  .step-icon {
    width: 36px;
    height: 36px;
  }

  .step-item span {
    font-size: 0.7rem;
  }

  /* Modal mobile */
  .gallery-modal-content {
    padding: 1rem;
    padding-top: calc(1rem + var(--safe-area-top));
    width: 95%;
  }

  .modal-header {
    margin-bottom: 1rem;
  }

  .modal-header h2 {
    font-size: 1.125rem;
  }

  .modal-header p {
    font-size: 0.8125rem;
  }

  .modal-close {
    top: calc(0.5rem + var(--safe-area-top));
    width: 40px;
    height: 40px;
  }

  .modal-slider-container {
    margin: 1rem 0;
  }

  .modal-actions {
    flex-direction: column;
    gap: 0.625rem;
    margin-top: 1rem;
  }

  .modal-actions .btn-primary {
    width: 100%;
    padding: 0.875rem 1.5rem;
  }
}

/* Mobile phones (480px and below) */
@media (max-width: 480px) {
  .preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 0.625rem;
  }

  .preview-remove-btn {
    opacity: 1;
    width: 24px;
    height: 24px;
    top: 0.25rem;
    right: 0.25rem;
  }

  .preview-remove-btn svg {
    width: 12px;
    height: 12px;
  }

  .preview-item .preview-name {
    padding: 0.25rem 0.375rem;
    font-size: 0.625rem;
  }

  .clear-all-btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
  }

  .multi-results-grid {
    grid-template-columns: 1fr;
  }

  .header-content {
    padding: 0.75rem 0.875rem;
    padding-top: calc(0.75rem + var(--safe-area-top));
  }

  .logo {
    gap: 0.5rem;
  }

  .logo svg {
    width: 26px;
    height: 26px;
  }

  .logo span {
    font-size: 0.9375rem;
  }

  .nav {
    gap: 0.125rem;
  }

  .nav-link {
    padding: 0.5rem 0.625rem;
    font-size: 0.78125rem;
  }

  main {
    padding-top: 52px;
  }

  .hero {
    padding: 1.25rem 0.75rem;
  }

  .hero-content {
    margin-bottom: 1.25rem;
  }

  .hero h1 {
    font-size: 1.375rem;
    margin-bottom: 0.5rem;
  }

  .hero-subtitle {
    font-size: 0.875rem;
  }

  .upload-section {
    padding: 0.875rem;
  }

  .upload-area {
    padding: 1.25rem 0.875rem;
  }

  .upload-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 0.75rem;
  }

  .upload-icon svg {
    width: 28px;
    height: 28px;
  }

  .preview-container img {
    max-height: 280px;
  }

  .remove-btn {
    width: 36px;
    height: 36px;
    top: 0.5rem;
    right: 0.5rem;
  }

  .option-group label {
    font-size: 0.8rem;
  }

  .toggle-btn {
    padding: 0.5rem 1rem;
  }

  .error-message {
    padding: 0.75rem 0.875rem;
    font-size: 0.8125rem;
    margin-top: 1rem;
  }

  .url-box input {
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
  }

  .toast {
    bottom: calc(0.875rem + var(--safe-area-bottom));
    font-size: 0.78125rem;
    padding: 0.5625rem 0.875rem;
  }

  .results-section {
    margin-top: 2rem;
    padding-top: 2rem;
  }

  .comparison-label {
    padding: 0.3125rem 0.625rem;
    font-size: 0.625rem;
    top: 0.5rem;
  }
  
  .comparison-label--before {
    left: 0.5rem;
  }
  
  .comparison-label--after {
    right: 0.5rem;
  }

  .slider-button {
    width: 38px;
    height: 38px;
  }
  
  .slider-button svg {
    width: 14px;
    height: 14px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .history-header {
    margin-bottom: 1rem;
  }

  .history-header h2 {
    font-size: 1.2rem;
  }

  .history-header p {
    font-size: 0.8125rem;
  }

  .empty-state {
    padding: 1.25rem 0.75rem;
  }

  .empty-state-content svg {
    width: 52px;
    height: 52px;
  }

  .empty-state-content h3 {
    font-size: 1rem;
  }

  .empty-upload-icon svg {
    width: 32px;
    height: 32px;
  }

  .empty-upload-box {
    padding: 1rem 0.875rem;
  }

  .empty-upload-text {
    font-size: 0.875rem;
  }

  .history-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .history-item img {
    height: 200px;
  }

  .history-item-info {
    padding: 0.75rem;
  }

  /* Processing overlay small screens */
  .processing-header h1 {
    font-size: 1.25rem;
  }

  .processing-subtitle {
    font-size: 0.875rem;
  }

  .processing-preview {
    width: 120px;
    height: 120px;
  }

  .processing-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
    margin: 1rem auto;
  }

  .processing-item {
    padding: 0.5rem;
  }

  .processing-item-progress-ring {
    width: 48px;
    height: 48px;
  }

  .processing-item-progress-icon svg {
    width: 18px;
    height: 18px;
  }

  .processing-item-status {
    font-size: 0.75rem;
  }

  .progress-ring {
    width: 64px;
    height: 64px;
  }

  .progress-step {
    font-size: 1rem;
  }

  .progress-detail {
    font-size: 0.8rem;
  }

  .processing-steps {
    padding: 0.75rem;
  }

  .step-icon {
    width: 32px;
    height: 32px;
  }

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

  .step-connector {
    width: 15px;
  }

  .processing-tips {
    padding: 0.75rem;
  }

  .processing-tips p {
    font-size: 0.8rem;
  }

  .btn-cancel {
    padding: 0.625rem 1.25rem;
    font-size: 0.8rem;
  }

  /* Modal small screens */
  .gallery-modal-content {
    width: 96%;
    padding: 0.875rem;
  }

  .modal-header h2 {
    font-size: 1.0625rem;
  }

  .modal-slider-button {
    width: 36px;
    height: 36px;
  }

  .modal-slider-button svg {
    width: 14px;
    height: 14px;
  }

  .modal-comparison-label {
    padding: 0.3125rem 0.5rem;
    font-size: 0.625rem;
  }

  .modal-comparison-label--before {
    left: 0.375rem;
  }
  
  .modal-comparison-label--after {
    right: 0.375rem;
  }
}

/* Small phones (360px and below) */
@media (max-width: 360px) {
  .hero h1 {
    font-size: 1.35rem;
  }

  .nav {
    gap: 0.125rem;
  }

  .nav-link {
    padding: 0.5rem 0.5rem;
    font-size: 0.75rem;
  }

  .upload-text {
    font-size: 0.9rem;
  }

  .upload-hint {
    font-size: 0.75rem;
  }

  .toggle-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .history-container {
    padding: 0.75rem 0.5rem;
  }

  .history-grid {
    gap: 0.625rem;
  }

  .history-item img {
    height: 180px;
  }

  .empty-upload-box {
    padding: 0.875rem 0.75rem;
  }

  .empty-upload-icon svg {
    width: 28px;
    height: 28px;
  }

  .processing-steps {
    gap: 0.125rem;
  }

  .step-item span {
    display: none;
  }

  .step-connector {
    width: 10px;
  }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .processing-content {
    padding: 1rem;
  }

  .processing-header h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
  }

  .processing-preview {
    width: 100px;
    height: 100px;
    margin: 1rem auto;
  }

  .processing-grid {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.5rem;
    margin: 1rem auto;
  }

  .processing-item {
    padding: 0.5rem;
  }

  .processing-item-progress-ring {
    width: 44px;
    height: 44px;
  }

  .processing-item-progress-icon svg {
    width: 16px;
    height: 16px;
  }

  .processing-item-status {
    font-size: 0.7rem;
  }

  .processing-status {
    margin: 1rem 0;
  }

  .processing-steps {
    margin: 1rem 0;
    padding: 0.75rem;
  }

  .processing-tips {
    margin: 0.75rem 0;
  }

  .hero {
    padding: 1rem;
  }

  .hero-content {
    margin-bottom: 1rem;
  }

  .preview-container img {
    max-height: 200px;
  }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .slider-line,
  .modal-slider-line {
    width: 1px;
  }
  
  /* Sharper borders on high-DPI screens */
  .history-item,
  .multi-result-card,
  .upload-section,
  .empty-upload-box {
    border-width: 0.5px;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .processing-glow {
    animation: none;
    opacity: 0.3;
  }

  .progress-icon {
    animation: none;
  }

  .step-item.active .step-icon {
    animation: none;
  }
}

/* ============ PACKAGE CREDITS STYLES ============ */

/* Credits Badge in Nav */
.credits-badge {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: var(--green);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: #166534;
  margin-right: 0.5rem;
}

.credits-badge svg {
  flex-shrink: 0;
}

/* Batch Actions Bar (Results Section) */
.batch-actions-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.btn-batch-download,
.btn-batch-package {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-batch-download {
  background: var(--primary);
  color: white;
}

.btn-batch-download:hover {
  background: var(--primary-hover);
}

.btn-batch-package {
  background: var(--purple);
  color: #5B21B6;
}

.btn-batch-package:hover {
  background: #d8d0f5;
}

/* ============ GALLERY SELECTION MODE STYLES ============ */

/* Selection Actions Bar */
.selection-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.selection-info {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.selection-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-selection-action {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-selection-action:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

.btn-selection-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-selection-action.btn-apply-credits {
  background: var(--green);
  border-color: transparent;
  color: #166534;
}

.btn-selection-action.btn-apply-credits:hover:not(:disabled) {
  background: #9ee5c7;
}

.btn-selection-action.btn-buy-package {
  background: var(--purple);
  border-color: transparent;
  color: #5B21B6;
}

.btn-selection-action.btn-buy-package:hover {
  background: #d8d0f5;
}

.btn-selection-cancel {
  padding: 0.5rem 0.875rem;
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-selection-cancel:hover {
  color: var(--error);
}

/* Selection Checkbox on History Items */
.selection-checkbox {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 24px;
  height: 24px;
  background: white;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 10;
}

.selection-checkbox svg {
  opacity: 0;
  color: white;
  transition: opacity 0.15s ease;
}

.selection-checkbox:hover {
  border-color: var(--primary);
}

.history-item.selected .selection-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.history-item.selected .selection-checkbox svg {
  opacity: 1;
}

/* History Grid in Selection Mode */
.history-grid.selection-mode .history-item {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.history-grid.selection-mode .history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.history-grid.selection-mode .history-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(29, 197, 60, 0.2);
}

/* Mobile adjustments for selection */
@media (max-width: 640px) {
  .selection-actions-bar {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .selection-info {
    text-align: center;
  }

  .selection-buttons {
    justify-content: center;
  }

  .batch-actions-bar {
    flex-direction: column;
  }

  .btn-batch-download,
  .btn-batch-package {
    width: 100%;
    justify-content: center;
  }

  .credits-badge {
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Dark mode support for system preference */
@media (prefers-color-scheme: dark) {
  /* Optional: Add dark mode styles here if needed */
}
