:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #232340;
  --border: #2a2a4a;
  --text: #e8e8f0;
  --text2: #9898b0;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --green: #22c55e;
  --green-dim: #166534;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html, body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* === Layout === */
.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

/* === Header === */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.app-logo span { background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.header-actions { display: flex; align-items: center; gap: 12px; }

/* === Auth === */
.auth-section { text-align: center; padding: 80px 20px; }
.auth-section h1 { font-size: 36px; margin-bottom: 8px; }
.auth-section p { color: var(--text2); margin-bottom: 32px; max-width: 480px; margin-left: auto; margin-right: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #5a4bd1; transform: translateY(-1px); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { background: #16a34a; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-icp { background: #3b00ff; color: #fff; }
.btn-icp:hover:not(:disabled) { background: #2f00cc; }

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === Form Controls === */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 100px; resize: vertical; }
select { cursor: pointer; }
.form-group { margin-bottom: 16px; }

/* === API Key === */
.api-key-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.api-key-bar .dot-green { width: 8px; height: 8px; background: var(--green); border-radius: 50%; display: inline-block; }
.api-key-bar .dot-red { width: 8px; height: 8px; background: var(--red); border-radius: 50%; display: inline-block; }
.api-key-input { flex: 1; background: transparent; border: none; color: var(--text2); font-size: 13px; }
.api-key-input:focus { outline: none; color: var(--text); }

/* === Tags / Chip Grid === */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text2);
  user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* === Variations === */
.variation-config {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.variation-config label { margin-bottom: 0; }
.variation-config input { width: 80px; text-align: center; }

/* === Generate Button === */
.generate-area { text-align: center; padding: 24px 0; }
.generate-btn {
  padding: 16px 48px;
  font-size: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.generate-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(108,92,231,0.3); }
.generate-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* === Progress === */
.progress-section { display: none; }
.progress-section.active { display: block; }

.progress-bar-wrap {
  background: var(--surface2);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 100px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-steps {
  list-style: none;
  font-size: 13px;
  color: var(--text2);
}
.progress-steps li {
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-steps li.done { color: var(--green); }
.progress-steps li.active { color: var(--accent2); font-weight: 600; }
.progress-steps li .step-icon { width: 18px; text-align: center; }

/* === Results === */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s;
}
.result-card:hover { border-color: var(--accent); }

.result-card .ad-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-applovin { background: #1a3a5c; color: #60a5fa; }
.badge-meta { background: #1a3a3c; color: #4ade80; }
.badge-tiktok { background: #3a1a3c; color: #f472b6; }
.badge-vungle { background: #3a2a1a; color: #fbbf24; }
.badge-google { background: #1a2a3c; color: #a78bfa; }
.badge-unity { background: #2a1a3c; color: #c084fc; }
.badge-mintegral { background: #1a2a2a; color: #34d399; }
.badge-ironsrc { background: #2a2a1a; color: #facc15; }

.result-card .ad-genre {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

.result-card .ad-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.result-card .ad-size {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
}

/* === User Badge === */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.user-badge .principal { color: var(--text2); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
  animation: slideUp 0.3s ease;
  max-width: 90%;
}
.toast-success { background: var(--green-dim); color: #bbf7d0; border: 1px solid var(--green); }
.toast-error { background: #3a1a1a; color: #fca5a5; border: 1px solid var(--red); }
.toast-info { background: #1a1a3a; color: #a5b4fc; border: 1px solid var(--accent); }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* === Responsive === */
@media (max-width: 640px) {
  .app-container { padding: 12px 16px; }
  .results-grid { grid-template-columns: 1fr; }
  .app-logo { font-size: 18px; }
}
