:root {
  color-scheme: light;
  --bg: #f3f7f5;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --line: #e1e9e6;
  --line-strong: #c9d7d3;
  --text: #16241f;
  --muted: #6b847d;
  --brand: #10a37f;
  --brand-soft: rgba(16, 163, 127, 0.10);
  --warn: #b45309;
  --ok: #059669;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 560px at 12% -12%, rgba(16, 163, 127, 0.12), transparent 62%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, 0.10), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* 顶部 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
}
.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #22d3ee);
  box-shadow: 0 8px 20px rgba(16, 163, 127, 0.22);
}
.brand h1 { margin: 0; font-size: 16px; letter-spacing: 0.02em; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.badges { margin-left: auto; display: flex; gap: 10px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}
.badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
}
.badge.ok { color: #087a60; border-color: rgba(16, 163, 127, 0.38); }
.badge.ok i { background: var(--ok); }

.admin-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
  flex-wrap: wrap;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(16, 163, 127, 0.06);
  white-space: nowrap;
}
.stat-chip b { color: var(--text); font-weight: 600; }

.notice {
  padding: 8px 24px;
  text-align: center;
  font-size: 12px;
  color: #92600a;
  background: rgba(251, 191, 36, 0.14);
  border-bottom: 1px solid rgba(217, 155, 20, 0.28);
}

/* 布局 */
.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px 24px 64px;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 420px;
  gap: 20px;
  align-items: start;
}
.col-mid, .col-right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

@media (max-width: 1280px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .templates { grid-column: 1 / -1; }
  .templates .template-list { max-height: 300px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px 14px 48px; }
  .badges { display: none; }
  .topbar-inner { padding: 12px 16px; }
}

/* 面板 */
.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 2px rgba(16, 40, 34, 0.04), 0 10px 30px rgba(16, 40, 34, 0.05);
  padding: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.head-actions { display: flex; align-items: center; gap: 12px; }

.muted { color: var(--muted); font-size: 12px; }
.hint { margin: 8px 0 0; font-size: 12px; color: #7b948d; }
.hint.warn { color: var(--warn); }
.pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  color: #0a7a60;
  background: var(--brand-soft);
}
.pill.ok { color: var(--ok); background: rgba(5, 150, 105, 0.10); }
.pill.fail { color: var(--danger); background: rgba(220, 38, 38, 0.09); }

/* 表单 */
.label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #55706a;
}
.input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: #a3b5b0; }
.input:focus {
  border-color: rgba(16, 163, 127, 0.6);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.14);
}
.textarea { resize: vertical; line-height: 1.6; }
.field { display: block; }
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 24px;
  font-size: 12px;
  color: #55706a;
}
.checkbox-field input { width: 16px; height: 16px; accent-color: var(--brand); }
input[type="range"] { width: 100%; accent-color: var(--brand); margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { cursor: not-allowed; opacity: 0.4; }
.btn-primary {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 10px 24px rgba(16, 163, 127, 0.20);
}
.btn-primary:hover:not(:disabled) { background: #0c8b6d; }
.btn-ghost {
  color: #37504a;
  border-color: var(--line);
  background: transparent;
}
.btn-ghost:hover:not(:disabled) { border-color: rgba(16, 163, 127, 0.45); color: var(--brand); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 10px; }
.full { width: 100%; margin-top: 14px; }
.link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--brand);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.link:hover { color: #0b7a5f; }
.muted-link { color: #6b847d; }
.muted-link:hover { color: var(--text); }

/* 模板库 */
.templates { position: sticky; top: 84px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: rgba(16, 163, 127, 0.45); color: var(--text); }
.chip.active {
  border-color: rgba(16, 163, 127, 0.55);
  background: var(--brand-soft);
  color: #0b7a5f;
}
.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 300px);
  overflow-y: auto;
  padding-right: 4px;
}
.template-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.template-item:hover { border-color: var(--line-strong); background: rgba(16, 40, 34, 0.03); }
.template-item.active { border-color: rgba(16, 163, 127, 0.55); background: var(--brand-soft); }
.template-item .t-head { display: flex; align-items: flex-start; gap: 8px; }
.template-item .t-icon { margin-top: 1px; }
.template-item .t-name { font-size: 13px; font-weight: 600; color: var(--text); }
.template-item .t-desc {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #6b847d;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.template-item .t-meta { margin-top: 6px; font-size: 11px; color: #8ba39c; }
.tag-default {
  flex-shrink: 0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  color: #0b7a5f;
  background: rgba(16, 163, 127, 0.14);
}

/* 口播 */
.voice-list { display: flex; flex-direction: column; gap: 10px; }
.voice-row { display: flex; align-items: center; gap: 8px; }
.voice-index { width: 48px; flex-shrink: 0; text-align: center; font-size: 12px; color: var(--muted); }
.voice-del {
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: #6b847d;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.voice-del:hover { border-color: rgba(220, 38, 38, 0.4); color: var(--danger); }
.voice-del:disabled { opacity: 0.3; cursor: not-allowed; }

/* 图片 */
.image-grid { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 16px; }
@media (max-width: 640px) { .image-grid { grid-template-columns: minmax(0, 1fr); } }
.image-side { display: flex; flex-direction: column; gap: 8px; }
.image-box {
  height: 160px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #f6faf8;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.image-box img { width: 100%; height: 100%; object-fit: cover; }
.image-box span { padding: 0 12px; text-align: center; font-size: 12px; color: #8ba39c; }
.row-actions { display: flex; gap: 8px; }
.row-actions .btn { flex: 1; }
.image-main { display: flex; flex-direction: column; gap: 12px; }

/* 提示词 */
.prompt-box { min-height: 330px; font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12px; }

/* 进度 */
.progress {
  height: 8px;
  border-radius: 999px;
  background: #132522;
  overflow: hidden;
}
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #22d3ee);
  transition: width 0.5s ease;
}
.video { width: 100%; margin-top: 12px; border-radius: 12px; background: #000; }

/* 历史 */
.history { display: flex; flex-direction: column; gap: 8px; max-height: 280px; overflow-y: auto; }
.history-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
}
.history-item:hover { border-color: rgba(16, 163, 127, 0.45); }
.history-item .h-thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: #eef4f2;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.history-item img { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; background: #eef4f2; flex-shrink: 0; }
.history-item .h-name { font-size: 12px; font-weight: 600; color: var(--text); }
.history-item .h-sub { margin-top: 2px; font-size: 11px; color: #8ba39c; }
.empty { padding: 10px 2px; font-size: 12px; color: #8ba39c; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  z-index: 80;
  max-width: min(90vw, 520px);
  padding: 10px 18px;
  border: 1px solid rgba(16, 163, 127, 0.35);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 16px 40px rgba(16, 40, 34, 0.16);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

[hidden] { display: none !important; }

/* 运行状态面板 */
.ops-dock {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  width: 360px;
  max-width: calc(100vw - 28px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-solid);
  box-shadow: 0 18px 44px rgba(16, 40, 34, 0.18);
  overflow: hidden;
}
.ops-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}
.ops-head strong { font-size: 13px; }
.ops-actions { display: flex; gap: 10px; }
.ops-list { max-height: 270px; overflow: auto; }
.ops-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.op-item {
  display: flex;
  gap: 9px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.op-item:first-child { border-top: 0; }
.op-icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  line-height: 1;
}
.op-running .op-icon {
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  animation: op-spin 0.8s linear infinite;
}
.op-done .op-icon { background: var(--ok); color: #fff; }
.op-fail .op-icon { background: var(--danger); color: #fff; }
.op-body { flex: 1; min-width: 0; }
.op-title { font-weight: 600; color: var(--text); }
.op-detail { margin-top: 2px; color: var(--muted); word-break: break-all; }
.op-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}
.op-meta a { color: var(--brand); }
.ops-dock.collapsed .ops-list { display: none; }
@keyframes op-spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) {
  .ops-dock { right: 14px; bottom: 14px; }
}

/* 分段接力任务 */
.chain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.chain-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 40, 34, 0.025);
  font-size: 12px;
}
.chain-idx { color: var(--muted); flex: none; }
.chain-state { color: var(--text); flex: 1; }
.chain-item .link { flex: none; }
.chain-success { border-color: rgba(5, 150, 105, 0.35); }
.chain-failed { border-color: rgba(220, 38, 38, 0.4); }
.chain-generating .chain-state { color: var(--accent, var(--brand)); }

/* 分段计划 */
.plan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}
.plan-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 40, 34, 0.025);
}
.plan-item .plan-idx { flex: none; color: var(--muted); font-size: 12px; }
.plan-item .plan-text {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-item .plan-dur { flex: none; width: 70px; }
.plan-item .plan-img { flex: none; width: 86px; padding: 2px 4px; font-size: 12px; }
.plan-item .plan-size { flex: none; color: var(--muted); font-size: 12px; }

/* 登录与用户信息 */
.user-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.login-mask {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(233, 240, 238, 0.8);
  backdrop-filter: blur(6px);
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 24px;
}
.login-card .field { margin-top: 12px; }
.login-card .hint { margin-top: 10px; }

/* 抖音解析 */
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form .input { flex: 1; min-width: 0; }
.douyin-result {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 14px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(16, 40, 34, 0.025);
}
.douyin-cover {
  width: 128px;
  height: 170px;
  border-radius: 10px;
  overflow: hidden;
  background: #eef4f2;
}
.douyin-cover img { width: 100%; height: 100%; object-fit: cover; }
.douyin-meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.douyin-title { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--text); }
.douyin-meta p { margin: 0; }
.douyin-meta .row-actions { margin-top: auto; padding-top: 8px; }
.douyin-meta .row-actions .btn { flex: none; }
@media (max-width: 560px) {
  .douyin-result { grid-template-columns: minmax(0, 1fr); }
  .douyin-cover { width: 100%; height: 200px; }
}

/* 多图参考 */
.image-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.image-thumbs .thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #eef4f2;
}
.image-thumbs .thumb.is-primary { border-color: #0b7a5f; box-shadow: 0 0 0 1px #0b7a5f inset; }
.image-thumbs .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-thumbs .thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  padding: 0;
  cursor: pointer;
}
.image-thumbs .thumb-index {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1px 3px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  text-align: center;
}

/* 图片生成 */
.image-result { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.image-result img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 12px;
  background: #f6faf8;
  border: 1px solid var(--line);
}
.image-result .row-actions .btn { flex: 1; text-decoration: none; }

/* 会员中心 */
.member-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.ms-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(16, 40, 34, 0.025);
  font-size: 12px;
}
.ms-item span { color: var(--muted); }
.ms-item b { color: var(--text); font-size: 13px; word-break: break-all; }
.package-cards { display: flex; flex-direction: column; gap: 8px; }
.package-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(16, 40, 34, 0.025);
}
.package-card p { margin: 0; font-size: 12px; }
.pc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pc-price { color: #0b7a5f; font-size: 13px; font-weight: 600; }
.pc-funcs { color: #6b847d; line-height: 1.5; }
.member-orders { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.member-orders summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.order-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
  font-size: 12px;
}
.order-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.order-main span { font-size: 11px; word-break: break-all; }
.order-side { display: flex; align-items: center; gap: 8px; flex: none; }
