/* ============================================================
   SparkScript AI — stylesheet (dark, modern AI SaaS)
   ============================================================ */

:root {
  --bg: #08090f;
  --bg-soft: #0d0f18;
  --panel: #121522;
  --panel-2: #171b2b;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eceef6;
  --muted: #9aa3b8;
  --accent: #7c5cff;
  --accent-2: #38bdf8;
  --grad: linear-gradient(100deg, #7c5cff 0%, #38bdf8 100%);
  --grad-soft: linear-gradient(100deg, rgba(124, 92, 255, 0.16), rgba(56, 189, 248, 0.16));
  --gold: #f5b83d;
  --green: #34d399;
  --red: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Sora', var(--font);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.desktop-only { display: inline; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }

/* ---------- shared ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px;
  padding: 10px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 24px -8px rgba(124, 92, 255, 0.55); }
.btn-primary:hover { box-shadow: 0 10px 30px -6px rgba(124, 92, 255, 0.7); }
.btn-ghost { background: rgba(255, 255, 255, 0.04); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); }
.btn-sm { padding: 7px 14px; font-size: 13.5px; border-radius: 10px; }
.btn-xs { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }

.link-btn { background: none; border: none; color: var(--accent-2); cursor: pointer; font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.link-btn:hover { text-decoration: underline; }

.input, .select, textarea.input {
  width: 100%; background: rgba(255,255,255,0.04); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); padding: 11px 13px; font-size: 15px; font-family: inherit;
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,.18); }
textarea.input { resize: vertical; min-height: 84px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa3b8' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; cursor: pointer; }
.select option { background: var(--panel-2); color: var(--text); }

.chip {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { background: rgba(255,255,255,0.1); }
.chip-gold { border-color: rgba(245,184,61,.4); color: var(--gold); }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}

/* ---------- landing: nav ---------- */

.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 16px clamp(20px, 5vw, 60px);
  background: rgba(8, 9, 15, 0.8); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 700; font-size: 19px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px; background: var(--grad); font-size: 16px;
}
.nav-links { display: flex; gap: 26px; font-size: 14.5px; color: var(--muted); }
.nav-links a:hover { color: var(--text); }
.nav-cta { display: flex; gap: 10px; }

/* ---------- hero ---------- */

.hero { position: relative; text-align: center; padding: 90px 24px 60px; overflow: hidden; }
.hero-glow {
  position: absolute; inset: -200px auto auto 50%; transform: translateX(-50%);
  width: 900px; height: 900px; background: radial-gradient(closest-side, rgba(124,92,255,.22), rgba(56,189,248,.08) 45%, transparent 70%);
  pointer-events: none; z-index: 0;
}
.hero > * { position: relative; z-index: 1; }
.hero-badge {
  display: inline-block; padding: 7px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: var(--grad-soft); border: 1px solid rgba(124,92,255,.3); color: #cfd3ff; margin-bottom: 22px;
}
.hero h1 {
  font-family: var(--display); font-weight: 800; font-size: clamp(40px, 6.4vw, 72px); line-height: 1.08; letter-spacing: -0.02em;
}
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { margin: 22px auto 0; max-width: 640px; color: var(--muted); font-size: clamp(16px, 2vw, 19px); }
.hero-sub em { color: var(--text); font-style: normal; }
.hero-cta { display: flex; gap: 14px; justify-content: center; margin-top: 34px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: clamp(16px, 4vw, 56px); justify-content: center; margin-top: 64px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--display); font-size: clamp(26px, 3vw, 34px); background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat span { color: var(--muted); font-size: 13px; max-width: 180px; }
.hero-note { margin-top: 30px; font-size: 11.5px; color: rgba(154,163,184,.7); }

/* ---------- sections ---------- */

.section { padding: 76px clamp(20px, 5vw, 60px); }
.section.alt { background: linear-gradient(180deg, rgba(255,255,255,0.015), rgba(255,255,255,0.025)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { text-align: center; max-width: 660px; margin: 0 auto 46px; }
.kicker { display: inline-block; font-size: 12.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 12px; }
.section-head h2 { font-family: var(--display); font-size: clamp(28px, 3.6vw, 40px); letter-spacing: -0.01em; }
.section-head p { color: var(--muted); margin-top: 12px; font-size: 16px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; max-width: 1100px; margin: 0 auto; }
.feature-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; transition: transform .2s ease, border-color .2s ease; }
.feature-card:hover { transform: translateY(-3px); border-color: rgba(124,92,255,.45); }
.f-icon { font-size: 30px; }
.feature-card h3 { margin: 14px 0 8px; font-size: 17px; font-family: var(--display); }
.feature-card p { color: var(--muted); font-size: 14.5px; }

/* template grid (shared landing + studio) */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; max-width: 1180px; margin: 0 auto 40px; }
.tpl-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; transition: transform .15s ease, border-color .2s ease;
  text-align: left; color: var(--text); position: relative;
}
.tpl-card:hover { transform: translateY(-2px); border-color: rgba(124,92,255,.5); }
.tpl-icon { font-size: 26px; line-height: 1; }
.tpl-name { font-weight: 700; font-size: 15px; }
.tpl-desc { color: var(--muted); font-size: 13px; line-height: 1.45; flex: 1; }
.tpl-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.07); color: var(--muted); font-weight: 600; }
.tag-pro { background: rgba(245,184,61,.14); color: var(--gold); }
.tag-free { background: rgba(52,211,153,.13); color: var(--green); }
.tag-engine { background: rgba(124,92,255,.16); color: #b9aaff; }
.tpl-lock {
  position: absolute; top: 14px; right: 14px; background: rgba(8,9,15,.72); border: 1px solid rgba(245,184,61,.4);
  color: var(--gold); font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: .03em;
}

/* steps */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 24px; max-width: 980px; margin: 0 auto; text-align: center; }
.step-num {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: 19px; color: #fff; background: var(--grad); box-shadow: 0 8px 20px -6px rgba(124,92,255,.5);
}
.step h3 { font-family: var(--display); margin-bottom: 6px; }
.step p { color: var(--muted); font-size: 14px; }

/* pricing */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 380px)); gap: 24px; justify-content: center; }
.price-card { background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 30px; position: relative; display: flex; flex-direction: column; gap: 16px; }
.price-card.highlight { border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 1px rgba(124,92,255,.25), 0 24px 60px -30px rgba(124,92,255,.5); }
.price-tag { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); background: var(--grad); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 14px; border-radius: 999px; }
.price-card h3 { font-family: var(--display); font-size: 20px; }
.price { font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1; }
.price span { font-size: 14px; font-weight: 500; color: var(--muted); }
.price-card ul { list-style: none; display: flex; flex-direction: column; gap: 9px; margin-bottom: 6px; }
.price-card li { font-size: 14.5px; color: var(--muted); padding-left: 26px; position: relative; }
.price-card li::before { content: '✓'; position: absolute; left: 0; color: var(--green); font-weight: 700; }

/* faq */
.faq { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq details { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 4px 20px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 15px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq summary::after { content: '+'; font-size: 20px; color: var(--muted); transition: transform .2s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--muted); font-size: 14.5px; padding-bottom: 16px; }

/* footer */
.footer { border-top: 1px solid var(--border); padding: 30px clamp(20px, 5vw, 60px); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; max-width: 1180px; margin: 0 auto; }
.footer-links { display: flex; gap: 20px; font-size: 13.5px; color: var(--muted); }
.footer-links a:hover { color: var(--text); }
.footer-note { font-size: 12.5px; color: rgba(154,163,184,.65); }

/* ============================================================
   STUDIO
   ============================================================ */

.studio-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px clamp(14px, 3vw, 30px); background: rgba(8,9,15,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

.studio-body { display: flex; min-height: calc(100vh - 60px); }

.studio-side {
  width: 168px; flex-shrink: 0; border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 6px;
  background: rgba(255,255,255,0.015);
}
.side-tab {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 11px; font-size: 14.5px; font-weight: 600; cursor: pointer; text-align: left;
}
.side-tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
.side-tab.active { background: var(--grad-soft); border-color: rgba(124,92,255,.35); color: var(--text); }
.side-spacer { flex: 1; }
.side-ghost { font-size: 13.5px; }

.studio-main { flex: 1; padding: 26px clamp(16px, 3vw, 40px) 60px; min-width: 0; }

.studio-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.studio-head h2 { font-family: var(--display); font-size: 24px; }

.cat-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.cat-chip {
  background: rgba(255,255,255,.04); border: 1px solid var(--border); color: var(--muted);
  padding: 6px 13px; border-radius: 999px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.cat-chip:hover { color: var(--text); }
.cat-chip.active { background: var(--grad-soft); border-color: rgba(124,92,255,.5); color: var(--text); }

.search-row { max-width: 420px; margin: 0 auto 22px; }
#template-grid { margin-bottom: 0; }

/* workspace */
.ws-cols { display: grid; grid-template-columns: minmax(320px, 460px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .ws-cols { grid-template-columns: 1fr; } }

.ws-form { padding: 22px; }
.ws-form-head { margin-bottom: 18px; }
.ws-form-head h3 { font-family: var(--display); font-size: 19px; margin-bottom: 4px; }
#ws-desc { font-size: 13.5px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .opt { color: var(--muted); font-weight: 400; }
.field select, .field textarea, .field input { margin-top: 0; }

.ws-actions { margin-top: 18px; }
.variations { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.variations .select { width: auto; }
#ws-hint { margin-top: 12px; font-size: 12.5px; }

.ws-output { padding: 18px; display: flex; flex-direction: column; min-height: 480px; max-height: 75vh; }
.ws-output-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.ws-output-head h3 { font-family: var(--display); font-size: 16px; }
.ws-output-tools { display: flex; align-items: center; gap: 7px; }

.output-box {
  flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-soft); padding: 20px; min-height: 360px;
}
.output-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-art { font-size: 40px; margin-bottom: 10px; }
#output-box pre.result {
  font-family: inherit; white-space: pre-wrap; word-break: break-word;
  font-size: 14.5px; line-height: 1.75; color: var(--text);
}
.result-block { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px dashed var(--border); }
.result-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.result-label { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.result-label button { margin-left: auto; }
.output-meta { margin-top: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

#offline-fallback { margin-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* history */
.history-list { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.history-item { display: flex; gap: 16px; align-items: flex-start; padding: 16px 18px; }
.history-item .tpl-icon { font-size: 24px; }
.history-main { flex: 1; min-width: 0; }
.history-title { font-weight: 700; font-size: 14.5px; }
.history-preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60ch; }
.history-date { font-size: 11.5px; color: rgba(154,163,184,.7); margin-top: 2px; }
.history-actions { display: flex; gap: 6px; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state .empty-art { font-size: 44px; }

/* ---------- modals ---------- */

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,5,10,.72); backdrop-filter: blur(6px); }
.modal-card {
  position: relative; z-index: 1; width: 100%; max-width: 520px;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 20px;
  padding: 28px; max-height: 90vh; overflow: auto; box-shadow: 0 40px 120px -30px rgba(0,0,0,.8);
}
.modal-card h3 { font-family: var(--display); font-size: 21px; margin-bottom: 8px; }
.modal-x { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,.06); border: none; color: var(--muted); width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 13px; }
.modal-x:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.mode-cards { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 10px; }
.mode-card {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--border); border-radius: 14px; padding: 14px; transition: border-color .15s ease, background .15s ease;
}
.mode-card:hover { background: rgba(255,255,255,.03); }
.mode-card input { margin-top: 4px; accent-color: var(--accent); }
.mode-card.selected { border-color: rgba(124,92,255,.6); background: var(--grad-soft); }
.mode-card b { display: block; font-size: 14.5px; margin-bottom: 2px; }

.byok-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.byok-fields label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }

.license-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.license-row .input { flex: 1; min-width: 200px; }
#license-status { font-weight: 600; }

.pricing-modal-card { max-width: 440px; text-align: center; }
.price-big { font-family: var(--display); font-weight: 800; font-size: 52px; margin: 18px 0 4px; }
.price-big span { font-size: 15px; color: var(--muted); font-weight: 500; }
.pricing-modal-card .btn { margin-top: 10px; }

.lock-card { max-width: 380px; text-align: center; }
.lock-art { font-size: 46px; margin-bottom: 8px; }

/* toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border-strong); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 14px; z-index: 200;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.8); max-width: min(92vw, 480px); text-align: center;
  animation: toast-in .25s ease;
}
.toast.ok { border-color: rgba(52,211,153,.5); }
.toast.err { border-color: rgba(248,113,113,.5); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* skeleton while generating */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.11), rgba(255,255,255,.05)); background-size: 200% 100%; animation: shine 1.2s infinite; height: 14px; margin-bottom: 10px; }
@keyframes shine { to { background-position: -200% 0; } }

/* responsive */
@media (max-width: 760px) {
  .nav-links { display: none; }
  .desktop-only { display: none; }
  .hero { padding-top: 60px; }
  .studio-side { width: auto; flex-direction: row; border-right: none; border-bottom: 1px solid var(--border); }
  .side-spacer { display: none; }
  .studio-body { flex-direction: column; }
  #tab-create .studio-head, .cat-chips { flex-direction: column; align-items: stretch; }
  .topbar-right .chip:nth-child(2) { display: none; }
}
