:root {
  --bg: #090b10;
  --panel: #12151d;
  --panel-2: #171b26;
  --panel-3: #1d2230;
  --line: #242a3a;
  --line-soft: #1c2130;
  --text: #eef1f7;
  --muted: #98a1b5;
  --muted-2: #6f7789;
  --accent: #7b61ff;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(900px 420px at 8% -8%, rgba(123, 97, 255, 0.18), transparent 65%),
    radial-gradient(700px 380px at 95% 0%, rgba(34, 211, 238, 0.1), transparent 60%);
  background-repeat: no-repeat;
}

a { color: var(--accent-2); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img, video { display: block; max-width: 100%; }

.boot { padding: 80px; text-align: center; color: var(--muted); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, #151925, #10131b);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #4a8bff 55%, var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 20px; letter-spacing: 0.5px;
  margin-bottom: 22px;
  box-shadow: 0 10px 30px rgba(123, 97, 255, 0.35);
}
.login-card h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: 0.5px; }
.login-card p { margin: 0 0 28px; color: var(--muted); font-size: 14px; }
.login-card .field { margin-bottom: 18px; }
.login-card .btn { width: 100%; height: 48px; margin-top: 6px; font-size: 16px; }
.login-tip { margin-top: 20px; font-size: 13px; color: var(--muted-2); line-height: 1.7; }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: rgba(13, 16, 23, 0.92);
  border-right: 1px solid var(--line-soft);
  padding: 26px 18px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 26px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #4a8bff 55%, var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
  box-shadow: 0 8px 22px rgba(123, 97, 255, 0.35);
}
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.3; }
.brand-sub { font-size: 12px; color: var(--muted-2); letter-spacing: 0.6px; }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  text-align: left;
  font-size: 15px;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item svg { width: 20px; height: 20px; flex: 0 0 20px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(123, 97, 255, 0.2), rgba(123, 97, 255, 0.04));
  border-color: rgba(123, 97, 255, 0.35);
  color: #fff;
}
.nav-item .badge {
  margin-left: auto;
  background: rgba(123, 97, 255, 0.25);
  color: #cfc7ff;
  border-radius: 999px;
  font-size: 12px;
  padding: 1px 9px;
}
.sidebar-foot { margin-top: auto; padding: 16px 6px 0; border-top: 1px solid var(--line-soft); }
.sidebar-foot .who { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 8px; font-size: 13px; }
.link-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }

.main { flex: 1; min-width: 0; padding: 30px 38px 70px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 26px; letter-spacing: 0.4px; }
.topbar .sub { color: var(--muted); font-size: 14px; }
.topbar .spacer { flex: 1; }

.provider-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  font-size: 13px; border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}
.provider-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.provider-pill.ok .dot { background: var(--ok); }

/* ---------- 通用组件 ---------- */
.card {
  background: linear-gradient(180deg, #141824, #10131b);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: 20px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.card-title h3 { margin: 0; font-size: 18px; letter-spacing: 0.3px; }
.card-title .hint { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px;
  border-radius: 12px; border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), #5b7bff);
  color: #fff; font-weight: 600; font-size: 15px;
  cursor: pointer; transition: transform .12s, filter .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: rgba(255, 255, 255, 0.04); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn.danger { background: rgba(248, 113, 113, 0.12); color: #ffb4b4; border-color: rgba(248, 113, 113, 0.35); }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.lg { height: 50px; padding: 0 26px; font-size: 16px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field > label { font-size: 14px; color: var(--muted); font-weight: 500; }
.field .desc { font-size: 12px; color: var(--muted-2); }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  background: #0d1017;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: rgba(123, 97, 255, 0.65); box-shadow: 0 0 0 3px rgba(123, 97, 255, 0.15); }
textarea { resize: vertical; line-height: 1.7; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: #0e1119;
  color: var(--muted); cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: #354060; }
.chip.active {
  color: #fff;
  border-color: rgba(123, 97, 255, 0.7);
  background: rgba(123, 97, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(123, 97, 255, 0.2);
}

.style-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.style-card {
  border: 1px solid var(--line); background: #0e1119; border-radius: 14px;
  padding: 16px 14px; cursor: pointer; text-align: left; transition: all .15s;
}
.style-card strong { display: block; font-size: 15px; margin-bottom: 4px; }
.style-card span { font-size: 12px; color: var(--muted-2); line-height: 1.5; display: block; }
.style-card:hover { border-color: #354060; }
.style-card.active { border-color: rgba(123, 97, 255, 0.75); background: rgba(123, 97, 255, 0.12); }

.check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #0e1119; cursor: pointer; font-size: 14px;
}
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.check small { display: block; color: var(--muted-2); font-size: 12px; }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-READY { color: #6ee7b7; background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.3); }
.st-FAILED, .st-CANCELLED { color: #fca5a5; background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.3); }
.st-SCRIPT_READY { color: #fcd34d; background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.3); }
.st-QUEUED, .st-SCRIPTING, .st-ASSETS, .st-RENDERING { color: #a5b4fc; background: rgba(129, 140, 248, 0.1); border-color: rgba(129, 140, 248, 0.3); }

.progress { height: 10px; background: #0b0e15; border-radius: 999px; overflow: hidden; border: 1px solid var(--line-soft); }
.progress > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width .5s ease;
}
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 8px; }

.logs {
  margin: 0; padding: 14px 16px; list-style: none;
  background: #0a0d13; border: 1px solid var(--line-soft); border-radius: 12px;
  font-size: 13px; color: var(--muted); max-height: 220px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.logs li { padding: 3px 0; }
.logs li.err { color: #fca5a5; }
.logs li.warn { color: #fcd34d; }
.logs time { color: var(--muted-2); margin-right: 10px; }

/* 工作台 */
.workbench { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr); gap: 22px; align-items: start; }
.form-stack { display: flex; flex-direction: column; gap: 22px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.upload {
  border: 1px dashed #2c3448; border-radius: 14px; padding: 18px;
  background: #0d1017; text-align: center; cursor: pointer; color: var(--muted);
  transition: border-color .15s, background .15s;
}
.upload:hover { border-color: rgba(123, 97, 255, 0.6); background: #10131c; }
.upload strong { color: var(--text); }
.thumbs { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.thumbs .thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 6px; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 12px; }

.recent { display: flex; flex-direction: column; gap: 12px; }
.recent-item {
  display: flex; gap: 12px; align-items: center;
  padding: 10px; border-radius: 12px; border: 1px solid var(--line-soft);
  background: #0e1119; cursor: pointer;
}
.recent-item:hover { border-color: #354060; }
.recent-item img, .recent-item .ph { width: 56px; height: 84px; border-radius: 8px; object-fit: cover; background: var(--panel-3); flex: 0 0 56px; }
.recent-item .t { font-size: 14px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recent-item .m { font-size: 12px; color: var(--muted-2); margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 任务中心 */
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.task-card {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(180deg, #141824, #10131b);
  cursor: pointer; transition: transform .15s, border-color .15s;
}
.task-card:hover { transform: translateY(-2px); border-color: #36405c; }
.task-thumb { position: relative; aspect-ratio: 16 / 9; background: #0b0e15; overflow: hidden; }
.task-thumb img { width: 100%; height: 100%; object-fit: cover; }
.task-thumb .status { position: absolute; left: 10px; top: 10px; backdrop-filter: blur(6px); }
.task-thumb .dur { position: absolute; right: 10px; bottom: 10px; font-size: 12px; background: rgba(0,0,0,.65); padding: 2px 8px; border-radius: 6px; color: #dbe2f0; }
.task-body { padding: 14px 16px 16px; }
.task-title { font-size: 15px; line-height: 1.5; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 45px; }
.task-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted-2); flex-wrap: wrap; }
.task-actions { display: flex; gap: 8px; margin-top: 14px; }

.empty {
  padding: 60px 20px; text-align: center; color: var(--muted-2);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty strong { display: block; color: var(--muted); font-size: 16px; margin-bottom: 6px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { color: var(--muted-2); font-weight: 500; font-size: 12px; letter-spacing: .5px; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--muted); }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(6px); z-index: 60;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 28px 20px; overflow: auto;
}
.modal {
  width: 100%; max-width: 940px;
  background: #10131c; border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow);
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 20px 26px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: rgba(16,19,28,.95); z-index: 2; border-radius: 22px 22px 0 0; }
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 24px 26px 30px; display: flex; flex-direction: column; gap: 22px; }
.modal-close { background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--muted); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 16px; }
.modal-close:hover { color: var(--text); }
.modal-foot {
  position: sticky; bottom: 0;
  margin: 6px -26px -30px; padding: 16px 26px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(16, 19, 28, 0.86), #10131c 40%);
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  border-radius: 0 0 22px 22px;
}

.detail-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.player-wrap { background: #05070b; border-radius: 16px; border: 1px solid var(--line-soft); overflow: hidden; }
.player-wrap video { width: 100%; max-height: 62vh; background: #000; }
.player-meta { display: flex; gap: 12px; font-size: 13px; color: var(--muted); padding: 12px 16px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }

.scene-edit { border: 1px solid var(--line-soft); background: #0d1017; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.scene-edit .idx { font-size: 12px; color: var(--muted-2); display: flex; justify-content: space-between; }
.scene-edit textarea { min-height: 64px; font-size: 14px; }
.scene-edit input { font-size: 14px; }

.copy-row { display: flex; gap: 8px; align-items: center; background: #0d1017; border: 1px solid var(--line-soft); border-radius: 12px; padding: 8px 8px 8px 14px; }
.copy-row .val { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-row .val.tags { color: var(--accent-2); }

.kv { display: grid; grid-template-columns: 128px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted-2); }
.kv dd { margin: 0; color: var(--text); word-break: break-all; }

.notice {
  border-radius: 12px; padding: 14px 16px; font-size: 13px; line-height: 1.7;
  border: 1px solid rgba(251, 191, 36, 0.28); background: rgba(251, 191, 36, 0.07); color: #f4d99a;
}
.notice.info { border-color: rgba(34, 211, 238, 0.25); background: rgba(34, 211, 238, 0.06); color: #9fe8f5; }

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  background: #1c2333; border: 1px solid #33405e; color: #fff;
  padding: 12px 20px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 90;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(248, 113, 113, .5); }

.hidden { display: none !important; }

@media (max-width: 1080px) {
  .workbench { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .style-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 14px 16px; gap: 10px; overflow-x: auto; }
  .brand { padding: 0 12px 0 0; }
  .brand-name, .brand-sub { display: none; }
  .nav { flex-direction: row; }
  .nav-item span.lbl { display: none; }
  .nav-item { padding: 10px; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .sidebar-foot .who span { display: none; }
  .main { padding: 20px 16px 60px; }
  .form-row { grid-template-columns: 1fr; }
}
