/* Bubbleagent 全局样式 · 小清新主题 */
:root {
  --bg: #f4faf7;
  --bg-card: #ffffff;
  --bg-soft: #f1f9f5;
  --border: #dfece6;
  --border-strong: #cfe3da;
  --text: #22343c;
  --muted: #7b919b;
  --primary: #10b981;
  --primary-hover: #0da271;
  --primary-deep: #0b8f66;
  --ok: #10b981;
  --err: #ef4444;
  --warn: #f59e0b;
  --radius: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 74, 58, .05), 0 4px 14px rgba(16, 74, 58, .06);
  --shadow-md: 0 8px 22px rgba(16, 74, 58, .12);
}

* { box-sizing: border-box; }

/* 确保 hidden 属性在所有元素上生效（覆盖 .btn/.chip 等的 display 设置） */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #e7f6ef 0%, #f4faf7 320px, #f9fcfb 100%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 20px 6px;
  gap: 12px;
}
.topbar.has-library { max-width: 1360px; }
.brand { font-size: 19px; font-weight: 800; letter-spacing: .3px; display: inline-flex; align-items: center; }
a.brand { text-decoration: none; color: inherit; transition: color .18s ease; }
a.brand:hover { color: var(--primary); }
.brand::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ee7b7, #10b981);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, .14);
  margin-right: 10px;
  flex-shrink: 0;
}
.brand .sub { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

main { max-width: 980px; margin: 0 auto; padding: 10px 20px 60px; }
/* 登录后：左侧资产库 + 右侧创作区两栏布局 */
main.has-library {
  max-width: 1360px;
  display: grid;
  /* 资产库约占页面 1/3，剩余宽度留给导演台操作区 */
  grid-template-columns: minmax(320px, 33.333%) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.main-col { min-width: 0; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 14px; font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
/* 主页“创作图片”快捷入口 */
.card h2 .kp-entry {
  margin-left: 2px;
  color: var(--primary-deep);
  border-color: #bfe6d6;
  background: #f2fbf7;
}
.card h2 .kp-entry:hover {
  background: #e7f8f0;
  border-color: #8fd8bd;
  color: var(--primary-deep);
}
.card h2::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 4px;
  background: linear-gradient(180deg, #6ee7b7, #10b981);
  flex-shrink: 0;
}

.muted { color: var(--muted); font-size: 13px; }
.small-text { font-size: 12px; }

/* ---------- 输入控件 ---------- */
.input, .textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  padding: 10px 13px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.input:hover, .textarea:hover { border-color: #b9d9cc; }
.input:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16, 185, 129, .14); }
.input::placeholder, .textarea::placeholder { color: #a4b8b0; }
.row > .input:not(.number-input) { flex: 1 1 0; width: auto; min-width: 0; }
.row > .number-input { flex: 0 0 auto; width: 110px; max-width: 110px; }
.textarea { resize: vertical; line-height: 1.7; }
.small-input { max-width: 160px; }
.aspect-select { max-width: 240px; cursor: pointer; }

.label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }

/* ---------- 按钮（含按键特效） ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease,
              border-color .18s ease, color .18s ease;
}
.btn:hover {
  border-color: #b9d9cc;
  background: var(--bg-soft);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(16, 74, 58, .1);
}
.btn:active { transform: translateY(0) scale(.96); box-shadow: none; }
.btn.primary {
  background: linear-gradient(135deg, #34d399, #10b981);
  border-color: #0d9e70;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(16, 185, 129, .28);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #2bc48a, #0da271);
  border-color: #0b8f66;
  box-shadow: 0 7px 18px rgba(16, 185, 129, .38);
}
.btn.primary:active { box-shadow: 0 2px 6px rgba(16, 185, 129, .3); }
/* 撤销排队等危险操作按钮 */
.btn.danger {
  color: #dc2626;
  border-color: #f5c2c2;
  background: #fff7f7;
}
.btn.danger:hover {
  background: #fdecec;
  border-color: #ef9a9a;
  box-shadow: 0 5px 14px rgba(220, 38, 38, .12);
}
.btn.big { padding: 13px 34px; font-size: 15px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.small-btn { padding: 6px 14px; font-size: 12.5px; border-radius: 9px; }

/* ---------- 分段选择 ---------- */
.seg {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}
.seg-item {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 18px;
  font-size: 13px;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  transition: background .18s ease, color .18s ease, transform .12s ease, box-shadow .18s ease;
}
.seg.small .seg-item { padding: 6px 14px; }
.seg-item:hover:not(:disabled):not(.active) { background: rgba(16, 185, 129, .08); color: var(--primary-deep); }
.seg-item:active:not(:disabled) { transform: scale(.95); }
.seg-item.active {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(16, 185, 129, .3);
}
.seg-item:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- H3 参考生成：素材上传（图片 / 视频 / 音频） ---------- */
.h3-uploads {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.up-block {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfefd;
}
.up-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 9px; flex-wrap: wrap; }
.up-title { font-size: 13.5px; font-weight: 700; flex-shrink: 0; }
.up-drop {
  border: 1px dashed #bfe0d2;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  background: #f8fdfa;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.up-drop:hover { border-color: #34d399; background: #f2fcf7; }
.up-drop:focus { outline: none; }
.up-drop:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.up-drop.drag { border-color: #10b981; background: #e9f9f1; }
.up-drop.busy { cursor: wait; opacity: .75; }
.up-hint { font-size: 12.5px; color: var(--muted); }
.up-list { display: flex; flex-wrap: wrap; gap: 10px; }
.up-list:not(:empty) { margin-top: 10px; }
.up-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 168px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
}
.up-item-audios { width: 220px; }
/* 素材卡拖动排序：拖动后引用编号按新位置重排 */
.up-item { cursor: grab; }
.up-item-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.up-grip {
  color: inherit; opacity: .5; font-size: 11px; line-height: 1;
  cursor: grab; user-select: none; letter-spacing: 1px;
}
.up-grip:hover { opacity: .9; }
.up-item.is-dragging { opacity: .45; border-style: dashed; }
.up-item.drop-before { box-shadow: inset 3px 0 0 var(--primary); }
.up-item.drop-after { box-shadow: inset -3px 0 0 var(--primary); }
.up-ref { font-size: 12px; font-weight: 700; letter-spacing: .2px; }
.up-ref-pic { color: #2563eb; }
.up-ref-vid { color: #7c3aed; }
.up-ref-aud { color: #059669; }
.up-thumb {
  width: 100%;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  background: #eef4f1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.up-thumb img, .up-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.up-thumb video { cursor: pointer; }
.up-thumb-audio { height: auto; padding: 2px 0; background: transparent; display: block; }
.up-audio { width: 100%; height: 34px; }
.up-item-foot { display: flex; align-items: center; gap: 6px; min-width: 0; }
.up-item-name {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.up-item-foot .btn { padding: 2px 8px; font-size: 12px; }

/* ---------- 提示词编辑器（自适应高度 + 引用标签） ---------- */
.prompt-editor {
  min-height: 112px;
  max-height: min(56vh, 560px);
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}
.prompt-editor.is-empty::before,
.prompt-editor:empty::before {
  content: attr(data-placeholder);
  color: #a4b8b0;
  white-space: pre-wrap;
  pointer-events: none;
}
.ref-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  margin: 0 2px;
  border: 1px solid #34d399;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  cursor: default;
  vertical-align: baseline;
}
.ref-chip-stale {
  border-color: #f87171;
  background: #fef2f2;
  color: #b91c1c;
}

/* ---------- @ 素材引用面板 ---------- */
.at-panel {
  position: fixed;
  /* 要盖在弹窗（1600）之上：提示词优化弹窗里也会用它选素材 */
  z-index: 1700;
  width: min(420px, calc(100vw - 24px));
  max-height: min(52vh, 460px);
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border: 1px solid #bfe0d2;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(16, 74, 58, .18);
}
.at-group + .at-group { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.at-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 4px 6px;
  color: var(--muted);
  font-size: 12px;
}
.at-upload {
  border: 0;
  background: transparent;
  color: var(--primary-deep);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.at-upload:hover { background: #eaf9f1; }
.at-empty {
  padding: 9px 10px;
  border-radius: 9px;
  background: #f8fdfa;
  color: var(--muted);
  font-size: 12px;
}
.at-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 7px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.at-item:hover, .at-item:focus-visible { background: #f0fbf5; outline: none; }
.at-item-thumb {
  width: 34px;
  height: 34px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #eef4f1;
  color: var(--muted);
  font-size: 11px;
  object-fit: cover;
  overflow: hidden;
}
.at-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12.5px;
}
.at-item-ref {
  flex: none;
  padding: 1px 7px;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 11.5px;
  font-weight: 700;
}

/* ---------- 提示词快捷标签（参考生成） ---------- */
.ref-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.ref-tags-label { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.ref-tag-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-tag {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid currentColor;
  background: #fff;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.ref-tag:hover { transform: translateY(-1px); }
.ref-tag:active { transform: translateY(0); }
.ref-tag.up-ref-pic:hover { background: #eff5ff; }
.ref-tag.up-ref-vid:hover { background: #f5f0ff; }
.ref-tag.up-ref-aud:hover { background: #ecfdf5; }
.ref-tag.ref-tag-dlg { color: #d97706; }
.ref-tag.ref-tag-dlg:hover { background: #fff8ed; }

/* ---------- 参数区 ---------- */
.options { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 16px; }
.options .opt .label { margin-top: 0; }
.submit-row { margin-top: 22px; }

/* ---------- 清晰度倍率滑条（参考生成） ---------- */
.h3-scale-range { width: 220px; accent-color: var(--primary); cursor: pointer; }
.h3-scale-val { min-width: 44px; font-variant-numeric: tabular-nums; }

/* ---------- 徽章 / 状态 ---------- */
.chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 99px;
  background: #eef7f2;
  border: 1px solid #d8ebe1;
  color: #4d6e60;
}
.chip.wait { color: #b46a09; background: #fdf5e6; border-color: #f3ddb5; }
.chip.ok { color: #0c8c60; background: #e8f9f1; border-color: #c6eeda; }
.chip.err { color: #d13c3c; background: #fdeeee; border-color: #f7d2d2; }

/* ---------- 任务进度 ---------- */
.task-line { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.task-line .right { margin-left: auto; font-variant-numeric: tabular-nums; }
.progress {
  height: 10px;
  background: #eef5f1;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-inner {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #6ee7b7, #10b981);
  box-shadow: 0 0 8px rgba(16, 185, 129, .45);
  transition: width .5s ease;
}

/* ---------- 提示信息 ---------- */
.msg { font-size: 13px; margin: 10px 0 0; }
.msg.error { color: var(--err); }
.msg.ok { color: var(--ok); }
.msg.warn { color: #b45309; }

/* ---------- 视频 ---------- */
.video {
  width: 100%;
  border-radius: 14px;
  background: #0f1720;
  margin-bottom: 12px;
  max-height: 480px;
  box-shadow: 0 6px 20px rgba(16, 74, 58, .16);
}

/* ---------- 分段导出：结果卡逐段播放 / 下载 ---------- */
.result-segments { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.result-segments-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 700;
}
.result-segments-list { display: flex; flex-direction: column; gap: 6px; }
.result-seg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  font-size: 12.5px;
}
.result-seg-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-seg-size { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 历史记录 ---------- */
.history { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 14px;
  background: #fbfefd;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.history-item:hover { border-color: #bfe0d2; background: #fff; box-shadow: 0 4px 12px rgba(16, 74, 58, .07); }
.h-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.history-item .h-prompt {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.history-item .h-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.history-item .h-name {
  flex: none;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
/* 每条记录的参数标签：时长 / 分辨率 / 优化项 / 所用时间 */
.h-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.h-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid #dbe7e1;
  border-radius: 999px;
  background: #f1f8f5;
  color: #557065;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.h-tag.h-on {
  border-color: rgba(16, 185, 129, .34);
  background: #eafaf3;
  color: #0b7a5a;
}
.h-tag.h-used {
  border-color: rgba(16, 185, 129, .28);
  background: #eefaf6;
  color: #0b7a5a;
  font-weight: 600;
}

/* ---------- 资产库（左侧整列） ---------- */
.library-panel {
  position: sticky;
  top: 16px;
  /* 面板从顶栏下方开始，减去顶部偏移（约 70px）与底部留白 */
  height: calc(100vh - 86px);
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.library-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; }
.library-title { font-size: 15px; font-weight: 800; display: inline-flex; align-items: center; gap: 8px; }
.library-title::before {
  content: "";
  width: 4px;
  height: 15px;
  border-radius: 4px;
  background: linear-gradient(180deg, #6ee7b7, #10b981);
  flex-shrink: 0;
}
.library-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.library-head .library-count { margin-left: auto; }
.lib-select-btn {
  flex: none;
  padding: 4px 9px;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.lib-select-btn:hover { border-color: var(--primary); color: var(--primary-deep); }
.lib-select-btn.is-on {
  border-color: var(--primary);
  background: rgba(16, 185, 129, .12);
  color: var(--primary-deep);
}

/* 搜索 */
.library-search { position: relative; flex: none; }
.lib-search-input { width: 100%; padding: 8px 30px 8px 10px; font-size: 13px; }
.lib-search-clear {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9bb0b8;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.lib-search-clear:hover { background: #f2f8f5; color: var(--text); }

.library-actions { display: flex; gap: 6px; flex: none; position: relative; }
.library-actions .btn { flex: 1; width: auto; padding: 7px 8px; }
/* 文件选择框：不能 display:none，iOS / 部分内置浏览器会拦截对隐藏 input 的 click() */
.lib-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* 新建文件夹 */
.lib-new-folder { display: flex; align-items: center; gap: 6px; flex: none; }
.lib-new-folder .input { flex: 1; min-width: 0; padding: 7px 9px; font-size: 13px; }
.lib-icon-btn {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #8ba3ad;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.lib-icon-btn:hover { background: #fef2f2; color: var(--err); }
.lib-icon-btn.plain:hover { background: #f2f8f5; color: var(--text); }
.lib-icon-btn.plain.lib-folder-upload:hover { background: #eafaf2; color: var(--primary-deep); }

/* 文件夹导航 */
.library-folders {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: none;
  max-height: 190px;
  overflow-y: auto;
}
.lib-folder {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.lib-folder:hover { background: #f2fbf7; }
.lib-folder.active { background: #e9f9f1; border-color: #bfe6d6; color: var(--primary-deep); font-weight: 600; }
.lib-folder.dragover { background: #d7f5e7; border-color: var(--primary); }
.lib-folder-icon { flex: none; width: 14px; text-align: center; color: #8ac9ad; font-size: 12px; }
.lib-folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-folder-count { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lib-folder-tools { display: none; align-items: center; gap: 1px; flex: none; }
.lib-folder:hover .lib-folder-tools { display: flex; }
.lib-folder-tools .lib-icon-btn { width: 20px; height: 20px; font-size: 13px; }

.library-tip { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.55; flex: none; }

/* 资产网格（面板内滚动） */
.library-grid {
  flex: 1;
  min-height: 90px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  padding: 2px;
  border-radius: 12px;
}
.library-grid.drag { background: #f2fcf7; outline: 2px dashed var(--primary); outline-offset: -3px; }
.lib-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  /* 不在这里裁剪：overflow:hidden 会让 grid item 的自动最小高度变成 0，
     大屏两列时整行被压成一条细带；缩略图自己裁剪圆角即可 */
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
  cursor: grab;
}
.lib-item:active { cursor: grabbing; }
.lib-item:hover { border-color: #bfe6d6; box-shadow: var(--shadow-sm); }
.lib-item.dragging { opacity: .45; }
.lib-item.is-selectable { cursor: pointer; }
.lib-item.is-selectable .lib-del { display: none; }
.lib-item.is-selected { border-color: var(--primary); background: rgba(16, 185, 129, .06); }
.lib-item.is-selected .lib-thumb { opacity: .82; }
.lib-check {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 3;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(255, 255, 255, .78);
  border-radius: 50%;
  background: rgba(7, 13, 18, .55);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}
.lib-item.is-selectable .lib-check { display: flex; }
.lib-item.is-selected .lib-check { border-color: var(--primary); background: var(--primary); }
.lib-thumb {
  position: relative;
  display: block;
  width: 100%;
  /* 用 padding 撑出 1:1：不依赖 aspect-ratio，旧内核也不会塌成细条 */
  height: 0;
  padding: 0 0 100%;
  min-height: 92px;
  border: 0;
  border-radius: 9px 9px 0 0;
  background: #f2f8f5;
  cursor: pointer;
  overflow: hidden;
}
.lib-thumb img, .lib-thumb video, .lib-thumb .lib-audio-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s ease;
}
.lib-thumb:hover img, .lib-thumb:hover video { transform: scale(1.04); }
.lib-audio-cover {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eaf9f1, #d9f2e6);
  color: var(--primary-deep);
  font-size: 22px;
}
.lib-badge {
  position: absolute;
  left: 4px;
  top: 4px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(10, 32, 24, .62);
  color: #fff;
  font-size: 10px;
  line-height: 1.5;
  pointer-events: none;
}
.lib-duration {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 0 4px;
  border-radius: 5px;
  background: rgba(10, 32, 24, .62);
  color: #fff;
  font-size: 10px;
  line-height: 1.6;
  pointer-events: none;
}
.lib-meta { display: flex; align-items: center; gap: 2px; padding: 3px 4px 4px 6px; }
.lib-name {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-del {
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9bb0b8;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease;
}
.lib-item:hover .lib-del { opacity: 1; }
.lib-del:hover { background: #fef2f2; color: var(--err); }
.lib-move:hover { background: #f2f8f5; color: var(--text); }

/* 「移动到文件夹」浮层 */
.lib-move-menu {
  position: fixed;
  z-index: 70;
  min-width: 148px;
  max-width: 220px;
  max-height: 240px;
  overflow-y: auto;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.lib-move-title { padding: 4px 8px 5px; font-size: 11px; color: var(--muted); }
.lib-move-tip { padding: 4px 8px 6px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.lib-move-item {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.lib-move-item:hover { background: #f2fbf7; }
.lib-move-item.active { background: #e9f9f1; color: var(--primary-deep); font-weight: 600; }
.lib-move-item:disabled { cursor: default; opacity: .55; }

/* 资产库批量选择操作条 */
.lib-batch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(16, 185, 129, .35);
  border-radius: 10px;
  background: rgba(16, 185, 129, .08);
}
.lib-batch-count { margin-right: auto; font-size: 12px; font-weight: 700; }
.lib-batch-bar .btn { padding: 3px 9px; font-size: 11.5px; }
.lib-batch-bar .lib-icon-btn { flex: none; }

.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
  flex: none;
}
.library-empty[hidden] { display: none; }
.library-empty-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eaf9f1;
  color: var(--primary-deep);
  font-size: 18px;
}

/* 容量条（5GB 总量） */
.library-usage { flex: none; border-top: 1px solid var(--border); padding-top: 8px; }
.lib-usage-bar { height: 5px; border-radius: 3px; background: #eef7f2; overflow: hidden; }
.lib-usage-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #6ee7b7, #10b981);
  transition: width .3s ease;
}
.lib-usage-bar.warn span { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.lib-usage-bar.full span { background: linear-gradient(90deg, #f87171, #ef4444); }
.lib-usage-text {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 选择弹窗里的多类型封面 */
.lib-pick-audio {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eaf9f1, #d9f2e6);
  color: var(--primary-deep);
  font-size: 26px;
}
.lib-pick .lib-badge { z-index: 1; }

/* ---------- 资产库选择弹窗 ---------- */
body.modal-open { overflow: hidden; }
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(18, 48, 38, .36);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.modal-card {
  width: min(720px, 100%);
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(16, 74, 58, .24);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head strong { font-size: 15px; }
.prompt-guide-actions { display: flex; align-items: center; gap: 8px; }
.prompt-guide-actions .btn { white-space: nowrap; }
.modal-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: #f2f8f5; color: var(--text); }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: #fbfefc;
}
.modal-spacer { flex: 1; }
.lib-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
.lib-pick {
  position: relative;
  aspect-ratio: 1 / 1;
  /* 同 .lib-thumb：避免行高按 min-content 估算时塌陷 */
  min-height: 96px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #f2f8f5;
  overflow: hidden;
  cursor: pointer;
  font-family: inherit;
}
.lib-pick img, .lib-pick video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-pick .lib-duration { z-index: 1; }
.lib-pick:hover { border-color: #a7e3c9; }
.lib-pick.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
.lib-pick-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 7px 5px;
  background: linear-gradient(transparent, rgba(10, 32, 24, .74));
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.lib-pick-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  border: 1px solid #cfe3da;
  color: transparent;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.lib-pick.selected .lib-pick-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.lib-picker-empty { margin-top: 0; }

/* 选择弹窗：文件夹筛选 + 点击顺序编号 */
.lib-picker-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.lib-picker-folder {
  width: auto;
  min-width: 150px;
  max-width: 240px;
  height: 32px;
  padding: 0 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.lib-picker-order-tip {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
}
.lib-pick-order {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(6, 30, 22, .28);
}

/* ---------- 历史样品（右侧整列） ---------- */
main.director-mode.has-samples {
  max-width: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}
.sample-panel {
  position: sticky;
  top: 16px;
  height: calc(100vh - 86px);
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
/* 导演台模式下与左侧资产库一样，和导演台同高 */
body.director-mode .sample-panel { height: 90vh; min-height: 600px; margin-top: 16px; }

.sample-head { display: flex; align-items: center; gap: 8px; flex: none; }
.sample-title { font-size: 15px; font-weight: 800; display: inline-flex; align-items: center; gap: 8px; }
.sample-title::before {
  content: "";
  width: 4px;
  height: 15px;
  border-radius: 4px;
  background: linear-gradient(180deg, #6ee7b7, #10b981);
  flex-shrink: 0;
}
.sample-count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sample-icon-btn {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.sample-icon-btn:hover { background: rgba(127, 147, 164, .14); color: var(--text); }

.sample-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.sample-actions .btn { flex: 1; width: auto; padding: 7px 8px; }
.sample-limit { flex: none; font-size: 11.5px; color: var(--muted); }
#sampleMsg { margin: 0; font-size: 12px; line-height: 1.5; flex: none; }

.sample-list {
  flex: 1;
  min-height: 100px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}
.sample-list:empty { display: none; }
.sample-item {
  position: relative;
  display: flex;
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.sample-item:hover { border-color: rgba(16, 185, 129, .55); background: var(--bg-card); }
.sample-item.is-active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(16, 185, 129, .16); }
.sample-thumb {
  flex: none;
  width: 64px;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .04em;
}
.sample-thumb img, .sample-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.sample-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sample-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sample-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sample-status {
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
}
.sample-status.is-queued { color: #fbbf24; border-color: rgba(251, 191, 36, .42); background: rgba(251, 191, 36, .10); }
.sample-status.is-running { color: #60a5fa; border-color: rgba(96, 165, 250, .42); background: rgba(96, 165, 250, .10); }
.sample-status.is-success { color: #34d399; border-color: rgba(52, 211, 153, .42); background: rgba(52, 211, 153, .10); }
.sample-status.is-failed { color: #f87171; border-color: rgba(248, 113, 113, .42); background: rgba(248, 113, 113, .08); }
.sample-status.is-cancelled { color: var(--muted); }
body.director-mode.is-light .sample-status.is-queued { color: #b45309; }
body.director-mode.is-light .sample-status.is-running { color: #1d4ed8; }
body.director-mode.is-light .sample-status.is-success { color: #0b7a5a; }
body.director-mode.is-light .sample-status.is-failed { color: #c0392b; }
.sample-meta-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sample-meta {
  flex: 1;
  min-width: 0;
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sample-open {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary-deep);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.sample-open:hover { text-decoration: underline; }
.sample-stop { color: var(--err); }
body.director-mode:not(.is-light) .sample-open { color: #6ee7b7; }
body.director-mode:not(.is-light) .sample-stop { color: #fca5a5; }
.sample-del {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: .6;
}
.sample-item:hover .sample-del { opacity: 1; }
.sample-del:hover { background: rgba(239, 68, 68, .14); color: var(--err); }

.sample-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}
.sample-empty p { margin: 0; font-size: 12px; }
.sample-empty-icon { font-size: 24px; color: var(--border-strong); line-height: 1; }
.sample-empty-note { font-size: 11px; line-height: 1.6; color: var(--muted); }

.sample-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sample-draft { flex: 1; min-width: 0; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample-link-btn {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.sample-link-btn:hover { color: var(--err); }
.sample-link-btn:disabled { opacity: .45; cursor: default; }

@media (max-width: 1080px) {
  .topbar.has-library { max-width: 980px; }
  main.has-library { display: block; max-width: 980px; }
  .library-panel { position: static; height: auto; max-height: none; margin-bottom: 14px; }
  .library-grid { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); max-height: 380px; }
  main.director-mode.has-samples { display: block; width: auto; }
  .sample-panel, body.director-mode .sample-panel {
    position: static;
    height: auto;
    min-height: 0;
    max-height: none;
    margin-top: 14px;
  }
  .sample-list { max-height: 420px; }
}

/* ---------- 窄屏适配（手机 / 小窗口） ---------- */
@media (max-width: 640px) {
  .topbar { padding: 14px 14px 4px; }
  .brand { font-size: 17px; }
  .brand .sub { display: none; }
  .top-right { gap: 8px; }
  main { padding: 8px 12px 48px; }
  .card { padding: 16px 14px; margin-top: 14px; border-radius: 16px; }

  .row { flex-wrap: wrap; }
  .options { flex-direction: column; gap: 16px; }
  .options .opt { width: 100%; }
  .options .opt .input { max-width: 100%; }
  .aspect-select, .small-input { max-width: 100%; }

  .submit-row .btn.big { width: 100%; }
  .input, .textarea { font-size: 16px; }
  .btn { padding: 10px 16px; }

  .task-line { flex-wrap: wrap; gap: 8px; }
  .history-item { flex-wrap: nowrap; }
  .h-main { flex-wrap: wrap; }
  .history-item .h-prompt { flex: 1 1 100%; order: 9; white-space: normal; }

  .library-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lib-picker-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lib-folder-tools { display: flex; }      /* 触屏没有 hover：文件夹操作常显 */
  .lib-del { opacity: 1; }                  /* 触屏：移动/删除按钮常显 */
  .modal-card { max-height: 88vh; }
  .modal-foot { gap: 8px; }
  #libPickerHint { display: none; }
}

/* ---------- 提示词说明弹窗 ---------- */
.prompt-guide-card {
  width: 60vw;
  height: 80vh;
  max-width: none;
  max-height: none;
}
.prompt-guide-body { padding: 16px 22px; }
.pg-doc { font-size: 13px; line-height: 1.8; color: var(--text); }
.pg-doc h2 { margin: 0 0 10px; font-size: 20px; line-height: 1.4; }
.pg-doc h3 { margin: 24px 0 8px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 16px; line-height: 1.5; }
.pg-doc h4 { margin: 16px 0 6px; font-size: 14px; }
.pg-doc p { margin: 8px 0; }
.pg-doc ul { margin: 6px 0 10px; padding-left: 22px; }
.pg-doc li { margin: 3px 0; }
.pg-doc blockquote {
  margin: 10px 0;
  padding: 9px 12px;
  border-left: 3px solid #b7dcca;
  border-radius: 0 8px 8px 0;
  background: #f5fbf8;
  color: #4c6270;
}
.pg-doc table { width: 100%; margin: 10px 0 14px; border-collapse: collapse; font-size: 12.5px; }
.pg-doc th, .pg-doc td { padding: 7px 9px; border: 1px solid var(--border); text-align: left; vertical-align: top; word-break: break-word; }
.pg-doc th { background: #f3f8f6; font-weight: 700; }
.pg-doc code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #f0f6f4;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.pg-doc pre {
  margin: 8px 0 14px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f6faf8;
  overflow-x: auto;
}
.pg-doc pre code { padding: 0; background: none; font-size: 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.pg-doc details { margin: 10px 0; }
.pg-doc summary { margin: 8px 0; cursor: pointer; font-weight: 700; color: var(--primary-deep); }
.pg-note { color: var(--muted); font-size: 12px; }
body.director-mode:not(.is-light) .pg-doc blockquote {
  background: rgba(45, 212, 167, .06);
  border-left-color: rgba(45, 212, 167, .45);
  color: #9fb3c2;
}
body.director-mode:not(.is-light) .pg-doc th { background: #13212c; }
body.director-mode:not(.is-light) .pg-doc code { background: #13212c; }
body.director-mode:not(.is-light) .pg-doc pre { background: #081017; border-color: #263545; }
body.director-mode:not(.is-light) .pg-doc summary { color: #34d399; }
@media (max-width: 900px) {
  .prompt-guide-card { width: 94vw; height: 86vh; }
  .prompt-guide-body { padding: 12px 14px; }
}

/* ---------- 上传进度面板（参考素材 / 资产库共用） ---------- */
.upload-progress {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1700;
  width: min(360px, calc(100vw - 36px));
  padding: 12px 14px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
}
.upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 700;
}
.upload-progress-close {
  padding: 0 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.upload-progress-close:hover { color: var(--text); background: var(--bg-soft); }
.upload-progress-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 220px;
  overflow-y: auto;
}
.upg-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
}
.upg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upg-pct {
  color: var(--primary-deep);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.upg-bar {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf5f1;
}
.upg-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6ee7b7, #10b981);
  transition: width .15s linear;
}
.upg-status {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
}
.upg-phase { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upg-row.is-done .upg-fill { background: #10b981; }
.upg-row.is-error .upg-fill { background: var(--err); }
.upg-row.is-error .upg-pct { color: var(--err); }
.upg-row.is-error .upg-status { color: var(--err); }
body.director-mode:not(.is-light) .upload-progress {
  background: #0e1a23;
  border-color: #263545;
  color: #d9e6ee;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
body.director-mode:not(.is-light) .upload-progress-close { color: #7f95a4; }
body.director-mode:not(.is-light) .upload-progress-close:hover {
  background: #172833;
  color: #d9e6ee;
}
body.director-mode:not(.is-light) .upg-bar { background: #172833; }
body.director-mode:not(.is-light) .upg-pct { color: #34d399; }
body.director-mode:not(.is-light) .upg-status { color: #7f95a4; }
body.director-mode:not(.is-light) .upg-row.is-error .upg-pct,
body.director-mode:not(.is-light) .upg-row.is-error .upg-status { color: #f87171; }
@media (max-width: 640px) {
  .upload-progress { right: 10px; left: 10px; bottom: 10px; width: auto; }
}

/* 队列弹窗：我的通道使用情况 */
.queue-channels {
  margin: 0 0 10px;
  font-size: 13px;
  color: #9fb3c8;
}
.queue-channels.is-full { color: #f0b46a; font-weight: 600; }
body.director-mode.is-light .queue-channels { color: #6b7c86; }
body.director-mode.is-light .queue-channels.is-full { color: #b45309; }

/* ---------- 素材台：左侧素材列表 + 参考素材 + 编辑器 三列 ---------- */

/* 覆盖 director.css 的两列布局（旧的分镜时间轴已移除）。
   director.css 后加载，这里用 .director-shell 提权，避免被 42%/58% 覆盖。 */
.director-shell .dr-stage {
  /* 三栏 + 两条可拖拽分隔条；拖动时 app.js 把前两项写成像素值并记忆 */
  --dr-split-w: 10px;
  --dr-col-mat: clamp(168px, 12.5vw, 200px);
  --dr-col-side: 58%;
  display: grid;
  /* 素材栏随视口平滑变化，避免 1180px 处 186→150 的宽度突变 */
  grid-template-columns:
    var(--dr-col-mat)
    var(--dr-split-w)
    minmax(220px, 1fr)
    var(--dr-split-w)
    var(--dr-col-side);
}

.mat-rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: rgba(0, 0, 0, .14);
  /* 三栏等高：高度跟随 .dr-stage 的行高，素材列表在剩余空间内部滚动 */
  align-self: stretch;
  height: auto;
  overflow: hidden;
}

.mat-rail-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 11px 12px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #8ea3b5;
  border-bottom: 1px solid var(--dr-line);
}
.mat-rail-head b { color: var(--dr-accent); font-size: 12px; letter-spacing: 0; }

.mat-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.mat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 8px 8px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, .02);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mat-item:hover { border-color: #2b3f52; background: rgba(255, 255, 255, .045); }
.mat-item.is-active {
  border-color: rgba(45, 212, 167, .32);
  background: linear-gradient(90deg, rgba(45, 212, 167, .12), rgba(45, 212, 167, .03));
  box-shadow: inset 2px 0 0 var(--dr-accent);
}

/* 列表里的封面改用固定小方寸（director.css 里是填满时间轴卡片的绝对定位） */
.mat-item .dr-clip-cover {
  position: relative;
  inset: auto;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #24333f;
  font-size: 9px;
  letter-spacing: 0;
  text-align: center;
  line-height: 1.25;
  padding: 0 3px;
}
.mat-item .dr-clip-cover img,
.mat-item .dr-clip-cover video { width: 100%; height: 100%; object-fit: cover; }
.mat-item .dr-clip-cover > span { font-size: 15px; line-height: 1; color: var(--dr-dim); }
.mat-item .dr-clip-cover::after { content: none; }

.mat-item-no {
  position: absolute;
  top: 6px;
  right: 7px;
  font-size: 9px;
  font-weight: 800;
  color: #4d6376;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.mat-item.is-active .mat-item-no { color: var(--dr-accent); }

.mat-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 16px;
}
.mat-item-name {
  font-size: 12px;
  font-weight: 700;
  color: #dce7f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mat-item-meta {
  font-size: 10.5px;
  color: var(--dr-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mat-item-del {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #5a7183;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.mat-item-del:hover { background: rgba(248, 113, 113, .16); color: #f87171; }

.mat-add {
  flex: none;
  margin: 0 10px 8px;
  padding: 8px 10px;
  border: 1px dashed #2c4356;
  border-radius: 9px;
  background: rgba(45, 212, 167, .05);
  color: #9ecdbd;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.mat-add:hover:not(:disabled) { border-color: var(--dr-accent); background: rgba(45, 212, 167, .12); color: #d6f5ea; }
.mat-add:disabled { opacity: .45; cursor: not-allowed; }

.mat-rail-foot {
  flex: none;
  padding: 0 12px 11px;
  font-size: 10px;
  line-height: 1.5;
  color: #55697a;
}

/* 素材名称输入（编辑器标题下） */
.mat-name-row { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.mat-name-label { flex: none; font-size: 10px; letter-spacing: .12em; color: var(--dr-dim); }
.mat-name-input { flex: 1 1 auto; min-width: 0; height: 28px; font-size: 12px; }

body.director-mode.is-light .mat-rail { background: #f7fafb; }
body.director-mode.is-light .mat-rail-head { color: #64757f; }
body.director-mode.is-light .mat-rail-foot { color: #8b9aa5; }
body.director-mode.is-light .mat-item { background: #fff; }
body.director-mode.is-light .mat-item:hover { border-color: #c9d5dc; background: #f4f8fa; }
body.director-mode.is-light .mat-item.is-active {
  border-color: rgba(10, 133, 96, .38);
  background: linear-gradient(90deg, rgba(10, 133, 96, .10), rgba(10, 133, 96, .02));
}
body.director-mode.is-light .mat-item .dr-clip-cover { border-color: #dbe3e8; }
body.director-mode.is-light .mat-item-name { color: #1e2a33; }
body.director-mode.is-light .mat-item-no { color: #93a5af; }
body.director-mode.is-light .mat-item-del { color: #93a5af; }
body.director-mode.is-light .mat-add {
  border-color: #c3d4dc;
  background: #eff8f4;
  color: #0b7a5a;
}

/* ---------- 种子：输入框 + 模式（随机 / 递增 / 递减 / 固定 / 手动） ---------- */
.dr-field-seed .dr-inline { gap: 6px; }
body.director-mode .dr-field-seed .dr-seed {
  width: 112px;
  min-width: 0;
  flex: 0 1 auto;
  font-variant-numeric: tabular-nums;
}
body.director-mode .dr-field-seed .dr-seed-mode {
  width: 78px;
  min-width: 0;
  flex: none;
  padding-left: 8px;
  padding-right: 4px;
  font-size: 11.5px;
}
body.director-mode .dr-field-seed .dr-seed[readonly] {
  color: var(--dr-dim);
  background: rgba(255, 255, 255, .02);
}
body.director-mode.is-light .dr-field-seed .dr-seed[readonly] {
  background: #f6f9fa;
}
/* 1081~1180 仍是三列，参数条宽度吃紧：收窄种子选择器与列间距，保持单行 */
@media (min-width: 1081px) and (max-width: 1180px) {
  body.director-mode .dr-params { column-gap: 14px; }
  body.director-mode .dr-field-seed .dr-seed { width: 96px; }
  body.director-mode .dr-field-seed .dr-seed-mode {
    width: 68px;
    padding-left: 6px;
    font-size: 11px;
  }
}
/* 侧栏（资产库 / 历史样品）打开后主区变窄，同步收窄种子控件，保持参数条单行 */
@media (min-width: 1440px) {
  main.director-mode.has-library .dr-params,
  main.director-mode.has-samples .dr-params { column-gap: 14px; }
  main.director-mode.has-library .dr-field-seed .dr-seed,
  main.director-mode.has-samples .dr-field-seed .dr-seed { width: 96px; }
  main.director-mode.has-library .dr-field-seed .dr-seed-mode,
  main.director-mode.has-samples .dr-field-seed .dr-seed-mode {
    width: 68px;
    padding-left: 6px;
    font-size: 11px;
  }
  main.director-mode.has-library .dr-field-res,
  main.director-mode.has-samples .dr-field-res {
    min-width: 160px;
    flex-basis: 160px;
  }
}
@media (max-width: 680px) {
  .dr-field-seed { flex: 1 1 100%; }
  .dr-field-seed .dr-inline { width: 100%; }
  body.director-mode .dr-field-seed .dr-seed { flex: 1 1 auto; width: auto; }
  body.director-mode .dr-field-seed .dr-seed-mode { width: 84px; }
}

@media (max-width: 1180px) {
  .mat-item .dr-clip-cover { width: 38px; height: 38px; }
}
/* 仍是三列时，director.css 在 ≤1180 加的底部分隔线会横在中间栏里，去掉 */
@media (min-width: 1081px) {
  .director-shell .dr-media-bar { border-bottom: 0; }
}
@media (max-width: 1080px) {
  /* 三列已变单列，不再需要 80vw 留白，把宽度还给内容（顶栏同步） */
  #mainLayout.director-mode {
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }
  body.director-mode .topbar.director-mode { width: 100%; }
  .director-shell .dr-stage { grid-template-columns: minmax(0, 1fr); }
  .mat-rail {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--dr-line);
  }
  .mat-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .mat-item { flex: 0 0 auto; width: 156px; }
  .mat-rail-foot { display: none; }
}

/* 资产库 / 历史样品：≤1439 时改到上下排列。
   三列时右侧 300px 会把编辑器压到 380px 以下（1081 时只剩 220px）。
   注意：director.css 在 ≥1081 给 .library-panel 写了 height:90vh，
   这里用 main.xxx .panel 提权，否则折叠后仍会撑成整屏高。 */
@media (max-width: 1439px) {
  main.director-mode.has-library { display: block; }
  main.director-mode.has-library .library-panel {
    position: static;
    height: auto;
    min-height: 0;
    max-height: none;
    margin: 0 0 14px;
  }
  main.director-mode.has-library .library-grid {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    max-height: 380px;
  }
  main.director-mode.has-samples { display: block; }
  main.director-mode.has-samples .sample-panel {
    position: static;
    height: auto;
    min-height: 0;
    max-height: none;
    margin-top: 14px;
  }
  main.director-mode.has-samples .sample-list { max-height: 420px; }
}
/* 折叠时样品面板排在页面末尾，打开后滚到可见位置 */
body.director-mode .sample-panel { scroll-margin-top: 14px; }

/* 大屏并排时资产库也收窄到 300px，把宽度留给编辑器 */
@media (min-width: 1440px) {
  main.director-mode.has-library { grid-template-columns: 300px minmax(0, 1fr); }
  body.director-mode .library-grid {
    /* 最小列宽用具体值：minmax(0,1fr) 会让 1:1 缩略图的行高算成 0 */
    grid-template-columns: repeat(2, minmax(104px, 1fr));
  }
}

/* 图片生成入口：位于顶栏「资产库」旁，比相邻 ghost 按钮略大，突出新功能。 */
body.director-mode .dr-topactions .dr-picture {
  height: 34px;
  padding: 0 15px;
  border-radius: 9px;
  border-color: rgba(45, 212, 167, .5);
  background: linear-gradient(180deg, rgba(45, 212, 167, .2), rgba(45, 212, 167, .1));
  color: #c9fbe9;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: none;
  box-shadow: 0 0 0 1px rgba(45, 212, 167, .08) inset;
}
body.director-mode .dr-topactions .dr-picture:hover {
  background: linear-gradient(180deg, rgba(45, 212, 167, .3), rgba(45, 212, 167, .16));
  border-color: rgba(94, 234, 212, .72);
  color: #eafff7;
}
body.director-mode .dr-topactions .dr-picture:focus-visible {
  outline: 2px solid rgba(45, 212, 167, .6);
  outline-offset: 2px;
}
body.director-mode.is-light .dr-topactions .dr-picture {
  border-color: rgba(15, 138, 99, .45);
  background: linear-gradient(180deg, rgba(15, 169, 124, .16), rgba(15, 169, 124, .08));
  color: #0b6b4f;
}
body.director-mode.is-light .dr-topactions .dr-picture:hover {
  border-color: rgba(15, 138, 99, .7);
  background: linear-gradient(180deg, rgba(15, 169, 124, .24), rgba(15, 169, 124, .12));
  color: #08543e;
}

/* 1081–1179：顶栏操作区较窄，收紧间距与内边距，避免新增按钮后多出一行。 */
@media (min-width: 1081px) and (max-width: 1179px) {
  body.director-mode .dr-topactions { gap: 5px; }
  body.director-mode .dr-topactions .dr-picture { padding: 0 10px; }
  body.director-mode #autoSaveBtn { max-width: 98px; }
}

/* 悬浮任务进度条：排队 / 生成中时固定在页面底部，
   刷新页面或任务卡滚出视野后仍能看到进度，点击跳到任务卡。 */
.task-dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 32px);
  padding: 9px 15px;
  border: 1px solid #263545;
  border-radius: 999px;
  background: rgba(11, 19, 26, .92);
  color: #dce7f0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .38);
  backdrop-filter: blur(10px);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.task-dock:hover {
  border-color: rgba(45, 212, 167, .5);
  background: rgba(15, 25, 34, .96);
  transform: translateX(-50%) translateY(-1px);
}
.task-dock:focus-visible { outline: 2px solid rgba(45, 212, 167, .6); outline-offset: 2px; }
.task-dock-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2dd4a7;
  animation: taskDockPulse 1.6s ease-out infinite;
}
.task-dock.is-queued .task-dock-dot { background: #fbbf24; animation-name: taskDockPulseQueued; }
.task-dock-text { max-width: 46vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.task-dock-hint { color: #7f93a4; font-size: 12px; font-weight: 500; }
@keyframes taskDockPulse {
  0% { box-shadow: 0 0 0 0 rgba(45, 212, 167, .5); }
  70% { box-shadow: 0 0 0 7px rgba(45, 212, 167, 0); }
  100% { box-shadow: 0 0 0 0 rgba(45, 212, 167, 0); }
}
@keyframes taskDockPulseQueued {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, .5); }
  70% { box-shadow: 0 0 0 7px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}
body.director-mode.is-light .task-dock {
  border-color: #cfdae1;
  background: rgba(255, 255, 255, .95);
  color: #1e2a33;
  box-shadow: 0 12px 30px rgba(24, 45, 60, .18);
}
body.director-mode.is-light .task-dock:hover { border-color: #8fd9bd; background: #fff; }
body.director-mode.is-light .task-dock-hint { color: #64757f; }
@media (max-width: 680px) {
  .task-dock { bottom: 12px; padding: 8px 13px; font-size: 12.5px; }
  .task-dock-text { max-width: 58vw; }
}
@media (prefers-reduced-motion: reduce) {
  .task-dock-dot { animation: none; }
}

/* ===== 图片放大预览（Krea2 / Qwen 图片页共用，见 imgviewer.js） ===== */
body.img-viewer-open { overflow: hidden; }
.img-viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: rgba(6, 10, 14, .93);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.img-viewer[hidden] { display: none; }
.img-viewer-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: zoom-out;
}
.img-viewer-stage.is-zoomed { cursor: grab; }
.img-viewer-stage.is-dragging { cursor: grabbing; }
.img-viewer-stage img {
  max-width: 94vw;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
  cursor: zoom-in;
  transition: transform .16s ease;
}
.img-viewer-stage.is-zoomed img { cursor: inherit; }
.img-viewer-close {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(20, 26, 34, .72);
  color: #e8eef5;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.img-viewer-close:hover { background: rgba(255, 255, 255, .18); transform: scale(1.06); }
.img-viewer-bar {
  position: absolute;
  left: 50%;
  bottom: 20px;
  z-index: 2;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(18, 24, 32, .78);
  color: #c7d3df;
  font-size: 12px;
  white-space: nowrap;
}
.img-viewer-hint { letter-spacing: .02em; }
.img-viewer-dl {
  color: #fff;
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  transition: background .15s;
}
.img-viewer-dl:hover { background: rgba(255, 255, 255, .26); }
/* 结果大图提示可点击放大 */
.result-img, .qw-result-img { cursor: zoom-in; }
@media (max-width: 680px) {
  .img-viewer-hint { display: none; }
  .img-viewer-bar { padding: 7px 10px; }
  .img-viewer-stage img { max-width: 100vw; }
}
