:root {
  --bg: #f6f5f9;
  --panel: #ffffff;
  --panel-2: #faf9fc;
  --line: #e6e3ee;
  --line-2: #d6d1e2;
  --text: #1f1b2b;
  --text-2: #5d5870;
  --text-3: #8d88a0;
  --accent: #6d5bd0;
  --accent-2: #5a48bd;
  --accent-soft: #efecfb;
  --ok: #1f9d6b;
  --ok-soft: #e5f6ee;
  --warn: #c27a00;
  --warn-soft: #fdf3df;
  --err: #d0443a;
  --err-soft: #fce9e7;
  --info: #2f6fd6;
  --info-soft: #e8f0fd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 20, 60, .06), 0 4px 16px rgba(30, 20, 60, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15131c; --panel: #1d1a27; --panel-2: #221f2e; --line: #2f2b3d; --line-2: #3c374d;
    --text: #ece9f5; --text-2: #b3adc6; --text-3: #847e98; --accent: #8f7ff0; --accent-2: #a294f5;
    --accent-soft: #2a2546; --ok-soft: #173327; --warn-soft: #3a2d12; --err-soft: #3d1c1a; --info-soft: #1a2944;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.boot { padding: 40px; color: var(--text-3); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 650; font-size: 15px; }
.brand-dot { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); margin-bottom: 2px; }
.nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.nav .count { margin-left: auto; background: var(--err); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; }
.side-foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--text-3); }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 650; }
.topbar .sub { color: var(--text-3); font-size: 13px; }
.topbar .spacer { flex: 1; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .brand { padding: 4px 8px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side-foot { display: none; }
  .main { padding: 16px; }
}

/* ---------- surfaces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card h2 .spacer { flex: 1; }
.card h3 { font-size: 13.5px; margin: 16px 0 8px; color: var(--text-2); font-weight: 600; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.stat { padding: 14px 16px; }
.stat .k { color: var(--text-3); font-size: 12.5px; }
.stat .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--text-3); font-size: 12px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.warn > i { background: var(--warn); } .bar.err > i { background: var(--err); }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- table ---------- */
.dropzone { display: block; margin-top: 10px; padding: 28px 16px; text-align: center; color: var(--text-2);
  border: 2px dashed var(--line-2); border-radius: var(--radius); background: var(--panel-2); cursor: pointer; }
.dropzone:hover, .dropzone.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.err-text { color: var(--err); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--panel-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.b-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.b-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.b-err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.b-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.b-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.b-live::before { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.field .hint { font-size: 12px; color: var(--text-3); }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 80px; font-family: var(--font); }
textarea.code { font-family: var(--mono); font-size: 12.5px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type=range] { padding: 0; accent-color: var(--accent); }
input.num { width: 90px; font-variant-numeric: tabular-nums; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.fields-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
@media (max-width: 760px) { .fields-2, .fields-3 { grid-template-columns: 1fr; } }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 36px; height: 20px; border-radius: 10px; background: var(--line-2); position: relative; transition: .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: 18px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); }
.tags .tag { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 1px 4px 1px 8px; display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; }
.tags .tag button { border: none; background: none; color: inherit; cursor: pointer; padding: 0 3px; font-size: 14px; line-height: 1; }
.tags input { border: none; box-shadow: none !important; flex: 1; min-width: 100px; padding: 3px 4px; }

/* ---------- buttons ---------- */
.btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--panel-2); border-color: var(--text-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--err); border-color: var(--err-soft); }
.btn.danger:hover { background: var(--err-soft); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn .spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg) } }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 36px 10px; color: var(--text-3); }
.notice { border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; border: 1px solid transparent; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--err-soft); color: var(--err); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--text-3); }
.pre { white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 360px; overflow: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { font: inherit; border: none; background: none; padding: 8px 12px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.timeline .ev { position: relative; padding: 0 0 12px; font-size: 13px; }
.timeline .ev::before { content: ""; position: absolute; left: -17px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); border: 2px solid var(--panel); }
.timeline .ev.ok::before { background: var(--ok); } .timeline .ev.err::before { background: var(--err); } .timeline .ev.retry::before { background: var(--warn); }
.pipeline { display: flex; gap: 0; overflow-x: auto; padding: 4px 0 6px; }
.pipeline .st { flex: 1; min-width: 86px; text-align: center; font-size: 12px; color: var(--text-3); position: relative; padding-top: 22px; }
.pipeline .st::before { content: ""; position: absolute; top: 6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--line-2); z-index: 1; }
.pipeline .st::after { content: ""; position: absolute; top: 11px; left: -50%; right: 50%; height: 2px; background: var(--line-2); }
.pipeline .st:first-child::after { display: none; }
.pipeline .st.done { color: var(--text-2); } .pipeline .st.done::before, .pipeline .st.done::after { background: var(--ok); }
.pipeline .st.cur { color: var(--accent); font-weight: 650; } .pipeline .st.cur::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pipeline .st.cur::after { background: var(--ok); }
.pipeline .st.bad::before { background: var(--err); box-shadow: 0 0 0 4px var(--err-soft); }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 14, 40, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 12px; width: min(620px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(980px, 100%); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 650; display: flex; align-items: center; }
.modal header .x { margin-left: auto; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--panel); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: 420px; font-size: 13px; }
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { margin: 0 0 4px; font-size: 20px; }

/* ---------- checklist ---------- */
.check { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: none; }
.check .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; display: grid; place-items: center; font-size: 12px; margin-top: 1px; }
.check.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.check .t { font-weight: 600; }
.check .d { color: var(--text-3); font-size: 12.5px; }
.check .go { margin-left: auto; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 220px minmax(0, 1fr) 290px; gap: 14px; align-items: start; }
@media (max-width: 1280px) { .editor { grid-template-columns: 1fr; } }
.stage-wrap { background: repeating-conic-gradient(var(--line) 0% 25%, var(--panel-2) 0% 50%) 50% / 20px 20px; border-radius: 8px; padding: 12px; border: 1px solid var(--line); }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #000; box-shadow: 0 2px 12px rgba(0,0,0,.25); user-select: none; touch-action: none; }
.stage .layer { position: absolute; cursor: move; }
.stage .layer.locked { cursor: default; }
.stage .layer.sel { outline: 2px solid var(--accent); outline-offset: 0; z-index: 9999 !important; }
.stage .layer img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.stage .bgimg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage .vbox { overflow: hidden; background: #222; }
.stage .vbox .frame { position: absolute; pointer-events: none; max-width: none; }
.stage .vbox .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; font-size: 13px; background: repeating-linear-gradient(45deg, #2b2b2b, #2b2b2b 10px, #333 10px, #333 20px); }
.stage .handle { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid var(--accent); border-radius: 3px; right: -7px; bottom: -7px; cursor: nwse-resize; }
.stage .overlay-img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.layers .ly { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.layers .ly:hover { background: var(--panel-2); }
.layers .ly.on { background: var(--accent-soft); color: var(--accent); }
.layers .ly img { width: 32px; height: 22px; object-fit: contain; background: var(--panel-2); border-radius: 3px; }
.asset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.asset-grid .a { border: 1px solid var(--line); border-radius: 6px; padding: 3px; cursor: pointer; background: repeating-conic-gradient(var(--line) 0% 25%, transparent 0% 50%) 50% / 10px 10px; }
.asset-grid .a:hover { border-color: var(--accent); }
.asset-grid .a img { width: 100%; height: 48px; object-fit: contain; display: block; }
.thumb { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
video.player { width: 100%; border-radius: 8px; background: #000; max-height: 420px; }
