:root {
  --bg: #0f1218; --panel: #171c26; --line: #262d3b; --fg: #e6e9ef; --muted: #8b94a7;
  --accent: #4f8cff; --accent-2: #7c5cff; --ok: #34c77b; --warn: #f0b429; --bad: #ff5c6c; --code: #0b0e14;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button { font: inherit; color: #fff; background: var(--accent); border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--fg); }
button.danger { background: var(--bad); }
button.small { padding: 5px 10px; font-size: 13px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input[readonly] { color: var(--muted); }
textarea { resize: vertical; }
a { color: var(--accent); }
pre { background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow: auto; font-size: 12.5px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.4em; }
.req { color: var(--bad); }

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 16px; }
.spacer { flex: 1; }
.health { font-size: 13px; color: var(--muted); }
.health .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.health.ok .dot { background: var(--ok); } .health.bad .dot { background: var(--bad); } .health.warn .dot { background: var(--warn); }

main { max-width: 1140px; margin: 0 auto; padding: 16px 20px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 8px; font-size: 18px; }
.card { background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.login { max-width: 520px; margin: 60px auto; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row select, .row input { width: auto; min-width: 120px; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; margin: 8px 0; white-space: nowrap; }
.check input { width: auto; }

/* 状态条 */
.dash { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 74px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 16px; font-weight: 600; margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.actions-tile { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.bar i.warn { background: var(--warn); } .bar i.bad { background: var(--bad); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.tabs button { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.tabs button.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.tabs .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.tabs .cnt { font-size: 11px; background: var(--line); border-radius: 999px; padding: 0 6px; margin-left: 2px; }

.task-head { margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.grid label, .grid .label { display: block; font-size: 13px; color: var(--muted); }
.grid label input, .grid label select, .grid label textarea { margin-top: 4px; }
.grid .full { grid-column: 1 / -1; }
.upload { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.thumb { max-height: 120px; margin-top: 8px; border-radius: 8px; border: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--code); cursor: pointer; font-size: 13px; user-select: none; }
.chip.on { border-color: var(--accent); color: #fff; background: rgba(79,140,255,.18); }
.chip .x { color: var(--muted); }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.msg { color: var(--muted); font-size: 13px; }
.msg.bad { color: var(--bad); } .msg.ok { color: var(--ok); }
.estimate { margin-top: 12px; white-space: pre-wrap; }

/* 任务卡片 */
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 10px; }
.job { border: 1px solid var(--line); border-radius: 10px; background: var(--code); display: flex; flex-direction: column; overflow: hidden; }
.job .pic { position: relative; background: #05070b; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.job .pic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.job .pic .ph { color: var(--muted); font-size: 12px; }
.job .pic .kind { position: absolute; left: 8px; top: 8px; }
.job .bd { padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; }
.job .hd { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.job .id { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--fg); white-space: nowrap; }
.badge.ok { background: rgba(52,199,123,.2); color: var(--ok); }
.badge.running, .badge.queued { background: rgba(240,180,41,.2); color: var(--warn); }
.badge.failed, .badge.guard_failed { background: rgba(255,92,108,.2); color: var(--bad); }
.badge.cancelled { color: var(--muted); }
.job .scene { font-size: 13px; max-height: 3.2em; overflow: hidden; }
.job .meta { font-size: 12px; color: var(--muted); }
.job .err { font-size: 12px; color: var(--bad); }
.job .ops { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.job .ops button { padding: 4px 10px; font-size: 12px; }

/* 角色库 */
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 10px; }
.char { border: 1px solid var(--line); border-radius: 10px; background: var(--code); overflow: hidden; display: flex; flex-direction: column; }
.char .pic { aspect-ratio: 3 / 4; background: #fff; display: flex; align-items: center; justify-content: center; }
.char .pic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.char .bd { padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.char .nm { font-weight: 600; font-size: 14px; }
.char .desc { color: var(--muted); max-height: 4.5em; overflow: hidden; }

/* 系统 */
.sys-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv b { color: var(--muted); font-weight: 500; white-space: nowrap; }
.cmd { white-space: pre; }
.tk-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tk-list th, .tk-list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tk-list th { color: var(--muted); font-weight: 500; }
.token-box { font-family: ui-monospace, Consolas, monospace; word-break: break-all; background: var(--code); border: 1px solid var(--accent); border-radius: 8px; padding: 10px; margin: 10px 0; user-select: all; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal-body { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; max-width: 960px; width: 100%; max-height: 90vh; overflow: auto; }
#modal-media img, #modal-media video { max-width: 100%; max-height: 60vh; display: block; margin: 12px auto; border-radius: 8px; }
.foot { text-align: center; padding: 20px; font-size: 12px; }
@media (max-width: 900px) { .dash { grid-template-columns: repeat(2, 1fr); } .sys-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } .upload { grid-template-columns: 1fr; } main { padding: 12px; } }
