:root {
  --bg: #0b0d14;
  --bg-2: #11141f;
  --panel: #161a28;
  --panel-2: #1c2132;
  --line: #262c40;
  --text: #e9ecf5;
  --muted: #9aa3bd;
  --brand: #7c6cff;
  --brand-2: #4bc6ff;
  --accent: #ff7ac6;
  --good: #3ad29f;
  --bad: #ff6b6b;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, .45);
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* the hidden attribute must win over any display rule below (modals, panes, previews) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

body {
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(124, 108, 255, .22), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(75, 198, 255, .14), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .6rem 1.1rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  background: var(--panel-2);
  color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(124, 108, 255, .35);
}
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, .04); }
.btn-lg { padding: .85rem 1.6rem; font-size: 1.05rem; }
.btn-sm { padding: .4rem .8rem; font-size: .85rem; }
.btn-block { width: 100%; }

.cost-tag {
  font-size: .72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, .18);
  padding: .12rem .5rem;
  border-radius: 999px;
}

/* ---------- brand / nav ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.01em;
}
.brand-mark {
  color: var(--brand-2);
  filter: drop-shadow(0 0 10px rgba(75, 198, 255, .6));
}
.brand-top { position: fixed; top: 1.4rem; left: 1.6rem; }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.3rem clamp(1rem, 5vw, 4rem);
  max-width: 1200px;
  margin: 0 auto;
}
.nav-links { display: flex; align-items: center; gap: 1.4rem; }
.nav-links a { color: var(--muted); font-weight: 500; }
.nav-links a.btn { color: inherit; }
.nav-links a:hover { color: var(--text); }

/* ---------- hero ---------- */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 6rem) clamp(1rem, 5vw, 4rem) 3rem;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 3rem;
  align-items: center;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .78rem;
  color: var(--brand-2);
  margin: 0 0 1rem;
  font-weight: 700;
}
.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.05;
  margin: 0 0 1.2rem;
  letter-spacing: -.02em;
}
.grad {
  background: linear-gradient(120deg, var(--brand-2), var(--brand), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { font-size: 1.15rem; color: var(--muted); max-width: 32rem; margin: 0 0 2rem; }
.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; }
.hero-note { color: var(--muted); font-size: .9rem; margin-top: 1.2rem; }

.hero-art { position: relative; height: 340px; }
.art-card {
  position: absolute;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  font-weight: 700;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-end;
}
.art-1 {
  inset: 0 30% 35% 0;
  background: linear-gradient(135deg, #2a2350, #1a2440);
}
.art-2 {
  inset: 42% 0 0 34%;
  background: linear-gradient(135deg, #16324a, #241a3f);
}
.art-glow {
  position: absolute;
  inset: 10% 20% 20% 10%;
  background: radial-gradient(circle, rgba(124, 108, 255, .5), transparent 70%);
  filter: blur(40px);
  z-index: -1;
}

/* ---------- features ---------- */
.features {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 5vw, 4rem);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.4rem;
}
.feature {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
}
.feature-icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-size: 1.3rem; margin-bottom: 1rem;
}
.feature h3 { margin: 0 0 .5rem; }
.feature p { color: var(--muted); margin: 0; }

/* ---------- how / pricing ---------- */
.how, .pricing {
  max-width: 1000px;
  margin: 0 auto;
  padding: 3rem clamp(1rem, 5vw, 4rem);
  text-align: center;
}
.how h2, .pricing h2 { font-size: 2rem; margin: 0 0 1.6rem; }
.steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.steps li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  text-align: left;
  color: var(--muted);
}
.steps span {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--panel-2); color: var(--brand-2);
  font-weight: 800; margin-right: .6rem;
}
.pricing-sub { color: var(--muted); margin: -1rem 0 2rem; }
.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.price-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.8rem 1.2rem;
}
.price-card.accent {
  border-color: var(--brand);
  background: linear-gradient(160deg, rgba(124, 108, 255, .16), var(--panel));
}
.price-card h3 { margin: 0 0 .6rem; font-size: 1.05rem; color: var(--muted); }
.price-num { font-size: 2.4rem; font-weight: 800; margin: 0; }
.price-num span { font-size: .9rem; color: var(--muted); font-weight: 600; margin-left: .35rem; }
.price-card p:last-child { color: var(--muted); margin: .2rem 0 0; }
.pricing-cta { margin-top: 2.4rem; }

/* ---------- footer ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  font-size: .9rem;
}

/* ---------- auth ---------- */
.auth { display: grid; place-items: center; min-height: 100vh; }
.auth-wrap { width: min(420px, 92vw); }
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-tabs { display: flex; background: var(--bg-2); border-radius: 999px; padding: .3rem; margin-bottom: 1.6rem; }
.auth-tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: .6rem; border-radius: 999px; font-weight: 600; cursor: pointer;
}
.auth-tab.active { background: var(--panel-2); color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label, .field { display: flex; flex-direction: column; gap: .45rem; font-size: .9rem; color: var(--muted); }
.auth-form input, .field textarea, .field select, .field input, #redeem-input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem .9rem;
  color: var(--text);
  font: inherit;
  width: 100%;
}
.auth-form input:focus, .field textarea:focus, .field select:focus, #redeem-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, .22);
}
.auth-error { color: var(--bad); font-size: .85rem; margin: 0; min-height: 1.1em; }
.auth-switch { text-align: center; color: var(--muted); margin: 1.2rem 0 0; font-size: .9rem; }
.auth-switch a { color: var(--brand-2); }
.auth-note { color: var(--muted); font-size: .78rem; text-align: center; margin: 1.4rem 0 0; opacity: .8; }

/* ---------- studio ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem clamp(1rem, 4vw, 2.4rem);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 20, .7);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-right { display: flex; align-items: center; gap: .9rem; }
.credits-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: .4rem .9rem; border-radius: 999px; font-weight: 700; font-size: .9rem;
}
.credits-dot { color: var(--accent); }
.user-email { color: var(--muted); font-size: .85rem; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.studio-grid {
  max-width: 1200px; margin: 1.4rem auto 0; padding: 0 clamp(1rem, 4vw, 2.4rem);
  display: grid; grid-template-columns: 380px 1fr; gap: 1.4rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
}
.controls { align-self: start; position: sticky; top: 90px; }
.mode-tabs { display: flex; background: var(--bg-2); border-radius: 999px; padding: .3rem; margin-bottom: 1.3rem; }
.mode-tab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: .6rem; border-radius: 999px; font-weight: 600; cursor: pointer; }
.mode-tab.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.mode-pane { display: flex; flex-direction: column; gap: 1.1rem; }
.field span { font-weight: 600; }
.controls-note { color: var(--muted); font-size: .78rem; margin: 1.2rem 0 0; opacity: .85; }

.source-box {
  border: 1px dashed var(--line); border-radius: 12px; padding: 1rem; text-align: center;
  background: var(--bg-2);
}
.source-preview { width: 100%; border-radius: 10px; margin-bottom: .8rem; display: block; }
.source-empty { color: var(--muted); font-size: .85rem; margin: 0 0 .9rem; }
.source-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }

.stage { min-height: 420px; display: flex; flex-direction: column; }
.stage-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.stage-head h2 { margin: 0; font-size: 1.15rem; }
.stage-status { color: var(--muted); font-size: .85rem; }
.stage-status.busy { color: var(--brand-2); }
.stage-status.bad { color: var(--bad); }
.stage-body { flex: 1; display: grid; place-items: center; }
.stage-empty { text-align: center; color: var(--muted); }
.stage-empty-art { font-size: 2.6rem; color: var(--brand); margin-bottom: .6rem; opacity: .7; }
.stage-media { max-width: 100%; max-height: 70vh; border-radius: 12px; box-shadow: var(--shadow); }
.stage-actions { margin-top: 1rem; display: flex; gap: .7rem; flex-wrap: wrap; justify-content: center; }

.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand-2);
  animation: spin 1s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.history-section { max-width: 1200px; margin: 1.4rem auto 3rem; }
.history-section h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; }
.history-item {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--line); cursor: pointer;
}
.history-item img, .history-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.history-item .tag {
  position: absolute; top: .4rem; left: .4rem;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: .68rem;
  padding: .1rem .45rem; border-radius: 999px; font-weight: 700;
}
.history-item.pending { display: grid; place-items: center; color: var(--muted); font-size: .8rem; }

/* ---------- modal + toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(5, 6, 12, .7); display: grid; place-items: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 1.8rem; width: min(400px, 92vw); box-shadow: var(--shadow); }
.modal-card h3 { margin: 0 0 .4rem; }
.modal-sub { color: var(--muted); margin: 0 0 1.2rem; font-size: .9rem; }
.modal-card form { display: flex; flex-direction: column; gap: 1rem; }
.modal-actions { display: flex; gap: .7rem; justify-content: flex-end; margin-top: 1.2rem; }

.redeem-block + .redeem-block { margin-top: 1.4rem; }
.redeem-divider {
  display: flex; align-items: center; gap: .8rem;
  color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em;
  margin: 0 0 1rem;
}
.redeem-divider::before, .redeem-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.rw-hint { color: var(--brand-2); font-size: .82rem; margin: 0; min-height: 1.1em; }
.rw-steps { color: var(--muted); font-size: .9rem; margin: 0 0 .5rem; padding-left: 1.2rem; line-height: 1.5; }
.rw-steps li + li { margin-top: .25rem; }
.rw-buy { color: var(--brand-2); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.rw-buy:hover { color: var(--text); }
.rw-note { color: var(--muted); font-size: .8rem; margin: 0 0 1rem; }
#rewarble-code { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .9rem; color: var(--text); font: inherit; width: 100%; }
#rewarble-code:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124, 108, 255, .22); }

.toast {
  position: fixed; bottom: 1.6rem; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: .8rem 1.3rem; border-radius: 999px; box-shadow: var(--shadow);
  z-index: 60; font-weight: 600;
}
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .features, .steps, .price-grid { grid-template-columns: 1fr; }
  .studio-grid { grid-template-columns: 1fr; }
  .controls { position: static; }
  .user-email { display: none; }
}
