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

:root {
  --bg-dark: #0a0a0a;
  --bg-card: #111113;
  --bg-hover: #1a1a1f;
  --accent-pink: #f472b6;
  --accent-coral: #fb7185;
  --accent-gradient: linear-gradient(135deg, #f9a8d4 0%, #f472b6 50%, #fb7185 100%);
  --text-primary: #f1f1f4;
  --text-secondary: #71717a;
  --border-color: #27272a;
}

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%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  opacity: 0.03;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.3) 2px,
    rgba(0, 0, 0, 0.3) 4px
  );
}

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

/* Header */
.header {
  text-align: center;
  padding: 50px 20px;
  margin-bottom: 40px;
  background: linear-gradient(180deg, rgba(244, 114, 182, 0.06) 0%, 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: 200px;
  height: 2px;
  background: var(--accent-gradient);
  border-radius: 2px;
}

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

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

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

.title-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.8rem, 9vw, 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 rgba(244, 114, 182, 0.3);
}

.pro-badge {
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.15em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.tagline {
  font-size: 0.95rem;
  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.25em;
  color: var(--text-secondary);
  margin-bottom: 22px;
  text-align: center;
}

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

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

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-pink);
  background: rgba(244, 114, 182, 0.04);
  transform: translateY(-2px);
}

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

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

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

.upload-formats {
  font-size: 0.72rem;
  color: var(--text-secondary);
  opacity: 0.5;
  margin-top: 8px;
  letter-spacing: 0.1em;
}

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

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

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

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

.image-info {
  padding: 12px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  letter-spacing: 0.05em;
}

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

.style-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

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

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

.style-card.active {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 25px rgba(244, 114, 182, 0.25);
}

.style-preview {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 8px;
  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, #555 0%, #222 50%, #000 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.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  font-weight: 500;
}

/* Options Section */
.options-section {
  margin-bottom: 35px;
  padding: 22px;
  background: var(--bg-card);
  border-radius: 14px;
  border: 1px solid var(--border-color);
}

.options-section .section-title {
  margin-bottom: 18px;
}

.options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-bottom: 18px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.option-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-pink);
  cursor: pointer;
}

.option-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.aspect-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.aspect-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.aspect-select {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.aspect-select:focus {
  outline: none;
  border-color: var(--accent-pink);
}

/* Generate Button */
.generate-btn {
  display: block;
  width: 100%;
  max-width: 450px;
  margin: 0 auto 55px;
  padding: 20px 45px;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.2em;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 14px;
  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;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(244, 114, 182, 0.4);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(244, 114, 182, 0);
  }
}

.generate-btn.active:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(244, 114, 182, 0.35);
  animation: none;
}

.generate-btn:disabled {
  opacity: 0.55;
  animation: none;
}

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

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

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

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

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

.frame-wrapper {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border-color);
  animation: fadeSlideIn 0.5s ease forwards;
  opacity: 0;
  transform: translateY(15px) scale(0.96);
  background: #000;
}

@keyframes fadeSlideIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.frame-canvas {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.35s ease, filter 0.35s ease;
}

.frame-wrapper:hover .frame-canvas {
  transform: scale(1.04);
  filter: brightness(1.08);
}

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

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

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

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

.action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.25s;
  letter-spacing: 0.02em;
}

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

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

.action-btn.primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(244, 114, 182, 0.35);
}

.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(0, 0, 0, 0.96);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-close {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 50px;
  height: 50px;
  background: transparent;
  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-close:hover {
  border-color: var(--accent-pink);
  color: var(--accent-pink);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 34px;
  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);
}

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

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

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

.lightbox-frame-wrapper {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

#lightboxCanvas {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}

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

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

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

.download-frame-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(244, 114, 182, 0.3);
}

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

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

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

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

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

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

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

/* Responsive */
@media (max-width: 768px) {
  .style-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

  .header {
    padding: 30px 15px;
  }

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

  .title-wrapper {
    flex-direction: column;
    gap: 8px;
  }

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

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

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

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

  .style-card {
    padding: 8px;
  }

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

  .options-grid {
    flex-direction: column;
    gap: 14px;
    align-items: flex-start;
    padding-left: 20px;
  }

  .frames-grid {
    gap: 5px;
  }

  .frame-badge {
    width: 22px;
    height: 22px;
    font-size: 0.65rem;
    top: 6px;
    left: 6px;
  }

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

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

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

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

  .lightbox-nav {
    width: 44px;
    height: 44px;
    font-size: 28px;
  }
}