/* =====================================================================
 * S2 智能引擎 · V88 终极修复（主代理亲自实现）
 * 覆盖用户 9 项问题中的视觉部分：
 *   #1 底部功能钮避让项目面板  #2 输入框塌缩换行  #4 视频卡尺寸统一
 *   #8 工作流期间作曲器最小化  #5 资产选择器  #6 悬浮预览
 *   #7 AI/手动/违规词/时长 弹窗
 * 组件统一使用 s2fx- 前缀，避免与历史补丁冲突。
 * ===================================================================== */

/* ---------- #1 项目面板展开时，作曲器整体右移 370px，底部浮动槽离开面板 ---------- */
.ws-main.s2proj-state-open > #wsComposer { margin-left: 370px !important; }
.ws-main.s2proj-state-collapsed > #wsComposer { margin-left: 46px !important; }
#workspaceShell #wsComposer #agBottomActionLeft.bottom-action-left { left: -6px !important; bottom: 0 !important; width: 123px !important; height: 100% !important; z-index: 70 !important; }
/* 面板展开时浮动槽随作曲器右移后，保证与面板右缘至少 26px 间隙 */
.ws-main.s2proj-state-open #wsComposer #agBottomActionLeft.bottom-action-left { left: 30px !important; }

/* ---------- #2 agent-mode 下 textarea 占满 composer-box（修复 width:auto 塌缩到 150px） ---------- */
#wsComposer.agent-mode #promptInput,
#wsComposer.s2-active #promptInput {
  width: 100% !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* ---------- #4 视频输出区：失败/生成/成片/生成中 四种卡完全等尺寸 ---------- */
.video-outputs-grid { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; }
.video-outputs-grid > .vo-item,
.video-outputs-grid > .vo-add {
  flex: 0 0 150px !important;
  width: 150px !important;
  height: 150px !important;
  margin: 0 !important;
  box-sizing: border-box;
}
.video-outputs-grid .vo-generating,
.video-outputs-grid .vo-failed,
.video-outputs-grid .vo-done {
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box;
  border-radius: 10px;
  overflow: hidden;
}
.video-outputs-grid .vo-add {
  border-radius: 10px !important;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.video-outputs-grid .vo-failed { padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.video-outputs-grid .vo-fail-reason { font-size: 11px; line-height: 1.4; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.video-outputs-grid .vo-fail-actions { display: flex; gap: 6px; margin-top: 2px; }
.video-outputs-grid .vo-retry-btn, .video-outputs-grid .vo-delete-btn { padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.video-outputs-grid .vo-done { position: relative; }
.video-outputs-grid .vo-cover-video { width: 100%; height: 100%; object-fit: cover; }

/* ---------- #8 工作流已确认步骤：作曲器最小化（隐藏输入区，仅留控制行） ---------- */
#wsComposer.s2-minimal .cp-refs,
#wsComposer.s2-minimal .composer-toolbar,
#wsComposer.s2-minimal #promptInput,
#wsComposer.s2-minimal .cp-corner,
#wsComposer.s2-minimal .send-stack,
#wsComposer.s2-minimal .cp-enter-hint,
#wsComposer.s2-minimal .composer-params,
#wsComposer.s2-minimal .mode-buttons,
#wsComposer.s2-minimal #s2ComposerBar { display: none !important; }
#wsComposer.s2-minimal .composer-box {
  padding: 8px 14px !important;
  border-radius: 14px !important;
  background: rgba(27,28,33,0.95) !important;
}
#wsComposer.s2-minimal .composer-bottom {
  justify-content: flex-end !important;
  border-top: none !important;
  padding-top: 0 !important;
  margin-top: 0 !important;
  min-height: 38px;
}
#wsComposer.s2-minimal #s2ModeSwitch { display: block !important; }

/* =====================================================================
 * #5 可视化「从资产库选取」选择器
 * ===================================================================== */
.s2fx-overlay {
  position: fixed; inset: 0; z-index: 2147483500;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  animation: s2fxFade .18s ease;
}
@keyframes s2fxFade { from { opacity: 0; } to { opacity: 1; } }
.s2fx-picker {
  width: 1210px; max-width: 96vw; max-height: 92vh;
  background: rgb(15,15,18);
  border: 0.67px solid rgba(99,102,241,0.2);
  border-radius: 16.8px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.s2fx-picker-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 24px;
}
.s2fx-picker-header .s2fx-hicon {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(99,102,241,0.14); color: #8b8ff7;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.s2fx-picker-header .s2fx-htitle h3 { margin: 0; font-size: 17px; color: rgba(255,255,255,0.92); font-weight: 600; }
.s2fx-picker-header .s2fx-htitle p { margin: 2px 0 0; font-size: 13px; color: rgba(255,255,255,0.45); }
.s2fx-picker-header .s2fx-close {
  margin-left: auto; width: 34px; height: 34px; border-radius: 9px;
  background: transparent; border: none; color: rgba(255,255,255,0.55);
  font-size: 18px; cursor: pointer;
}
.s2fx-picker-header .s2fx-close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.s2fx-tabs { display: flex; gap: 8px; padding: 0 24px 14px; }
.s2fx-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 0.67px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.62); font-size: 13.5px; cursor: pointer;
}
.s2fx-tab .s2fx-tab-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: rgba(255,255,255,0.08); font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
}
.s2fx-tab.s2fx-tab-active {
  background: rgba(99,102,241,0.16);
  border-color: rgba(99,102,241,0.45);
  color: #a5a8f8;
}
.s2fx-tab.s2fx-tab-active .s2fx-tab-count { background: rgba(99,102,241,0.35); color: #fff; }
.s2fx-picker-body { flex: 1; overflow-y: auto; padding: 6px 24px 16px; }
.s2fx-item-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.s2fx-item-card {
  border-radius: 12px; overflow: hidden; cursor: pointer;
  border: 1.5px solid transparent; background: rgba(255,255,255,0.03);
  transition: transform .15s, border-color .15s;
}
.s2fx-item-card:hover { transform: translateY(-2px); border-color: rgba(99,102,241,0.4); }
.s2fx-item-card.s2fx-selected { border-color: rgb(99,102,241); box-shadow: 0 0 0 2px rgba(99,102,241,0.25); }
.s2fx-item-preview { position: relative; width: 100%; aspect-ratio: 352/264; background: #16161b; }
.s2fx-item-preview img { width: 100%; height: 100%; object-fit: cover; }
.s2fx-item-check {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  background: rgb(99,102,241); color: #fff; display: none;
  align-items: center; justify-content: center;
}
.s2fx-item-card.s2fx-selected .s2fx-item-check { display: flex; }
.s2fx-item-info { padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.s2fx-item-type { font-size: 11px; color: rgba(255,255,255,0.4); }
.s2fx-item-name { font-size: 13.5px; color: rgba(255,255,255,0.85); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s2fx-no-more { text-align: center; color: rgba(255,255,255,0.32); font-size: 12.5px; padding: 18px 0 4px; }
.s2fx-picker-footer {
  display: flex; align-items: center; padding: 16px 24px;
  border-top: 0.67px solid rgba(255,255,255,0.07);
}
.s2fx-footer-info { font-size: 13px; color: rgba(255,255,255,0.45); }
.s2fx-footer-actions { margin-left: auto; display: flex; gap: 10px; }
.s2fx-btn { padding: 10px 22px; border-radius: 10px; font-size: 14px; cursor: pointer; border: 0.67px solid transparent; }
.s2fx-btn-secondary { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8); }
.s2fx-btn-primary { background: rgb(99,102,241); color: #fff; }
.s2fx-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* =====================================================================
 * #6 出镜资产悬浮预览
 * ===================================================================== */
.s2fx-preview {
  position: fixed; z-index: 2147483600;
  padding: 0.25rem;
  background: rgba(20,20,28,0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8.4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  pointer-events: none;
  animation: s2fxFade .12s ease;
}
.s2fx-preview img {
  width: 224px; height: 126px; object-fit: cover;
  border-radius: 6px; display: block;
}
.s2fx-preview .s2fx-preview-cap {
  font-size: 12px; color: rgba(255,255,255,0.7); padding: 5px 4px 2px;
}

/* =====================================================================
 * #7-A AI 修改（regen-popup：文本模型下拉 + 修改意见 + 直接重新生成）
 * ===================================================================== */
.s2fx-regen {
  position: fixed; z-index: 2147483600;
  width: 280px;
  background: rgba(30,31,37,0.95);
  border: 0.67px solid rgba(255,255,255,0.1);
  border-radius: 10.5px;
  padding: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  animation: s2fxFade .14s ease;
}
.s2fx-regen-model-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.s2fx-regen-model-label { font-size: 12.5px; color: rgba(255,255,255,0.55); flex: 0 0 auto; }
.s2fx-regen-model-picker { position: relative; flex: 1; }
.s2fx-regen-model-select {
  width: 100%; box-sizing: border-box;
  background: rgba(255,255,255,0.05);
  border: 0.67px solid rgba(255,255,255,0.12);
  border-radius: 8px; color: rgba(255,255,255,0.85);
  padding: 7px 26px 7px 10px; font-size: 12.5px; cursor: pointer;
  appearance: none; text-align: left;
}
.s2fx-regen-model-picker .s2fx-regen-caret { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,0.5); font-size: 11px; pointer-events: none; }
.s2fx-regen-input {
  width: 100%; box-sizing: border-box; resize: none;
  background: rgba(255,255,255,0.05);
  border: 0.67px solid rgba(255,255,255,0.1);
  border-radius: 8px; color: rgba(255,255,255,0.88);
  padding: 8px 10px; font-size: 13px; font-family: inherit; line-height: 1.5;
}
.s2fx-regen-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.s2fx-regen-cancel { background: transparent; border: none; color: rgba(255,255,255,0.6); font-size: 13px; cursor: pointer; padding: 6px 10px; }
.s2fx-regen-confirm {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgb(99,102,241); color: #fff;
  border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.s2fx-regen-confirm:disabled { opacity: .6; cursor: wait; }
.s2fx-regen-menu {
  position: absolute; z-index: 2147483601;
  width: 220px; max-height: 200px; overflow-y: auto;
  background: rgba(18,15,26,0.98);
  border: 0.67px solid rgba(255,255,255,0.12);
  border-radius: 10.5px; padding: 5px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.7);
}
.s2fx-regen-menu-item { padding: 7px 10px; border-radius: 7px; font-size: 12.5px; color: rgba(255,255,255,0.78); cursor: pointer; white-space: nowrap; }
.s2fx-regen-menu-item:hover { background: rgba(99,102,241,0.2); color: #fff; }
.s2fx-regen-menu-item.s2fx-menu-active { color: #a5a8f8; background: rgba(99,102,241,0.14); }

/* =====================================================================
 * #7-B 手动修改（shoudong-modal）
 * ===================================================================== */
.s2fx-manual-mask {
  position: fixed; inset: 0; z-index: 2147483550;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  animation: s2fxFade .18s ease;
}
.s2fx-manual {
  width: 780px; max-width: 94vw;
  background: rgba(30,31,37,0.95);
  border: 0.67px solid rgba(255,255,255,0.1);
  border-radius: 12.6px; padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.65);
}
.s2fx-manual-header { display: flex; align-items: center; margin-bottom: 14px; }
.s2fx-manual-header span { font-size: 16px; color: rgba(255,255,255,0.9); font-weight: 600; }
.s2fx-manual-close { margin-left: auto; background: transparent; border: none; color: rgba(255,255,255,0.55); font-size: 18px; cursor: pointer; }
.s2fx-manual textarea {
  width: 100%; box-sizing: border-box; resize: vertical;
  min-height: 360px;
  background: rgba(255,255,255,0.04);
  border: 0.67px solid rgba(255,255,255,0.1);
  border-radius: 10px; color: rgba(255,255,255,0.88);
  padding: 12px 14px; font-size: 14.7px; line-height: 25px; font-family: inherit;
}
.s2fx-manual-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.s2fx-manual-save { background: rgb(99,102,241); color: #fff; border: none; border-radius: 10px; padding: 10px 24px; font-size: 14px; cursor: pointer; }

/* =====================================================================
 * #7-C 违规词智能替换（wg-dialog）
 * ===================================================================== */
.s2fx-wg-mask {
  position: fixed; inset: 0; z-index: 2147483560;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  animation: s2fxFade .18s ease;
}
.s2fx-wg {
  width: 460px; max-width: 94vw;
  background: rgb(22,23,28);
  border: 0.67px solid rgba(255,255,255,0.1);
  border-radius: 14px; padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.65);
}
.s2fx-wg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.s2fx-wg-head .s2fx-wg-hicon { width: 34px; height: 34px; border-radius: 9px; background: rgba(99,102,241,0.16); color: #8b8ff7; display: flex; align-items: center; justify-content: center; }
.s2fx-wg-title { font-size: 16px; color: rgba(255,255,255,0.9); font-weight: 600; }
.s2fx-wg-close { margin-left: auto; background: transparent; border: none; color: rgba(255,255,255,0.55); font-size: 18px; cursor: pointer; }
.s2fx-wg-status { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 14px 0 8px; gap: 6px; }
.s2fx-wg-status-ic { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.s2fx-wg-status-ic.s2fx-ok { background: rgba(34,197,94,0.15); color: #22c55e; }
.s2fx-wg-status-msg { font-size: 15px; color: rgba(255,255,255,0.9); margin-top: 6px; }
.s2fx-wg-status-sub { font-size: 13px; color: rgba(255,255,255,0.45); }
.s2fx-wg-spinner { width: 42px; height: 42px; border: 3px solid rgba(99,102,241,0.25); border-top-color: rgb(99,102,241); border-radius: 50%; animation: s2fxSpin .8s linear infinite; }
@keyframes s2fxSpin { to { transform: rotate(360deg); } }
.s2fx-wg-result { margin: 6px 0; }
.s2fx-wg-row { padding: 10px 12px; border-radius: 9px; background: rgba(255,255,255,0.03); margin-bottom: 8px; font-size: 13px; line-height: 1.6; }
.s2fx-wg-row .s2fx-wg-before { color: #f87171; text-decoration: line-through; }
.s2fx-wg-row .s2fx-wg-after { color: #4ade80; }
.s2fx-wg-actions { display: flex; justify-content: center; margin-top: 14px; }
.s2fx-wg-apply { background: rgb(99,102,241); color: #fff; border: none; border-radius: 10px; padding: 10px 26px; font-size: 14px; cursor: pointer; }

/* =====================================================================
 * #7-D 时长选择（duration-picker：严格 5/10/15）
 * ===================================================================== */
.s2fx-dur {
  position: fixed; z-index: 2147483600;
  width: 120px;
  background: rgba(30,31,37,0.95);
  border: 0.67px solid rgba(255,255,255,0.1);
  border-radius: 8.4px; padding: 6px;
  box-shadow: 0 10px 36px rgba(0,0,0,0.6);
  animation: s2fxFade .12s ease;
}
.s2fx-dur-title { padding: 4px 9px 7px; font-size: 12px; color: rgba(255,255,255,0.45); white-space: nowrap; }
.s2fx-dur-opt { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 10px; border-radius: 7px; font-size: 13.5px; color: rgba(255,255,255,0.72); cursor: pointer; white-space: nowrap; }
.s2fx-dur-opt:hover { background: rgba(255,255,255,0.08); color: #fff; }
.s2fx-dur-opt.s2fx-dur-active { color: #8ab6ff; font-weight: 600; }
.s2fx-dur-opt svg { display: none; }
.s2fx-dur-opt.s2fx-dur-active svg { display: block; }
