:root {
  --bg-primary: #f5f5f0;
  --bg-card: #ffffff;
  --bg-elevated: #eeeee8;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-muted: #9a9a9a;
  --border-color: #e0e0d8;
  --accent: #3d5afe;
  --accent-secondary: #00c9a7;
  --accent-gradient: linear-gradient(135deg, #3d5afe 0%, #7c4dff 50%, #e040fb 100%);
  --error: #f4511e;
  --success: #00c9a7;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

.dark {
  --bg-primary: #0c0c14;
  --bg-card: #14141f;
  --bg-elevated: #1c1c2e;
  --text-primary: #ededf0;
  --text-secondary: #9898a8;
  --text-muted: #5c5c72;
  --border-color: #2a2a3e;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

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

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

/* Animated background */
.bg-mesh {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-mesh::before,
.bg-mesh::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
  animation: float 20s ease-in-out infinite;
}

.bg-mesh::before {
  width: 600px; height: 600px;
  background: #3d5afe;
  top: -200px; left: -100px;
  animation-delay: 0s;
}

.bg-mesh::after {
  width: 500px; height: 500px;
  background: #e040fb;
  bottom: -200px; right: -100px;
  animation-delay: -10s;
}

.dark .bg-mesh::before { opacity: 0.08; }
.dark .bg-mesh::after { opacity: 0.06; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(80px, -60px) scale(1.1); }
  66% { transform: translate(-40px, 40px) scale(0.95); }
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 20px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
}

.upload-zone:hover {
  border-color: #3d5afe;
  box-shadow: 0 0 0 4px rgba(61, 90, 254, 0.08);
}

.upload-zone.dragover {
  border-color: #3d5afe;
  background: rgba(61, 90, 254, 0.04);
  box-shadow: 0 0 0 4px rgba(61, 90, 254, 0.15), 0 0 40px rgba(61, 90, 254, 0.1);
  transform: scale(1.01);
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.upload-zone.dragover::before { opacity: 0.04; }

@keyframes dash {
  to { stroke-dashoffset: -20; }
}

/* Gradient text */
.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Comparison slider */
.comparison-container {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
  background: var(--bg-elevated);
}

.comparison-container img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: white;
  box-shadow: 0 0 12px rgba(0,0,0,0.4);
  z-index: 10;
  transform: translateX(-50%);
}

.slider-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.slider-handle-arrows {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  color: #333;
  font-size: 14px;
  font-weight: 700;
}

/* Progress shimmer */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.shimmer {
  background: linear-gradient(90deg, transparent 30%, rgba(61,90,254,0.08) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}

/* Pulse */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.pulse-text {
  animation: pulse-soft 2s ease-in-out infinite;
}

/* Toast */
@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

.toast-enter { animation: slide-in 0.3s ease-out forwards; }
.toast-exit { animation: slide-out 0.3s ease-in forwards; }

/* Confetti */
@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0.3); opacity: 0; }
}

.confetti-piece {
  position: fixed;
  top: -10px;
  width: 10px;
  height: 10px;
  z-index: 9999;
  pointer-events: none;
  animation: confetti-fall 3s ease-in forwards;
}

/* Buttons */
.btn-primary {
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 28px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 24px rgba(61,90,254,0.3);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 28px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: #3d5afe;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 24px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-outline:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: background 0.4s, border-color 0.4s;
}

/* Thumbnail */
.thumb-item {
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.thumb-item:hover { border-color: rgba(61,90,254,0.3); }
.thumb-item.active { border-color: #3d5afe; box-shadow: 0 0 0 3px rgba(61,90,254,0.15); }

/* Zoom indicator */
.zoom-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  z-index: 20;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

/* Label badges */
.label-badge {
  position: absolute;
  bottom: 12px;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 15;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.label-original {
  left: 12px;
  background: rgba(0,0,0,0.55);
  color: white;
}

.label-upscaled {
  right: 12px;
  background: rgba(61,90,254,0.8);
  color: white;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* Mobile tweaks */
@media (max-width: 640px) {
  .btn-primary, .btn-secondary, .btn-outline {
    width: 100%;
    justify-content: center;
  }
}

/* Progress bar */
.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 0.3s ease;
}

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

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: #3d5afe;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Fade in */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease-out forwards;
}