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

body {
  background: #0A0A0F;
  overflow-x: hidden;
}

/* Film grain overlay */
.film-grain {
  position: relative;
}
.film-grain::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  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='1'/%3E%3C/svg%3E");
  background-size: 128px 128px;
  mix-blend-mode: overlay;
  z-index: 2;
  border-radius: inherit;
  animation: grainShift 0.3s steps(4) infinite;
}

@keyframes grainShift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(-1px, 2px); }
  100% { transform: translate(0, 0); }
}

/* Glowing textarea */
.glow-border {
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.3), 0 0 20px rgba(139, 92, 246, 0.1);
  transition: box-shadow 0.4s ease;
}
.glow-border:focus-within {
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.7), 0 0 40px rgba(139, 92, 246, 0.2), 0 0 80px rgba(139, 92, 246, 0.05);
}

/* Generate button */
.btn-generate {
  background: linear-gradient(135deg, #8B5CF6 0%, #F59E0B 100%);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}
.btn-generate::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, #8B5CF6 0%, #F59E0B 50%, #8B5CF6 100%);
  background-size: 200% 200%;
  animation: shimmer 3s ease infinite;
  border-radius: inherit;
  z-index: -1;
  filter: blur(8px);
  opacity: 0.6;
}
.btn-generate:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.4);
}
.btn-generate:active {
  transform: translateY(0);
}
.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

/* Player crossfade */
.frame-display img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.8s ease-in-out;
}

/* Progress bar */
.progress-bar {
  background: linear-gradient(90deg, #8B5CF6, #F59E0B);
  transition: width 0.5s ease;
}

/* Timeline thumbnail */
.timeline-thumb {
  transition: all 0.2s ease;
  cursor: pointer;
  border: 2px solid transparent;
}
.timeline-thumb:hover {
  border-color: #8B5CF6;
  transform: scale(1.05);
}
.timeline-thumb.active {
  border-color: #F59E0B;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* Scrollbar */
::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #12121E;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb {
  background: #8B5CF6;
  border-radius: 3px;
}

/* Toast */
.toast-enter {
  animation: toastIn 0.4s ease forwards;
}
.toast-exit {
  animation: toastOut 0.3s ease forwards;
}
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* Scanlines */
.scanlines {
  position: relative;
}
.scanlines::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 3;
  border-radius: inherit;
}

/* History card */
.history-card {
  transition: all 0.25s ease;
}
.history-card:hover {
  background: #1A1A2E;
  transform: translateX(4px);
}

/* Fade in */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up {
  animation: fadeUp 0.6s ease forwards;
}
.fade-up-1 { animation-delay: 0.1s; opacity: 0; }
.fade-up-2 { animation-delay: 0.2s; opacity: 0; }
.fade-up-3 { animation-delay: 0.3s; opacity: 0; }
.fade-up-4 { animation-delay: 0.4s; opacity: 0; }

/* Clapperboard animation */
@keyframes clap {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-15deg); }
  30% { transform: rotate(0deg); }
}
.clap-anim {
  display: inline-block;
  animation: clap 2s ease infinite;
  transform-origin: bottom left;
}

/* Loading dots */
@keyframes loadDot {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}
.load-dot:nth-child(1) { animation: loadDot 1.4s 0s infinite; }
.load-dot:nth-child(2) { animation: loadDot 1.4s 0.2s infinite; }
.load-dot:nth-child(3) { animation: loadDot 1.4s 0.4s infinite; }