:root {
  --bg: #0b0a12;
  --surface: #15131f;
  --surface-2: #1d1a2a;
  --border: #2b2740;
  --text: #f4f2fb;
  --muted: #a7a3bf;
  --accent: #ff3d6e;
  --accent-2: #ff9f1c;
  --violet: #8b6cff;
  --ok: #22c55e;
  --err: #ff5470;
  --grad: linear-gradient(100deg, var(--accent), var(--accent-2));
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background-image: radial-gradient(900px 500px at 85% -10%, rgba(255, 61, 110, 0.12), transparent 60%), radial-gradient(700px 400px at -10% 10%, rgba(139, 108, 255, 0.12), transparent 60%);
  background-repeat: no-repeat;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* nav */
.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px max(16px, calc((100vw - 1240px) / 2)); position: sticky; top: 0; z-index: 30; background: rgba(11, 10, 18, 0.82); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.logo { font-weight: 800; font-size: 20px; text-decoration: none; display: flex; align-items: center; gap: 8px; letter-spacing: -0.02em; white-space: nowrap; }
.logo b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--grad); color: #fff; font-size: 13px; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); font-weight: 600; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ' ▾'; color: var(--muted); }
.menu-list { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 6px; min-width: 230px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); }
.menu-list a { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; }
.menu-list a:hover, .menu-list a[aria-current] { background: var(--surface-2); }

main { padding: 0 16px; }

/* buttons + fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 700; cursor: pointer; text-decoration: none; transition: transform 0.12s, background 0.15s, opacity 0.15s; }
.btn:hover:not(:disabled) { background: #26223a; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 8px 28px rgba(255, 61, 110, 0.35); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--grad); }
.btn.big { width: 100%; padding: 16px 20px; font-size: 18px; border-radius: 14px; }
.btn.ghost { background: transparent; }
.btn.pulse { animation: pulse 2s infinite; }
.btn.busy { background: var(--surface-2); box-shadow: none; }
@keyframes pulse { 0%, 100% { box-shadow: 0 8px 28px rgba(255, 61, 110, 0.35); } 50% { box-shadow: 0 8px 40px rgba(255, 159, 28, 0.6); } }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field > span output { color: var(--text); text-transform: none; margin-left: 4px; }
input[type=text], input[type=url], input[type=number], input:not([type]), select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; font-size: 16px;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--violet); outline: none; box-shadow: 0 0 0 3px rgba(139, 108, 255, 0.25); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1 1 180px; }
.row.small { align-items: center; }
.row .btn { margin-bottom: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.checks { gap: 22px; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); font-weight: 600; font-size: 14px; cursor: pointer; }
.chip[aria-checked=true] { background: var(--text); color: var(--bg); border-color: var(--text); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatch[aria-pressed=true] { box-shadow: 0 0 0 3px var(--text); }

.tabs { display: flex; gap: 6px; background: var(--bg); padding: 5px; border-radius: 14px; border: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { flex: 1; white-space: nowrap; padding: 9px 12px; border-radius: 10px; border: 0; background: transparent; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected=true] { background: var(--surface-2); color: var(--text); }
.tab-panel { margin-bottom: 14px; }

/* studio */
.studio { max-width: 1240px; margin: 24px auto; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.panel { min-width: 0; }
.intro { margin-bottom: 18px; }
.eyebrow { color: var(--accent-2); font-weight: 700; font-size: 14px; margin: 0 0 8px; }
.intro h1 { font-size: clamp(30px, 4vw, 44px); font-weight: 900; }
.lede { color: var(--muted); font-size: 17px; margin: 0; max-width: 62ch; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 6px; margin-bottom: 14px; }
.step h2 { font-size: 18px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.num { width: 28px; height: 28px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; font-size: 14px; font-weight: 800; color: #fff; flex: none; }
#generate { margin: 0; }
.toolbar { max-width: 1240px; margin: 16px auto 0; display: flex; align-items: center; gap: 12px; }
.back { flex: none; text-decoration: none; font-weight: 800; padding: 9px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.back:hover { border-color: var(--accent); }
.switcher { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.switcher::-webkit-scrollbar { display: none; }
.switcher a { flex: none; text-decoration: none; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border); font-weight: 600; font-size: 14px; color: var(--muted); }
.switcher a[aria-current] { color: var(--text); border-color: var(--accent); background: rgba(255, 61, 110, 0.12); }
.hero-input { background: var(--bg); border: 2px solid var(--accent); border-radius: 16px; padding: 14px; margin-bottom: 4px; }
.hero-input label { display: block; margin-bottom: 8px; font-size: 17px; }
.row.tight { gap: 8px; align-items: center; flex-wrap: nowrap; margin-bottom: 14px; }
.row.tight.wrap { flex-wrap: wrap; }
.row.tight .btn { margin: 0; }
.row.tight input { flex: 1; min-width: 0; }
.row.tight select { width: auto; flex: 1 1 140px; }
.hero-input .row.tight { margin: 0; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 700; margin: 14px 0; font-size: 13px; text-transform: uppercase; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
textarea.big { min-height: 180px; font-size: 17px; }
details.more { margin-bottom: 12px; }
details.more summary { cursor: pointer; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
details.extras > summary { list-style: none; cursor: pointer; }
details.extras > summary::-webkit-details-marker { display: none; }
details.extras > summary h2::after { content: '▾'; margin-left: auto; color: var(--muted); font-size: 14px; }
.mbar { display: none; }
.hero-form { display: flex; gap: 10px; max-width: 680px; margin: 0 auto 12px; }
.hero-form input { flex: 1; min-width: 0; font-size: 18px; padding: 16px 18px; border-radius: 14px; border: 2px solid var(--accent); background: var(--bg); }
.hero-form .btn { width: auto; white-space: nowrap; }
.section-title { text-align: center; font-size: 28px; margin: 40px 0 22px; }
.feature { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 18px; max-width: 980px; margin: 0 auto; }
.feature-thumb { display: block; aspect-ratio: 9 / 16; border-radius: 16px; overflow: hidden; background: #120f1c; }
.feature-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.feature h2 { font-size: clamp(26px, 4vw, 38px); margin-bottom: 8px; }
.feature-body > p { color: var(--muted); }
.feature .hero-form { margin: 18px 0 10px; max-width: none; }
@media (max-width: 700px) { .feature { grid-template-columns: 1fr; } .feature-thumb { max-width: 220px; margin: 0 auto; } }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-bottom: 14px; }
.bg-tile { position: relative; border: 2px solid var(--border); border-radius: 12px; padding: 0; overflow: hidden; background: var(--bg); cursor: pointer; aspect-ratio: 9 / 16; display: block; }
.bg-tile img, .bg-tile .tile-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-tile .tile-video { z-index: 1; }
.bg-tile span { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; padding: 18px 4px 6px; font-size: 12px; font-weight: 800; text-align: center; background: linear-gradient(transparent, rgba(0, 0, 0, 0.85)); }
.bg-tile[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.bg-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.bg-mode { padding: 14px 10px; border-radius: 14px; border: 2px solid var(--border); background: var(--bg); font-weight: 800; cursor: pointer; font-size: 15px; }
.bg-mode[aria-selected=true] { border-color: var(--accent); background: rgba(255, 61, 110, 0.12); }
.bg-group { margin: 4px 0 8px; font-weight: 800; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 28px 16px; border: 2px dashed var(--border); border-radius: 16px; cursor: pointer; margin-bottom: 14px; }
.dropzone:hover { border-color: var(--accent); }
.dz-ico { font-size: 36px; }
.dz-sub { color: var(--muted); font-size: 14px; max-width: 40ch; }
.dz-file { color: var(--ok); font-weight: 700; }

.preview-col { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 12px; }
.studio { margin-top: 16px; }
.phone { position: relative; border-radius: 28px; overflow: hidden; background: #000; border: 6px solid #1f1c2c; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55); }
.phone canvas { width: 100%; aspect-ratio: 9 / 16; display: block; cursor: pointer; }
.big-play { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 76px; height: 76px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.92); color: #111; font-size: 28px; cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 26px 12px 10px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)); }
.controls .play { border: 0; background: none; font-size: 18px; cursor: pointer; width: 28px; }
.controls .scrub { flex: 1; height: 20px; }
.controls .time { font-size: 12px; font-variant-numeric: tabular-nums; color: #ddd; white-space: nowrap; }
.progress .bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--grad); transition: width 0.2s; }
.progress .txt { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.after { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.after .btn { width: 100%; }

/* toasts */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(92vw, 440px); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); font-weight: 600; transition: opacity 0.4s, transform 0.4s; }
.toast.ok { border-color: var(--ok); }
.toast.error { border-color: var(--err); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* content */
.content { max-width: 900px; margin: 40px auto; }
.content h2 { font-size: 26px; margin-top: 1.6em; }
.how { padding-left: 22px; color: var(--muted); }
.how li { margin-bottom: 8px; }
.faq { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); }
.faq summary { font-weight: 700; cursor: pointer; }
.faq p { color: var(--muted); margin: 10px 0 0; }
.legal { max-width: 760px; }
.legal p { color: var(--muted); }

/* home */
.hero { max-width: 900px; margin: 0 auto; text-align: center; padding: 60px 0 36px; }
.hero h1 { font-size: clamp(38px, 7vw, 76px); font-weight: 900; letter-spacing: -0.04em; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lede { margin: 0 auto 28px; font-size: 19px; }
.hero .btn { width: auto; display: inline-flex; padding: 16px 30px; }
.formats { max-width: 1240px; margin: 0 auto; }
.format-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.format-grid.small { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.format-card { text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 10px 10px 16px; transition: transform 0.18s, border-color 0.18s; display: block; }
.format-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.format-card .thumb { position: relative; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; background: linear-gradient(160deg, #241f38, #120f1c); margin-bottom: 12px; }
.format-card video { width: 100%; height: 100%; object-fit: cover; display: block; }
.format-card .emoji { position: absolute; top: 10px; left: 10px; font-size: 22px; background: rgba(0, 0, 0, 0.5); border-radius: 10px; padding: 2px 7px; }
.format-card h3 { font-size: 18px; margin: 0 6px 4px; }
.format-card p { color: var(--muted); font-size: 14px; margin: 0 6px; }
.format-grid.small .format-card p { display: none; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.features > div { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.features h3 { font-size: 16px; }
.features p { color: var(--muted); margin: 0; font-size: 14px; }

.foot { border-top: 1px solid var(--border); margin-top: 40px; padding: 30px 16px 40px; text-align: center; color: var(--muted); font-size: 14px; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-bottom: 12px; }
.foot-links a { text-decoration: none; }
.foot-links a:hover { color: var(--text); }
.ad-slot:empty { display: none; }
.ad-slot { display: flex; justify-content: center; margin: 20px auto; max-width: 100%; overflow: hidden; }

@media (max-width: 900px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; max-width: 420px; width: 100%; margin: 0 auto; }
  .preview-col #generate { display: none; }
  .mbar { display: flex; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(11, 10, 18, 0.92); backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
  .mbar .btn { flex: 1; padding: 14px; font-size: 16px; }
  .mbar .mb-dl:not(:disabled) { background: var(--ok); color: #04210f; border: 0; }
  body:has(.mbar) .foot { padding-bottom: 110px; }
  .hero-form { flex-direction: column; }
  .hero-form .btn { width: 100%; }
}
@media (max-width: 520px) {
  .step { padding: 14px 14px 4px; }
  .hero { padding-top: 40px; }
  .format-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .format-card p { display: none; }
  .format-card h3 { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { .btn.pulse { animation: none; } * { scroll-behavior: auto !important; } }
.ai-wide { width: 100%; padding: 14px; margin-bottom: 18px; font-size: 16px; border-style: dashed; }
.link-status { margin: 8px 2px 0; font-size: 14px; font-weight: 600; color: var(--muted); min-height: 0; }
.link-status:empty { display: none; }
.link-status.ok { color: var(--ok); }
.link-status.err { color: var(--err); }
@media (max-width: 900px) { #toasts { bottom: calc(96px + env(safe-area-inset-bottom)); } }
.gen-error { background: rgba(255, 84, 112, 0.12); border: 1px solid var(--err); color: #ffc2cc; border-radius: 12px; padding: 10px 14px; font-weight: 700; margin: 0 0 14px; }
.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.mode-card { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 14px; border: 2px solid var(--border); background: var(--bg); cursor: pointer; }
.mode-card b { font-size: 15px; }
.mode-card span { color: var(--muted); font-size: 13px; line-height: 1.35; }
.mode-card[aria-selected=true] { border-color: var(--accent); background: rgba(255, 61, 110, 0.12); }
@media (max-width: 700px) { .mode-cards { grid-template-columns: 1fr; } }
.mode-cards.two { grid-template-columns: 1fr 1fr; }
.ai-wide.primary { border-style: solid; }
@media (max-width: 700px) { .mode-cards.two { grid-template-columns: 1fr 1fr; } .mode-card span { display: none; } }
.ad-slot { flex-direction: column; align-items: center; }
.ad-gutter { position: fixed; top: 110px; z-index: 5; }
.ad-gutter.left { left: max(8px, calc((100vw - 1240px) / 2 - 184px)); }
.ad-gutter.right { right: max(8px, calc((100vw - 1240px) / 2 - 184px)); }
.ad-native { margin-top: 30px; }
#export.dl:not(:disabled), .mbar .mb-dl:not(:disabled) { background: var(--ok); color: #04210f; border: 0; box-shadow: 0 8px 26px rgba(34, 197, 94, 0.35); }
#export.dl:disabled { opacity: 0.45; }
.btn.save, .mbar .mb-dl.save { background: #0a84ff; color: #fff; border: 0; box-shadow: 0 8px 26px rgba(10, 132, 255, 0.35); }
.own-clip { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; border: 1px dashed var(--border); border-radius: 14px; background: var(--bg); }
.own-clip span { color: var(--muted); font-size: 14px; }
.own-clip b { color: var(--text); }
.own-clip .btn { margin: 0; }
.progress .bar.working .fill { background-image: linear-gradient(115deg, rgba(255,255,255,0.28) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.28) 50%, rgba(255,255,255,0.28) 75%, transparent 75%), var(--grad); background-size: 28px 28px, auto; animation: stripes 0.8s linear infinite; }
@keyframes stripes { to { background-position: 28px 0, 0 0; } }
.progress .fill { transition: width 0.15s linear; }
#gen-progress { margin-top: -4px; }
.mbar-progress { position: absolute; left: 0; right: 0; top: 0; height: 4px; background: transparent; opacity: 0; transition: opacity 0.3s; }
.mbar-progress.on { opacity: 1; }
.mbar-progress .mfill { height: 100%; width: 0; background: var(--grad); transition: width 0.15s linear; }
