/* ===== FLYGROW 爆款引擎 — 用户端主题 ===== */
:root {
  --bg: #05070f;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(12, 17, 32, 0.78);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.17);
  --text: #eef2fb;
  --dim: #8fa0bd;
  --accent: #6366f1;
  --accent2: #22d3ee;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #22d3ee 100%);
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --purple: #c4b5fd;
  --blue: #60a5fa;
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}
::selection { background: rgba(99, 102, 241, 0.4); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* ---- 极光背景 ---- */
.aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(ellipse 80% 60% at 15% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
              radial-gradient(ellipse 70% 55% at 85% 110%, rgba(34, 211, 238, 0.12), transparent 60%),
              var(--bg);
}
.aurora::before, .aurora::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5;
}
.aurora::before { width: 520px; height: 520px; left: -140px; top: 12%; background: rgba(99, 102, 241, 0.22); animation: drift1 22s ease-in-out infinite alternate; }
.aurora::after { width: 460px; height: 460px; right: -120px; bottom: -80px; background: rgba(34, 211, 238, 0.16); animation: drift2 28s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(90px, 60px) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-70px, -50px) scale(1.08); } }

/* ---- 通用 ---- */
.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}
.btn-primary {
  background: var(--grad);
  color: #fff; border: none; cursor: pointer;
  border-radius: 12px; padding: 11px 22px; font-size: 14px; font-weight: 600;
  letter-spacing: 0.5px; transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
  box-shadow: 0 6px 22px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 10px 28px rgba(99, 102, 241, 0.45); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary.big { width: 100%; padding: 13px 22px; font-size: 15px; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.05); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 7px 14px;
  cursor: pointer; font-size: 13px; transition: background .15s ease;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }
.dim { color: var(--dim); font-size: 12px; }

input[type="text"], input[type="password"], textarea, select {
  background: rgba(5, 8, 18, 0.6);
  border: 1px solid var(--border-strong);
  color: var(--text); border-radius: 12px; padding: 11px 14px;
  font-size: 14px; width: 100%; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
select { cursor: pointer; }

/* 输出模板：每项 = 标签 + 写作要求（脚本生成第⑤步） */
.tpl-box { display: flex; flex-direction: column; gap: 8px; }
.tpl-row { display: flex; align-items: center; gap: 8px; }
.tpl-row .tpl-tag {
  flex: 0 0 108px; width: 108px; min-width: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; font-weight: 600; color: var(--purple);
  padding: 11px 10px;
}
.tpl-row .tpl-req { flex: 1; min-width: 0; font-size: 13px; }
.tpl-del {
  flex: 0 0 auto; width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--dim); border: none; border-radius: 8px;
  font-size: 18px; line-height: 1; cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.tpl-del:hover { color: var(--red); background: rgba(248, 113, 113, 0.12); }
.tpl-add {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  margin: 4px 0 10px;
  padding: 10px 16px;
  background: rgba(196, 181, 253, 0.06);
  color: var(--purple);
  border: 1px dashed rgba(196, 181, 253, 0.4);
  border-radius: 12px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.tpl-add:hover { background: rgba(196, 181, 253, 0.14); border-color: rgba(196, 181, 253, 0.75); color: #fff; }
.tpl-add:active { transform: translateY(1px); }

/* ---- 登录 / 注册 ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: min(420px, 94vw); padding: 36px 34px; position: relative; overflow: hidden; }
.auth-card::before {
  content: ""; position: absolute; top: -80px; left: 50%; transform: translateX(-50%);
  width: 300px; height: 160px; background: var(--grad); filter: blur(70px); opacity: 0.25; border-radius: 50%;
}
.brand { text-align: center; margin-bottom: 26px; position: relative; }
.brand .logo {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-size: 28px; box-shadow: 0 10px 30px rgba(99, 102, 241, 0.45);
}
.brand h1 { font-size: 22px; letter-spacing: 1px; }
.brand h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand p { color: var(--dim); font-size: 12.5px; margin-top: 6px; letter-spacing: 2px; }

.auth-tabs { display: flex; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 20px; position: relative; }
.auth-tabs button {
  flex: 1; background: transparent; border: none; color: var(--dim); padding: 9px 0;
  border-radius: 9px; cursor: pointer; font-size: 14px; transition: all .2s ease;
}
.auth-tabs button.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35); }
.field { margin-bottom: 14px; position: relative; }
.field label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 6px; }
.auth-err { min-height: 20px; color: var(--red); font-size: 12.5px; margin-bottom: 10px; }
.auth-hint { text-align: center; color: var(--dim); font-size: 12px; margin-top: 14px; }
.machine-panel {
  margin-top: 16px; padding: 13px 14px; border-radius: 12px;
  background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.28);
  font-size: 12.5px; line-height: 1.7;
}
.machine-panel b { color: var(--green); }
.machine-code-box {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px;
}
.machine-code-box code {
  flex: 1; background: rgba(0, 0, 0, 0.35); border: 1px dashed rgba(52, 211, 153, 0.4);
  padding: 6px 10px; border-radius: 8px; color: var(--green); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.machine-code-box button { flex-shrink: 0; }

/* ---- 顶栏（唯一导航栏：页面 tab + 脚本生成 tab + 余额信息合一，滚动后吸顶） ---- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 22px; border-radius: 0;
  border-left: none; border-right: none; border-top: none;
}
/* 公告条：显示在顶部导航下方（nav 之后、内容区之前） */
.announce-bar {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 12px 22px 0; padding: 10px 14px;
  background: linear-gradient(135deg, rgba(251, 191, 36, .12), rgba(251, 146, 60, .10));
  border: 1px solid rgba(251, 191, 36, .35);
  border-radius: 12px; color: var(--text); font-size: 13px;
}
.announce-icon { font-size: 16px; line-height: 1.5; }
.announce-body { flex: 1; white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.announce-close {
  background: transparent; border: none; color: var(--dim); cursor: pointer;
  font-size: 14px; padding: 2px 7px; border-radius: 6px; line-height: 1.4;
}
.announce-close:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.nav-tabs { display: inline-flex; align-items: center; gap: 4px; }
/* 用户菜单：点「👤 用户名」下拉显示 机器码/余额/单价/退出登录 */
.user-menu { position: relative; margin-left: auto; }
.user-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 6px 13px; font-size: 12.5px; color: var(--text);
  cursor: pointer; white-space: nowrap; transition: background .15s ease;
}
.user-btn:hover { background: rgba(255, 255, 255, 0.1); }
.user-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 70;
  min-width: 220px; padding: 8px;
  background: var(--panel-strong); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.ud-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 8px 12px; border-radius: 10px; font-size: 12.5px; color: var(--text);
  background: transparent; border: none; cursor: default; text-align: left;
}
.ud-item.copy-btn { cursor: pointer; }
.ud-item.copy-btn:hover { background: rgba(52, 211, 153, 0.08); }
.ud-name { color: var(--dim); }
.ud-val { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
#udBalance { color: var(--green); }
#udBalance.low { color: var(--red); }
#udPrice { color: var(--yellow); }
.ud-nav { cursor: pointer; }
.ud-nav:hover { background: rgba(99, 102, 241, 0.12); }
.ud-logout { cursor: pointer; border-top: 1px solid var(--border); border-radius: 0 0 10px 10px; color: var(--red); }
.ud-logout:hover { background: rgba(248, 113, 113, 0.1); }
/* 脚本生成 tab（生成流程/生成历史/重置/API配置）：顶栏内紧凑胶囊样式 */
#sgSubNav { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.topbar .sg-tab {
  background: transparent; border: 1px solid rgba(255,255,255,.17); color: var(--dim);
  padding: 5px 13px; border-radius: 999px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; transition: all .18s ease;
}
.topbar .sg-tab:hover { color: var(--text); background: rgba(255,255,255,.06); }
.topbar .sg-tab.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.topbar .sg-tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: rgba(0,0,0,.2); font-size: 11px; margin-left: 4px; }
.topbar .sg-tab.active .sg-tab-badge { background: rgba(255,255,255,.25); }
.topbar .subtab { padding: 6px 14px; font-size: 13px; }
.brand-mini { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; }
.brand-mini .logo {
  width: 34px; height: 34px; border-radius: 10px; background: var(--grad);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}
.brand-mini em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.chips { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; align-items: center; }
#moreBtn { display: none; }   /* 桌面端隐藏「更多」，移动端折叠信息用 */
.chip {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 13px; font-size: 12.5px; color: var(--text);
}
.chip .val { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.chip.balance .val { color: var(--green); font-weight: 700; font-size: 13.5px; }
.chip.price .val { color: var(--yellow); font-weight: 600; }
.chip.copy-btn { cursor: pointer; transition: all .15s ease; }
.chip.copy-btn:hover { border-color: rgba(52, 211, 153, 0.5); background: rgba(52, 211, 153, 0.08); }
.chip.copy-btn:hover .val { color: var(--green); }

/* ---- 二级导航 ---- */
.subnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px; padding: 10px 24px; margin-top: -1px;
  border-left: none; border-right: none; border-top: none; border-radius: 0;
  max-width: 1440px; margin-left: auto; margin-right: auto;
}
.subtab {
  background: transparent; border: 1px solid transparent; color: var(--dim);
  padding: 8px 18px; border-radius: 999px; cursor: pointer; font-size: 13.5px;
  transition: all .18s ease;
}
.subtab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.subtab.active { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35); }
/* 导航右侧组：API 对接 tab + 脚本生成附加区整体推至最右 */
.subnav-right { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
/* 脚本生成 subnav 附加区（描述 + 重置/API配置按钮），仅切到脚本生成时显示 */
.sg-subnav { display: inline-flex; align-items: center; gap: 10px; }
.sg-subnav-sub { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.sg-subnav-btn { padding: 5px 12px !important; font-size: 12px; white-space: nowrap; }
@media (max-width: 900px) { .sg-subnav-sub { display: none; } }

/* ---- 主布局 ---- */
.layout { display: grid; grid-template-columns: minmax(400px, 460px) 1fr; gap: 20px; padding: 24px; max-width: 1440px; margin: 0 auto; align-items: start; }
@media (max-width: 1020px) { .layout { grid-template-columns: 1fr; } .chips { margin-left: 0; } .topbar { flex-wrap: wrap; } }

/* ---- API 对接页 ---- */
.api-layout { display: flex; flex-direction: column; gap: 20px; padding: 24px; max-width: 1080px; margin: 0 auto; }
.api-layout .card { padding: 24px; }
.api-layout h2 { font-size: 16.5px; margin-bottom: 6px; }
.api-layout .lead { color: var(--dim); font-size: 13px; line-height: 1.7; margin-bottom: 16px; }
.key-list { display: flex; flex-direction: column; gap: 10px; }
.key-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
  border-radius: 13px; padding: 12px 16px; transition: border-color .15s ease;
}
.key-row:hover { border-color: var(--border-strong); }
.key-row .k-code { font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; color: var(--green); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-row .k-label { color: var(--dim); font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-row .k-badge { background: rgba(99, 102, 241, 0.16); border: 1px solid rgba(99, 102, 241, 0.4); color: #a5b4fc; font-size: 11px; padding: 2px 9px; border-radius: 999px; }
.key-row .k-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-danger { background: transparent; border: 1px solid rgba(248, 113, 113, 0.35); color: var(--red); border-radius: 10px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; transition: all .15s ease; }
.btn-danger:hover { background: rgba(248, 113, 113, 0.12); }

.card { padding: 24px; }
.card h2 { font-size: 16.5px; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.card h2 .sub { font-size: 12px; color: var(--dim); font-weight: 400; margin-left: auto; }

/* ---- 创建任务 ---- */
.step-label { font-size: 13px; color: var(--dim); margin: 18px 0 9px; font-weight: 600; letter-spacing: 0.5px; }
.step-label:first-of-type { margin-top: 0; }
.step-label .count { font-weight: 400; float: right; }
.step-label .count.full { color: var(--yellow); }

.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: 14px;
  padding: 26px 18px; text-align: center; cursor: pointer; color: var(--dim);
  transition: all .18s ease; font-size: 13px; position: relative;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(99, 102, 241, 0.07); color: var(--text); }
.dropzone.small { padding: 16px 18px; }
.dropzone .dz-icon { font-size: 26px; display: block; margin-bottom: 6px; }
.dropzone input[type="file"] { display: none; }

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-top: 12px; }
.img-cell { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; border: 1px solid var(--border); background: rgba(0, 0, 0, 0.3); }
.img-cell img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; transition: transform .15s ease; }
.img-cell img:hover { transform: scale(1.05); }
.img-cell .rm {
  position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.65); color: #fff; border: none; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center; transition: all .15s ease; backdrop-filter: blur(4px);
}
.img-cell .rm:hover { background: var(--red); }

.audio-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.audio-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
  border-radius: 11px; padding: 9px 12px; font-size: 13px;
}
.audio-row .a-ico { font-size: 16px; }
.audio-row .a-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.audio-row .a-size { color: var(--dim); font-size: 11.5px; }
.audio-row .rm {
  background: transparent; border: none; color: var(--dim); cursor: pointer; font-size: 14px; padding: 2px 6px;
  border-radius: 6px; transition: all .15s ease;
}
.audio-row .rm:hover { color: var(--red); background: rgba(248, 113, 113, 0.12); }

textarea#prompt { min-height: 110px; resize: vertical; line-height: 1.6; font-family: inherit; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 9px; }
.prompt-head .step-label { margin: 0; }
.ai-prompt-btn {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 4px 12px; white-space: nowrap;
  background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(168,85,247,.18));
  color: var(--text); border: 1px solid rgba(99,102,241,.5);
  border-radius: 999px; font-size: 13px; font-weight: 600; line-height: 1.4; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.ai-prompt-btn:hover { transform: translateY(-1px); border-color: rgba(168,85,247,.8); box-shadow: 0 6px 18px rgba(99,102,241,.25); }
.ai-prompt-btn:active { transform: translateY(0); }
.ai-prompt-btn:disabled { opacity: .45; cursor: not-allowed; }
.char-count { text-align: right; color: var(--dim); font-size: 11.5px; margin-top: 5px; }

.opt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.opt-row label { font-size: 12.5px; color: var(--dim); display: flex; flex-direction: column; gap: 6px; }
.opt-row select { font-size: 13.5px; }

.cost-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; padding: 14px 16px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(34, 211, 238, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.22);
}
.cost-row .cost b { font-size: 19px; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.cost-row .cost .dim { display: block; margin-top: 3px; }
.cost-row .bal { text-align: right; font-size: 12.5px; color: var(--dim); }
.cost-row .bal b { font-size: 15px; color: var(--green); }
.cost-row .bal .low { color: var(--red); }

#submitBtn { margin-top: 18px; }

/* ---- 队列 ---- */
.queue { min-height: 60vh; }
.queue-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.queue-head h2 { margin-bottom: 0; }
.queue-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-pill {
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 13px; font-size: 12px; color: var(--dim);
}
.stat-pill b { color: var(--text); margin-left: 4px; }

.task-list { display: flex; flex-direction: column; gap: 14px; }
.task-card {
  border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  background: rgba(255, 255, 255, 0.03); transition: border-color .2s ease;
  animation: fadeUp .3s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.task-card:hover { border-color: var(--border-strong); }
.task-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.task-thumbs { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.task-thumb {
  width: 54px; height: 54px; border-radius: 12px; object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border); background: rgba(0, 0, 0, 0.3);
  cursor: zoom-in; transition: border-color .15s ease, transform .15s ease;
}
.task-thumb:hover { border-color: var(--accent); transform: scale(1.04); }
.thumb-more {
  width: 54px; height: 54px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.06); border: 1px dashed var(--border-strong);
  color: var(--dim); font-size: 12px;
}
.task-title { flex: 1; min-width: 0; }
.task-title .t-id { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--dim); }
.task-title .t-meta { font-size: 12px; color: var(--dim); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.task-prompt {
  font-size: 13px; color: var(--dim); line-height: 1.55; margin-bottom: 12px;
  word-break: break-all;   /* 提示词完整显示，不截断 */
}
/* 长提示词：默认固定高度收起，点「展开」平滑动画显示全文，再点收起 */
.task-prompt .tp-short { display: block; max-height: 62px; overflow: hidden; }
.task-prompt .tp-full {
  display: block; max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height .4s ease, opacity .35s ease;
}
.task-prompt.expanded .tp-short { display: none; }
.task-prompt.expanded .tp-full { max-height: 4000px; opacity: 1; }
.tp-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 6px; width: 26px; height: 22px; padding: 0; font-size: 12px; line-height: 1;
  color: var(--accent2); background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.25); border-radius: 8px; cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.tp-toggle:hover { background: rgba(34, 211, 238, 0.18); }
.tp-toggle:active { transform: scale(0.92); }
.tp-toggle .chev { display: inline-block; transition: transform .3s ease; }
.task-prompt.expanded .tp-toggle .chev { transform: rotate(180deg); }

.tag { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.tag.queued { background: rgba(251, 191, 36, 0.13); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.3); }
.tag.running { background: rgba(96, 165, 250, 0.13); color: var(--blue); border: 1px solid rgba(96, 165, 250, 0.3); }
.tag.downloading { background: rgba(196, 181, 253, 0.13); color: var(--purple); border: 1px solid rgba(196, 181, 253, 0.3); }
.tag.retry_download { background: rgba(251, 146, 60, 0.13); color: #fdba74; border: 1px solid rgba(251, 146, 60, 0.3); }
.tag.completed { background: rgba(52, 211, 153, 0.13); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }
.tag.failed { background: rgba(248, 113, 113, 0.13); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.3); }

.progress-wrap { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.progress-track { flex: 1; height: 7px; background: rgba(255, 255, 255, 0.07); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 99px; background: var(--grad);
  transition: width .8s ease; position: relative; overflow: hidden;
}
.progress-fill.active::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.progress-num { font-size: 12px; font-family: ui-monospace, Menlo, monospace; color: var(--dim); min-width: 36px; text-align: right; }
.queue-pos { font-size: 12px; color: var(--yellow); }

.task-error {
  font-size: 12.5px; color: var(--red); background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.22); border-radius: 10px;
  padding: 8px 12px; margin: 8px 0 12px; word-break: break-all; line-height: 1.55;
}
.task-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.task-cost { font-size: 12px; color: var(--yellow); margin-left: auto; }
.task-enhance { font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.task-enhance.done { color: #4ade80; background: rgba(74, 222, 128, 0.12); }
.task-enhance.failed { color: #ef4444; background: rgba(239, 68, 68, 0.12); }

.task-logs {
  margin-top: 12px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; max-height: 220px; overflow-y: auto;
  font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; line-height: 1.65; color: var(--dim);
}

.empty {
  text-align: center; padding: 70px 20px; color: var(--dim); font-size: 13.5px;
}
.empty .e-ico { font-size: 40px; display: block; margin-bottom: 14px; opacity: 0.7; }

/* ---- API 配置弹窗（位于 #scriptgenView 之外：scriptgen.css 的 modal 样式是 #scriptgenView 作用域，
     不加这组非作用域样式时弹窗 0×0 不可见——「API 配置点击失效」根因） ---- */
#settingsModal { position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center; background: rgba(3, 5, 12, 0.82); backdrop-filter: blur(10px); padding: 24px; }
#settingsModal .modal {
  position: static; display: block;   /* 覆盖通用 .modal 的 display:flex（否则 h3/字段/按钮被排成一行） */
  width: min(560px, 94vw); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(160deg, rgba(22, 28, 52, 0.97), rgba(10, 13, 26, 0.97));
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 18px; padding: 26px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); animation: popIn 0.2s ease;
}
#settingsModal .modal h3 { font-size: 16px; margin-bottom: 20px; color: var(--text); }
#settingsModal .modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
#settingsModal .modal .btn { background: rgba(255, 255, 255, 0.08); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 18px; font-size: 13px; cursor: pointer; }
#settingsModal .modal .btn.primary { background: var(--grad); border: none; }
#settingsModal .hint { color: var(--dim); font-size: 12px; line-height: 1.7; }
/* 弹窗内输入框：多数没有 type 属性（CSS 属性选择器 [type="text"] 匹配不到默认 text），必须用不带类型的规则覆盖 */
#settingsModal input {
  background: rgba(5, 8, 18, 0.6); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; width: 100%; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#settingsModal input:focus { border-color: rgba(99, 102, 241, 0.65); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18); }

/* ---- 修改密码弹窗 ---- */
#pwdModal { position: fixed; inset: 0; z-index: 320; display: none; align-items: center; justify-content: center; background: rgba(3, 5, 12, 0.82); backdrop-filter: blur(10px); padding: 24px; }
#pwdModal .modal {
  position: static; display: block;
  width: min(460px, 94vw); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(160deg, rgba(22, 28, 52, 0.97), rgba(10, 13, 26, 0.97));
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 18px; padding: 26px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); animation: popIn 0.2s ease;
}
#pwdModal .modal h3 { font-size: 16px; margin-bottom: 20px; color: var(--text); }
#pwdModal .modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
#pwdModal .modal .btn { background: rgba(255, 255, 255, 0.08); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 18px; font-size: 13px; cursor: pointer; }
#pwdModal .modal .btn.primary { background: var(--grad); border: none; }
#pwdModal input {
  background: rgba(5, 8, 18, 0.6); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; width: 100%; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#pwdModal input:focus { border-color: rgba(99, 102, 241, 0.65); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18); }

/* ---- 视频分类选择弹窗（位于 #scriptgenView 之外） ---- */
#categoryModal { position: fixed; inset: 0; z-index: 310; display: none; align-items: center; justify-content: center; background: rgba(3, 5, 12, 0.82); backdrop-filter: blur(10px); padding: 24px; }
#categoryModal .modal {
  position: static; display: block;
  width: min(600px, 94vw); max-height: 88vh; overflow-y: auto;
  background: linear-gradient(160deg, rgba(22, 28, 52, 0.97), rgba(10, 13, 26, 0.97));
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 18px; padding: 26px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); animation: popIn 0.2s ease;
}
#categoryModal .modal h3 { font-size: 16px; margin-bottom: 8px; color: var(--text); }
#categoryModal .modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
#categoryModal .modal .btn { background: rgba(255, 255, 255, 0.08); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 18px; font-size: 13px; cursor: pointer; }
#categoryModal .cat-modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
#categoryModal .cat-card {
  border: 1.5px solid var(--border-strong); border-radius: 14px; padding: 18px 12px;
  text-align: center; cursor: pointer; background: rgba(255, 255, 255, 0.03);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
#categoryModal .cat-card:hover { transform: translateY(-2px); border-color: rgba(99, 102, 241, 0.6); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35); }
#categoryModal .cat-card.selected { border-color: #6366f1; background: rgba(99, 102, 241, 0.14); }
#categoryModal .cat-ico { font-size: 26px; margin-bottom: 8px; }
#categoryModal .cat-name { font-size: 14px; font-weight: 700; color: var(--text); }
#categoryModal .cat-desc { font-size: 11.5px; color: var(--dim); margin-top: 6px; line-height: 1.6; }


/* ---- 视频预览弹窗 ---- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 5, 12, 0.82); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card { width: min(860px, 96vw); animation: popIn .25s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(12px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.modal-head .m-close { background: transparent; border: none; color: var(--dim); font-size: 17px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.modal-head .m-close:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.modal-card video { width: 100%; display: block; border-radius: 0 0 var(--radius) var(--radius); background: #000; max-height: 74vh; }
.modal-foot { display: flex; gap: 10px; padding: 13px 18px; border-top: 1px solid var(--border); justify-content: flex-end; }

/* ---- Toast ---- */
#toastBox { position: fixed; top: 74px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
/* 下载/保存图库 顶部悬浮进度条 */
#dlProgress {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  width: min(400px, 92vw); z-index: 150; display: none;
  background: var(--panel-strong); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
#dlProgress .dlp-label { font-size: 12.5px; color: var(--text); margin-bottom: 7px; }
#dlProgress .dlp-track { height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; overflow: hidden; }
#dlProgress .dlp-fill { height: 100%; width: 2%; background: var(--grad); border-radius: 99px; transition: width .25s ease; }
.toast {
  background: var(--panel-strong); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 12px 18px; font-size: 13px; backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); animation: slideIn .25s ease; max-width: 340px;
}
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ===== 移动端适配 ===== */
@media (max-width: 520px) {
  /* z-index 关键：.glass 的 backdrop-filter 让 topbar 自成层叠上下文，z-index 必须在这里提升，
     否则「更多」下拉（内部 z-index 出不了 topbar 的上下文）会被主内容盖住。
     ⚠️ position: sticky（不是 relative）：顶栏现在是唯一导航栏要吸顶；sticky 本身即定位元素，
     「更多」下拉的 absolute 锚点不受影响 */
  .topbar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; position: sticky; top: 0; z-index: 60; }
  .announce-bar { margin: 8px 12px 0; padding: 9px 12px; font-size: 12.5px; }
  /* 移动端两行布局：第一行 = 爆款引擎标题 + 用户菜单；第二行 = 生成中心/脚本生成 tab（+ 脚本生成子 tab） */
  .brand-mini { font-size: 14px; flex: 1; min-width: 0; }
  .nav-tabs { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #sgSubNav { order: 4; }
  /* 用户菜单下拉适配移动端 */
  .user-menu { margin-left: auto; }
  .user-btn { padding: 5px 11px; font-size: 12px; white-space: nowrap; }
  .user-dropdown { right: 0; min-width: 200px; max-width: calc(100vw - 24px); }
  .chip { padding: 5px 9px; font-size: 11px; }
  .subnav { padding: 8px 12px; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .subtab { padding: 7px 13px; font-size: 12.5px; white-space: nowrap; flex: 0 0 auto; }
  .subnav-right { gap: 6px; }
  .sg-subnav-btn { padding: 4px 9px !important; font-size: 11px; }
  .layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .card { padding: 16px 14px; }
  .task-card { padding: 12px; }
  /* 多图任务：缩略图独占一行横向滚动，标题/状态挪到下一行，避免多图时挤压错乱 */
  .task-head { flex-wrap: wrap; row-gap: 8px; }
  .task-thumbs {
    order: -1; flex: 1 0 100%; width: 100%; min-width: 0; max-width: 100%;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; scrollbar-width: none;
  }
  .task-thumbs::-webkit-scrollbar { display: none; }
  .auth-wrap { padding: 12px; }
  .auth-card { padding: 26px 18px; }
  .machine-code-box { flex-wrap: wrap; }
  /* 防 iOS 输入聚焦自动放大 */
  .field input, .field textarea, .field select, input[type="text"], input[type="password"] { font-size: 16px; }
  .modal-card { width: 96vw; }
  /* 脚本生成器视图（原生融合）在手机上的内边距 */
  #scriptgenView .sg-tabs { padding: 0 12px; }
  #scriptgenView .sg-tab { padding: 6px 12px; font-size: 12.5px; }
  #historyView { padding: 0 12px; }
}

/* ---- 爆款复刻 ---- */
.rp-layout { max-width: 860px; margin: 0 auto; padding: 24px 20px 60px; }
.rp-layout h2 { font-size: 20px; margin: 6px 0 4px; }
.rp-layout .step-tip { color: var(--dim); font-size: 13px; margin: 0 0 18px; line-height: 1.6; }
.rp-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.rp-card h3 { font-size: 15.5px; margin-bottom: 14px; color: var(--text); }
.rp-sections { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.rp-section { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.rp-section .rp-sec-head { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 13.5px; color: var(--text); margin-bottom: 6px; }
.rp-section .rp-sec-no { color: var(--accent); font-weight: 800; }
.rp-section .rp-sec-body { font-size: 13px; color: var(--dim); line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.rp-gen-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.rp-gen-row .field { flex: 0 1 150px; margin-bottom: 0; }
.rp-gen-row .field label { white-space: nowrap; }
.rp-gen-row .btn-primary { margin-bottom: 0; flex: 0 0 auto; }
.rp-gen-row .btn-ghost { margin-bottom: 0; flex: 0 0 auto; }
#replicaView textarea#rpPrompt { min-height: 180px; resize: vertical; line-height: 1.6; font-family: inherit; }
#replicaView input[type="file"] { color: var(--dim); font-size: 13px; }
.rp-product-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.rp-product-drop { flex: 1; min-width: 220px; }
.rp-product-preview { flex: 0 0 96px; width: 96px; height: 96px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: rgba(0, 0, 0, 0.3); }
.rp-product-preview img, .rp-product-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.rp-product-preview img { cursor: zoom-in; }
.rp-video-preview { flex: 0 0 176px; width: 176px; height: 100px; background: #000; }
.rp-video-preview video { object-fit: contain; }
.rp-output { margin-top: 6px; }
.rp-save-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.rp-save-row input { flex: 1; min-width: 200px; }
.rp-save-row .btn-primary { flex: 0 0 auto; }
.rp-saved-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.rp-saved-row select { flex: 1; min-width: 200px; }
.rp-saved-row .btn-ghost { flex: 0 0 auto; }
@media (max-width: 640px) {
  .rp-layout { padding: 14px 12px 60px; }
  .rp-card { padding: 16px 14px; }
  .rp-gen-row { gap: 10px; }
  .rp-gen-row .field { flex: 1 1 130px; }
  .rp-product-row { flex-direction: column; align-items: stretch; }
  .rp-product-drop { min-width: 0; }
  .rp-product-preview { flex: 0 0 auto; width: 100%; height: 140px; }
}
