:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1c2330; --muted: #6b7587; --line: #e2e5ea;
  --brand: #3b5bdb; --brand-d: #2f49b0; --ok: #2b8a3e; --bad: #c92a2a; --warn: #e67700;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 14px rgba(20,30,50,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --panel: #1b2029; --ink: #e8ebf0; --muted: #98a2b3; --line: #2b3240; --brand: #6d86f5; --brand-d: #8ba0ff; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; } h2 { font-size: 1.1rem; margin: 0 0 .75rem; } h3 { font-size: .95rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.topbar { background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 18px; height: 56px; }
.topbar .brand { font-weight: 700; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.topbar .brand img { height: 28px; max-width: 90px; object-fit: contain; }
.topbar nav { display: flex; gap: 14px; flex: 1; } .topbar nav a { color: var(--muted); } .topbar nav a.on { color: var(--ink); font-weight: 600; }
.page { padding: 24px 0 60px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; min-height: 38px; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-d); }
.btn.danger { color: var(--bad); } .btn.small { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: .85rem; font-weight: 600; margin: 0 0 4px; }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
textarea { resize: vertical; min-height: 64px; }
input[type=color] { width: 44px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
input[type=range] { width: 100%; }
.row { display: flex; gap: 10px; align-items: end; } .row > * { flex: 1; } .row > .auto { flex: 0 0 auto; }
.field { margin-bottom: 12px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert.ok { background: rgba(43,138,62,.1); border-color: rgba(43,138,62,.35); } .alert.bad { background: rgba(201,42,42,.1); border-color: rgba(201,42,42,.35); }
.secret { font: 700 1.25rem ui-monospace, Consolas, monospace; letter-spacing: .06em; background: var(--bg); padding: 6px 10px; border-radius: 6px; user-select: all; }

table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; } th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--bg); border: 1px solid var(--line); }
.badge.done { color: var(--ok); } .badge.failed { color: var(--bad); } .badge.queued, .badge.rendering { color: var(--warn); } .badge.off { color: var(--muted); }

.auth { max-width: 380px; margin: 12vh auto 0; }
.clip-card { display: flex; flex-direction: column; gap: 8px; } .clip-card .thumb { aspect-ratio: 1; background: var(--bg); border-radius: 8px; overflow: hidden; display: grid; place-items: center; color: var(--muted); }
.clip-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--brand); background: rgba(59,91,219,.05); }

/* ---- editor ---- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.stage { position: sticky; top: 12px; }
.stage-box { background: #000; border-radius: var(--radius); display: grid; place-items: center; padding: 10px; min-height: 280px; }
.stage-box canvas { max-width: 100%; max-height: 66vh; border-radius: 4px; touch-action: none; cursor: default; }
.transport { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.timeline { position: relative; height: 84px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; overflow: hidden; touch-action: none; user-select: none; }
.timeline canvas { width: 100%; height: 100%; display: block; }
.timeline .shade { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,.45); pointer-events: none; }
.timeline .handle { position: absolute; top: 0; bottom: 0; width: 12px; margin-left: -6px; background: var(--brand); cursor: ew-resize; border-radius: 3px; }
.timeline .playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #ff5d5d; pointer-events: none; }
.panel { display: flex; flex-direction: column; gap: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; } .tabs button { flex: 1; padding: 7px 4px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; font: inherit; cursor: pointer; font-size: .85rem; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 260px; overflow: auto; }
.swatch { position: relative; aspect-ratio: 1; border-radius: 8px; border: 2px solid transparent; background-size: cover; background-position: center; cursor: pointer; }
.swatch.on { border-color: var(--brand); outline: 2px solid var(--brand); }
.swatch .x { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 20px; height: 20px; line-height: 18px; cursor: pointer; font-size: 12px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; } .seg button { flex: 1; padding: 6px; border: 0; background: var(--bg); color: var(--ink); cursor: pointer; font: inherit; font-size: .85rem; } .seg button.on { background: var(--brand); color: #fff; }
.layer { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; background: var(--bg); }
.layer.active { border-color: var(--brand); }
.cue { display: grid; grid-template-columns: 62px 62px 1fr 28px; gap: 6px; margin-bottom: 6px; align-items: center; } .cue input { padding: 5px 6px; font-size: .85rem; }
.render-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.share-video { max-width: 560px; width: 100%; border-radius: var(--radius); background: #000; }
