:root {
  --bg: #0d1015;
  --bg-2: #131820;
  --panel: #161c25;
  --panel-2: #1b222d;
  --line: #242c39;
  --text: #e7ecf3;
  --muted: #8b97a8;
  --accent: #f5a524;
  --accent-2: #ffbe55;
  --ok: #3fb950;
  --err: #f85149;
  --run: #58a6ff;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  touch-action: manipulation;
  background: radial-gradient(1200px 600px at 15% -10%, #1a2230 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 21, .82);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, #f5a524, #e0632a);
  color: #201400; font-size: 20px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(245, 165, 36, .25);
}
.brand h1 { margin: 0; font-size: 16px; letter-spacing: .3px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.status { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 12px; white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.ready { color: #c9f5cf; border-color: #24512c; background: #10231a; }
.pill.ready .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.loading .dot { background: var(--accent); animation: pulse 1.1s infinite; }
.pill.error { color: #ffd7d5; border-color: #5b2320; background: #261211; }
.pill.error .dot { background: var(--err); }

@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------- 布局 ---------- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 22px 26px;
  align-items: start;
}

.panel {
  position: sticky; top: 84px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}

.block h2 {
  margin: 0 0 10px; font-size: 12px; font-weight: 600;
  color: var(--muted); letter-spacing: .8px; text-transform: uppercase;
}
.block h2 b {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; margin-right: 7px;
  border-radius: 6px; background: #2b2113; color: var(--accent);
  font-size: 11px;
}

/* 拖拽区 */
.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 12px;
  border: 1.5px dashed #33404f; border-radius: 10px;
  background: #10151c; cursor: pointer; text-align: center;
  transition: .15s border-color, .15s background;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #171308; }
.dropzone input { display: none; }
.dz-icon { font-size: 20px; color: var(--accent); line-height: 1; }
.dz-main { font-size: 13px; }
.dz-sub { font-size: 11px; color: var(--muted); }

.filelist { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 150px; overflow: auto; }
.filelist li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px;
}
.filelist li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist li em { margin-left: auto; color: var(--muted); font-style: normal; font-size: 11px; }
.filelist li button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; }
.filelist li button:hover { color: var(--err); }

.folder-row { display: flex; gap: 8px; margin-top: 10px; }
.folder-row input {
  flex: 1; min-width: 0;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #0f141b; color: var(--text);
  font-size: 12px;
}
.folder-row input::placeholder { color: #5f6b7c; }

/* 参数 */
.field {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 9px; font-size: 13px;
}
.field select, .field input {
  width: 132px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--line); background: #0f141b; color: var(--text); font-size: 12px;
}
.fixed-val {
  color: var(--muted); font-size: 12px;
  padding: 6px 9px; border-radius: 8px;
  background: #0f141b; border: 1px dashed #2b3441;
}
.check {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin: 7px 0; font-size: 13px; color: var(--text);
}
.check input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.num-inline, .sel-inline {
  width: 58px; padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: #0f141b; color: var(--text); font-size: 12px;
}
.sel-inline { width: 92px; }

.hint { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.hint.center { text-align: center; }
.hint.err { color: #ff9d99; }

button, .ghost {
  font: inherit; cursor: pointer; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 12px; font-size: 12.5px; transition: .15s;
}
button:hover, .ghost:hover { border-color: #3a4658; background: #222b38; }
button:disabled { opacity: .45; cursor: not-allowed; }
.ghost { text-decoration: none; display: inline-flex; align-items: center; }
.ghost.danger { color: #ffb3ae; }
.ghost.danger:hover { border-color: #5b2320; background: #261211; }

.primary {
  width: 100%; padding: 12px 14px;
  border: 0; border-radius: 10px;
  background: linear-gradient(140deg, var(--accent-2), #ef8b1b);
  color: #241503; font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 20px rgba(245, 165, 36, .22);
}
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(1px); }

/* ---------- 任务区 ---------- */
.jobs { min-width: 0; }
.jobs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.jobs-head h2 { margin: 0; font-size: 15px; }
.jobs-tools { display: flex; align-items: center; gap: 8px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: .15s border-color, .15s transform;
}
.card:hover { border-color: #35404f; }
.card.running { border-color: #2b4a75; box-shadow: 0 0 0 1px rgba(88, 166, 255, .15) inset; }

.thumb {
  position: relative; aspect-ratio: 3 / 2; background: #0a0e13;
  display: grid; place-items: center; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { color: #405066; font-size: 11px; text-align: center; padding: 10px; }
.thumb .badge {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 8px; border-radius: 999px; font-size: 11px;
  background: rgba(9, 12, 17, .78); border: 1px solid #2a3342; color: var(--muted);
  backdrop-filter: blur(4px);
}
.badge.queued { color: #c7d2e0; }
.badge.running { color: var(--run); border-color: #2b4a75; }
.badge.done { color: #9be8a6; border-color: #24512c; }
.badge.error { color: #ffb3ae; border-color: #5b2320; }
.badge.cancelled { color: #d0b6e8; border-color: #3d2c52; }

.card-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 7px; }
.card-title { display: flex; align-items: baseline; gap: 8px; }
.card-title strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title em { margin-left: auto; color: var(--muted); font-style: normal; font-size: 11px; white-space: nowrap; }

.meta { color: var(--muted); font-size: 11.5px; display: flex; gap: 8px; flex-wrap: wrap; }

.bar { height: 5px; border-radius: 999px; background: #0c1117; overflow: hidden; border: 1px solid #1d2530; }
.bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #2f81f7, #58a6ff); transition: width .4s; }
.bar.indeterminate i {
  width: 38% !important;
  animation: slide 1.15s linear infinite;
  background: linear-gradient(90deg, transparent, #58a6ff, transparent);
}
@keyframes slide { from { transform: translateX(-60%) } to { transform: translateX(300%) } }
.card.done .bar i { background: linear-gradient(90deg, #2ea043, #3fb950); }
.card.error .bar i { background: linear-gradient(90deg, #b62324, #f85149); }

.stage-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.stage-row .err-text { color: #ff9d99; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.actions button, .actions a { padding: 5px 9px; font-size: 11.5px; border-radius: 7px; }
.actions button.accent {
  border-color: #6b4a12; color: #ffd08a;
  background: linear-gradient(140deg, rgba(245,165,36,.22), rgba(245,165,36,.08));
}
.actions button.accent:hover { border-color: var(--accent); background: rgba(245,165,36,.28); }

.empty { padding: 60px 0; text-align: center; color: #56637a; }
.empty span { font-size: 15px; }
.empty p { margin: 6px 0 0; font-size: 12px; }

/* ---------- 查看器 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 7, 10, .72);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 24px;
}
.modal.hidden { display: none; }
.modal-box {
  width: min(1400px, 100%); height: min(880px, 100%);
  background: #0b0e13;
  border: 1px solid #2a3342; border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.modal-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modal-title strong { font-size: 14px; }
.modal-tools { display: flex; gap: 7px; flex-wrap: wrap; }

.canvas-wrap { position: relative; flex: 1; min-height: 0; }
#vCanvas { width: 100%; height: 100%; display: block; cursor: grab; }
#vCanvas:active { cursor: grabbing; }
.canvas-tip, .canvas-badge {
  position: absolute; bottom: 12px; padding: 5px 10px; border-radius: 8px;
  background: rgba(9, 12, 17, .7); border: 1px solid #232b38; color: var(--muted); font-size: 11.5px;
  pointer-events: none;
}
.canvas-tip { left: 12px; }
.canvas-badge { right: 12px; }

/* ---------- 日志 ---------- */
.log-box { height: min(74vh, 760px); width: min(1100px, 100%); }
.log-body {
  flex: 1; margin: 0; padding: 12px 14px; overflow: auto; min-height: 0;
  font: 12px/1.55 Consolas, "Cascadia Mono", "Microsoft YaHei UI", monospace;
  color: #c9d5e3; background: #0a0e13; white-space: pre-wrap; word-break: break-all;
}
.jobs-tools button.active { border-color: var(--accent); color: #ffd08a; background: rgba(245,165,36,.16); }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  padding: 10px 14px; border-radius: 10px; font-size: 12.5px;
  background: #1b222d; border: 1px solid #2c3644; color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: toast-in .18s ease-out;
}
.toast.ok { border-color: #24512c; }
.toast.err { border-color: #5b2320; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

/* 触屏：放大点击区域 */
@media (hover: none) {
  .actions button, .actions a { padding: 9px 12px; font-size: 12.5px; }
  .jobs-tools button { padding: 9px 12px; }
  .ghost, button { min-height: 38px; }
  .dz-sub { display: none; }
}

@media (max-width: 980px) {
  main { grid-template-columns: 1fr; }
  .panel { position: static; }
}
