/**
 * 宗式讲义 AI工具箱 — 玻璃拟态 + 工业深色科技 + 莫兰迪低饱和
 * 变量名与旧内联 style 中的 var(--*) 保持兼容
 */
:root {
  /* 深邃背景层 */
  --bg-void: #06080d;
  --bg-mid: #101820;
  --bg-start: #121a24;
  --bg-end: #070a10;
  /* 玻璃与表面 */
  --surface: rgba(22, 30, 42, 0.72);
  --surface2: rgba(12, 16, 24, 0.88);
  --card: rgba(18, 26, 36, 0.5);
  --glass-tint: rgba(130, 155, 175, 0.06);
  --glass-highlight: rgba(255, 255, 255, 0.09);
  /* 冷色描边 / 分隔 */
  --border: rgba(160, 185, 200, 0.12);
  --border-card: rgba(175, 198, 212, 0.18);
  --border-cool: rgba(140, 175, 195, 0.22);
  /* 文字 */
  --text: #e6eaee;
  --muted: #8b97a8;
  /* 莫兰迪科技强调色 */
  --accent: #6d968c;
  --accent2: #5a7f76;
  --accent-soft: rgba(109, 150, 140, 0.35);
  --accent-glow: rgba(120, 175, 160, 0.28);
  --danger: #b07878;
  --warn: #b09a72;
  --link-warm: #9e8f84;
  --link-warm-dim: #8a7d72;
  /* 布局 */
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 160px;
  /* 模糊 */
  --blur-glass: 22px;
  --blur-glass-strong: 32px;
  --blur-overlay: 14px;
  /* 阴影与发光 */
  --shadow-elev: 0 16px 48px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.22);
  --shadow-edge: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  --glow-neon: 0 0 36px rgba(100, 145, 155, 0.14);
  --glow-accent: 0 0 24px var(--accent-glow);
  /* 统一控件高度（按钮族） */
  --ctrl-h: 38px;
  --ctrl-pad-x: 16px;
  --ctrl-fs: 13px;
  --ctrl-radius: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--bg-void);
}

/* 背景层次：渐变 + 光晕叠层 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(ellipse 100% 70% at 15% -5%, rgba(90, 115, 135, 0.22) 0%, transparent 52%),
    radial-gradient(ellipse 80% 55% at 95% 45%, rgba(55, 75, 98, 0.18) 0%, transparent 48%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(40, 55, 72, 0.25) 0%, transparent 55%),
    linear-gradient(168deg, var(--bg-start) 0%, var(--bg-mid) 42%, var(--bg-end) 100%);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(180deg, transparent 0%, rgba(4, 6, 10, 0.55) 100%);
  opacity: 0.85;
  pointer-events: none;
}

/* ---------- Topbar ---------- */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  position: relative;
  background: linear-gradient(180deg, rgba(24, 32, 44, 0.55) 0%, rgba(14, 18, 26, 0.35) 100%);
  backdrop-filter: blur(var(--blur-glass)) saturate(1.05);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(1.05);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-inset), 0 8px 32px rgba(0, 0, 0, 0.25);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  z-index: 2;
}

.topbar-left img {
  height: 30px;
  filter: drop-shadow(0 0 12px rgba(120, 150, 160, 0.2));
}

.topbar-brand {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* 与系统标题栏区分：页面内居中显示当前项目名（系统标题栏在 Windows 上无法居中） */
.topbar-window-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: min(520px, 40vw);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  margin-left: auto;
  z-index: 2;
}

.api-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.status-dot.green {
  background: var(--accent2);
  box-shadow: 0 0 10px var(--accent-glow), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.status-dot.red {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(176, 120, 120, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* 顶栏 · 背景音乐开关（与密钥状态区右缘对齐） */
.topbar-bgm-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: 10px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}

.bgm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--border-cool);
  border-radius: 999px;
  background: linear-gradient(165deg, rgba(26, 34, 48, 0.65) 0%, rgba(14, 20, 30, 0.55) 100%);
  box-shadow: var(--shadow-inset), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.bgm-toggle:hover {
  border-color: rgba(140, 175, 195, 0.32);
  color: var(--text);
}

.bgm-toggle:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

.bgm-toggle-track {
  position: relative;
  width: 44px;
  height: 22px;
  border-radius: 11px;
  flex-shrink: 0;
  background: rgba(55, 65, 82, 0.65);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: background 0.22s ease, box-shadow 0.22s ease;
}

.bgm-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(245, 248, 252, 0.98) 0%, rgba(195, 205, 218, 0.95) 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.22s ease;
}

.bgm-toggle.is-on .bgm-toggle-track {
  background: linear-gradient(90deg, rgba(74, 108, 98, 0.92) 0%, rgba(109, 150, 140, 0.55) 100%);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.25),
    0 0 12px rgba(109, 150, 140, 0.22);
}

.bgm-toggle.is-on .bgm-toggle-knob {
  transform: translateX(22px);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 10px rgba(120, 175, 160, 0.35);
}

.bgm-toggle-state {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  min-width: 26px;
  text-align: center;
  color: var(--muted);
  transition: color 0.2s;
}

.bgm-toggle.is-on .bgm-toggle-state {
  color: rgba(160, 205, 190, 0.95);
  text-shadow: 0 0 12px rgba(109, 150, 140, 0.35);
}

.bgm-toggle.is-off .bgm-toggle-state {
  color: var(--muted);
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  height: calc(100vh - 52px);
  padding: 15px;
  gap: 15px;
  align-items: stretch;
  flex-shrink: 0;
}

.sidebar {
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
  height: 100%;
}

.nav-group {
  background: linear-gradient(165deg, rgba(26, 34, 48, 0.45) 0%, rgba(14, 20, 30, 0.38) 100%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 10px 8px;
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  backdrop-filter: blur(var(--blur-glass)) saturate(1.08);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(1.08);
  box-shadow: var(--shadow-elev), var(--shadow-inset), var(--shadow-edge);
}

.nav-group-label {
  font-size: 11px;
  color: var(--muted);
  padding: 0 8px 8px;
  letter-spacing: 0.5px;
}

.nav-item {
  padding: 9px 10px;
  border-radius: var(--ctrl-radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: rgba(160, 185, 200, 0.08);
  box-shadow: var(--shadow-inset);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(109, 150, 140, 0.35) 0%, rgba(90, 127, 118, 0.5) 100%);
  color: #f0f4f2;
  font-weight: 600;
  border-color: rgba(140, 185, 175, 0.35);
  box-shadow: var(--glow-neon), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.sidebar-project-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  margin-top: auto;
}

.project-mode-label {
  display: none;
  width: 100%;
  box-sizing: border-box;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.35;
  padding: 0 4px;
  text-align: center;
  word-break: break-word;
}

.project-mode-label.show {
  display: block;
}

.nav-project-btn {
  width: 100%;
  justify-content: center;
  font-size: 12px;
  min-height: 34px;
}

.nav-project-btn--quiet {
  opacity: 0.85;
  font-size: 11px;
  min-height: 30px;
}

.nav-project-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.open-project-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.open-project-row:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-cool);
}

.open-project-row-title {
  font-size: 13px;
  font-weight: 600;
}

.open-project-row-meta {
  font-size: 11px;
  color: var(--muted);
}

/* ---------- 保存项目进度（不确定进度条） ---------- */
.project-save-progress-overlay {
  z-index: 4600;
  pointer-events: auto;
}

.project-save-progress-card {
  max-width: 420px;
}

.project-save-progress-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 4px;
}

.project-save-progress-bar-wrap {
  position: relative;
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin: 14px 0 10px;
}

.project-save-progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 38%;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(95, 135, 125, 0.95), rgba(140, 185, 175, 0.85));
  animation: projectSaveIndeterminate 1.25s ease-in-out infinite;
}

@keyframes projectSaveIndeterminate {
  0% {
    left: -40%;
  }
  100% {
    left: 102%;
  }
}

.project-save-progress-elapsed {
  font-size: 12px;
  color: var(--text);
  margin: 0 0 8px;
  font-variant-numeric: tabular-nums;
}

.project-save-progress-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

/* ---------- Main / Preview glass panels ---------- */
.main,
.preview {
  flex: 1;
  background: linear-gradient(160deg, rgba(28, 36, 50, 0.42) 0%, rgba(16, 22, 32, 0.38) 100%);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(var(--blur-glass-strong)) saturate(1.06);
  -webkit-backdrop-filter: blur(var(--blur-glass-strong)) saturate(1.06);
  box-shadow: var(--shadow-elev), var(--shadow-inset), var(--glow-neon);
}

.preview {
  width: 640px;
  flex: 0 0 auto;
  min-height: 0;
}

.main-header {
  height: 60px;
  flex-shrink: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0%, transparent 40%);
}

.main-header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.main-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
}

/* ---------- 帮助弹窗 ---------- */
.help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(var(--blur-overlay));
  -webkit-backdrop-filter: blur(var(--blur-overlay));
}

.help-overlay.show {
  display: flex;
}

/* 页面居中提示 / 确认（替代原生 alert、confirm） */
.app-dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 4500;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: rgba(4, 6, 10, 0.65);
  backdrop-filter: blur(var(--blur-overlay));
  -webkit-backdrop-filter: blur(var(--blur-overlay));
}

.app-dialog-overlay.show {
  display: flex;
}

.app-dialog {
  width: 100%;
  max-width: 400px;
  max-height: min(80vh, 520px);
  overflow: auto;
  background: linear-gradient(165deg, rgba(30, 38, 52, 0.96) 0%, rgba(18, 24, 34, 0.98) 100%);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  box-shadow: var(--shadow-elev), var(--glow-neon);
  backdrop-filter: blur(var(--blur-glass-strong));
  -webkit-backdrop-filter: blur(var(--blur-glass-strong));
  animation: modalIn 0.28s ease;
}

.app-dialog-title {
  padding: 16px 20px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.app-dialog-message {
  padding: 14px 20px 18px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.app-dialog-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 12px;
  padding: 0 20px 18px;
}

/* 覆盖全局 .btn-submit { width:100% }，否则双按钮会上下各占一行 */
.app-dialog-actions .btn-submit {
  width: auto;
}

/* 取消 + 确定：同一行、左右均分、同宽同高 */
.app-dialog-actions:has(.btn-secondary) {
  justify-content: stretch;
}

.app-dialog-actions:has(.btn-secondary) .btn-secondary,
.app-dialog-actions:has(.btn-secondary) .btn-submit {
  flex: 1 1 0;
  min-width: 0;
}

/* 仅「确定」单按钮时居中，不占满整行 */
.app-dialog-actions:not(:has(.btn-secondary)) {
  justify-content: center;
}

.app-dialog-actions:not(:has(.btn-secondary)) .btn-submit {
  flex: 0 1 auto;
  min-width: 140px;
}

.app-dialog-body {
  padding: 0 20px 16px;
}

.app-dialog-body .form-group:last-child {
  margin-bottom: 0;
}

.app-dialog-body .app-dialog-actions {
  padding: 12px 0 0;
  margin: 0;
}

#appDialogConfirm.is-danger {
  background: linear-gradient(135deg, rgba(160, 90, 90, 0.95) 0%, rgba(120, 60, 60, 0.98) 100%);
  border-color: rgba(200, 120, 120, 0.45);
  color: #fff;
}

.help-modal {
  background: linear-gradient(165deg, rgba(30, 38, 52, 0.92) 0%, rgba(18, 24, 34, 0.95) 100%);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-elev), var(--glow-neon);
  backdrop-filter: blur(var(--blur-glass-strong));
  -webkit-backdrop-filter: blur(var(--blur-glass-strong));
  animation: modalIn 0.28s ease;
}

.help-modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(26, 34, 48, 0.98) 0%, rgba(22, 28, 38, 0.92) 100%);
  z-index: 1;
  border-radius: 16px 16px 0 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.help-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.help-modal-close {
  width: 36px;
  height: 36px;
  min-height: var(--ctrl-h);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  font-size: 15px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-inset);
}

.help-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.help-modal-body {
  padding: 16px 20px 24px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
}

.help-modal-body p {
  margin-bottom: 10px;
}

.help-modal-body h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin: 16px 0 6px;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}

.help-modal-body h2:first-child {
  margin-top: 0;
}

.help-modal-body ul {
  list-style: none;
  padding: 0;
  margin: 6px 0 10px;
}

.help-modal-body ul li {
  padding: 3px 0 3px 14px;
  position: relative;
}

.help-modal-body ul li::before {
  content: "•";
  position: absolute;
  left: 3px;
  color: var(--accent);
}

.help-modal-divider {
  border: none;
  border-top: 1px dashed rgba(160, 185, 200, 0.15);
  margin: 16px 0;
}

.help-modal-footer {
  font-size: 11px;
  color: var(--muted);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.help-overlay#sourceVideoOverlay {
  z-index: 5000;
}

/* 源视频弹窗：按视频固有分辨率铺开，整体不超过视口（过大时等比缩小，可滚动） */
.help-modal.source-video-modal {
  width: max-content;
  max-width: 96vw;
  max-height: 94vh;
  overflow: auto;
}

.source-video-modal-body {
  padding: 8px 12px 16px;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.source-video-modal-body .source-video-player {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(96vw - 32px);
  max-height: calc(94vh - 80px);
  border-radius: 10px;
  background: #000;
}

/* ---------- Preview column ---------- */
.preview-header {
  height: 60px;
  flex-shrink: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-sizing: border-box;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
}

.preview-header > span:first-of-type {
  min-width: 0;
}

#pendingVideoBadge {
  display: none;
  margin-left: 4px;
  padding: 0 5px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent);
  color: #0a0e14;
  vertical-align: middle;
  box-shadow: 0 0 12px var(--accent-soft);
}

#pendingVideoBadge.show {
  display: inline-block;
}

.pending-video-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow-inset);
}

.pending-video-row:last-child {
  margin-bottom: 0;
}

.pending-video-row .pv-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.pending-video-row .pv-id {
  font-size: 12px;
  word-break: break-all;
  color: var(--text);
  margin-bottom: 6px;
}

.pending-video-row .pv-prompt {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  max-height: 4.5em;
  overflow: hidden;
  margin-bottom: 8px;
}

.pending-video-row .pv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pending-video-manual {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.pending-video-manual-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.pending-video-manual-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pending-video-manual-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.preview-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.preview-content {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-task-status-dock {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 22, 0.42);
}

.preview-task-status-drawer {
  max-height: 280px;
  overflow: hidden;
  transition: max-height 0.28s ease;
}

.preview-task-status-drawer.is-collapsed {
  max-height: 0;
  pointer-events: none;
}

.preview-task-status-log {
  max-height: 280px;
  overflow-y: auto;
  padding: 8px 10px 10px;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text);
  word-break: break-all;
}

.preview-task-status-empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 12px 8px;
}

.preview-task-status-line {
  padding: 2px 0;
}

.preview-task-status-toggle {
  width: 100%;
  margin: 0;
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: none !important;
  border-top: 1px solid var(--border) !important;
  flex-shrink: 0;
  min-height: 36px;
  font-size: 12px;
  box-sizing: border-box;
}

.preview-content:has(#codingStreamOutput) #codingLoading,
.preview-content:has(#gemini30StreamOutput) #gemini30Loading,
.preview-content:has(#minimaxChatCherryMount) #chatStreamLoading {
  flex-shrink: 0;
}

.preview-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.preview-img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* 结果预览：图片右下角悬浮「插入参考图」 */
.preview-img-wrap {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  align-self: stretch;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.preview-img-wrap .preview-img {
  display: block;
  width: 100%;
}

/* 结果预览：左上角「下载」（常显，便于无右键宿主环境另存） */
.preview-download-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 4;
  box-sizing: border-box;
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  line-height: 1.2;
  border-radius: var(--ctrl-radius);
  border: 1px solid var(--border-card);
  background: rgba(18, 26, 36, 0.92);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.preview-download-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.preview-download-btn:disabled {
  opacity: 0.75;
  cursor: wait;
}

.preview-copy-url-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 2;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.2;
  border-radius: 8px;
  border: 1px solid var(--border-card);
  background: rgba(18, 26, 36, 0.92);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.preview-img-wrap:hover .preview-copy-url-btn,
.preview-img-wrap:focus-within .preview-copy-url-btn {
  opacity: 1;
  visibility: visible;
}

/* 结果预览：视频悬停右上角「查看源视频」 */
.preview-video-wrap {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  align-self: stretch;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.preview-video-wrap .preview-video {
  display: block;
  width: 100%;
  vertical-align: middle;
}

.preview-source-video-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  box-sizing: border-box;
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  line-height: 1.2;
  border-radius: var(--ctrl-radius);
  border: 1px solid var(--border-card);
  background: rgba(18, 26, 36, 0.92);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.preview-video-wrap:hover .preview-source-video-btn,
.preview-video-wrap:focus-within .preview-source-video-btn {
  opacity: 1;
  visibility: visible;
}

.preview-source-video-btn:hover {
  background: var(--accent2);
  border-color: var(--accent);
  color: #fff;
}

@media (hover: none) and (pointer: coarse) {
  .preview-source-video-btn {
    opacity: 0.95;
    visibility: visible;
  }
}

.preview-copy-url-btn:hover {
  background: var(--accent2);
  border-color: var(--accent);
  color: #fff;
}

.preview-copy-url-btn--done {
  background: var(--accent2);
  border-color: var(--accent);
}

@media (hover: none) and (pointer: coarse) {
  .preview-copy-url-btn {
    opacity: 0.9;
    visibility: visible;
  }
}

.preview-audio {
  width: 100%;
}

.preview-link {
  font-size: 12px;
  color: var(--link-warm);
  text-align: center;
}

.preview-link .btn {
  margin-top: 8px;
}

.preview-link a {
  color: var(--link-warm);
  text-decoration: none;
}

.preview-link a:hover {
  color: var(--link-warm-dim);
  text-decoration: underline;
}

.lyrics-preview-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.lyrics-preview-wrap .lyrics-title {
  text-align: center;
  color: var(--link-warm);
  font-size: 12px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.lyrics-preview-wrap textarea {
  flex: 1;
  min-height: 0;
  resize: none;
}

/* ---------- Config bar ---------- */
.config-bar {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(160, 185, 200, 0.25) transparent;
  background: linear-gradient(0deg, rgba(8, 12, 18, 0.5) 0%, transparent 100%);
}

/* 密钥设置弹窗内：纵向列表 */
.config-bar.config-bar--modal {
  padding: 0;
  border-top: none;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
  overflow: visible;
  gap: 14px;
  background: transparent;
}

.config-bar::-webkit-scrollbar {
  height: 4px;
}

.config-bar::-webkit-scrollbar-thumb {
  background: rgba(160, 185, 200, 0.25);
  border-radius: 2px;
}

.config-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.config-item span {
  color: var(--muted);
}

.config-item input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--ctrl-radius);
  padding: 8px 12px;
  color: var(--text);
  font-size: 12px;
  width: 180px;
  min-height: 36px;
  box-shadow: var(--shadow-inset);
}

/* 密钥弹窗：标签一行，输入框与保存同排同高 */
.config-item.config-item--modal-row {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.config-bar--modal .config-key-inline {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
}

.config-bar--modal .config-key-inline input {
  flex: 1;
  min-width: 0;
  width: auto;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
  padding: 0 12px;
  line-height: normal;
}

.config-bar--modal .config-key-inline .btn {
  flex-shrink: 0;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
  padding: 0 16px;
  align-self: stretch;
}

/* ---------- 统一按钮族 ---------- */
.help-btn,
.btn,
.btn-primary,
.btn-secondary,
button.btn-secondary,
.config-item .btn,
#pendingVideoBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--ctrl-h);
  padding: 0 var(--ctrl-pad-x);
  border-radius: var(--ctrl-radius);
  font-size: var(--ctrl-fs);
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, filter 0.2s;
  border: 1px solid transparent;
  box-sizing: border-box;
  white-space: nowrap;
}

.help-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-card);
  color: var(--muted);
  box-shadow: var(--shadow-inset);
}

.help-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: var(--border-cool);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(120, 165, 152, 0.95) 0%, rgba(95, 135, 125, 0.98) 100%);
  color: #0a0e12;
  border-color: rgba(160, 200, 190, 0.35);
  box-shadow: var(--shadow-inset), var(--glow-accent);
}

.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: var(--shadow-inset), 0 0 28px var(--accent-glow);
}

.btn-secondary,
button.btn-secondary {
  background: linear-gradient(180deg, rgba(36, 44, 58, 0.65) 0%, rgba(22, 28, 40, 0.75) 100%);
  color: var(--text);
  border-color: var(--border-card);
  box-shadow: var(--shadow-inset);
}

.btn-secondary:hover,
button.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-cool);
}

.btn-secondary:disabled,
.btn-primary:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

/* 与面板内「帮我优化」同规格（30px 高、0 10px 内边距、12px 字），覆盖统一 .btn 族 */
.preview-video-wrap .preview-source-video-btn.btn.btn-secondary {
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  line-height: 1.2;
  box-sizing: border-box;
  gap: 0;
}

.third-party-revert-wrap {
  display: inline-flex;
  vertical-align: middle;
}

.third-party-revert-wrap > button[disabled] {
  pointer-events: none;
}

/* 与「帮我优化」同排：未成功优化前明确不可点；成功后与视频页 Grok 视频一致为完整可交互次要按钮 */
.third-party-revert-wrap > button.btn-secondary:not(:disabled) {
  opacity: 1;
  cursor: pointer;
  pointer-events: auto;
}

.third-party-revert-wrap > button.btn-secondary:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* 各面板「帮我优化」与同排「回退」：固定 30px 高（覆盖统一按钮族 --ctrl-h） */
div:has(> .third-party-revert-wrap) > button.btn.btn-secondary,
.third-party-revert-wrap > button.btn.btn-secondary {
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  line-height: 1.2;
  box-sizing: border-box;
}

/* 「高级自定义」：仅当对应提示词内已有非空 ADV_CUSTOM 块时高亮 */
button.btn.btn-secondary.btn-adv-custom.btn-adv-custom--active {
  opacity: 1;
  cursor: pointer;
  border-color: rgba(118, 158, 148, 0.4);
  background: linear-gradient(
    168deg,
    rgba(98, 132, 122, 0.42) 0%,
    rgba(74, 108, 100, 0.46) 52%,
    rgba(58, 86, 80, 0.4) 100%
  );
  color: rgba(220, 238, 230, 0.98);
  box-shadow:
    var(--shadow-inset),
    0 0 0 1px rgba(128, 172, 158, 0.14),
    0 0 16px rgba(92, 138, 124, 0.24);
  text-shadow: 0 0 12px rgba(110, 155, 138, 0.28);
}

button.btn.btn-secondary.btn-adv-custom.btn-adv-custom--active:hover {
  border-color: rgba(138, 184, 170, 0.48);
  background: linear-gradient(
    168deg,
    rgba(108, 144, 132, 0.52) 0%,
    rgba(84, 120, 110, 0.54) 52%,
    rgba(68, 98, 90, 0.48) 100%
  );
  filter: brightness(1.04);
}

/* 各面板「📤 上传」（doImageUpload）：统一 30px 高、同宽，与参考图/URL 行搭配 */
button.btn.btn-secondary[onclick*="doImageUpload("] {
  min-height: 30px;
  height: 30px;
  width: 76px;
  min-width: 76px;
  max-width: 76px;
  padding: 0;
  font-size: 12px;
  line-height: 1.2;
  box-sizing: border-box;
  flex-shrink: 0;
}

.btn-submit,
.screenplay-preview-controls .btn-sp-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--ctrl-h);
  padding: 0 var(--ctrl-pad-x);
  border-radius: var(--ctrl-radius);
  font-size: var(--ctrl-fs);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid rgba(160, 200, 190, 0.28);
  background: linear-gradient(135deg, rgba(115, 158, 148, 0.95) 0%, rgba(88, 128, 118, 0.98) 100%);
  color: #080c10;
  transition: filter 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-inset), var(--glow-accent);
}

.btn-submit:hover,
.screenplay-preview-controls .btn-sp-generate:hover {
  filter: brightness(1.05);
  box-shadow: var(--shadow-inset), 0 0 32px var(--accent-glow);
}

/* 预览区内居中的次级主按钮（不占满整行） */
.btn-submit.btn-submit-inline {
  width: auto;
  display: inline-flex;
  min-width: 168px;
}

.btn-submit:disabled,
.screenplay-preview-controls .btn-sp-generate:disabled {
  background: linear-gradient(135deg, #4a5560 0%, #3a4048 100%);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(230, 234, 238, 0.55);
  cursor: not-allowed;
  filter: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.btn-generate-wrap {
  position: relative;
  width: 100%;
}

.btn-generate-wrap > .loading {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: 0;
  padding: 6px 10px;
  text-align: center;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-direction: row;
  flex-wrap: wrap;
  background: rgba(8, 12, 18, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--ctrl-radius);
  z-index: 4;
  pointer-events: none;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-inset);
}

.btn-generate-wrap > .loading.show {
  display: flex;
}

.btn-generate-wrap > .loading .spinner {
  margin: 0;
  width: 22px;
  height: 22px;
  border-width: 2px;
  flex-shrink: 0;
}

.btn-generate-wrap > .loading .loading-text {
  font-size: 12px;
  line-height: 1.3;
  text-align: left;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-inset);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: rgba(120, 165, 150, 0.45);
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(109, 150, 140, 0.12);
}

.form-group textarea {
  resize: vertical;
  min-height: 180px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.hqimg-subpanel {
  margin-bottom: 8px;
}

/* 高质生图 / MiniMax 图像 / MiniMax 视频 / 高质视频：上区滚动，「仓库」固定在主栏底部 */
#panel-hqimg.panel.active,
#panel-image.panel.active,
#panel-mvid.panel.active,
#panel-svid.panel.active {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  box-sizing: border-box;
}

#panel-hqimg.panel.active .hqimg-panel-scroll,
#panel-image.panel.active .hqimg-panel-scroll,
#panel-mvid.panel.active .hqimg-panel-scroll,
#panel-svid.panel.active .hqimg-panel-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

/* 高质生图 · 仓库：与参数页同一玻璃窗口融合（透明底、吃进 main-content 内边距，底栏贴主窗下沿） */
.hqimg-warehouse {
  margin: 0 -20px -20px;
  padding: 14px 20px 20px;
  border: none;
  border-radius: 0;
  border-top: 1px solid rgba(160, 185, 200, 0.08);
  background: transparent;
  box-shadow: none;
  box-sizing: border-box;
  min-height: clamp(120px, 25vh, 360px);
  min-height: clamp(120px, 25dvh, 360px);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* 第一行：标题 + 三个按钮（横向、整体居右） */
.hqimg-warehouse-head {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.hqimg-warehouse-title {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.02em;
}

.hqimg-warehouse-head-actions {
  margin-left: auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* 仓库分类：与侧栏 nav-item 同款样式，横向「| 全部 | …」 */
.hqimg-warehouse-filter-row {
  gap: 0;
  align-items: stretch;
}

.hqimg-warehouse-filter-row .warehouse-filter-sep {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: rgba(160, 185, 200, 0.38);
  font-size: 12px;
  font-weight: 400;
  user-select: none;
  padding: 0 1px;
  line-height: 1;
}

/* 仓库分类：弱「按钮」感，像文案；选中时仅在文字上方有淡淡顶光 */
.hqimg-warehouse-filter-row .nav-item {
  position: relative;
  margin-bottom: 0;
  flex-shrink: 0;
  white-space: nowrap;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: 10px 10px 6px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(200, 215, 210, 0.72);
  transition: color 0.18s ease;
}

.hqimg-warehouse-filter-row .nav-item::before {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%) scaleX(0.35);
  top: 4px;
  width: 100%;
  max-width: 3.2em;
  height: 1.5px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(185, 218, 200, 0.5) 42%,
    rgba(155, 198, 178, 0.3) 58%,
    transparent
  );
  box-shadow:
    0 0 5px rgba(150, 200, 175, 0.14),
    0 2px 10px rgba(110, 160, 140, 0.08);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.hqimg-warehouse-filter-row .nav-item:hover {
  background: transparent;
  border: none;
  box-shadow: none;
}

.hqimg-warehouse-filter-row .nav-item:hover:not(.active) {
  color: rgba(208, 218, 212, 0.8);
}

.hqimg-warehouse-filter-row .nav-item.active {
  border: none;
  background: transparent;
  box-shadow: none;
  /* 仅比未选中略亮一点，主要靠顶光 + 略重字重表示选中 */
  color: rgba(212, 222, 216, 0.86);
  font-weight: 600;
}

.hqimg-warehouse-filter-row .nav-item.active::before {
  opacity: 0.8;
  transform: translateX(-50%) scaleX(1);
}

.hqimg-warehouse-filter-row .nav-item:focus-visible {
  outline: none;
  box-shadow: none;
  color: rgba(212, 222, 216, 0.86);
}

.hqimg-warehouse-filter-row .nav-item:focus-visible::after {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 2px;
  height: 1px;
  border-radius: 1px;
  background: rgba(140, 190, 170, 0.45);
}

.hqimg-warehouse-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.hqimg-warehouse-col-main {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border-radius: 0;
  background: transparent;
  border: none;
}

/* 历史卡 · 加入仓库（左上，悬停显示；与右上角删除错开） */
.history-card-add-warehouse {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 11;
  max-width: calc(100% - 8px);
  padding: 2px 5px;
  margin: 0;
  border: none;
  border-radius: 5px;
  font-size: 9px;
  line-height: 1.15;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: #fff;
  background: rgba(90, 127, 118, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.history-card:hover .history-card-add-warehouse {
  opacity: 1;
  pointer-events: auto;
}

.history-card-add-warehouse:hover {
  background: rgba(109, 150, 140, 1);
}

.history-card-add-warehouse:focus-visible {
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
}

@media (hover: none) and (pointer: coarse) {
  .history-card-add-warehouse {
    opacity: 0.88;
    pointer-events: auto;
  }
}

/* 加入仓库 · 下拉单选（fixed，贴近触发按钮） */
.warehouse-dropdown-root {
  display: none;
  z-index: 4800;
}

.warehouse-dropdown-panel {
  min-width: 220px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 10px 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
  background: linear-gradient(165deg, rgba(30, 38, 52, 0.98) 0%, rgba(18, 24, 34, 0.99) 100%);
  box-shadow: var(--shadow-elev), 0 12px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(var(--blur-glass-strong));
  -webkit-backdrop-filter: blur(var(--blur-glass-strong));
}

.warehouse-dropdown-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}

.warehouse-dropdown-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.warehouse-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.12s ease;
}

.warehouse-dropdown-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.warehouse-dropdown-option input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent2);
  cursor: pointer;
  flex-shrink: 0;
}

.warehouse-dropdown-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* 覆盖全局 .btn-submit { width:100% }，取消与确定同一行 */
.warehouse-dropdown-actions .btn-submit,
.warehouse-dropdown-actions .btn-secondary {
  width: auto;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 32px;
  padding: 0 14px;
  font-size: 12px;
}

/* 仓库内容区：小卡片网格 */
.hqimg-warehouse-empty {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  padding: 8px 2px 4px;
}

.warehouse-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  align-content: start;
}

.warehouse-mini-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-inset);
}

.warehouse-mini-card:hover {
  border-color: rgba(120, 165, 150, 0.4);
  box-shadow: var(--shadow-inset), 0 0 12px rgba(100, 145, 140, 0.12);
}

.warehouse-mini-card-media {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.warehouse-mini-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.warehouse-mini-thumb--ph {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.warehouse-mini-card-meta {
  padding: 4px 5px 5px;
}

.warehouse-mini-card-label {
  font-size: 10px;
  color: var(--text);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.warehouse-mini-card-cats {
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.warehouse-mini-card-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  width: 20px;
  height: 20px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 5px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.warehouse-mini-card:hover .warehouse-mini-card-remove {
  opacity: 1;
  pointer-events: auto;
}

.warehouse-mini-card-remove:hover {
  background: rgba(180, 55, 55, 0.9);
}

.warehouse-mini-card-insert {
  position: absolute;
  bottom: 26px;
  right: 3px;
  z-index: 2;
  max-width: calc(100% - 8px);
  padding: 2px 7px;
  margin: 0;
  border: none;
  border-radius: 5px;
  font-size: 10px;
  line-height: 1.35;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  background: rgba(35, 75, 65, 0.92);
  color: rgba(235, 250, 245, 0.98);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.warehouse-mini-card:hover .warehouse-mini-card-insert {
  opacity: 1;
  pointer-events: auto;
}

.warehouse-mini-card-insert:hover {
  background: rgba(55, 115, 95, 0.96);
  color: #fff;
}

/* 高质视频 · veo 参考图：覆盖 .form-group textarea 的 min-height:180px，默认单行高、长 URL 换行 */
.form-group textarea.svid-veo-urls-textarea {
  min-height: 34px;
  height: auto;
  max-height: 200px;
  overflow-y: auto;
  padding: 6px 8px;
  line-height: 1.4;
  resize: vertical;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

@supports (field-sizing: content) {
  .form-group textarea.svid-veo-urls-textarea {
    field-sizing: content;
    min-height: 2.1em;
    max-height: 200px;
  }
}

select {
  cursor: pointer;
}

.result-area {
  margin-top: 10px;
}

.result-area > *:first-child {
  margin-top: 10px;
}

.result-done {
  font-size: 13px;
  color: var(--link-warm);
  text-align: center;
}

.result-error {
  background: rgba(176, 120, 120, 0.12);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: #d4a8a8;
  font-size: 13px;
  box-shadow: var(--shadow-inset);
}

.result-link {
  font-size: 12px;
  color: var(--link-warm);
  margin-top: 10px;
  text-align: center;
}

.result-link a {
  color: var(--link-warm);
  text-decoration: none;
}

.result-link a:hover {
  text-decoration: underline;
}

.chat-box {
  background: linear-gradient(180deg, rgba(20, 26, 36, 0.9) 0%, rgba(14, 18, 26, 0.92) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  max-height: calc(100vh - 350px);
  overflow-y: auto;
  box-shadow: var(--shadow-inset);
}

.chat-msg {
  margin-bottom: 12px;
}

.chat-msg .role {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 4px;
}

.chat-msg.user .role {
  color: #7a9ab8;
}

.chat-msg.assistant .role {
  color: var(--accent);
}

.chat-msg .content {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.loading {
  display: none;
  text-align: center;
  padding: 20px;
}

.loading.show {
  display: block;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  color: var(--muted);
  font-size: 13px;
}

.loading-dots::after {
  content: "";
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75% {
    content: "...";
  }
  100% {
    content: "";
  }
}

.audio-player {
  width: 100%;
  margin-top: 10px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.coding-subnav {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.coding-subnav-btn {
  flex: 1;
  min-height: var(--ctrl-h);
  padding: 0 var(--ctrl-pad-x);
  border-radius: var(--ctrl-radius);
  border: 1px solid var(--border-card);
  background: linear-gradient(180deg, rgba(36, 44, 58, 0.5) 0%, rgba(22, 28, 38, 0.55) 100%);
  color: var(--muted);
  cursor: pointer;
  font-size: var(--ctrl-fs);
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
  box-shadow: var(--shadow-inset);
}

.coding-subnav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: var(--border-cool);
}

.coding-subnav-btn.active {
  background: linear-gradient(135deg, rgba(115, 158, 148, 0.4) 0%, rgba(90, 128, 118, 0.55) 100%);
  color: #eef2f0;
  border-color: rgba(140, 185, 175, 0.4);
  box-shadow: var(--glow-neon), var(--shadow-inset);
}

#panel-coding.panel-coding-screenplay.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#codingScreenplayMid {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  gap: 0;
}

#codingScreenplayMid.show {
  display: flex;
}

.coding-mid-stream-wrap {
  position: relative;
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(16, 22, 32, 0.95) 0%, rgba(10, 14, 20, 0.98) 100%);
  box-shadow: var(--shadow-inset), var(--shadow-elev);
}

.coding-mid-stream-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

#screenplayStreamTokens {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#screenplayStreamTokens strong {
  color: var(--accent);
  font-weight: 600;
}

#screenplayCherryMount {
  flex: 1;
  min-height: 220px;
  overflow: auto;
}

#minimaxChatCherryMount {
  align-self: stretch;
  min-height: 200px;
  max-height: min(70vh, calc(100vh - 220px));
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(140, 165, 155, 0.18);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 165, 155, 0.45) rgba(255, 255, 255, 0.05);
}

#minimaxChatCherryMount::-webkit-scrollbar {
  width: 8px;
}

#minimaxChatCherryMount::-webkit-scrollbar-thumb {
  background: rgba(140, 155, 145, 0.45);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

#codingStreamOutput,
#gemini30StreamOutput {
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  max-height: min(70vh, calc(100vh - 220px));
  font-size: 13px;
  line-height: 1.75;
  padding: 10px 12px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(140, 165, 155, 0.15);
  white-space: normal;
  word-break: break-word;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 165, 155, 0.45) rgba(255, 255, 255, 0.05);
}

#codingStreamOutput::-webkit-scrollbar,
#gemini30StreamOutput::-webkit-scrollbar {
  width: 8px;
}

#codingStreamOutput::-webkit-scrollbar-thumb,
#gemini30StreamOutput::-webkit-scrollbar-thumb {
  background: rgba(140, 155, 145, 0.45);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root),
#screenplayCherryMount .cherry-markdown,
#minimaxChatCherryMount .cherry-markdown {
  background: rgba(10, 14, 20, 0.97) !important;
  color: #c4c8c4 !important;
}

.chat-msg .content.minimax-md-root {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(140, 165, 155, 0.14);
  white-space: normal;
}

#screenplayCherryMount .cherry-markdown,
#minimaxChatCherryMount .cherry-markdown {
  min-height: 100%;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root),
:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) *,
#screenplayCherryMount .cherry-markdown,
#screenplayCherryMount .cherry-markdown *,
#minimaxChatCherryMount .cherry-markdown,
#minimaxChatCherryMount .cherry-markdown * {
  border-left: none !important;
  box-shadow: none !important;
  outline: none !important;
}

#screenplayCherryMount .cherry-markdown .cherry-previewer,
#screenplayCherryMount .cherry-markdown .cherry-previewer *,
#minimaxChatCherryMount .cherry-markdown .cherry-previewer,
#minimaxChatCherryMount .cherry-markdown .cherry-previewer * {
  border-left-width: 0 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h1,
:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h2,
:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h3,
:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h4,
#screenplayCherryMount .cherry-markdown h1,
#screenplayCherryMount .cherry-markdown h2,
#screenplayCherryMount .cherry-markdown h3,
#screenplayCherryMount .cherry-markdown h4,
#minimaxChatCherryMount .cherry-markdown h1,
#minimaxChatCherryMount .cherry-markdown h2,
#minimaxChatCherryMount .cherry-markdown h3,
#minimaxChatCherryMount .cherry-markdown h4 {
  color: #5f9380 !important;
  border-bottom: 1px solid rgba(140, 165, 155, 0.22) !important;
  font-weight: 700 !important;
  margin: 12px 0 6px !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h1 {
  font-size: 18px !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h2 {
  font-size: 16px !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h3 {
  font-size: 14px !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h5,
:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) h6,
#screenplayCherryMount .cherry-markdown h5,
#screenplayCherryMount .cherry-markdown h6,
#minimaxChatCherryMount .cherry-markdown h5,
#minimaxChatCherryMount .cherry-markdown h6 {
  margin: 8px 0 4px 0 !important;
  color: #5f9380 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) p,
#screenplayCherryMount .cherry-markdown p,
#minimaxChatCherryMount .cherry-markdown p {
  color: #babeb8 !important;
  margin: 4px 0 !important;
  line-height: 1.65 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) br,
#screenplayCherryMount .cherry-markdown br,
#minimaxChatCherryMount .cherry-markdown br {
  display: block;
  content: "";
  margin: 0;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) ul,
:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) ol,
#screenplayCherryMount .cherry-markdown ul,
#screenplayCherryMount .cherry-markdown ol,
#minimaxChatCherryMount .cherry-markdown ul,
#minimaxChatCherryMount .cherry-markdown ol {
  padding-left: 20px !important;
  margin: 8px 0 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) li,
#screenplayCherryMount .cherry-markdown li,
#minimaxChatCherryMount .cherry-markdown li {
  margin: 4px 0 !important;
  color: #babeb8 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) strong,
#screenplayCherryMount .cherry-markdown strong,
#minimaxChatCherryMount .cherry-markdown strong {
  color: #9aaf9e !important;
  font-weight: 700 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) em,
#screenplayCherryMount .cherry-markdown em,
#minimaxChatCherryMount .cherry-markdown em {
  font-style: italic !important;
  color: #babeb8 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) table,
#screenplayCherryMount .cherry-markdown table,
#minimaxChatCherryMount .cherry-markdown table {
  background: rgba(24, 34, 42, 0.75) !important;
  border-collapse: collapse !important;
  width: 100% !important;
  border: 1px solid rgba(140, 165, 155, 0.2) !important;
  margin: 8px 0 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) th,
#screenplayCherryMount .cherry-markdown th,
#minimaxChatCherryMount .cherry-markdown th {
  background: #2c3c40 !important;
  color: #e0ddd4 !important;
  font-weight: 600 !important;
  padding: 10px 14px !important;
  border: 1px solid rgba(140, 165, 155, 0.22) !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) td,
#screenplayCherryMount .cherry-markdown td,
#minimaxChatCherryMount .cherry-markdown td {
  background: rgba(22, 32, 40, 0.55) !important;
  color: #c4c2b8 !important;
  padding: 8px 14px !important;
  border: 1px solid rgba(140, 165, 155, 0.12) !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) tr:nth-child(even) td,
#screenplayCherryMount .cherry-markdown tr:nth-child(even) td,
#minimaxChatCherryMount .cherry-markdown tr:nth-child(even) td {
  background: rgba(30, 42, 48, 0.5) !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) pre,
#screenplayCherryMount .cherry-markdown pre,
#minimaxChatCherryMount .cherry-markdown pre {
  background: rgba(0, 0, 0, 0.45) !important;
  border-radius: 8px !important;
  border: 1px solid rgba(140, 165, 155, 0.15) !important;
  padding: 12px !important;
  margin: 8px 0 !important;
  overflow-x: auto !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) code,
#screenplayCherryMount .cherry-markdown code,
#minimaxChatCherryMount .cherry-markdown code {
  background: rgba(0, 0, 0, 0.35) !important;
  color: #b0aca0 !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  font-family: "Fira Code", Consolas, monospace !important;
  font-size: 12px !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) pre code,
#screenplayCherryMount .cherry-markdown pre code,
#minimaxChatCherryMount .cherry-markdown pre code {
  background: transparent !important;
  padding: 0 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) blockquote,
#screenplayCherryMount .cherry-markdown blockquote,
#minimaxChatCherryMount .cherry-markdown blockquote {
  background: rgba(22, 32, 38, 0.45) !important;
  border-left: 3px solid #6d8580 !important;
  color: #b0aca0 !important;
  padding: 10px 16px !important;
  margin: 8px 0 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) a,
#screenplayCherryMount .cherry-markdown a,
#minimaxChatCherryMount .cherry-markdown a {
  color: #7a9a98 !important;
}

:is(#codingStreamOutput, #gemini30StreamOutput, .minimax-md-root) hr,
#screenplayCherryMount .cherry-markdown hr,
#minimaxChatCherryMount .cherry-markdown hr {
  border: none !important;
  border-top: 1px solid rgba(140, 165, 155, 0.2) !important;
  margin: 12px 0 !important;
}

.screenplay-preview-controls label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}

.screenplay-preview-controls .sp-mode-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.screenplay-preview-controls .sp-mode-btn {
  flex: 1;
  min-height: var(--ctrl-h);
  padding: 0 10px;
  border-radius: var(--ctrl-radius);
  border: 1px solid var(--border-card);
  background: linear-gradient(180deg, rgba(36, 44, 58, 0.5) 0%, rgba(22, 28, 38, 0.55) 100%);
  color: var(--muted);
  cursor: pointer;
  font-size: var(--ctrl-fs);
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-inset);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.screenplay-preview-controls .sp-mode-btn:hover {
  border-color: var(--border-cool);
  color: var(--text);
}

.screenplay-preview-controls .sp-mode-btn.active {
  background: linear-gradient(135deg, rgba(115, 158, 148, 0.4) 0%, rgba(90, 128, 118, 0.55) 100%);
  color: #eef2f0;
  border-color: rgba(140, 185, 175, 0.4);
  box-shadow: var(--glow-neon), var(--shadow-inset);
}

.screenplay-preview-controls input,
.screenplay-preview-controls textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 12px;
  box-shadow: var(--shadow-inset);
}

.screenplay-preview-controls textarea {
  min-height: 120px;
  resize: vertical;
}

.screenplay-preview-controls select#screenplayModel {
  margin-bottom: 22px;
}

.quality-group {
  display: none;
}

.quality-group.show {
  display: block;
}

.emotion-tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  box-shadow: var(--shadow-inset);
}

.emotion-tag:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  border-color: var(--border-cool);
}

.history-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  /* 悬停 scale 时略向左右扩展，留边避免贴边裁切 */
  padding: 4px 6px 10px 6px;
  margin-top: 10px;
  margin-bottom: 12px;
  display: none;
}

.history-gallery.show {
  display: flex;
}

.history-gallery::-webkit-scrollbar {
  height: 4px;
}

.history-gallery::-webkit-scrollbar-thumb {
  background: rgba(160, 185, 200, 0.2);
  border-radius: 2px;
}

.history-card {
  position: relative;
  flex-shrink: 0;
  width: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  /* 以顶边为锚点缩放，避免默认中心缩放时整体上移撑出上方区域 */
  transform-origin: center top;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-inset);
}

.history-card-close {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 12;
  width: 22px;
  height: 22px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.history-card:hover .history-card-close {
  opacity: 1;
  pointer-events: auto;
}

.history-card-close:hover {
  background: rgba(180, 55, 55, 0.92);
  color: #fff;
}

.history-card-close:focus-visible {
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid var(--accent, rgba(120, 200, 170, 0.8));
  outline-offset: 1px;
}

.history-card:hover {
  transform: scale(1.05);
  border-color: rgba(120, 165, 150, 0.45);
  box-shadow: 0 0 20px rgba(100, 145, 140, 0.15);
}

.history-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
  display: block;
}

.history-card-audio {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.history-card-label {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding: 3px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

::-webkit-scrollbar-thumb {
  background: rgba(140, 155, 145, 0.4);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(140, 155, 145, 0.55);
}

.url-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.url-preview-img {
  position: relative;
  flex: 0 0 auto;
  width: 160px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
}

.url-preview-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ref-url-preview-frame {
  margin-top: 8px;
  display: none;
  width: 100%;
  max-width: 200px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-inset);
}

.ref-url-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.url-preview-img:hover {
  border-color: rgba(120, 165, 150, 0.45);
}

.url-preview-img .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(176, 120, 120, 0.88);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  line-height: 1;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  cursor: zoom-out;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#lightbox.show {
  display: flex;
}

#lightbox img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.65), 0 0 1px rgba(160, 185, 200, 0.2);
  cursor: default;
}

#lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  font-size: 28px;
  color: rgba(230, 234, 238, 0.65);
  cursor: pointer;
  line-height: 1;
}

#lightbox-close:hover {
  color: #fff;
}

.history-empty {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 16px 0;
}

/* TTS 高级设置折叠：文本链样式，不参与统一按钮高度 */
#ttsAdvancedToggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  margin: 0;
  min-height: auto;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}

#ttsAdvancedToggle:hover {
  color: var(--text);
}

/* Flex 行内主按钮与次要按钮对齐 */
.btn-generate-wrap .btn-submit[style*="flex"] {
  flex: 1;
}

.btn-generate-wrap [style*="display:flex"] .btn-secondary,
.btn-generate-wrap [style*="display:flex"] button.btn-secondary {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  body {
    overflow: auto;
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 15px;
    gap: 10px;
  }

  .topbar-left img {
    height: 24px;
  }

  .topbar-brand {
    font-size: 12px;
  }

  .topbar-window-title {
    font-size: 12px;
    max-width: min(280px, 52vw);
  }

  .api-status {
    font-size: 10px;
  }

  .layout {
    flex-direction: column;
    height: auto;
    padding: 10px;
    gap: 10px;
  }

  .sidebar {
    width: 100%;
    height: auto;
    flex: none;
    overflow: hidden;
  }

  .nav-group {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 6px 8px;
    height: auto;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
  }

  .nav-group::-webkit-scrollbar {
    height: 4px;
  }

  .nav-group::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
  }

  .nav-group-label {
    display: none;
  }

  .nav-item {
    flex-shrink: 0;
    font-size: 12px;
    padding: 8px 12px;
    margin-bottom: 0;
  }

  .main {
    width: 100%;
    flex: auto;
    height: auto;
  }

  .main-content {
    padding: 15px;
  }

  .hqimg-warehouse {
    margin: 0 -15px -15px;
    padding: 12px 15px 15px;
  }

  .preview {
    width: 100%;
    flex: auto;
    height: auto;
    min-height: 250px;
  }

  .preview-content {
    width: 100%;
  }

  .config-bar:not(.config-bar--modal) {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 15px;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
  }

  .config-bar:not(.config-bar--modal) .config-item {
    width: 100%;
    justify-content: space-between;
  }

  .config-bar:not(.config-bar--modal) .config-item input {
    min-width: 0;
    width: 130px;
  }

  .config-bar:not(.config-bar--modal) .config-item .btn {
    white-space: nowrap;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .btn-submit,
  .screenplay-preview-controls .btn-sp-generate {
    min-height: 40px;
    font-size: 13px;
  }
}

/* ========== 高级自定义 · 五列老虎机弹窗 ========== */
.adv-custom-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 4600;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(var(--blur-overlay));
  -webkit-backdrop-filter: blur(var(--blur-overlay));
}

.adv-custom-modal-overlay.show {
  display: flex;
}

.adv-custom-modal {
  width: 100%;
  max-width: min(735px, calc(100vw - 24px));
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, rgba(28, 36, 50, 0.97) 0%, rgba(16, 22, 32, 0.99) 100%);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  box-shadow: var(--shadow-elev), 0 0 40px rgba(90, 130, 118, 0.12);
  backdrop-filter: blur(var(--blur-glass-strong));
  -webkit-backdrop-filter: blur(var(--blur-glass-strong));
  animation: modalIn 0.28s ease;
  overflow: hidden;
  box-sizing: border-box;
}

.adv-custom-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.adv-custom-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.adv-custom-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-cool);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.adv-custom-modal-close:hover {
  color: var(--text);
  border-color: rgba(140, 175, 195, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

.adv-custom-modal-cols {
  display: grid;
  grid-template-columns: repeat(5, 135px);
  justify-content: center;
  gap: 8px;
  padding: 12px 12px 8px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.adv-custom-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 135px;
  max-width: 135px;
  min-width: 0;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(100, 130, 120, 0.15);
  border-radius: 12px;
  padding: 8px 6px 6px;
}

.adv-custom-col-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  flex-shrink: 0;
  min-height: 28px;
}

.adv-custom-col-head-title {
  font-size: 12px;
  font-weight: 700;
  color: rgba(175, 210, 198, 0.95);
  letter-spacing: 0.12em;
  text-align: center;
}

.adv-slot-nav {
  flex-shrink: 0;
  height: 22px;
  width: 100%;
  margin: 0;
  padding: 2px 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: rgba(145, 182, 168, 0.88);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, transform 0.1s ease;
}

.adv-slot-nav:hover {
  color: rgba(200, 230, 215, 0.98);
  background: transparent;
  border-color: transparent;
}

.adv-slot-nav:focus-visible {
  outline: 2px solid rgba(120, 168, 150, 0.45);
  outline-offset: 2px;
}

.adv-slot-nav:active {
  transform: scale(0.9);
}

.adv-slot-nav-tri {
  font-size: 10px;
  line-height: 1;
  transform: scaleX(1.2);
  pointer-events: none;
}

.adv-slot-viewport {
  flex: 1;
  min-height: 120px;
  max-height: 216px;
  height: 216px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin: 4px 0;
  border-radius: 10px;
  border: 1px solid rgba(60, 78, 72, 0.45);
  background: rgba(6, 10, 14, 0.55);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.35);
  overscroll-behavior: contain;
}

.adv-slot-viewport::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.adv-slot-rail {
  padding: 72px 0;
  box-sizing: border-box;
}

.adv-slot-item-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
}

.adv-slot-item-img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.adv-slot-item {
  min-height: 72px;
  height: 72px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s, filter 0.15s;
}

.adv-slot-item:last-child {
  border-bottom: none;
}

.adv-slot-item-icon {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.adv-slot-item-name {
  font-size: 10px;
  font-weight: 600;
  color: rgba(200, 218, 208, 0.88);
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.adv-slot-item--active .adv-slot-item-icon,
.adv-slot-item--active .adv-slot-item-img {
  animation: advSlotPulse 1.6s ease-in-out infinite;
}

.adv-slot-item--active {
  background: rgba(95, 138, 124, 0.12);
  box-shadow: inset 0 0 0 1px rgba(120, 168, 150, 0.35);
  border-radius: 8px;
}

@keyframes advSlotPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(120, 175, 155, 0));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(120, 175, 155, 0.45));
  }
}

.adv-slot-desc {
  flex-shrink: 0;
  margin-top: 4px;
  min-height: 32px;
  padding: 6px 4px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(80, 110, 100, 0.2);
  text-align: center;
}

.adv-slot-desc-text {
  font-size: 10px;
  color: rgba(175, 190, 182, 0.92);
  line-height: 1.45;
  word-break: break-word;
  text-align: center;
}

.adv-custom-modal-preview {
  flex-shrink: 0;
  margin: 0 12px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(195, 228, 212, 0.95);
  background: linear-gradient(90deg, rgba(20, 36, 32, 0.65) 0%, rgba(14, 26, 28, 0.75) 100%);
  border: 1px solid rgba(110, 155, 138, 0.28);
  box-shadow: 0 0 18px rgba(80, 130, 110, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  word-break: break-word;
}

.adv-custom-modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 14px;
  flex-shrink: 0;
  border-top: 1px solid rgba(80, 100, 95, 0.2);
}

.adv-custom-modal-foot .btn-secondary,
.adv-custom-modal-foot .btn-submit {
  min-width: 96px;
  width: auto;
}

@media (max-width: 720px) {
  .adv-custom-modal-cols {
    grid-template-columns: 1fr;
    justify-content: stretch;
    max-height: none;
    overflow-y: auto;
  }

  .adv-custom-col {
    width: 100%;
    max-width: none;
  }
}
