:root {
  --bg-deep:      #14101c;
  --bg-panel:     #1f1830;
  --bg-card:      #2b2342;
  --purple:       #6a3fd1;
  --purple-dim:   #4a3580;
  --gold:         #e8b339;
  --text:         #f1edf9;
  --text-dim:     #a89bc4;
  --green:        #3fae5c;
  --red:          #d14f4f;
  --font-display: 'Segoe UI Semibold', 'Segoe UI', system-ui, sans-serif;
  --font-body:    'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ─────────────────────────────────────────────── */
.top-bar {
  background: var(--bg-panel);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #352a52;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--gold);
}
.btn-ghost {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.btn-ghost:hover { color: var(--text); border-color: var(--purple); }

/* ── Step indicator ─────────────────────────────────────────────── */
.step-bar {
  background: linear-gradient(135deg, var(--purple) 0%, #4a2a8c 100%);
  padding: 16px 24px 14px;
  border-bottom: 3px solid var(--gold);
}
.step-bar h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  text-align: center;
}
.step-dots { display: flex; justify-content: center; gap: 10px; }
.step-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: all 0.2s;
}
.step-dot.active { background: var(--gold); transform: scale(1.3); }
.step-dot.done    { background: rgba(255,255,255,0.7); }

/* ── Screen area ─────────────────────────────────────────────── */
.screen-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.screen-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 0 6px;
  text-align: center;
}
.screen-subtitle {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 0 0 26px;
  text-align: center;
  max-width: 480px;
}

/* ── Welcome / capture screen ───────────────────────────────────── */
.capture-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
}
.big-btn {
  background: var(--bg-card);
  border: 2px solid var(--purple-dim);
  color: var(--text);
  border-radius: 14px;
  padding: 26px 30px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  font-family: var(--font-body);
}
.big-btn .icon { font-size: 2rem; }
.big-btn:hover { border-color: var(--purple); transform: translateY(-2px); }
.big-btn.primary { border-color: var(--gold); background: linear-gradient(135deg, var(--bg-card), #3a2d1a); }

#cameraVideo, #capturedPreview {
  width: 100%;
  max-width: 480px;
  border-radius: 14px;
  background: #000;
  border: 2px solid var(--purple-dim);
}
.camera-wrap { position: relative; width: 100%; max-width: 480px; }
.camera-controls {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap;
}
.shutter-btn {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: white;
  border: 4px solid var(--gold);
  cursor: pointer;
}
.shutter-btn:hover { background: #f2f2f2; }

/* ── Quick-pick / style thumbnail grids ─────────────────────────── */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}
@media (max-width: 700px) { .thumb-grid { grid-template-columns: repeat(2, 1fr); } }
.thumb-card {
  background: var(--bg-card);
  border: 2px solid #3d3160;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.12s;
}
.thumb-card:hover { border-color: var(--purple); transform: translateY(-2px); }
.thumb-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.thumb-img {
  width: 100%; aspect-ratio: 1;
  background: #100c18;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 0.74rem; text-align: center; padding: 8px;
}
.thumb-img img { width: 100%; height: 100%; object-fit: cover; }
.thumb-label { padding: 10px 8px; text-align: center; font-size: 0.9rem; font-weight: 600; }

/* 3x3 quick-pick grid — 8 styles + 1 "Customize" tile */
.quick-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) { .quick-grid { grid-template-columns: repeat(2, 1fr); } }
.thumb-card.customize-card {
  border-style: dashed;
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--bg-card), #3a2d1a);
  display: flex;
  flex-direction: column;
}
.thumb-card.customize-card .thumb-img {
  font-size: 2rem;
  background: transparent;
}
.thumb-card.customize-card .thumb-label { color: var(--gold); }

/* ── Option grids (wizard buttons) ──────────────────────────────── */
.options-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
@media (max-width: 700px) { .options-grid { grid-template-columns: repeat(2, 1fr); } }
.opt-btn {
  background: var(--bg-card);
  border: 2px solid #3d3160;
  color: var(--text);
  border-radius: 10px;
  padding: 22px 12px;
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  min-height: 76px;
  text-align: center;
  font-family: var(--font-body);
}
.opt-btn:hover { border-color: var(--purple); transform: translateY(-1px); }
.opt-btn.selected { background: var(--purple); border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.opt-btn.highlight { border-color: var(--gold); background: linear-gradient(135deg, var(--bg-card), #3a2d1a); }
.opt-btn.highlight::after {
  content: "✨ Suggested"; display: block; font-size: 0.7rem;
  color: var(--gold); margin-top: 4px; font-weight: 700;
}

/* ── Text input page ─────────────────────────────────────────────── */
.text-input-wrap { width: 100%; max-width: 480px; }
.text-input-wrap input {
  width: 100%; background: var(--bg-card); border: 2px solid #3d3160;
  color: var(--text); border-radius: 10px; padding: 16px; font-size: 1.05rem; text-align: center;
}
.text-input-wrap input::placeholder { color: var(--text-dim); }
.text-input-wrap input:focus { outline: none; border-color: var(--purple); }

.skip-link {
  margin-top: 18px; color: var(--text-dim); font-size: 0.88rem; text-decoration: underline; cursor: pointer;
}
.skip-link:hover { color: var(--text); }

/* ── Nav bar ─────────────────────────────────────────────────────── */
.nav-bar {
  background: var(--bg-panel);
  border-top: 1px solid #352a52;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.nav-btn {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  border: none; border-radius: 8px; padding: 14px 28px; cursor: pointer; transition: all 0.15s;
}
.nav-btn.back { background: transparent; border: 1px solid var(--purple-dim); color: var(--text-dim); }
.nav-btn.back:hover { border-color: var(--purple); color: var(--text); }
.nav-btn.next { background: #555; color: #999; cursor: not-allowed; }
.nav-btn.next.ready { background: var(--green); color: white; cursor: pointer; }
.nav-btn.next.ready:hover { background: #4cc56f; }
.nav-btn.create { background: var(--gold); color: #2a1f00; }
.nav-btn.create:hover { background: #f5c34f; }
.nav-center { color: var(--text-dim); font-size: 0.84rem; }

/* ── Processing screen ───────────────────────────────────────────── */
.spinner {
  width: 56px; height: 56px;
  border: 5px solid var(--purple-dim);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result screen ───────────────────────────────────────────────── */
.result-image-wrap {
  width: 100%; max-width: 480px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--gold);
  margin-bottom: 20px;
}
.result-image-wrap img { width: 100%; display: block; }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.error-box {
  background: rgba(209,79,79,0.12);
  border: 1px solid var(--red);
  color: #ffb3b3;
  border-radius: 10px;
  padding: 16px 20px;
  max-width: 480px;
  text-align: center;
}

/* ── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--green); color: white;
  padding: 12px 20px; border-radius: 8px; font-size: 0.9rem; font-weight: 600;
  opacity: 0; transform: translateY(10px); transition: all 0.25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
