:root {
  --bg: #0b0b0e;
  --bg-2: #121217;
  --panel: #15151b;
  --panel-2: #1b1b22;
  --line: #26262e;
  --line-soft: #1f1f26;
  --text: #ece8df;
  --text-dim: #9c9aa3;
  --text-faint: #6c6a73;
  --accent: #e8a94e;
  --accent-strong: #d98a2b;
  --accent-ink: #1a1208;
  --ok: #57c785;
  --warn: #e8a94e;
  --err: #e5645a;
  --info: #5aa7e0;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --serif: "Songti SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body { position: relative; overflow-x: hidden; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.85em; background: #202028; padding: 1px 5px; border-radius: 4px; color: #e8d9b0; }

/* ---- 背景氛围 ---- */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.glow { position: fixed; width: 60vw; height: 60vw; border-radius: 50%; filter: blur(120px); z-index: 0; pointer-events: none; opacity: 0.08; }
.glow-a { top: -25vw; left: -15vw; background: radial-gradient(circle, #e8a94e, transparent 70%); }
.glow-b { bottom: -30vw; right: -20vw; background: radial-gradient(circle, #5aa7e0, transparent 70%); }

/* ---- 顶栏 ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  background: rgba(11, 11, 14, 0.8);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  font-family: var(--serif); font-size: 26px; color: var(--accent); line-height: 1;
  transform: translateY(-1px);
}
.brand-text h1 {
  margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 600;
  letter-spacing: 0.12em; color: var(--text);
}
.brand-sub {
  margin: 0; font-family: var(--mono); font-size: 10px; letter-spacing: 0.28em;
  color: var(--text-faint); text-transform: uppercase;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.dot-status {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px;
  background: var(--text-faint); transition: background .2s;
}
.dot-status[data-state="ok"] { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-status[data-state="err"] { background: var(--err); box-shadow: 0 0 8px var(--err); }
.dot-status[data-state="busy"] { background: var(--info); box-shadow: 0 0 8px var(--info); }

/* ---- 按钮 ---- */
.btn {
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  border-radius: 9px; border: 1px solid transparent; cursor: pointer;
  padding: 9px 16px; transition: all .15s ease; color: var(--text);
  background: transparent; letter-spacing: 0.02em;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: var(--panel-2); border-color: var(--line); color: var(--text-dim); }
.btn-ghost:hover { border-color: #3a3a44; color: var(--text); }
.btn-link { text-decoration: none; }
.btn-accent { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-accent:hover { background: var(--accent-strong); }
.btn-outline { border-color: var(--line); color: var(--text-dim); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon { padding: 8px 10px; line-height: 1; }

.btn-generate {
  width: 100%; margin-top: 22px; padding: 15px;
  font-size: 16px; font-weight: 700; letter-spacing: 0.3em;
  background: linear-gradient(135deg, #f0b95c, #d98a2b);
  color: #1a1208; border: none; border-radius: 11px;
  position: relative; overflow: hidden;
}
.btn-generate:hover { filter: brightness(1.05); }
.btn-generate:disabled { filter: grayscale(0.4) brightness(0.7); cursor: not-allowed; }
.btn-generate-label { position: relative; z-index: 1; }

/* ---- 设置抽屉 ---- */
.settings-panel {
  border-bottom: 1px solid var(--line); background: var(--bg-2);
  animation: slideDown .18s ease;
}
.settings-inner { max-width: 1280px; margin: 0 auto; padding: 20px 26px; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---- 布局 ---- */
.layout {
  position: relative; z-index: 1;
  max-width: 1280px; margin: 0 auto; padding: 26px;
  display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
  gap: 22px; align-items: start;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 15px;
  padding: 26px; position: relative;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft);
}
.panel-head h2 { margin: 0; font-family: var(--serif); font-size: 20px; letter-spacing: 0.1em; }
.panel-head-note { font-family: var(--mono); font-size: 10px; color: var(--text-faint); letter-spacing: 0.08em; }

/* ---- 表单字段 ---- */
.field { margin-bottom: 18px; }
.field > label {
  display: block; font-size: 13px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 7px; letter-spacing: 0.03em;
}
.required { color: var(--err); }
.optional { color: var(--text-faint); font-weight: 400; font-size: 12px; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 13px; font-size: 14px; font-family: var(--sans);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,169,78,0.14); }
textarea { resize: vertical; min-height: 110px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239c9aa3' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 36px; cursor: pointer; }
option { background: var(--panel-2); color: var(--text); }

.hint { margin: 6px 0 0; font-size: 12px; color: var(--text-faint); }
.input-row { display: flex; gap: 9px; }
.input-row input { flex: 1; }
.input-row-key { position: relative; }
.count-row { text-align: right; font-size: 12px; color: var(--text-faint); font-family: var(--mono); margin-top: 5px; }

.model-control { display: flex; gap: 9px; }
.model-control select { flex: 1; }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text-dim); font-size: 13px; cursor: pointer;
  transition: all .13s ease; user-select: none; font-family: var(--sans);
}
.chip:hover { border-color: #3a3a44; color: var(--text); }
.chip.active { border-color: var(--accent); color: var(--accent); background: rgba(232,169,78,0.08); }

.inline-dims { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
.dim { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); }
.dim input { width: 84px; padding: 8px 10px; }
.dim-x { color: var(--text-faint); }

/* ---- 图片上传 ---- */
.image-control { display: flex; flex-direction: column; gap: 10px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1.5px dashed var(--line); border-radius: 11px; padding: 24px;
  cursor: pointer; text-align: center; transition: all .15s; gap: 5px;
  background: var(--bg-2);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(232,169,78,0.04); }
.dropzone-main { font-size: 14px; color: var(--text-dim); font-weight: 500; }
.dropzone-sub { font-size: 12px; color: var(--text-faint); }
.image-preview { position: relative; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); }
.image-preview img { display: block; max-width: 100%; max-height: 220px; margin: 0 auto; }
.btn-remove {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.7); color: #fff; cursor: pointer; font-size: 14px;
}
.btn-remove:hover { background: var(--err); }

/* ---- 高级参数 ---- */
details.advanced { margin: 4px 0 0; }
details.advanced summary {
  cursor: pointer; font-size: 13px; color: var(--text-faint); user-select: none;
  padding: 4px 0; list-style: none;
}
details.advanced summary::before { content: "▸ "; }
details.advanced[open] summary::before { content: "▾ "; }
details.advanced summary:hover { color: var(--text-dim); }
.advanced-grid { display: flex; gap: 18px; padding: 12px 2px 0; }

.footnote { margin: 12px 0 0; font-size: 12px; color: var(--text-faint); text-align: center; }

/* ---- 任务列表 ---- */
.task-head-actions { display: flex; align-items: center; gap: 8px; }
.task-count { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.task-list { display: flex; flex-direction: column; gap: 13px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-icon { font-size: 40px; color: var(--line); font-family: var(--serif); }
.empty-state p { margin: 8px 0 0; }
.empty-sub { font-size: 13px; }

.task-card {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2);
  padding: 16px; animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.task-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.task-model { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.task-meta { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
}
.badge-queued { background: rgba(154,154,163,0.14); color: var(--text-dim); }
.badge-processing { background: rgba(90,167,224,0.14); color: var(--info); }
.badge-succeeded { background: rgba(87,199,133,0.14); color: var(--ok); }
.badge-failed { background: rgba(229,100,90,0.14); color: var(--err); }

.pulse { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.task-prompt { font-size: 13px; color: var(--text-dim); margin: 0 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-error { font-size: 12px; color: var(--err); background: rgba(229,100,90,0.08); border-radius: 8px; padding: 9px 11px; margin: 0 0 8px; word-break: break-all; }

.task-video { width: 100%; border-radius: 9px; background: #000; display: block; margin: 0 0 10px; max-height: 340px; }
.task-actions { display: flex; gap: 8px; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; }

.footer {
  position: relative; z-index: 1; text-align: center; padding: 28px;
  color: var(--text-faint); font-size: 12px; border-top: 1px solid var(--line);
  margin-top: 18px;
}
.footer-sep { margin: 0 10px; opacity: 0.4; }