/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --accent: #ff2d55;
  --accent-dark: #cc2244;
  --bg: #0e0e0e;
  --bg2: #1a1a1a;
  --bg3: #242424;
  --text: #f5f5f5;
  --text-muted: #888;
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}

/* ─── Step system ─── */
#app { position: relative; }

.step {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 0 env(safe-area-inset-bottom);
  animation: fadeIn 0.25s ease;
}
.step.active { display: flex; flex-direction: column; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Header ─── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}
.logo-text {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.tagline { font-size: 12px; color: var(--text-muted); }

/* ─── Form card ─── */
.form-card, .pick-card, .share-card {
  flex: 1;
  padding: 20px 20px 32px;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

h1 { font-size: 28px; font-weight: 900; margin-bottom: 6px; }
h2 { font-size: 22px; font-weight: 800; margin-bottom: 16px; }
h3 { font-size: 14px; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
     letter-spacing: 0.08em; margin: 20px 0 10px; }

.subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

/* ─── Fields ─── */
.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.field .hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #555;
  margin-left: 6px;
}
.field input {
  display: block;
  width: 100%;
  background: var(--bg2);
  border: 1.5px solid #2e2e2e;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 14px 16px;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: #444; }

/* ─── Occasion grid ─── */
.occasion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.occasion-btn {
  background: var(--bg2);
  border: 1.5px solid #2e2e2e;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.occasion-btn:last-child { grid-column: 1 / -1; }
.occasion-btn:hover { border-color: #555; background: var(--bg3); }
.occasion-btn.active {
  border-color: var(--accent);
  background: rgba(255, 45, 85, 0.12);
  color: var(--accent);
}

/* ─── Buttons ─── */
.btn-primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 17px;
  font-weight: 800;
  padding: 18px;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-appearance: none;
}
.btn-primary:hover:not(:disabled) { opacity: 0.9; transform: scale(1.01); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary {
  display: inline-block;
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  border-radius: 50px;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 28px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: rgba(255,45,85,0.1); }

.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 0 16px;
  display: block;
}

.free-note {
  text-align: center;
  font-size: 12px;
  color: #444;
  margin-top: 12px;
}

/* ─── Pricing cards ─── */
.pricing-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 4px;
}
.pricing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg2);
  border: 1.5px solid #2e2e2e;
  border-radius: var(--radius);
  padding: 14px 10px 12px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s;
  position: relative;
}
.pricing-card:hover { border-color: #555; background: var(--bg3); transform: translateY(-1px); }
.pricing-card--featured { border-color: var(--accent); }
.pricing-card--featured:hover { border-color: var(--accent); filter: brightness(1.08); }
.pricing-badge {
  position: absolute;
  top: -10px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 20px;
}
.pricing-emoji { font-size: 22px; margin-bottom: 4px; }
.pricing-name { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.pricing-price { font-size: 22px; font-weight: 900; margin: 2px 0; }
.pricing-desc { font-size: 11px; color: var(--text-muted); text-align: center; }

/* ─── Upsell banner (shown on 429) ─── */
.upsell-banner {
  background: rgba(255,45,85,0.08);
  border: 1.5px solid rgba(255,45,85,0.3);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  text-align: center;
}
.upsell-banner.hidden { display: none; }
.upsell-title { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.upsell-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.upsell-actions { display: flex; flex-direction: column; gap: 8px; }
.upsell-btn {
  display: block;
  background: var(--bg3);
  border: 1.5px solid #3a3a3a;
  border-radius: 50px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  text-decoration: none;
  transition: all 0.15s;
}
.upsell-btn:hover { border-color: #666; }
.upsell-btn--main {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.upsell-btn--main:hover { opacity: 0.9; }

/* ─── License key UI ─── */
#license-bar { margin-top: 12px; text-align: center; }

.license-toggle {
  background: none;
  border: none;
  color: #555;
  font-size: 12px;
  cursor: pointer;
  margin-top: 6px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.license-toggle:hover { color: var(--text-muted); }

.license-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.license-form.hidden { display: none; }

.license-form input {
  background: var(--bg2);
  border: 1.5px solid #2e2e2e;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
  letter-spacing: 0.04em;
  padding: 12px 14px;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.15s;
}
.license-form input:focus { border-color: var(--accent); }

.btn-activate {
  background: #1e1e1e;
  border: 1.5px solid #3a3a3a;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-activate:hover { border-color: var(--accent); color: var(--accent); }

.license-error {
  font-size: 12px;
  color: var(--accent);
  text-align: center;
}
.license-error.hidden { display: none; }

.quota-badge {
  display: inline-block;
  background: rgba(52, 199, 89, 0.15);
  border: 1px solid rgba(52, 199, 89, 0.3);
  color: #34c759;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  margin-top: 8px;
}

/* ─── Loading ─── */
#step-loading {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 20px;
}
.loading-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.spinner {
  width: 48px; height: 48px;
  border: 3px solid #2e2e2e;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-main { font-size: 20px; font-weight: 700; }
.loading-sub { font-size: 14px; color: var(--text-muted); }

/* ─── Roast options ─── */
.roast-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.roast-option {
  background: var(--bg2);
  border: 2px solid #2e2e2e;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}
.roast-option:hover { border-color: #555; background: var(--bg3); }
.roast-option.selected {
  border-color: var(--accent);
  background: rgba(255,45,85,0.1);
}

/* ─── Template grid ─── */
.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tmpl-btn {
  background: var(--bg2);
  border: 1.5px solid #2e2e2e;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.tmpl-btn:hover { border-color: #555; background: var(--bg3); }
.tmpl-btn.active {
  border-color: var(--accent);
  background: rgba(255,45,85,0.1);
  color: var(--accent);
}

/* ─── Ratio grid ─── */
.ratio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}
.ratio-btn {
  background: var(--bg2);
  border: 1.5px solid #2e2e2e;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.ratio-btn:hover { border-color: #555; }
.ratio-btn.active {
  border-color: var(--accent);
  background: rgba(255,45,85,0.1);
  color: var(--accent);
}

/* ─── Share step ─── */
.share-intro {
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  padding-top: 12px;
}

.card-preview {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 20px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 32px rgba(255,45,85,0.2);
}
.card-preview img {
  width: 100%;
  display: block;
}

.share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  padding: 14px 10px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  color: #fff;
}
.share-btn:hover { opacity: 0.9; transform: scale(1.02); }
.share-btn:active { transform: scale(0.97); }

.share-btn.whatsapp  { background: #25d366; }
.share-btn.instagram { background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.share-btn.tiktok    { background: #010101; border: 1px solid #333; }
.share-btn.copy      { background: var(--bg3); border: 1px solid #444; color: var(--text); }

.roast-again-cta {
  text-align: center;
  padding-top: 8px;
}
.roast-again-cta p {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* ─── Confetti canvas ─── */
#confetti-container canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ─── Responsive tweaks ─── */
@media (min-width: 480px) {
  .form-card, .pick-card, .share-card { padding: 32px 32px 48px; }
  h1 { font-size: 32px; }
}
