/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface-2: #1c1c26;
  --border: #2a2a3a;
  --accent: #7c3aed;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --accent-2: #06b6d4;
  --text: #f1f1f5;
  --text-muted: #8888aa;
  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.2s ease;
}

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

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  text-align: center;
  padding: 48px 0 40px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-glow);
  border: 1px solid rgba(124,58,237,0.4);
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 20px;
}

.header h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, #c4b5fd 50%, #06b6d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.header p {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Form Card ────────────────────────────────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  margin-bottom: 32px;
}

.form-section {
  margin-bottom: 28px;
}

.form-section:last-child { margin-bottom: 0; }

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

label span.required { color: #f87171; margin-left: 2px; }

input[type="text"],
input[type="url"],
textarea,
select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  font-family: inherit;
}

input[type="text"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { resize: vertical; min-height: 80px; }

select option { background: var(--surface-2); }

/* ── Color pickers ────────────────────────────────────────────────────────── */
.color-row {
  display: flex;
  gap: 16px;
}

.color-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
}

input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  background: none;
}

.color-hex {
  font-size: 13px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Typography selector ──────────────────────────────────────────────────── */
.typo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.typo-option {
  position: relative;
}

.typo-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.typo-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}

.typo-option input:checked + label {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.typo-preview {
  font-size: 18px;
  line-height: 1;
  color: var(--text);
}

.typo-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Photo upload ─────────────────────────────────────────────────────────── */
.photo-upload {
  display: flex;
  align-items: center;
  gap: 16px;
}

.photo-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 28px;
  color: var(--text-muted);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-upload-label {
  flex: 1;
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--transition);
}

.btn-upload:hover { border-color: var(--accent); }

.photo-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

#photoInput { display: none; }

/* ── Submit button ────────────────────────────────────────────────────────── */
.btn-generate {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  margin-top: 8px;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 24px var(--accent-glow);
}

.btn-generate:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 8px 32px var(--accent-glow);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Loading ──────────────────────────────────────────────────────────────── */
#loadingSection {
  display: none;
  text-align: center;
  padding: 80px 20px;
}

.progress-wrap {
  max-width: 440px;
  margin: 0 auto;
}

.progress-label {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 20px;
  font-weight: 500;
  min-height: 24px;
  transition: opacity 0.3s ease;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 0.4s ease;
}

.progress-pct {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Results section ──────────────────────────────────────────────────────── */
#resultsSection { display: none; }

.results-header {
  text-align: center;
  margin-bottom: 32px;
}

.results-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.results-header p { color: var(--text-muted); font-size: 14px; }

.versions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.version-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition);
}

.version-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 32px var(--accent-glow);
}

.version-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.version-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
}

.v1 .version-tag { background: rgba(124,58,237,0.2); color: #c4b5fd; }
.v2 .version-tag { background: rgba(6,182,212,0.15); color: #67e8f9; }

.btn-select {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-select:hover,
.version-card.selected .btn-select {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Slides strip ─────────────────────────────────────────────────────────── */
.slides-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.slides-strip::-webkit-scrollbar { height: 4px; }
.slides-strip::-webkit-scrollbar-track { background: transparent; }
.slides-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.slide-thumb {
  flex-shrink: 0;
  width: 180px;
  height: 180px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}

.slide-thumb:hover { transform: scale(1.03); border-color: var(--accent); }

.slide-thumb canvas { display: block; }

/* ── Analysis panel ───────────────────────────────────────────────────────── */
.analysis-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.analysis-panel h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 16px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.analysis-item {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px;
}

.analysis-item-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.analysis-item-value {
  font-size: 13px;
  color: var(--text);
}

/* ── Corrections & actions ────────────────────────────────────────────────── */
#actionsSection { display: none; }

.actions-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
}

.actions-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.actions-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

#correctionsInput {
  min-height: 100px;
  margin-bottom: 12px;
}

.actions-row {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  flex: 1;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition);
}

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

.btn-download {
  flex: 2;
  padding: 12px;
  background: linear-gradient(135deg, #059669, #047857);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity var(--transition);
  box-shadow: 0 4px 16px rgba(5,150,105,0.3);
}

.btn-download:hover { opacity: 0.9; }
.btn-download:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Error toast ──────────────────────────────────────────────────────────── */
.error-toast {
  display: none;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: var(--radius);
  color: #fca5a5;
  padding: 14px 18px;
  font-size: 14px;
  margin-bottom: 20px;
}

/* ── Slide modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  max-width: 90vmin;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 13px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .typo-grid { grid-template-columns: repeat(3, 1fr); }
  .versions-grid { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr 1fr; }
  .form-card { padding: 20px; }
  .actions-row { flex-direction: column; }
}
