:root {
  --bg: #f5f6fb; --bg2: #eceef8; --card: #ffffff; --text: #1a1c28; --muted: #6a7086; --border: #e1e4f0;
  --accent: #6c4cff; --accent2: #b44cff; --accent-soft: #efeaff; --ok: #12a150; --warn: #b7791f; --warn-bg: #fff6df;
  --danger: #d64545; --shadow: 0 1px 2px rgba(20,22,40,.05), 0 8px 24px rgba(20,22,40,.06);
  --r: 14px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1017; --bg2: #151722; --card: #1a1c28; --text: #eceef7; --muted: #9096ad; --border: #2a2d3f;
    --accent: #8b73ff; --accent2: #c471ff; --accent-soft: #272248; --warn: #ffd37a; --warn-bg: #3a3016;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); color: var(--text); line-height: 1.5;
  background: radial-gradient(900px 380px at 50% -120px, var(--accent-soft), transparent), var(--bg); min-height: 100vh; }
main { max-width: 1120px; margin: 0 auto; padding: 8px 20px 48px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 18px; display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
h3 { font-size: 14px; margin: 16px 0 4px; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }

/* top bar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--card) 80%, transparent);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand small { display: block; font-size: 12px; }
.logo { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 6px 16px rgba(108,76,255,.35); }
nav { display: flex; gap: 4px; }

/* hero */
.hero { text-align: center; padding: 44px 0 28px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 17px; margin: 10px 0 0; }

/* plans */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.plan { position: relative; text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--card);
  border: 2px solid var(--border); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.plan:hover { transform: translateY(-2px); border-color: var(--accent); }
.plan.active { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--card) 60%); }
.plan b { font-size: 16px; text-transform: capitalize; }
.plan .price { font-size: 28px; font-weight: 800; margin: 6px 0 10px; }
.plan .price small { font-size: 13px; font-weight: 500; }
.plan ul { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.plan li { padding: 2px 0; } .plan li::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.plan li.off::before { content: "– "; color: var(--muted); } .plan li.off { opacity: .6; }
.plan .badge { position: absolute; top: 12px; right: 12px; }

/* layout + cards */
.layout { display: grid; grid-template-columns: 1fr 1.25fr; gap: 18px; align-items: start; margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); }

/* forms */
.field { margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 96px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.hint { display: block; margin-top: 4px; font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; font-weight: 400; margin: 4px 0 16px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.check.inline { margin: 0; align-items: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text);
  transition: transform .1s, box-shadow .15s, opacity .15s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; padding: 13px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #fff; border-top-color: transparent; animation: spin .7s linear infinite; }
.link { background: none; border: 0; padding: 6px 10px; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; border-radius: 8px; }
.check .link { padding: 0; font-size: inherit; text-decoration: underline; }
.link:hover { background: var(--accent-soft); }
@keyframes spin { to { transform: rotate(360deg); } }

/* preview */
.stage-frame { border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 16/9; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.stage-frame canvas { width: 100%; height: 100%; display: block; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

/* storyboard */
.scene-list { list-style: none; counter-reset: s; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.scene-list li { counter-increment: s; position: relative; padding: 12px 14px 12px 52px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
.scene-list li:not(.muted)::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; display: grid;
  place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; }
.scene-list li.muted { padding-left: 14px; }
.scene-list .meta { font-size: 12px; color: var(--muted); }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
pre { margin: 8px 0 0; padding: 12px; font-size: 12px; background: var(--bg2); border-radius: 10px; white-space: pre-wrap; max-height: 160px; overflow: auto; }

/* feedback */
.pill, .tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--ok); color: #fff; }
.banner { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 14px; background: var(--warn-bg); color: var(--warn); }
.usage { margin-top: 10px; font-size: 12px; color: var(--muted); text-align: center; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; font-size: 14px; color: #fff; background: #2a2d3f; box-shadow: var(--shadow); animation: pop .2s ease; }
.toast.error { background: var(--danger); } .toast.ok { background: var(--ok); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* dialogs */
dialog { width: min(680px, calc(100vw - 32px)); max-height: 85vh; overflow: auto; border: 1px solid var(--border); border-radius: 16px;
  padding: 24px 28px; background: var(--card); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(10,10,20,.55); backdrop-filter: blur(3px); }
dialog h2 { margin-bottom: 4px; } dialog p, dialog li { font-size: 14px; color: var(--muted); margin: 4px 0; }
dialog ul { padding-left: 20px; }
.close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--bg2); color: var(--text); font-size: 14px; }

footer { text-align: center; padding: 28px 20px 40px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); }
footer a { color: var(--accent); } footer p { margin: 4px 0; }

/* responsive + motion */
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .plan-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } .topbar { padding: 12px 16px; } main { padding: 8px 14px 40px; } .card { padding: 16px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } html { scroll-behavior: auto; } }
