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

:root {
  --bg-dark: #0a0a0a;
  --bg-card: #111113;
  --bg-hover: #1a1a1f;
  --accent-1: #a855f7;
  --accent-2: #ec4899;
  --accent-cyan: #00d4ff;
  --accent-gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --epic-gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #c4b5fd 100%);
  --ai-gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --text-primary: #e8e8ec;
  --text-secondary: #8a8a94;
  --border-color: #2a2a32;
}

body {
  font-family: 'JetBrains Mono', monospace;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

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

.app-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

/* Header */
.header {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 40px;
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.08) 0%, rgba(236, 72, 153, 0.05) 50%, transparent 100%);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.05) 0%, transparent 50%);
  animation: headerGlow 8s ease-in-out infinite;
}

@keyframes headerGlow {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(10%, 10%); }
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.film-icon {
  width: 48px;
  height: 48px;
  color: var(--accent-1);
}

.film-icon .sparkle {
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  letter-spacing: 0.15em;
  background: var(--ai-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 300;
  letter-spacing: 0.1em;
}

/* Section Titles */
.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.2em;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: center;
}

/* Upload Section */
.upload-section {
  margin-bottom: 40px;
}

.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-2);
  background: rgba(236, 72, 153, 0.05);
  box-shadow: 0 0 30px rgba(236, 72, 153, 0.1);
}

.upload-icon {
  width: 80px;
  height: 80px;
  color: var(--text-secondary);
  opacity: 0.6;
}

.upload-text {
  font-size: 1.1rem;
  color: var(--text-primary);
}

.upload-subtext {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.upload-formats {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.6;
}

.powered-badge {
  font-size: 0.7rem;
  color: var(--accent-1);
  background: rgba(168, 85, 247, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* Preview */
.preview-container {
  position: relative;
  max-width: 400px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.preview-image {
  width: 100%;
  display: block;
}

.remove-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.remove-btn:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

/* Style Section */
.style-section {
  margin-bottom: 30px;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.style-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.style-card:hover {
  border-color: var(--accent-1);
  transform: translateY(-2px);
}

.style-card.active {
  border-color: var(--accent-2);
  background: rgba(236, 72, 153, 0.1);
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.3);
}

.style-preview {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.warm-preview {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #92400e 100%);
}

.cool-preview {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 50%, #0e7490 100%);
}

.noir-preview {
  background: linear-gradient(135deg, #737373 0%, #404040 50%, #171717 100%);
}

.vintage-preview {
  background: linear-gradient(135deg, #d6c9a8 0%, #b8a882 50%, #8b7355 100%);
}

.scifi-preview {
  background: linear-gradient(135deg, #ec4899 0%, #a855f7 50%, #06b6d4 100%);
}

.epic-preview {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 40%, #c4b5fd 70%, #6b7280 100%);
}

.style-name {
  font-size: 0.75rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  font-weight: 500;
}

.style-desc {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

.new-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent-gradient);
  color: white;
  font-size: 0.5rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* Context Section */
.context-section {
  margin-bottom: 30px;
}

.context-input {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.context-input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.1);
}

.context-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Generate Button */
.generate-btn {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 50px;
  padding: 18px 40px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.15em;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-secondary);
  cursor: not-allowed;
  transition: all 0.3s ease;
}

.generate-btn.active {
  background: var(--ai-gradient);
  border-color: transparent;
  color: #fff;
  cursor: pointer;
}

.generate-btn.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(168, 85, 247, 0.4);
}

.generate-btn:disabled {
  opacity: 0.6;
}

.btn-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

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

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

/* Progress Section */
.progress-section {
  max-width: 600px;
  margin: 0 auto 30px;
  text-align: center;
}

.progress-indicators {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.progress-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.3s ease;
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
}

.progress-dot.completed {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: white;
}

.progress-dot.active {
  background: var(--bg-card);
  border-color: var(--accent-2);
  color: var(--accent-2);
  box-shadow: 0 0 15px rgba(236, 72, 153, 0.5);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 15px rgba(236, 72, 153, 0.5); }
  50% { box-shadow: 0 0 25px rgba(236, 72, 153, 0.8); }
}

.progress-dot.pending {
  opacity: 0.4;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 15px;
}

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

.progress-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.progress-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Grid Section */
.grid-section {
  margin-bottom: 40px;
}

.frames-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 30px;
}

.frame-wrapper {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border-color);
  animation: fadeIn 0.4s ease forwards;
  background: var(--bg-card);
}

.frame-wrapper.pending {
  border-color: var(--border-color);
}

.frame-wrapper.generating {
  border-color: var(--accent-2);
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.4);
  animation: generatingPulse 1.5s ease-in-out infinite;
}

@keyframes generatingPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(236, 72, 153, 0.4); }
  50% { box-shadow: 0 0 35px rgba(236, 72, 153, 0.7); }
}

.frame-wrapper.completed {
  border-color: var(--border-color);
}

.frame-wrapper.completed:hover {
  border-color: var(--accent-1);
  transform: scale(1.02);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.frame-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(236, 72, 153, 0.15) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.frame-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.frame-wrapper:hover .frame-image {
  transform: scale(1.05);
}

.frame-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-primary);
  z-index: 2;
}

.frame-label-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.5rem;
  color: var(--accent-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 2;
}

.frame-hover-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  text-align: center;
  color: var(--text-primary);
  opacity: 0;
  transition: opacity 0.3s;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 16px;
  border-radius: 20px;
}

.frame-wrapper:hover .frame-hover-text {
  opacity: 1;
}

.frame-wrapper.error {
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--accent-2);
  font-size: 0.8rem;
}

.retry-btn {
  padding: 4px 12px;
  background: var(--accent-gradient);
  border: none;
  border-radius: 4px;
  color: white;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
}

/* Action Bar */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn svg {
  width: 18px;
  height: 18px;
}

.action-btn.primary {
  background: var(--ai-gradient);
  border: none;
  color: #fff;
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(168, 85, 247, 0.4);
}

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

.action-btn.secondary:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 28px;
  cursor: pointer;
  transition: all 0.2s;
}

.lightbox-close:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 32px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-nav:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.lightbox-nav.prev {
  left: 20px;
}

.lightbox-nav.next {
  right: 20px;
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 90vw;
  max-height: 85vh;
}

.lightbox-image {
  max-width: 100%;
  max-height: 65vh;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.lightbox-info {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.frame-number {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.frame-label {
  color: var(--accent-1);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.regenerate-single {
  padding: 8px 16px;
}

.download-frame-btn {
  padding: 10px 20px;
  background: var(--ai-gradient);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.download-frame-btn:hover {
  transform: translateY(-2px);
}

/* Footer */
.footer {
  padding: 30px 20px;
  text-align: center;
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
}

.film-strip {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 15px 0;
}

.film-hole {
  width: 12px;
  height: 8px;
  background: var(--border-color);
  border-radius: 2px;
}

.film-hole.sparkle-hole {
  background: var(--accent-1);
  animation: sparkleHole 2s ease-in-out infinite;
}

@keyframes sparkleHole {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; box-shadow: 0 0 10px var(--accent-1); }
}

.footer-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.footer-text a {
  color: var(--accent-1);
  text-decoration: none;
}

.footer-text a:hover {
  text-decoration: underline;
}

.footer-powered {
  font-size: 0.7rem;
  color: var(--accent-2);
}

/* Responsive */
@media (max-width: 600px) {
  .app-container {
    padding: 15px;
  }

  .header {
    padding: 25px 15px;
  }

  .logo-section {
    flex-direction: column;
    gap: 10px;
  }

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

  .upload-zone {
    padding: 40px 20px;
  }

  .upload-icon {
    width: 60px;
    height: 60px;
  }

  .style-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .style-card {
    padding: 8px;
  }

  .style-name {
    font-size: 0.55rem;
  }

  .style-desc {
    display: none;
  }

  .new-tag {
    font-size: 0.4rem;
    padding: 1px 4px;
  }

  .progress-indicators {
    gap: 4px;
  }

  .progress-dot {
    width: 28px;
    height: 28px;
    font-size: 0.65rem;
  }

  .frames-grid {
    gap: 4px;
  }

  .frame-badge {
    width: 20px;
    height: 20px;
    font-size: 0.6rem;
    top: 4px;
    left: 4px;
  }

  .frame-label-badge {
    font-size: 0.4rem;
    padding: 2px 4px;
    top: 4px;
    right: 4px;
  }

  .action-bar {
    flex-direction: column;
  }

  .action-btn {
    width: 100%;
    justify-content: center;
  }

  .lightbox-nav.prev {
    left: 10px;
  }

  .lightbox-nav.next {
    right: 10px;
  }

  .lightbox-info {
    flex-direction: column;
    gap: 10px;
  }
}