:root {
  --bg: #070911;
  --card: rgba(17, 24, 39, .88);
  --card-2: rgba(12, 17, 30, .9);
  --line: rgba(148, 163, 184, .16);
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #7c3aed;
  --primary-2: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 20px;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 5% -10%, rgba(124, 58, 237, .28), transparent 32%),
    radial-gradient(circle at 100% 5%, rgba(37, 99, 235, .22), transparent 28%),
    var(--bg);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: #c4b5fd; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 17, .78);
  backdrop-filter: blur(20px);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 30px rgba(124, 58, 237, .34);
}
.brand strong { display: block; font-size: 17px; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.health { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pill { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 800; }
.pill.ok { color: #6ee7b7; background: rgba(16, 185, 129, .1); }
.pill.warn { color: #fbbf24; background: rgba(245, 158, 11, .1); }
.setup-link { padding: 7px 10px; border-radius: 999px; text-decoration: none; font-size: 12px; font-weight: 750; background: rgba(148, 163, 184, .09); border: 1px solid var(--line); }

.shell { width: min(1480px, calc(100% - 30px)); margin: 26px auto 60px; }
.hero {
  display: grid;
  grid-template-columns: 1.5fr .6fr;
  align-items: center;
  gap: 28px;
  margin-bottom: 20px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(17, 24, 39, .91), rgba(15, 23, 42, .66));
  box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 9px; color: #a78bfa; font-size: 11px; font-weight: 900; letter-spacing: .16em; }
h1, h2 { margin: 0; line-height: 1.08; }
h1 { max-width: 900px; font-size: clamp(34px, 5vw, 64px); }
h2 { font-size: clamp(24px, 3vw, 34px); }
.hero-copy { max-width: 930px; margin: 18px 0 0; color: #cbd5e1; font-size: 16px; line-height: 1.72; }
.hero-badge { display: grid; gap: 8px; padding: 22px; border: 1px solid rgba(167, 139, 250, .28); border-radius: 17px; background: rgba(124, 58, 237, .12); }
.hero-badge span { color: #cbd5e1; line-height: 1.55; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, .85fr); gap: 20px; align-items: start; }
.card {
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--card), var(--card-2));
  box-shadow: var(--shadow);
}
.progress-card { position: sticky; top: 92px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
label { display: block; margin: 0 0 8px; color: #cbd5e1; font-size: 13px; font-weight: 760; }
.label-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.label-row span { color: var(--muted); font-size: 12px; }
.control {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: rgba(2, 6, 23, .62);
  transition: border-color .2s, box-shadow .2s;
}
.control:focus { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, .13); }
textarea.control { padding: 14px; resize: vertical; line-height: 1.62; }
.script { min-height: 360px; }
small { color: var(--muted); line-height: 1.45; }

.advanced { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(2, 6, 23, .34); overflow: hidden; }
.advanced summary { padding: 15px 16px; cursor: pointer; color: #ddd6fe; font-weight: 800; }
.advanced[open] summary { border-bottom: 1px solid var(--line); }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 17px; }
.uploads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 17px 17px; }
.upload { min-height: 82px; margin: 0; padding: 12px; display: grid; place-items: center; text-align: center; border: 1px dashed rgba(148, 163, 184, .32); border-radius: 12px; background: rgba(15, 23, 42, .42); cursor: pointer; }
.upload input { width: 100%; margin-top: 8px; font-size: 11px; }
.toggles { display: flex; gap: 14px; flex-wrap: wrap; padding: 0 17px 17px; }
.toggles label { margin: 0; display: flex; align-items: center; gap: 8px; }
.toggles input { width: 17px; height: 17px; accent-color: var(--primary); }

.button {
  min-height: 46px;
  padding: 0 17px;
  color: white;
  border: 0;
  border-radius: 12px;
  font-weight: 850;
  transition: transform .15s, filter .15s, opacity .15s;
}
.button:hover { transform: translateY(-1px); filter: brightness(1.07); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.button.success { width: 100%; margin-top: 14px; background: var(--success); }
.button.danger { width: 100%; margin-top: 10px; background: var(--danger); }
.button.ghost { background: rgba(148, 163, 184, .1); border: 1px solid var(--line); }
.button.small { min-height: 38px; padding: 0 13px; font-size: 12px; }
.button.build { width: 100%; min-height: 72px; margin-top: 18px; display: grid; place-items: center; gap: 2px; }
.button.build span { font-size: 17px; }
.button.build small { color: rgba(255, 255, 255, .76); }
.browser-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.browser-note.bad { color: #fca5a5; }

.format-badge { padding: 9px 12px; border-radius: 10px; color: #6ee7b7; font-weight: 950; letter-spacing: .08em; background: rgba(16, 185, 129, .1); border: 1px solid rgba(16, 185, 129, .24); }
.progress-track { height: 13px; overflow: hidden; border-radius: 999px; background: rgba(148, 163, 184, .13); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8b5cf6, #06b6d4); transition: width .25s linear; }
.status-message { min-height: 68px; margin-top: 14px; padding: 14px; color: #cbd5e1; line-height: 1.55; border-radius: 12px; background: rgba(2, 6, 23, .48); }
.pipeline { display: grid; gap: 9px; margin-top: 14px; }
.pipeline-step { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 11px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: rgba(15, 23, 42, .38); }
.pipeline-step > span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: #cbd5e1; font-weight: 900; background: rgba(148, 163, 184, .12); }
.pipeline-step strong, .pipeline-step small { display: block; }
.pipeline-step small { margin-top: 2px; }
.pipeline-step.active { border-color: rgba(139, 92, 246, .45); background: rgba(124, 58, 237, .1); }
.pipeline-step.active > span { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: white; }
.pipeline-step.done { border-color: rgba(16, 185, 129, .28); background: rgba(16, 185, 129, .07); }
.pipeline-step.done > span { background: var(--success); color: white; }
.pipeline-step.error { border-color: rgba(239, 68, 68, .35); background: rgba(239, 68, 68, .08); }
.pipeline-step.error > span { background: var(--danger); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.metrics div { padding: 11px; border-radius: 11px; text-align: center; background: rgba(148, 163, 184, .08); }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); font-size: 11px; }
.metrics strong { margin-top: 3px; }
.preview { position: relative; margin-top: 14px; aspect-ratio: 16 / 9; overflow: hidden; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; background: #000; }
.preview canvas, .preview video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.preview-placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding: 22px; color: #64748b; text-align: center; pointer-events: none; }

.legal-note { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 18px; padding: 16px 4px; color: #94a3b8; font-size: 12px; }
.legal-note a { margin-left: auto; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: min(430px, calc(100% - 40px)); padding: 14px 16px; color: white; border: 1px solid var(--line); border-radius: 12px; background: #111827; box-shadow: var(--shadow); opacity: 0; transform: translateY(18px); pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #450a0a; border-color: rgba(248, 113, 113, .38); }

@media (max-width: 1120px) {
  .hero, .workspace { grid-template-columns: 1fr; }
  .progress-card { position: static; }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .shell { width: min(100% - 18px, 1480px); margin-top: 12px; }
  .hero, .card { padding: 18px; }
  .settings-grid, .uploads { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .card-head, .label-row { flex-direction: column; align-items: stretch; }
  .legal-note a { margin-left: 0; }
}
