:root {
  --bg: #0b0d14;
  --bg2: #11141f;
  --card: #161a28;
  --card2: #1d2233;
  --line: #262c40;
  --text: #eef0f6;
  --muted: #9aa3b8;
  --p1: #7c5cff;
  --p2: #22d3ee;
  --accent: #f59e0b;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(34, 211, 238, 0.12), transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 1.05rem; margin-top: 22px; color: #dfe3ee; }
h3 { font-size: 0.95rem; margin-top: 14px; color: #dfe3ee; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
code { background: var(--card2); padding: 2px 6px; border-radius: 6px; font-size: 0.85em; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; max-width: 1200px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand b { color: var(--p2); font-weight: 800; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--p1), var(--p2)); display: inline-block; position: relative; }
.logo::after { content: ''; position: absolute; inset: 7px; border: 2.5px solid #fff; border-radius: 4px; border-bottom: none; border-right: none; transform: rotate(45deg) translate(2px, 2px); }
nav { display: flex; gap: 10px; }
.panel { max-width: 1200px; margin: 0 auto; padding: 8px 24px 60px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; } }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card2); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  transition: transform 0.08s, background 0.15s, opacity 0.15s; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { background: #242a3d; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--p1), #5b8def); border: none; color: #fff; box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.accent { background: linear-gradient(135deg, var(--accent), #f97316); border: none; color: #1a1200; }
.btn.accent .muted { color: #3b2a00; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.btn.lg { padding: 14px 22px; font-size: 1.02rem; }
.btn.sm { padding: 7px 12px; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn .cost { font-weight: 500; opacity: 0.85; font-size: 0.9em; }
.pill { display: inline-block; padding: 5px 12px; border-radius: 999px; background: rgba(124, 92, 255, 0.15); color: #c4b5fd; font-size: 0.8rem; font-weight: 600; border: 1px solid rgba(124, 92, 255, 0.35); }

/* ---------- landing ---------- */
.hero { max-width: 1200px; margin: 30px auto 0; padding: 20px 24px; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.4rem); font-weight: 800; letter-spacing: -0.03em; margin: 18px 0 14px; }
.grad { background: linear-gradient(90deg, var(--p1), var(--p2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 1.08rem; max-width: 560px; }
.hero-cta { display: flex; gap: 12px; margin: 22px 0; flex-wrap: wrap; }
.hero-points { list-style: none; padding: 0; margin: 0; color: #cdd3e3; display: grid; gap: 8px; }
.hero-points li::before { content: '✓'; color: var(--ok); font-weight: 800; margin-right: 10px; }
.hero-art { position: relative; height: 420px; }
.card-art { position: absolute; border-radius: 18px; box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, 0.08); overflow: hidden; }
.card-art .chip { position: absolute; left: 14px; bottom: 14px; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(8px); padding: 6px 10px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; }
.card-art.a { width: 56%; height: 70%; left: 0; top: 0; background: linear-gradient(160deg, #e9e4ff, #c7d2fe 60%, #93c5fd); transform: rotate(-4deg); }
.card-art.b { width: 48%; height: 62%; right: 0; top: 10%; background: linear-gradient(160deg, #1f1b2e, #3b2a4f 60%, #0f0c1a); transform: rotate(5deg); }
.card-art.c { width: 44%; height: 42%; left: 28%; bottom: 0; background: linear-gradient(160deg, #0ea5e9, #7c5cff); transform: rotate(-2deg); }
.card-art .play { position: absolute; inset: 0; margin: auto; width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); }
.card-art .play::after { content: ''; position: absolute; left: 22px; top: 17px; border-left: 18px solid #111; border-top: 11px solid transparent; border-bottom: 11px solid transparent; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } .hero-art { height: 300px; } }
.how { max-width: 1200px; margin: 60px auto; padding: 0 24px; }
.how h2 { font-size: 1.6rem; margin-bottom: 20px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .steps { grid-template-columns: repeat(2, 1fr); } }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.step span { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--p1), var(--p2)); font-weight: 800; margin-bottom: 10px; }
.step p { color: var(--muted); margin: 0; font-size: 0.92rem; }
.foot { text-align: center; color: var(--muted); padding: 30px; font-size: 0.85rem; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(5, 7, 12, 0.75); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; width: min(440px, 100%); padding: 26px; position: relative; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.close { position: absolute; right: 12px; top: 10px; background: none; border: none; color: var(--muted); font-size: 1.6rem; cursor: pointer; line-height: 1; }
.form { display: grid; gap: 14px; margin-top: 16px; }
label { display: grid; gap: 6px; font-size: 0.88rem; color: #cdd3e3; font-weight: 500; margin-top: 10px; }
label small { color: var(--muted); font-weight: 400; }
input[type='text'], input[type='email'], input[type='password'], textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text); padding: 11px 12px; border-radius: 10px; font: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--p1); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2); }
textarea { resize: vertical; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; }
.tab { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.tab.active { background: var(--card2); color: var(--text); border-color: var(--line); }
.main-tabs { max-width: 1200px; margin: 6px auto 10px; padding: 0 24px; }
.auth-tabs .tab { flex: 1; }
.small-tabs .tab { padding: 6px 10px; font-size: 0.85rem; }

/* ---------- app header ---------- */
.userbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.credits { display: inline-flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); color: var(--text); padding: 8px 14px; border-radius: 999px; font: inherit; cursor: pointer; }
.credits b { font-size: 1.05rem; }
.coin { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fde68a, var(--accent)); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25); display: inline-block; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--p1), var(--p2)); display: grid; place-items: center; font-weight: 700; font-size: 0.9rem; }
.banner { max-width: 1152px; margin: 8px auto; padding: 12px 16px; border-radius: 12px; font-size: 0.9rem; }
.banner.warn { background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.35); color: #fcd34d; }

/* ---------- dropzone ---------- */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); background: var(--card); min-height: 220px; display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden; transition: border-color 0.15s, background 0.15s; }
.dropzone:hover, .dropzone.over { border-color: var(--p1); background: #181c2c; }
.dropzone.compact { min-height: 64px; margin-top: 10px; }
.dz-empty { text-align: center; padding: 20px; color: var(--muted); }
.dz-empty b { color: var(--text); }
.dz-icon { font-size: 1.8rem; margin-bottom: 6px; }
#upload-preview { max-width: 100%; max-height: 360px; object-fit: contain; display: block; }

/* ---------- choices ---------- */
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.choice { background: var(--card); border: 1px solid var(--line); color: var(--text); padding: 11px 12px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-align: left; line-height: 1.3; }
.choice small { display: block; color: var(--muted); font-weight: 400; font-size: 0.78rem; margin-top: 2px; }
.choice.active { border-color: var(--p1); background: rgba(124, 92, 255, 0.14); box-shadow: 0 0 0 2px rgba(124, 92, 255, 0.25) inset; }
.generate-box { margin-top: 22px; }

/* ---------- results ---------- */
.result { margin-top: 20px; }
.result-media { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; }
.result-media img, .result-media video { max-width: 100%; max-height: 560px; display: block; }
.result-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.progress-box { display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--p2); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- thumbs / gallery ---------- */
.thumb-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.thumb { aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--card); position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.active { border-color: var(--p2); }
.video-ref-preview { margin-top: 12px; }
.video-ref-preview img { max-height: 260px; border-radius: 10px; border: 1px solid var(--line); }
.gallery-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.gcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.gcard .media { aspect-ratio: 1; background: #0e1119; display: grid; place-items: center; cursor: pointer; position: relative; }
.gcard .media img, .gcard .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gcard .media .badge { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, 0.6); padding: 3px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; }
.gcard .media .status { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 10px; }
.gcard .actions { display: flex; gap: 6px; padding: 8px; }
.gcard .actions .btn { flex: 1; padding: 7px 8px; font-size: 0.8rem; }
.lightbox-card { position: relative; max-width: min(1000px, 96vw); }
.lightbox-card img, .lightbox-card video { max-width: 96vw; max-height: 90vh; border-radius: 12px; display: block; }
.lightbox-card .close { right: -4px; top: -36px; }

/* ---------- ad modal ---------- */
.modal.ad { background: rgba(0, 0, 0, 0.92); }
.ad-card { width: min(900px, 100%); background: #000; border-radius: 16px; overflow: hidden; border: 1px solid #222; }
.ad-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #0a0a0a; }
.ad-timer { font-weight: 800; font-variant-numeric: tabular-nums; background: #fff; color: #000; padding: 4px 12px; border-radius: 999px; }
.ad-stage { aspect-ratio: 16 / 9; background: #000; display: grid; place-items: center; }
.ad-stage video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
#ad-adsense { width: 100%; height: 100%; display: grid; place-items: center; }
.ad-fallback { width: 100%; height: 100%; display: grid; place-items: center; background: radial-gradient(700px 400px at 30% 20%, rgba(124, 92, 255, 0.35), transparent 60%), radial-gradient(600px 400px at 80% 90%, rgba(34, 211, 238, 0.3), transparent 60%), #0b0d14; }
.ad-fallback-inner { text-align: center; padding: 24px; }
.ad-fallback-inner .logo.big { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 14px; }
.ad-fallback-inner .logo.big::after { inset: 16px; border-width: 5px; }
.ad-fallback-inner h2 { font-size: 1.6rem; margin: 6px 0; }
.ad-fallback-inner p { color: var(--muted); margin: 4px 0 10px; }
.ad-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; background: #0a0a0a; flex-wrap: wrap; }

/* ---------- ledger / toast ---------- */
.ledger { list-style: none; padding: 0; margin: 10px 0 0; max-height: 50vh; overflow: auto; }
.ledger li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.ledger .plus { color: var(--ok); font-weight: 700; }
.ledger .minus { color: #fca5a5; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2437; border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 12px; z-index: 100; box-shadow: var(--shadow); max-width: 92vw; font-size: 0.92rem; }
.toast.err { border-color: rgba(239, 68, 68, 0.5); background: #2a1619; }
.toast.ok { border-color: rgba(34, 197, 94, 0.5); background: #15261b; }
