/* 深世影创作台 — 深色工作站视觉
   颜色全部用变量，方便后面换主题；不引任何外部字体（CSP 只允许 self）。 */
:root {
  --bg: #0b0d12;
  --bg-1: #12151d;
  --bg-2: #181c26;
  --bg-3: #1f2431;
  --line: #2a3040;
  --line-2: #363e52;
  --fg: #e8ecf4;
  --fg-2: #9aa4b8;
  --fg-3: #6b7488;
  --acc: #4f8cff;
  --acc-2: #2f6fe0;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --purple: #a78bfa;
  --r: 10px;
  --r-s: 6px;
  --shadow: 0 8px 32px rgba(0, 0, 0, .45);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--acc); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2c3345; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.boot { display: grid; place-items: center; height: 100vh; color: var(--fg-2); letter-spacing: .08em; }

/* ── 加载页（品牌第一印象） ───────────────────────────── */
.boot-inner { text-align: center; display: grid; gap: 10px; justify-items: center; }
.boot-logo {
  font-size: 30px; font-weight: 700; letter-spacing: -.02em;
  background: linear-gradient(96deg, #7fb0ff, #2f6fe0 62%, #9d7bff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.boot-tag { font-size: 12px; color: var(--fg-3); letter-spacing: .04em; }
.boot-bar { width: 132px; height: 2px; background: #1b2233; border-radius: 2px; overflow: hidden; margin-top: 6px; }
.boot-bar i {
  display: block; width: 40%; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, transparent, #4d86ef, transparent);
  animation: bootslide 1.15s ease-in-out infinite;
}
@keyframes bootslide { 0% { transform: translateX(-120%); } 100% { transform: translateX(360%); } }
@media (prefers-reduced-motion: reduce) { .boot-bar i { animation: none; width: 100%; opacity: .5; } }

/* ── 提示块 ───────────────────────────────────────────── */
.notice {
  background: #12172a; border: 1px solid #23304d; border-left: 3px solid var(--acc);
  border-radius: var(--r-s); padding: 11px 13px; font-size: 12.5px; line-height: 1.75;
  color: var(--fg-2); margin-bottom: 16px;
}
.notice b { color: var(--fg); margin-right: 8px; }

/* ── 品牌标识（侧栏 / 登录页共用） ─────────────────────── */
.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-mark, .auth-mark {
  display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none;
  border-radius: 6px; background: linear-gradient(140deg, #4d86ef, #2f6fe0 60%, #7a5cf0);
  color: #fff; font-size: 13px; font-weight: 700; line-height: 1; letter-spacing: 0;
}
/* 字母由 CSS 生成而不是写在 DOM 里：装饰性字符不该进入可读文本，
   否则 h1 的 textContent 会变成 "SSsyTV Studio"，读屏也会念两遍 S。 */
.brand-mark::before, .auth-mark::before { content: 'S'; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.auth-mark { width: 26px; height: 26px; border-radius: 7px; font-size: 15px; margin-right: 6px; vertical-align: -5px; }
.auth-light { color: var(--fg-3); font-weight: 500; }

/*
 * hidden 属性必须真的生效。
 * 浏览器自带的 [hidden]{display:none} 是 UA 样式，优先级低于任何作者写的
 * display 规则 —— 也就是说 .boot{display:grid}、.inspector{...display} 这类规则
 * 会把 el.hidden = true 彻底架空。上一版就踩到了：#boot 明明设了 hidden，
 * 却仍占满 100vh，把整个应用顶到首屏之外，所有页面看起来都是「一片空白」。
 * 这里显式兜底，任何人以后给带 hidden 的元素写 display 都不会再翻车。
 */
[hidden] { display: none !important; }

/* ── 基础控件 ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: var(--r-s); border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--fg); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: #262c3c; border-color: #46506a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn[data-variant="primary"] { background: var(--acc-2); border-color: var(--acc); }
.btn[data-variant="primary"]:hover { background: var(--acc); }
.btn[data-variant="ghost"] { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn[data-variant="ghost"]:hover { background: var(--bg-3); color: var(--fg); }
.btn[data-variant="danger"] { border-color: #6b2b30; color: #ff9b9b; }
.btn[data-variant="danger"]:hover { background: #3a1d22; }
.btn[data-size="sm"] { padding: 5px 10px; font-size: 12.5px; }
.btn[data-size="xs"] { padding: 3px 8px; font-size: 12px; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: #0e1119; color: var(--fg); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--acc); }
textarea { resize: vertical; min-height: 68px; font-family: inherit; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--fg-2); margin-bottom: 5px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--fg-2); }
.dim { color: var(--fg-3); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11.5px;
  background: var(--bg-3); color: var(--fg-2); border: 1px solid var(--line);
}
.tag[data-tone="ok"] { color: #6ee7b7; border-color: #1c5c47; background: #10241d; }
.tag[data-tone="warn"] { color: #fcd34d; border-color: #665018; background: #241d0c; }
.tag[data-tone="err"] { color: #fca5a5; border-color: #6b2b30; background: #2a1418; }
.tag[data-tone="acc"] { color: #93c5fd; border-color: #274a7a; background: #10203a; }
.tag[data-tone="purple"] { color: #c4b5fd; border-color: #4a3d7a; background: #1c1730; }

/* ── 布局 ─────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 208px 1fr; height: 100vh; }
.side {
  background: var(--bg-1); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side .brand { padding: 16px 16px 10px; font-weight: 700; letter-spacing: .02em; }
.side .brand small { display: block; font-weight: 400; color: var(--fg-3); font-size: 11px; letter-spacing: .12em; margin-top: 2px; }
.side nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.side nav a {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--r-s);
  color: var(--fg-2); font-size: 13.5px;
}
.side nav a:hover { background: var(--bg-2); color: var(--fg); }
.side nav a[aria-current="page"] { background: #1b2233; color: var(--fg); box-shadow: inset 2px 0 0 var(--acc); }
.side nav a .ic { width: 16px; text-align: center; opacity: .85; }
.side .foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--fg-3); }
.side .foot .who { color: var(--fg-2); word-break: break-all; margin-bottom: 6px; }
.main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 52px; flex: 0 0 52px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--bg-1);
}
.topbar h1 { font-size: 15px; margin: 0; font-weight: 600; }
.page { flex: 1; min-height: 0; overflow: auto; }

/* ── 卡片 / 表格 ──────────────────────────────────────── */
.wrap-pad { padding: 20px; max-width: 1320px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; transition: border-color .15s, transform .1s;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--line-2); transform: translateY(-1px); }
.card h3 { margin: 0 0 6px; font-size: 14.5px; font-weight: 600; }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi .box { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.kpi .box .n { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .box .l { font-size: 11.5px; color: var(--fg-3); letter-spacing: .06em; text-transform: uppercase; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--fg-3); font-weight: 500; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; }
table.tbl tr:hover td { background: #141822; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ── 登录 ─────────────────────────────────────────────── */
.auth { display: grid; place-items: center; height: 100vh; background: radial-gradient(1200px 600px at 50% -10%, #16203a 0%, var(--bg) 60%); }
.auth .box { width: 360px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 14px; padding: 26px; box-shadow: var(--shadow); }
.auth h1 { margin: 0 0 4px; font-size: 20px; }
.auth .sub { color: var(--fg-3); font-size: 12.5px; margin-bottom: 20px; }
.auth .tabs { display: flex; gap: 4px; background: #0e1119; border-radius: var(--r-s); padding: 3px; margin-bottom: 16px; }
.auth .tabs button { flex: 1; padding: 6px; border: 0; background: transparent; color: var(--fg-2); border-radius: 5px; cursor: pointer; }
.auth .tabs button[aria-pressed="true"] { background: var(--bg-3); color: var(--fg); }
.auth .err { color: var(--err); font-size: 12.5px; min-height: 18px; margin-top: 8px; }

/* ── 工作台 ───────────────────────────────────────────── */
.studio { display: grid; grid-template-columns: 1fr 372px; height: 100%; min-height: 0; }
.canvas-wrap { position: relative; overflow: hidden; background: #0a0c11; min-width: 0; }
.canvas-wrap canvas { display: block; width: 100%; height: 100%; cursor: default; }
.canvas-wrap.panning canvas { cursor: grabbing; }
.canvas-hud {
  position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px; align-items: center;
  background: rgba(18, 21, 29, .92); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px;
  backdrop-filter: blur(8px); font-size: 12px; color: var(--fg-2);
}
.canvas-tip {
  position: absolute; left: 12px; top: 12px; max-width: 380px; font-size: 12px; color: var(--fg-3);
  background: rgba(18, 21, 29, .8); border: 1px solid var(--line); border-radius: var(--r-s); padding: 6px 10px;
  pointer-events: none;
}
.inspector {
  position: absolute; right: 12px; bottom: 12px; width: 300px; max-height: 62%;
  overflow: auto; background: rgba(18, 21, 29, .96); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px; box-shadow: var(--shadow);
}
.inspector h4 { margin: 0 0 10px; font-size: 13px; display: flex; justify-content: space-between; }

.panel { background: var(--bg-1); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panel .tabs { display: flex; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.panel .tabs button {
  flex: 1; padding: 11px 4px; border: 0; background: transparent; color: var(--fg-3);
  cursor: pointer; font-size: 12.5px; border-bottom: 2px solid transparent;
}
.panel .tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--acc); }
.panel .body { flex: 1; overflow: auto; padding: 12px; min-height: 0; }
.panel .foot { border-top: 1px solid var(--line); padding: 10px; flex: 0 0 auto; }

.msg { display: flex; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.msg .who { flex: 0 0 40px; font-size: 11px; color: var(--fg-3); padding-top: 2px; }
.msg .bubble { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; white-space: pre-wrap; word-break: break-word; }
.msg[data-role="user"] .bubble { background: #17233a; border-color: #27406b; }

.stage {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--r-s);
  border: 1px solid transparent; cursor: pointer; font-size: 13px;
}
.stage:hover { background: var(--bg-2); border-color: var(--line); }
.stage .idx { flex: 0 0 22px; font-family: var(--mono); font-size: 11px; color: var(--fg-3); }
.stage .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage[data-status="done"] .nm { color: var(--fg); }
.stage[data-status="todo"] .nm { color: var(--fg-2); }
.stage[data-status="running"] .nm { color: var(--acc); }

.job-item { border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px 10px; margin-bottom: 8px; font-size: 12.5px; }
.job-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.job-item .err { color: #fca5a5; font-size: 11.5px; margin-top: 4px; word-break: break-word; }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.asset { border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; background: var(--bg-2); cursor: pointer; }
.asset .thumb { aspect-ratio: 16/10; background: #0a0c11 center/cover no-repeat; display: grid; place-items: center; color: var(--fg-3); font-size: 11px; }
.asset .meta { padding: 6px 8px; font-size: 11.5px; color: var(--fg-2); display: flex; justify-content: space-between; gap: 6px; }

/* ── 时间线 ───────────────────────────────────────────── */
.tl { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tl-head { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tl-body { flex: 1; overflow: auto; padding: 16px; }
.track { display: grid; grid-template-columns: 96px 1fr; gap: 10px; margin-bottom: 10px; align-items: stretch; }
.track .lbl { font-size: 12px; color: var(--fg-2); padding-top: 8px; }
.track .lane { position: relative; min-height: 62px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.clip {
  position: absolute; top: 6px; bottom: 6px; border-radius: 5px; overflow: hidden;
  border: 1px solid #3a4a6b; background: #1b2740; cursor: grab; font-size: 11px;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 3px 5px;
}
.clip .cbg { position: absolute; inset: 0; background: center/cover no-repeat; opacity: .55; }
.clip .ct { position: relative; color: #fff; text-shadow: 0 1px 3px #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip[data-kind="text"] { background: #2a2233; border-color: #55406b; }
.clip[data-kind="audio"] { background: #13302a; border-color: #2b6154; }
.tl-ruler { height: 22px; margin-left: 106px; border-bottom: 1px solid var(--line); position: relative; margin-bottom: 6px; }
.tl-ruler span { position: absolute; top: 2px; font-size: 10px; color: var(--fg-3); font-family: var(--mono); transform: translateX(-50%); }
.tl-ruler span::after { content: ''; position: absolute; left: 50%; top: 14px; width: 1px; height: 5px; background: var(--line-2); }

/* ── 弹层 ─────────────────────────────────────────────── */
.modal-mask { position: fixed; inset: 0; background: rgba(4, 6, 10, .72); display: grid; place-items: center; z-index: 50; }
.modal { width: 520px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); overflow: auto; background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); }
.modal h2 { margin: 0; font-size: 15px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal .mbody { padding: 16px; }
.modal .mfoot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
pre.json { background: #0b0e15; border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px; font-family: var(--mono); font-size: 12px; overflow: auto; max-height: 340px; white-space: pre-wrap; word-break: break-word; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1d2431; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 10px 16px; font-size: 13px; box-shadow: var(--shadow); z-index: 99; max-width: min(560px, 90vw);
}
.toast[data-tone="err"] { border-color: #6b2b30; color: #ffb4b4; }
.toast[data-tone="ok"] { border-color: #1c5c47; color: #a7f3d0; }

.empty { text-align: center; color: var(--fg-3); padding: 40px 12px; font-size: 13px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) {
  .studio { grid-template-columns: 1fr; grid-template-rows: 1fr 320px; }
  .split { grid-template-columns: 1fr; }
}
