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

:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1c1c20;
  --border: #2a2a2f;
  --text: #e8e6e3;
  --text-dim: #8a8a8e;
  --accent: #c4f042;
  --accent-dim: #a3c836;
  --danger: #ff4d6a;
  --radius: 14px;
  --radius-sm: 8px;
}

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── NOISE OVERLAY ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: 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='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 9999;
}

/* ── AMBIENT GLOW ── */
.ambient {
  position: fixed; top: -30vh; left: 50%; transform: translateX(-50%);
  width: 80vw; height: 60vh;
  background: radial-gradient(ellipse, rgba(196,240,66,0.06) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ── LAYOUT ── */
.wrapper {
  position: relative; z-index: 1;
  max-width: 680px; margin: 0 auto;
  padding: 60px 24px 100px;
}

/* ── NAV ── */
nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 64px;
}
.logo {
  font-family: 'Instrument Serif', serif;
  font-size: 1.5rem; letter-spacing: -0.02em;
  color: var(--text);
}
.logo span { color: var(--accent); }
.pill {
  font-size: 0.7rem; font-weight: 500;
  background: rgba(196,240,66,0.1); color: var(--accent);
  padding: 5px 12px; border-radius: 100px;
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* ── HERO ── */
.hero {
  text-align: center; margin-bottom: 56px;
}
.hero h1 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 1.1; letter-spacing: -0.03em;
  margin-bottom: 18px;
}
.hero h1 em {
  font-style: italic; color: var(--accent);
}
.hero p {
  color: var(--text-dim); font-size: 1.05rem;
  line-height: 1.6; max-width: 480px; margin: 0 auto 28px;
}
.hero-badges {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.hero-badges .badge {
  font-size: 0.75rem; font-weight: 500;
  padding: 6px 14px; border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}
.hero-badges .badge svg { width: 14px; height: 14px; }

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  position: relative;
  overflow: hidden;
}
.card + .card { margin-top: 20px; }

/* ── UPLOAD AREA ── */
.api-key-section {
  padding: 16px 20px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px dashed var(--border);
}
.api-key-section.saved {
  border-color: var(--accent);
  border-style: solid;
  background: rgba(196, 240, 66, 0.04);
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(196,240,66,0.03);
}
.upload-zone svg {
  width: 40px; height: 40px; color: var(--text-dim);
  margin-bottom: 14px;
}
.upload-zone h3 {
  font-size: 1rem; font-weight: 500; margin-bottom: 6px;
}
.upload-zone p {
  font-size: 0.82rem; color: var(--text-dim);
}
.upload-zone input { display: none; }

/* ── IMAGE PREVIEW ── */
.preview-container {
  display: none; position: relative;
  border-radius: var(--radius-sm); overflow: hidden;
}
.preview-container img {
  width: 100%; display: block;
  border-radius: var(--radius-sm);
}
.preview-container .remove-btn {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
}
.preview-container .remove-btn:hover { background: var(--danger); }

/* ── PROMPT INPUT ── */
.prompt-section {
  display: none; margin-top: 20px;
}
.prompt-label {
  font-size: 0.82rem; color: var(--text-dim);
  margin-bottom: 8px; display: block; font-weight: 500;
}
.prompt-row {
  display: flex; gap: 10px;
}
.prompt-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-family: inherit; font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
}
.prompt-input::placeholder { color: var(--text-dim); opacity: 0.6; }
.prompt-input:focus { border-color: var(--accent); }

.generate-btn {
  flex-shrink: 0;
  background: var(--accent);
  color: #0a0a0b;
  border: none; border-radius: var(--radius-sm);
  padding: 0 24px;
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
  display: flex; align-items: center; gap: 8px;
}
.generate-btn:hover { transform: scale(1.02); }
.generate-btn:active { transform: scale(0.98); }
.generate-btn:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none;
}
.generate-btn svg { width: 18px; height: 18px; }

/* ── QUICK EDITS ── */
.quick-edits {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px;
}
.quick-edit {
  font-size: 0.75rem; font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.quick-edit:hover {
  border-color: var(--accent); color: var(--accent);
  background: rgba(196,240,66,0.05);
}

/* ── LOADING ── */
.loading-overlay {
  display: none;
  position: absolute; inset: 0;
  background: rgba(10,10,11,0.85);
  backdrop-filter: blur(12px);
  z-index: 10;
  flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: var(--radius);
  gap: 18px;
}
.loading-overlay.active { display: flex; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 0.9rem; color: var(--text-dim);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }

/* ── RESULT ── */
.result-section {
  display: none; margin-top: 20px;
}
.result-section img {
  width: 100%; border-radius: var(--radius-sm);
  display: block;
}
.result-actions {
  display: flex; gap: 10px; margin-top: 14px;
}
.result-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.85rem; font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s;
}
.result-btn.primary {
  background: var(--accent); color: #0a0a0b; border: none;
}
.result-btn.primary:hover { opacity: 0.9; }
.result-btn.secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.result-btn.secondary:hover { border-color: var(--text-dim); }

/* ── USAGE BAR ── */
.usage-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.usage-bar .left {
  font-size: 0.82rem; color: var(--text-dim);
}
.usage-bar .left strong {
  color: var(--accent); font-weight: 600;
}
.usage-dots {
  display: flex; gap: 6px;
}
.usage-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all 0.3s;
}
.usage-dot.used {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── PAYWALL MODAL ── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 24px;
}
.modal-backdrop.active { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 440px; width: 100%;
  padding: 40px 32px;
  text-align: center;
  position: relative;
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 50%; color: var(--text-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover { color: var(--text); border-color: var(--text-dim); }

.modal .emoji { font-size: 2.5rem; margin-bottom: 16px; }
.modal h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.6rem; margin-bottom: 10px;
  letter-spacing: -0.02em;
}
.modal p {
  color: var(--text-dim); font-size: 0.92rem;
  line-height: 1.6; margin-bottom: 24px;
}
.modal .price {
  font-size: 2.2rem; font-weight: 600;
  color: var(--accent); margin-bottom: 4px;
}
.modal .price-sub {
  font-size: 0.82rem; color: var(--text-dim);
  margin-bottom: 24px;
}
.modal .features {
  text-align: left; margin-bottom: 28px;
}
.modal .feature-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  font-size: 0.88rem; color: var(--text-dim);
}
.modal .feature-item svg {
  width: 18px; height: 18px; color: var(--accent); flex-shrink: 0;
}
.subscribe-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent); color: #0a0a0b;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}
.subscribe-btn:hover { transform: scale(1.02); }
.subscribe-btn:active { transform: scale(0.98); }

/* ── ERROR TOAST ── */
.toast {
  position: fixed; bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-2);
  border: 1px solid var(--danger);
  color: var(--text);
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.visible {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ── FOOTER ── */
footer {
  text-align: center;
  padding: 40px 0 30px;
  font-size: 0.78rem;
  color: var(--text-dim);
  opacity: 0.5;
}

/* ── ANIMATIONS ── */
.fade-in {
  animation: fadeIn 0.5s ease both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ── */
@media (max-width: 520px) {
  .wrapper { padding: 40px 16px 80px; }
  .card { padding: 22px; }
  .prompt-row { flex-direction: column; }
  .generate-btn { padding: 14px; justify-content: center; }
  .result-actions { flex-direction: column; }
}
