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

:root {
  --bg-dark: #0a0a0a;
  --bg-card: #111114;
  --bg-hover: #1a1a1f;
  --accent-pink: #ec4899;
  --accent-purple: #a855f7;
  --accent-gradient: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
  --text-primary: #f0f0f5;
  --text-secondary: #7a7a88;
  --border-color: #252530;
  --glow-pink: rgba(236, 72, 153, 0.4);
  --glow-purple: rgba(168, 85, 247, 0.3);
}

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.025;
  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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)'/%3E%3C/svg%3E");
}

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

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

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: var(--accent-gradient);
  opacity: 0.6;
}

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

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

.film-icon {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 0 12px var(--glow-pink));
}

.title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.8rem, 10vw, 4.5rem);
  letter-spacing: 0.12em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 40px var(--glow-pink);
  line-height: 1;
}

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

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

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

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

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

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

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

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

.upload-formats {
  font-size: 0.7rem;
  color: var(--text-secondary);
  opacity: 0.5;
  margin-top: 4px;
}

/* Preview */
.preview-container {
  position: relative;
  max-width: 380px;
  margin: 0 auto;
  border-radius: 14px;
  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: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.remove-btn:hover {
  background: var(--accent-pink);
  border-color: var(--accent-pink);
  transform: scale(1.1);
}

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

.style-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.style-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 80px;
  flex: 0 0 auto;
}

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

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

.style-preview {
  width: 70px;
  height: 44px;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.warm-preview {
  background: linear-gradient(135deg, #f5d0a9 0%, #d4915c 50%, #a66832 100%);
}

.cool-preview {
  background: linear-gradient(135deg, #7ecad9 0%, #3d8c9e 50%, #1a5a6e 100%);
}

.noir-preview {
  background: linear-gradient(135deg, #5a5a5a 0%, #2a2a2a 50%, #0a0a0a 100%);
}

.vintage-preview {
  background: linear-gradient(135deg, #e8dcc8 0%, #c4b49a 50%, #8a7860 100%);
}

.scifi-preview {
  background: linear-gradient(135deg, #00e5ff 0%, #8b5cf6 50%, #ff0080 100%);
}

.natural-preview {
  background: linear-gradient(135deg, #8fd9a8 0%, #5cb27a 50%, #2e8b57 100%);
}

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

/* Generate Button */
.generate-btn {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 0 auto 44px;
  padding: 18px 36px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  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;
  box-shadow: 0 4px 24px var(--glow-pink);
}

.generate-btn.active:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 36px var(--glow-pink);
}

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

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

.loader-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s 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: 10px;
  margin-bottom: 28px;
}

.frame-wrapper {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border-color);
  animation: frameReveal 0.5s ease forwards;
  opacity: 0;
  transform: scale(0.92);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

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

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

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

.frame-wrapper:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5), 0 0 20px var(--glow-pink);
  z-index: 2;
}

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

.frame-hover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(0, 0, 0, 0.85));
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 14px;
  opacity: 0;
  transition: opacity 0.3s;
}

.frame-hover-overlay span {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

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

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

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

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

.action-btn.primary {
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  box-shadow: 0 2px 12px var(--glow-pink);
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--glow-pink);
}

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

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

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

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

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

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

.lightbox-nav:hover {
  border-color: var(--accent-pink);
  color: var(--accent-pink);
  background: rgba(236, 72, 153, 0.1);
}

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

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

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

#lightboxCanvas {
  max-width: 100%;
  max-height: 68vh;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

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

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

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

.download-frame-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--glow-pink);
}

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

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

.film-hole {
  width: 14px;
  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-pink);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-text a:hover {
  color: var(--accent-purple);
  text-decoration: underline;
}

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

  .header {
    padding: 28px 16px;
    margin-bottom: 24px;
  }

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

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

  .title {
    font-size: 2.4rem;
  }

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

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

  .style-grid {
    gap: 8px;
  }

  .style-card {
    padding: 8px;
    min-width: 70px;
  }

  .style-preview {
    width: 55px;
    height: 36px;
  }

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

  .generate-btn {
    padding: 16px 24px;
    font-size: 1.3rem;
  }

  .frames-grid {
    gap: 6px;
  }

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

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

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

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

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

  .lightbox-nav {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
}