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

:root {
  --bg-dark: #050507;
  --bg-card: #0f0f12;
  --bg-hover: #1a1a1f;
  --accent-1: #c9a0dc;
  --accent-2: #ff6b8a;
  --accent-gradient: linear-gradient(135deg, #c9a0dc 0%, #ff6b8a 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(201, 160, 220, 0.08) 0%, transparent 100%);
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

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

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

.title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  letter-spacing: 0.15em;
  background: var(--accent-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;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-1);
  background: rgba(201, 160, 220, 0.05);
}

.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;
  margin-top: 8px;
}

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

.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: 40px;
}

.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: 10px;
}

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

.style-card.active {
  border-color: var(--accent-1);
  background: rgba(201, 160, 220, 0.1);
  box-shadow: 0 0 20px rgba(201, 160, 220, 0.2);
}

.style-preview {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.warm-preview {
  background: linear-gradient(135deg, #d4a574 0%, #c98747 50%, #8b5a2b 100%);
}

.cool-preview {
  background: linear-gradient(135deg, #4a90a4 0%, #2d6b77 50%, #1a4a5e 100%);
}

.noir-preview {
  background: linear-gradient(135deg, #4a4a4a 0%, #1a1a1a 50%, #000000 100%);
}

.vintage-preview {
  background: linear-gradient(135deg, #c9b896 0%, #a89070 50%, #7a6650 100%);
}

.scifi-preview {
  background: linear-gradient(135deg, #00d4ff 0%, #7c3aed 50%, #ff006e 100%);
}

.natural-preview {
  background: linear-gradient(135deg, #7ab893 0%, #5a9472 50%, #3a7450 100%);
}

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

/* 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(--accent-gradient);
  border-color: transparent;
  color: #fff;
  cursor: pointer;
}

.generate-btn.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(201, 160, 220, 0.3);
}

.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); }
}

/* 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: 1px solid var(--border-color);
  animation: fadeIn 0.4s ease forwards;
  opacity: 0;
  transform: scale(0.95);
}

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

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

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

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

.frame-hover-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  font-size: 0.7rem;
  text-align: center;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.3s;
}

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

/* 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(--accent-gradient);
  border: none;
  color: #fff;
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(201, 160, 220, 0.3);
}

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

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

/* 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-1);
  color: var(--accent-1);
}

.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-1);
  color: var(--accent-1);
}

.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: 80vh;
}

#lightboxCanvas {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

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

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

.download-frame-btn {
  padding: 10px 20px;
  background: var(--accent-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;
}

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

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

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

/* 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.6rem;
  }

  .frames-grid {
    gap: 4px;
  }

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

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

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

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

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