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

body {
  overflow-x: hidden;
}

/* Background grain */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.5;
}

/* Ambient glow */
body::after {
  content: '';
  position: fixed;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 80vw;
  height: 60vh;
  background: radial-gradient(ellipse, rgba(168, 85, 247, 0.06) 0%, rgba(244, 114, 182, 0.03) 40%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#root {
  position: relative;
  z-index: 1;
}

.gradient-text {
  background: linear-gradient(135deg, #a855f7, #ec4899, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-border {
  position: relative;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg, #a855f7, #ec4899, #f97316);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Dashed upload zone */
.upload-zone {
  border: 2px dashed rgba(168, 85, 247, 0.3);
  transition: all 0.3s ease;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: rgba(168, 85, 247, 0.7);
  background: rgba(168, 85, 247, 0.04);
}

.upload-zone.drag-over {
  animation: pulse-border 1s ease infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(168, 85, 247, 0.7); }
  50% { border-color: rgba(244, 114, 182, 0.7); }
}

/* Shimmer */
.shimmer {
  background: linear-gradient(90deg, rgba(30,30,42,1) 25%, rgba(50,50,70,1) 50%, rgba(30,30,42,1) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* Glass card */
.glass {
  background: rgba(22, 22, 31, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Toast */
.toast-enter {
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-exit {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* Button gradient hover */
.btn-gradient {
  background: linear-gradient(135deg, #a855f7, #ec4899);
  transition: all 0.2s ease;
}

.btn-gradient:hover {
  background: linear-gradient(135deg, #9333ea, #db2777);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3);
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.5);
}

/* Fade in animation */
.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

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

/* Check animation */
.check-anim svg {
  animation: checkPop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes checkPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* History thumbnail */
.history-thumb {
  transition: all 0.2s ease;
}

.history-thumb:hover {
  transform: scale(1.03);
  border-color: rgba(168, 85, 247, 0.4);
}

/* Compare mode */
.compare-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .compare-container {
    grid-template-columns: 1fr;
  }
}

/* Spin for regenerate */
.spin {
  animation: spin 0.6s ease;
}

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