/* ============================================================
   Video Studio · Design System v2
   统一令牌 / 组件 / 状态 / 响应式，纯 CSS，零依赖
   ============================================================ */

:root {
  color-scheme: dark;

  /* 表面与层次：低饱和蓝灰，避免大面积纯黑 */
  --bg: #090e18;
  --bg-glow: #101a2c;
  --surface-1: #111a29;
  --surface-2: #182437;
  --surface-3: #223149;
  --surface-inset: #0c1422;
  --line: #293951;
  --line-soft: #1d2a3e;
  --line-strong: #405472;

  /* 文本 */
  --text: #edf3fc;
  --text-2: #b4c1d5;
  --text-3: #8293ad;
  /* 次要文字对比度：三套主题都要求在 --surface-1 上 >= 4.5、--surface-2 上 >= 4.2（原来只有 2.6~3.6），
     色相不变，只向主文字色靠近；层级仍是 faint < text-3 < text-2 */
  --text-faint: #76869f;

  /* 品牌与状态 */
  --primary: #5b7cfa;
  --primary-hover: #7190ff;
  --primary-soft: rgba(91, 124, 250, 0.14);
  --primary-line: rgba(115, 145, 255, 0.46);
  --teal: #36d6c3;
  --success: #42d7a4;
  --warning: #f4bc56;
  --danger: #fb7b91;
  --info: #82a4ff;

  /* 4 / 8px 间距体系 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* 圆角、阴影与动效 */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.18);
  --shadow-2: 0 20px 55px rgba(0, 0, 0, 0.25);
  --focus: 0 0 0 3px rgba(112, 143, 255, 0.26);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* 主题语义令牌（供多主题覆盖） */
  --text-strong: #f8faff;
  --header-bg: rgba(9, 14, 24, 0.82);
  --overlay-1: rgba(255, 255, 255, 0.018);
  --overlay-2: rgba(255, 255, 255, 0.03);
  --overlay-3: rgba(255, 255, 255, 0.07);
  --accent-teal-text: #86e8d8;
  --accent-blue-text: #b3c4ff;
  --accent-blue-text-2: #d3ddff;
  --accent-blue-text-3: #b3c9ff;
  --accent-warn-text: #f8d38c;
  --accent-danger-text: #ffb4c1;
  --page-glow-1: rgba(74, 105, 235, 0.16);
  --page-glow-2: rgba(42, 198, 182, 0.075);
  --warn-soft: rgba(244, 188, 86, 0.08);
  --warn-line: rgba(244, 188, 86, 0.4);
  --upload-text: #b3c4ff;
  --upload-text-hover: #e0e7ff;
  --upload-hover-bg: rgba(91, 124, 250, 0.23);
  --info-soft: rgba(91, 124, 250, 0.09);
  --info-line: rgba(115, 145, 255, 0.4);

  --font: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* ============================================================
   主题：白色（light）
   ============================================================ */
html[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f6fb;
  --bg-glow: #eaf0fa;
  --surface-1: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eaf0f9;
  --surface-inset: #f1f4fa;
  --line: #dce3ef;
  --line-soft: #e8edf5;
  --line-strong: #bdcadd;

  --text: #17243a;
  --text-2: #4b5b72;
  --text-3: #64738a;
  --text-faint: #6a778a;

  --primary: #4b67dd;
  --primary-hover: #3e58c8;
  --primary-soft: rgba(75, 103, 221, 0.09);
  --primary-line: rgba(75, 103, 221, 0.32);
  --teal: #138e80;
  --success: #138e69;
  --warning: #a96e16;
  --danger: #cc455e;
  --info: #4b67dd;

  --shadow-1: 0 2px 8px rgba(37, 53, 82, 0.06);
  --shadow-2: 0 18px 48px rgba(37, 53, 82, 0.08);
  --focus: 0 0 0 3px rgba(75, 103, 221, 0.18);

  --text-strong: #12203a;
  --header-bg: rgba(255, 255, 255, 0.86);
  --overlay-1: rgba(23, 36, 58, 0.018);
  --overlay-2: rgba(23, 36, 58, 0.032);
  --overlay-3: rgba(23, 36, 58, 0.06);
  --accent-teal-text: #117568;
  --accent-blue-text: #3d58c0;
  --accent-blue-text-2: #304aa5;
  --accent-blue-text-3: #3d58c0;
  --accent-warn-text: #92600f;
  --accent-danger-text: #b93650;
  --page-glow-1: rgba(75, 103, 221, 0.1);
  --page-glow-2: rgba(19, 142, 128, 0.06);
  --warn-soft: rgba(169, 110, 22, 0.07);
  --warn-line: rgba(169, 110, 22, 0.32);
  --upload-text: #3d58c0;
  --upload-text-hover: #2e4391;
  --upload-hover-bg: rgba(75, 103, 221, 0.14);
  --info-soft: rgba(75, 103, 221, 0.07);
  --info-line: rgba(75, 103, 221, 0.32);
}

/* ============================================================
   主题：黄色（warm）—— 暖纸底 + 琥珀强调
   ============================================================ */
html[data-theme="warm"] {
  color-scheme: light;

  --bg: #fdf7e8;
  --bg-glow: #fbf1d6;
  --surface-1: #fffdf7;
  --surface-2: #fbf4e4;
  --surface-3: #f6ecd5;
  --surface-inset: #fdf8ec;
  --line: #e7d9b8;
  --line-soft: #f0e6ce;
  --line-strong: #d4bf92;

  --text: #33291a;
  --text-2: #5f5237;
  --text-3: #7e6e51;
  --text-faint: #807355;

  --primary: #b8791a;
  --primary-hover: #a26812;
  --primary-soft: rgba(184, 121, 26, 0.12);
  --primary-line: rgba(184, 121, 26, 0.38);
  --teal: #0f8f7c;
  --success: #16865c;
  --warning: #b8791a;
  --danger: #c73f4e;
  --info: #2f63c8;

  --shadow-1: 0 1px 2px rgba(51, 41, 26, 0.1);
  --shadow-2: 0 16px 38px rgba(51, 41, 26, 0.12);
  --focus: 0 0 0 3px rgba(184, 121, 26, 0.24);

  --text-strong: #33291a;
  --header-bg: rgba(255, 253, 247, 0.9);
  --overlay-1: rgba(51, 41, 26, 0.022);
  --overlay-2: rgba(51, 41, 26, 0.04);
  --overlay-3: rgba(51, 41, 26, 0.07);
  --accent-teal-text: #0b7365;
  --accent-blue-text: #2b58b0;
  --accent-blue-text-2: #234b9c;
  --accent-blue-text-3: #2b58b0;
  --accent-warn-text: #8f5e07;
  --accent-danger-text: #b52f3d;
  --page-glow-1: rgba(184, 121, 26, 0.13);
  --page-glow-2: rgba(15, 143, 124, 0.08);
  --warn-soft: rgba(184, 121, 26, 0.09);
  --warn-line: rgba(184, 121, 26, 0.42);
  --upload-text: #8a5a08;
  --upload-text-hover: #6d4605;
  --upload-hover-bg: rgba(184, 121, 26, 0.2);
  --info-soft: rgba(47, 99, 200, 0.07);
  --info-line: rgba(47, 99, 200, 0.4);
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(900px 520px at 8% -8%, var(--page-glow-1), transparent 66%),
    radial-gradient(760px 480px at 96% 0%, var(--page-glow-2), transparent 66%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin-top: 0; }

:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

::selection { background: rgba(91, 141, 239, 0.34); color: #fff; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r);
  text-decoration: none;
  transition: top 0.18s;
}
.skip-link:focus { top: 12px; }

/* ============================================================
   顶栏
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line-soft);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.header-inner {
  max-width: 1520px;
  margin: 0 auto;
  min-height: 72px;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  flex: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #7392ff, #5b7cfa 54%, #45c9c0);
  box-shadow: 0 8px 24px rgba(91, 124, 250, 0.25), inset 0 1px 0 rgba(255,255,255,.22);
}
.brand-mark .ico { width: 19px; height: 19px; }
.brand-mark-img { background: linear-gradient(145deg, #45c9c0, #5b7cfa 62%, #8296ff); }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: -0.15px; }
.brand-text small { font-size: 11px; color: var(--text-3); margin-top: 3px; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: var(--overlay-1);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 104px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.nav-link .ico { width: 16px; height: 16px; }
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active {
  color: var(--text-strong);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
}
.nav-link.is-active .ico { color: var(--accent-blue-text); }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.node-field { display: flex; align-items: center; gap: 8px; }
.node-field label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.node-field select { min-width: 132px; height: 34px; font-size: 12px; }

/* 外观主题切换 */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}
.theme-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}
.theme-btn .ico { width: 15px; height: 15px; }
.theme-btn:hover { color: var(--text); background: var(--surface-3); }
.theme-btn.is-active {
  color: var(--primary);
  background: var(--surface-1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16), inset 0 0 0 1px var(--line);
}
.theme-btn:focus-visible { outline: none; box-shadow: var(--focus); }

/* 宽屏：三个主题按钮平铺；窄屏收成一个按钮 + 下拉（见 680 断点） */
.theme-toggle { display: none; }
.theme-options { display: flex; align-items: center; gap: 2px; }
.theme-name { display: none; }

/* ============================================================
   通用按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease),
    box-shadow 0.18s var(--ease), transform 0.12s var(--ease), filter 0.18s var(--ease);
}
.btn .ico { width: 16px; height: 16px; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 12px; border-radius: 9px; }
.btn-sm .ico { width: 14px; height: 14px; }
.btn-xs { min-height: 28px; padding: 0 9px; font-size: 11px; border-radius: var(--r-sm); }
.btn-lg { min-height: 50px; padding: 0 22px; font-size: 14px; border-radius: 13px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(72, 99, 220, 0.22), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); filter: brightness(1.04); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-danger { background: rgba(251, 113, 133, 0.12); border-color: rgba(251, 113, 133, 0.4); color: var(--accent-danger-text); }
.btn-danger:hover { background: rgba(251, 113, 133, 0.2); }

/* 本地上传：强调型描边按钮，与输入框同高 */
.btn-upload {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--upload-text);
  font-weight: 600;
}
.btn-upload:hover:not(:disabled) {
  background: var(--upload-hover-bg);
  border-color: var(--primary);
  color: var(--upload-text-hover);
}
.btn-upload .ico { width: 15px; height: 15px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* 兼容旧类名 */
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--text); }
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
}
.mini-btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.mini-btn.primary { background: var(--primary-soft); border-color: var(--primary-line); color: var(--accent-blue-text-2); }

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--info);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent-blue-text-3); text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* ============================================================
   API Key 栏
   ============================================================ */
.keybar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 28px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--line-soft);
}
.keybar-ico { color: var(--text-3); }
.keybar input { max-width: 380px; height: 34px; font-size: 12px; }
.keybar-tip, .keybar .tip { font-size: 11.5px; color: var(--text-3); }

/* ============================================================
   页面骨架
   ============================================================ */
.app-main {
  max-width: 1520px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin-bottom: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--info);
  text-transform: uppercase;
}
.eyebrow span { color: var(--text-faint); margin: 0 5px; }

.page-head h2 {
  margin: 0;
  font-size: clamp(23px, 2vw, 28px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.035em;
}
.page-sub { margin: 0; max-width: 720px; font-size: 12.5px; color: var(--text-2); line-height: 1.7; }

.page-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-1);
  color: var(--text-2);
  font-size: 11.5px;
  white-space: nowrap;
}
.page-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(440px, 0.96fr) minmax(0, 1.04fr);
  gap: 24px;
  align-items: start;
}

/* ============================================================
   面板
   ============================================================ */
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface-1);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--overlay-2), transparent);
}

.panel-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.panel-step {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--primary-line);
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--accent-blue-text);
  font-size: 13px;
  font-weight: 700;
}
.panel-step-alt { border-color: rgba(54, 214, 195, 0.32); background: rgba(54, 214, 195, 0.09); color: var(--accent-teal-text); }
.panel-title h3 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.panel-title p { margin: 3px 0 0; font-size: 11.5px; color: var(--text-3); }
.panel-icon { color: var(--text-faint); width: 19px; height: 19px; }

.panel-body { padding: 24px; }
.panel-foot {
  position: relative;
  padding: 20px 24px 22px;
  border-top: 1px solid var(--line-soft);
  background: var(--overlay-1);
}
.preview-panel { position: sticky; top: 96px; }

/* ============================================================
   表单基础
   ============================================================ */
fieldset.section-block {
  min-width: 0;
  margin: 0 0 24px;
  padding: 0 0 24px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
}
fieldset.section-block:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}
.section-title .ico { width: 15px; height: 15px; color: var(--info); }
.req { color: var(--danger); font-weight: 600; }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 18px;
  margin-bottom: 7px;
}
.label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.field-hint { font-size: 11.5px; color: var(--text-3); }
.field-hint b { color: var(--info); font-size: 12.5px; }
.field-help { margin: 6px 0 0; font-size: 11px; line-height: 1.55; color: var(--text-3); }
.muted { color: var(--text-faint); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}
input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
select:hover,
textarea:hover { border-color: var(--line-strong); }
textarea {
  height: auto;
  min-height: 136px;
  padding: 12px 14px;
  line-height: 1.75;
  resize: vertical;
}
select {
  cursor: pointer;
  padding-right: 32px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371829c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
}
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.15);
}

.char-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
}
.mode-hint { color: var(--info); }

/* 提示词预置：贴在输入框下方，点一下追加一句，不直接生成
   系统预置是内置常量，我的预置跟账号走（存库），两行分开摆 */
.preset-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 9px;
}
.preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.preset-chips { display: contents; }
.preset-label { font-size: 11px; color: var(--text-faint); margin-right: 1px; }
.preset-empty {
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--text-faint);
  cursor: pointer;
}
.preset-empty:hover { color: var(--text-2); }
.preset-empty:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.preset-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px 0 9px;
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.preset-add .ico { width: 14px; height: 14px; }
.preset-add:hover { border-color: var(--primary-line); background: var(--primary-soft); color: var(--text); }
.preset-add:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.preset-manage { margin-left: 2px; font-size: 11.5px; }
.preset-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.preset-editor input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-1);   /* 以前写的 --surface 从来没定义过，输入框背景一直是透明的 */
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
}
.preset-editor input:focus { outline: none; border-color: var(--primary-line); box-shadow: var(--focus); }
.preset-editor .btn { flex: none; }
.preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.preset-btn .ico { width: 15px; height: 15px; color: var(--accent-blue-text-3); }
.preset-btn > span { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-btn:hover { border-color: var(--primary-line); background: var(--primary-soft); color: var(--text); }
.preset-btn:active { transform: translateY(0.5px); }
.preset-btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
/* 管理态：chip 变成可删除，虚线边框 + 红叉，避免误以为点了会填入 */
.preset-btn.is-manage { border-style: dashed; color: var(--text-2); }
.preset-btn.is-manage:hover { border-color: var(--danger); background: var(--surface-2); color: var(--danger); }
.preset-btn.is-manage .ico { color: var(--danger); width: 13px; height: 13px; }

/* 模型卡 */
.model-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }

.model-opt { position: relative; display: block; cursor: pointer; min-width: 0; }
.model-opt input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.mo-body {
  position: relative;
  display: block;
  height: 100%;
  min-height: 48px;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}
.model-opt:hover .mo-body { border-color: var(--line-strong); background: var(--surface-3); }
.model-opt input:focus-visible + .mo-body { box-shadow: var(--focus); }
.model-opt input:checked + .mo-body {
  border-color: var(--primary-line);
  background: linear-gradient(145deg, var(--primary-soft), transparent 75%), var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--primary-soft);
}
.model-opt input:checked + .mo-body::after {
  content: "✓";
  position: absolute;
  top: 9px;
  right: 10px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.mo-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-right: 16px; }
.mo-top b { font-size: 12px; font-weight: 620; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mo-top em {
  flex: none;
  font-style: normal;
  font-size: 10px;
  color: var(--accent-teal-text);
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid rgba(45, 212, 191, 0.24);
  border-radius: 20px;
  padding: 1px 7px;
  white-space: nowrap;
}
.mo-desc { display: block; margin-top: 7px; font-size: 11px; line-height: 1.5; color: var(--text-3); }

/* 分段控件 */
.segmented {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.segmented button {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, box-shadow 0.14s;
}
.segmented button:hover { color: var(--text); background: var(--surface-3); }
.segmented button.active {
  background: var(--surface-3);
  color: var(--text-strong);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.segmented button:focus-visible { outline: none; box-shadow: var(--focus); }

/* 滑杆 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  margin: 10px 0;
  border: 0;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) var(--fill, 35%), var(--surface-3) var(--fill, 35%), var(--surface-3) 100%);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  background: #fff;
  cursor: grab;
}
input[type="range"]:focus-visible { box-shadow: var(--focus); }

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative;
  flex: none;
  width: 38px;
  height: 21px;
  border-radius: 20px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: background 0.18s, border-color 0.18s;
}
.switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text-3);
  transition: left 0.18s, background 0.18s;
}
.switch input:checked + .track { background: var(--primary); border-color: var(--primary-hover); }
.switch input:checked + .track .thumb { left: 19px; background: #fff; }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch-text { font-size: 12px; color: var(--text-2); }

/* 高级区 */
.advanced {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--overlay-1);
  overflow: hidden;
}
.advanced > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  list-style: none;
  cursor: pointer;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.16s;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary:hover { background: var(--surface-2); }
.adv-summary { display: inline-flex; align-items: center; gap: 9px; }
.adv-summary .ico { color: var(--text-3); }
.adv-chevron {
  width: 7px;
  height: 7px;
  border-right: 1.6px solid var(--text-3);
  border-bottom: 1.6px solid var(--text-3);
  transform: rotate(45deg);
  transition: transform 0.18s;
}
.advanced[open] .adv-chevron { transform: rotate(225deg); }
.adv-body { padding: 16px; border-top: 1px solid var(--line-soft); }

/* ============================================================
   分组 / 提示 / 素材
   ============================================================ */
.sub { padding-top: 16px; margin-top: 16px; border-top: 1px dashed var(--line); }
.sub:first-child { padding-top: 0; margin-top: 0; border-top: 0; }
.sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}
.sub-head > span:first-child { display: inline-flex; align-items: center; gap: 7px; }
.sub-head .ico { width: 14px; height: 14px; color: var(--text-3); }
.sub-head-gap { margin-top: 18px; }
.sub-head + .sub-head { margin-top: 14px; }

.hint-right { display: flex; align-items: center; gap: 10px; }
.badge, .tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-warn { border-color: rgba(251, 191, 36, 0.32); background: rgba(251, 191, 36, 0.08); color: var(--accent-warn-text); }
.tag-accent { border-color: rgba(45, 212, 191, 0.3); background: rgba(45, 212, 191, 0.08); color: var(--accent-teal-text); }
.tag-muted { border-color: var(--line); color: var(--text-3); }

/* 统一提示条：左侧色条 + 绝对定位徽章（避免窄屏下文字被 flex 挤成竖列） */
.sub-tip, .sub-warn, .sub-error {
  position: relative;
  display: block;
  margin: 0 0 10px;
  padding: 9px 11px 9px 34px;
  border-left: 2px solid;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 11px;
  line-height: 1.65;
}
.sub-tip::before, .sub-warn::before, .sub-error::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 10px;
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border: 1.4px solid currentColor;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}
.sub-tip { background: var(--warn-soft); border-color: var(--warn-line); color: var(--accent-warn-text); }
.sub-tip::before { content: "i"; color: var(--warning); }
.sub-tip b { color: var(--accent-warn-text); font-weight: 600; }
.sub-warn { background: var(--info-soft); border-color: var(--info-line); color: var(--accent-blue-text); }
.sub-warn::before { content: "!"; color: var(--info); }
.sub-warn b { color: var(--accent-blue-text-3); font-weight: 600; }
.sub-error { background: rgba(251, 113, 133, 0.09); border-color: rgba(251, 113, 133, 0.6); color: var(--accent-danger-text); }
.sub-error::before { content: "×"; color: var(--danger); }
.sub-error b { color: var(--accent-danger-text); font-weight: 600; }
.sub-error i {
  font-style: normal;
  color: var(--accent-danger-text);
  background: var(--overlay-3);
  border-radius: 3px;
  padding: 0 3px;
  font-family: var(--mono);
  font-size: 10px;
}
.note { font-size: 10.5px; color: var(--warning); }
.sub input:not([type="range"]) { margin-bottom: 7px; }

.url-add { display: flex; align-items: stretch; gap: 7px; flex-wrap: wrap; }
.url-add input { flex: 1 1 160px; min-width: 0; height: 38px; }
.url-add .btn { flex: none; height: 38px; padding: 0 13px; }

/* 首尾帧 */
.frame-block { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; background: var(--overlay-1); }
.frame-block .sub-tip { margin-top: 2px; }
.frame-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.frame-field { min-width: 0; }
.frame-field .field-head { margin-bottom: 6px; }
.frame-field .url-add { margin-top: 8px; }
.frame-field .url-add input { flex: 1 1 80px; }
.frame-state { font-size: 10.5px; color: var(--text-faint); }
.frame-state.on { color: var(--success); }
.frame-state.bad { color: var(--warning); }

.drop-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 9px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  background: var(--surface-inset);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-row:hover { border-color: var(--primary); background: rgba(91, 141, 239, 0.06); }
.drop-row.dragover { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--focus); }
.drop-hint { font-size: 10.5px; color: var(--text-3); line-height: 1.4; }
.frame-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.frame-preview img { width: 44px; height: 44px; flex: none; object-fit: cover; border-radius: var(--r-sm); background: var(--surface-inset); }
.frame-info { flex: 1; min-width: 0; font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 素材 chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
}
.chip span { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-img { width: 20px; height: 20px; flex: none; object-fit: cover; border-radius: 4px; background: var(--surface-inset); }
.chip-no {
  flex: none;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--accent-blue-text);
  font-size: 10px;
  font-weight: 600;
}
.chip button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.chip button:hover { color: var(--danger); }

/* 图片页模型行 */
.model-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.model-row:last-of-type { margin-bottom: 0; }
.row-label { flex: none; width: 30px; font-size: 12px; color: var(--text-3); }
.model-row .segmented { flex: 1; min-width: 0; }
.model-note { margin: 10px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--text-3); }
#modelKey {
  padding: 2px 7px;
  border: 1px solid var(--primary-line);
  border-radius: var(--r-sm);
  background: var(--primary-soft);
  color: var(--accent-blue-text);
  font-family: var(--mono);
  font-size: 11px;
}
#qualityGroup, #formatGroup { flex-wrap: wrap; }
#qualityGroup button, #formatGroup button { flex: 1 1 0; }
.grid-2 > .segmented { align-self: center; }

/* 提交区 */
.submit-btn { width: 100%; }
.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-foot { margin: 10px 0 0; font-size: 11px; color: var(--text-faint); text-align: center; }

/* ============================================================
   预览区
   ============================================================ */
.preview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 500;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill[data-state="running"] { color: var(--accent-blue-text); border-color: var(--primary-line); background: var(--primary-soft); }
.status-pill[data-state="running"]::before { background: var(--info); animation: pulse 1.3s infinite; }
.status-pill[data-state="succeeded"] { color: var(--accent-teal-text); border-color: rgba(45, 212, 191, 0.34); background: rgba(45, 212, 191, 0.09); }
.status-pill[data-state="succeeded"]::before { background: var(--teal); }
.status-pill[data-state="failed"] { color: var(--accent-danger-text); border-color: rgba(251, 113, 133, 0.36); background: rgba(251, 113, 133, 0.09); }
.status-pill[data-state="failed"]::before { background: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.28; } }

.task-id {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seed-tag, .meta-tag {
  flex: none;
  padding: 3px 9px;
  border: 1px solid var(--primary-line);
  border-radius: var(--r-sm);
  background: var(--primary-soft);
  color: var(--accent-blue-text);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}
.seed-tag { cursor: pointer; }
.seed-tag:hover { background: rgba(91, 141, 239, 0.24); color: #fff; }
.meta-tag { border-color: rgba(45, 212, 191, 0.3); background: rgba(45, 212, 191, 0.09); color: var(--accent-teal-text); }

.progress-wrap { margin-bottom: 14px; }
.progress { height: 5px; border-radius: 5px; overflow: hidden; background: var(--surface-3); }
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--primary), var(--teal));
  transition: width 0.45s ease;
}
.progress-bar.indeterminate { width: 35% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.progress-text { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; font-size: 11.5px; color: var(--text-3); }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 300px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background:
    radial-gradient(600px 340px at 50% 0%, var(--primary-soft), transparent 72%),
    linear-gradient(145deg, var(--surface-inset), var(--surface-2));
  transition: width 0.18s var(--ease), height 0.18s var(--ease);
}
.stage.portrait { width: auto; max-width: 100%; height: min(60vh, 560px); margin: 0 auto; }
.stage.portrait video { border-radius: var(--r-lg); }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.empty { padding: 24px; text-align: center; color: var(--text-3); }
.empty-art {
  position: relative;
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--accent-blue-text);
  box-shadow: 0 12px 32px rgba(0,0,0,.12), inset 0 1px 0 var(--overlay-3);
}
.empty-art .ico { width: 30px; height: 30px; stroke-width: 1.5; }
.empty-spark { position: absolute; top: -8px; right: -10px; font-size: 16px; color: var(--teal); }
.empty h4 { margin-bottom: 7px; font-size: 15px; font-weight: 650; color: var(--text); }
.empty p { margin: 4px 0; font-size: 12.5px; }
.empty-sub { font-size: 11px !important; color: var(--text-faint) !important; }
.empty-icon { font-size: 26px; color: var(--text-faint); margin-bottom: 8px; }

.result-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 13px; }
.result-actions .btn { width: 100%; }

/* 保存状态：JS 会整体覆盖 className，状态类必须独立可用 */
.save-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.5;
}
.save-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--text-3); }
.save-text { flex: 1; min-width: 0; }
.save-row code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--overlay-3);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10.5px;
  word-break: break-all;
}
.save-row.ok { border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.07); color: var(--accent-teal-text); }
.save-row.ok .save-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16); }
.save-row.fail { border-color: rgba(251, 113, 133, 0.32); background: rgba(251, 113, 133, 0.09); color: var(--accent-danger-text); }
.save-row.fail .save-dot { background: var(--danger); }
.save-row.saving .save-dot { background: var(--info); animation: savePulse 1s ease-in-out infinite; }
@keyframes savePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.error-box {
  position: relative;
  margin-top: 13px;
  padding: 11px 13px 11px 39px;
  border: 1px solid rgba(251, 113, 133, 0.34);
  border-radius: var(--r);
  background: rgba(251, 113, 133, 0.08);
  color: var(--accent-danger-text);
  font-size: 12px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}
.error-box::before {
  content: "!";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--danger);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.raw { margin-top: 11px; font-size: 11.5px; color: var(--text-3); }
.raw summary { cursor: pointer; padding: 4px 0; }
.raw summary:hover { color: var(--text-2); }
.raw pre {
  margin: 8px 0 0;
  padding: 11px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface-inset);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
}

/* 历史 */
.history { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line-soft); }
.history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.h-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface-inset);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.h-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-1); }
.h-item:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.h-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #000; }
.h-thumb-img { aspect-ratio: 1 / 1; object-fit: cover; }
.h-thumb-wrap { position: relative; line-height: 0; }
.h-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  padding: 1px 6px;
  border: 1px solid rgba(45, 212, 191, 0.45);
  border-radius: 4px;
  background: var(--surface-1);
  color: var(--accent-teal-text);
  font-size: 9.5px;
  line-height: 1.5;
  backdrop-filter: blur(3px);
}
.h-meta { position: relative; padding: 7px 9px; }
.h-meta b { display: block; overflow: hidden; padding-right: 42px; color: var(--text-2); font-size: 11px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.h-meta span { font-size: 10px; color: var(--text-faint); }
.h-seed { display: block; margin-top: 2px; color: var(--accent-blue-text); font-family: var(--mono); font-size: 10px; }
.h-reuse {
  position: absolute;
  top: 6px;
  right: 7px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-3);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}
.h-reuse:hover { border-color: var(--primary); color: var(--accent-blue-text-2); }

/* 图片页预览 */
.stage.img-stage { aspect-ratio: auto; min-height: 320px; max-height: 66vh; padding: 8px; }
.stage.img-stage #result { display: block; max-width: 100%; max-height: 62vh; object-fit: contain; border-radius: var(--r); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 90;
  max-width: min(90vw, 520px);
  padding: 10px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface-3);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 8px; background: var(--surface-3); background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: padding-box; }

/* ============================================================
   手机端（由 env.js 打上 data-env="mobile"）
   结果按钮做大、提示放宽——手机是手指在点，不是鼠标
   ============================================================ */
html[data-env="mobile"] .result-actions { grid-template-columns: 1fr; gap: 10px; }
html[data-env="mobile"] .result-actions .btn { min-height: 44px; font-size: 13px; }
html[data-env="mobile"] .save-row { padding: 10px 12px; font-size: 12px; line-height: 1.55; }
html[data-env="mobile"] .save-row .link-btn { min-height: 30px; }
html[data-env="mobile"] .preset-btn,
html[data-env="mobile"] .preset-add { height: 34px; font-size: 12.5px; }
html[data-env="mobile"] .preset-editor input { height: 36px; }
html[data-env="mobile"] .stage video { max-height: 62vh; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1200px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .preview-panel { position: static; }
}

@media (max-width: 960px) {
  .header-inner { flex-wrap: wrap; gap: 12px 16px; padding: 12px 20px 10px; }
  .main-nav { order: 3; width: 100%; }
  .nav-link { flex: 1 1 0; }
  .header-actions { margin-left: auto; min-width: 0; }
  .app-main { padding: 26px 20px 52px; }
  .keybar { padding: 12px 20px; flex-wrap: wrap; }
  .keybar input { max-width: none; flex: 1 1 220px; }
  .keybar-tip { width: 100%; }
}

@media (max-width: 680px) {
  body { background-attachment: scroll; }
  .header-inner { gap: 10px 12px; padding: 10px 14px 8px; }
  .brand { gap: 9px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
  .brand-text strong { font-size: 14px; }
  .header-actions { gap: 7px; }
  .theme-switch { position: relative; gap: 1px; padding: 2px; }
  .theme-btn { width: 30px; height: 30px; }
  .theme-toggle {
    display: grid; place-items: center;
    width: 30px; height: 30px;
    border: 0; border-radius: 999px; background: transparent;
    color: var(--text-2); cursor: pointer;
  }
  .theme-toggle .ico { width: 15px; height: 15px; }
  .theme-toggle:hover { color: var(--text); background: var(--surface-3); }
  .theme-toggle:focus-visible { outline: none; box-shadow: var(--focus); }
  .theme-options {
    display: none;
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 90;
    flex-direction: column; gap: 2px;
    min-width: 132px; padding: 6px;
    border: 1px solid var(--line); border-radius: 14px;
    background: var(--surface-1);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24);
  }
  .theme-switch.is-open .theme-options { display: flex; }
  .theme-options .theme-btn {
    width: 100%; height: 36px;
    display: flex; align-items: center; justify-content: flex-start;
    gap: 9px; padding: 0 10px; border-radius: 9px;
  }
  .theme-options .theme-btn .ico { width: 16px; height: 16px; }
  .theme-name { display: inline; font-size: 12.5px; color: inherit; }
  .main-nav { gap: 2px; padding: 3px; border-radius: 12px; }
  .nav-link { min-width: 0; min-height: 40px; gap: 5px; padding: 7px 6px; font-size: 12px; }
  .nav-link .ico { width: 14px; height: 14px; }
  .app-main { padding: 22px 14px 44px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
  .page-head h2 { font-size: 23px; }
  .page-chip { align-self: flex-start; }
  .panel { border-radius: 16px; box-shadow: var(--shadow-1); }
  .panel-head { min-height: 64px; padding: 14px 18px; }
  .panel-body { padding: 20px 18px; }
  .panel-foot { padding: 18px; }
  fieldset.section-block { margin-bottom: 22px; padding-bottom: 22px; }
  .grid-2, .frame-grid { grid-template-columns: 1fr; gap: 14px; }
  .model-grid { grid-template-columns: 1fr; gap: 8px; }
  .mo-body { min-height: 46px; padding: 13px 12px; }
  .model-row { align-items: flex-start; flex-direction: column; gap: 7px; }
  .model-row .segmented { width: 100%; }
  .row-label { width: auto; }
  .segmented { min-height: 42px; }
  .segmented button { min-height: 32px; }
  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  select, textarea { font-size: 16px; }
  .url-add input { flex-basis: 100%; }
  .url-add .btn { flex: 1 1 auto; min-height: 42px; }
  .frame-field .url-add input { flex-basis: 0; }
  .frame-field .url-add .btn { flex: none; }
  .node-field label { display: none; }
  .node-field select { min-width: 108px; max-width: 132px; }
  .result-actions { grid-template-columns: 1fr; }
  .history-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { min-height: 230px; }
  .stage.img-stage { min-height: 250px; }
  .toast { bottom: max(18px, env(safe-area-inset-bottom)); width: calc(100% - 28px); text-align: center; }
}

@media (max-width: 420px) {
  .brand-text small { display: none; }
  .brand-text strong { font-size: 13px; }
  .header-actions { gap: 5px; }
  .theme-btn { width: 28px; height: 30px; }
  .nav-link { font-size: 11.5px; }
  .nav-link .ico { display: none; }
  #keyBtn span { display: none; }
  #keyBtn { width: 36px; padding: 0; }
  .node-field select { min-width: 96px; }
  .history-list { gap: 8px; }
  .h-meta b { padding-right: 0; }
  .h-reuse { position: static; margin-top: 5px; }
}

@media (max-width: 360px) {
  .app-header .brand-text { display: none; }
}

@media (hover: none) and (pointer: coarse) {
  /* 触控目标：独立图标按钮 44px，行内文字按钮 40px，手指才点得准。
     各处把按钮写死成 28~32px 的规则（窄屏主题钮、弹窗关闭、查看器关闭、退出、补存行）
     要么优先级更高、要么写了固定宽高，这里统一用 html 开头提权、用 min- 压过去。 */
  html .link-btn, html .chip button, html .h-reuse,
  html .save-row .link-btn, html .user-chip .link-btn, html .sp-del {
    min-height: 40px;
    min-width: 40px;
  }
  html .theme-btn, html .theme-options .theme-btn,
  html .auth-modal-close, html .viewer-close, html .preset-empty, html .btn-sm {
    min-width: 44px;
    min-height: 44px;
  }
  html .theme-toggle { width: 44px; height: 44px; }
  html .viewer-close { top: -4px; right: 0; }
  html .btn, html .preset-btn, html .preset-add, html .segmented button { min-height: 44px; }
}

/* 降低动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 强制颜色模式（高对比度） */
@media (forced-colors: active) {
  .btn, .panel, .stage, .segmented, .status-pill { border: 1px solid CanvasText; }
  .nav-link.is-active { forced-color-adjust: none; }
}

/* ============================================================
   图片查看器（参考图 / 首尾帧放大）
   ============================================================ */
.chip-img { cursor: zoom-in; }
.frame-preview img { cursor: zoom-in; }

body.viewer-open { overflow: hidden; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
}
.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 14, 0.78);
  backdrop-filter: blur(4px);
}
.viewer-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 1100px);
  max-height: 90vh;
}
.viewer-img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  border-radius: var(--r-lg);
  background: #0b1018;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  object-fit: contain;
}
.viewer-cap {
  max-width: 100%;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(10, 14, 21, 0.62);
  color: #dbe6f5;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-cap:empty { display: none; }
.viewer-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(16, 22, 34, 0.92);
  color: #eaf0fa;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.16s, transform 0.12s;
}
.viewer-close:hover { background: rgba(30, 42, 61, 0.96); transform: scale(1.06); }
.viewer-close:focus-visible { outline: none; box-shadow: var(--focus); }

@media (max-width: 680px) {
  .viewer { padding: 14px; }
  .viewer-img { max-height: 72vh; border-radius: var(--r); }
  .viewer-close { top: -10px; right: -6px; width: 32px; height: 32px; }
}
