:root {
  --bg: #0b0b0f;
  --panel: #15151c;
  --panel2: #1c1c25;
  --line: #2a2a36;
  --text: #ececf1;
  --muted: #8d8da0;
  --accent: #7c5cff;
  --accent2: #9a82ff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.error { color: var(--err); min-height: 1.2em; }
input[type=text], input[type=password] {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 14px; outline: none;
}
input:focus { border-color: var(--accent); }

.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 9px 14px;
  border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; }
.btn:hover { border-color: #3a3a4a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent2); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #04170b; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.round { width: 38px; height: 38px; border-radius: 50%; padding: 0; }
.link { background: none; border: 0; color: var(--accent2); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.brand { font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand span { color: var(--accent2); }
.brand.big { font-size: 30px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px;
  display: flex; flex-direction: column; gap: 12px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.tab.active { color: var(--text); background: var(--panel2); }
.tabpane { padding: 18px 20px; }

/* Drop zone */
.drop { border: 2px dashed var(--line); border-radius: 16px; min-height: 60vh; display: grid; place-items: center;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: #7c5cff10; }
.drop h2 { margin: 8px 0 4px; }
.drop-icon { font-size: 34px; color: var(--accent2); }

/* Editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-rows: auto auto; gap: 16px; }
.preview-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.stage-wrap { background: #000; border-radius: var(--radius); display: grid; place-items: center; height: 62vh; overflow: hidden; }
.stage { position: relative; height: 100%; max-width: 100%; }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage canvas { cursor: ns-resize; }
.guide { position: absolute; left: 0; right: 0; border-top: 2px dashed #ffffffaa; pointer-events: none; }
.controls { display: flex; align-items: center; gap: 12px; }
.controls .hint { margin-left: auto; }

.side { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-title { font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; }
.steps .val { color: var(--muted); font-size: 12px; text-align: right; }
.steps .bar { grid-column: 2 / 4; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
li.run .dot { background: var(--warn); animation: pulse 1s infinite; }
li.ok .dot { background: var(--ok); }
li.err .dot { background: var(--err); }
li.err .val { color: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }
.bar { height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.bar.big { height: 10px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.seg { display: flex; background: var(--panel2); border-radius: 9px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; background: none; border: 0; color: var(--muted); padding: 7px; border-radius: 7px; cursor: pointer; font-weight: 600; }
.seg button.active { background: var(--accent); color: #fff; }
.swatches { display: flex; gap: 8px; margin-bottom: 6px; }
.swatch { width: 34px; height: 34px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; position: relative; }
.swatch.active { border-color: #fff; }
.swatch.ai::after { content: "IA"; position: absolute; top: -8px; right: -8px; background: #fff; color: #000; font-size: 9px;
  font-weight: 800; padding: 1px 4px; border-radius: 6px; }
.export-box { margin-top: 12px; }
.export-box p { margin: 8px 0 0; }

/* Timeline */
.timeline-card { grid-column: 1 / 3; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tl-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.tl-head .card-title { margin: 0; }
.tl-head .zoom { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.timeline { position: relative; overflow-x: auto; overflow-y: hidden; height: 92px; background: var(--panel2); border-radius: 9px; user-select: none; }
.tl-inner { position: relative; height: 100%; }
.tl-ruler { position: absolute; top: 0; left: 0; right: 0; height: 22px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tl-tick { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line); font-size: 10px; color: var(--muted); padding-left: 3px; }
.tl-track { position: absolute; top: 34px; left: 0; right: 0; height: 44px; cursor: pointer; }
.tl-label { position: sticky; left: 0; }
.cap { position: absolute; top: 0; height: 44px; background: #7c5cff33; border: 1px solid #7c5cff88; border-radius: 6px;
  font-size: 11px; padding: 3px 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #e9e5ff; cursor: pointer; }
.cap:hover { background: #7c5cff55; }
.cap.sel { border-color: #fff; background: #7c5cff77; }
.cap input { width: 100%; background: #000; border: 1px solid var(--accent); color: #fff; font-size: 12px; padding: 4px; border-radius: 4px; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #ff4d6d; pointer-events: none; z-index: 5; }

/* Exports table */
.jobs { width: 100%; border-collapse: collapse; margin-top: 8px; }
.jobs th, .jobs td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.jobs th { color: var(--muted); font-weight: 600; }
.badge { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.badge.done { background: #22c55e22; color: var(--ok); }
.badge.rendering, .badge.queued { background: #f59e0b22; color: var(--warn); }
.badge.error { background: #ef444422; color: var(--err); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2a2a36; color: #fff;
  padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 30px #0008; z-index: 100; max-width: 90vw; }
.toast.err { background: #5b1a1a; }

@media (max-width: 1000px) {
  .editor { grid-template-columns: 1fr; }
  .timeline-card { grid-column: 1; }
}
