/* 千问 Token Plan 创作页面统一样式（独立命名空间，不影响既有页面） */
:root {
  --qw: #615ced;
  --qw-2: #9b5cf6;
  --qw-dark: #4c46d6;
  --qw-accent: #f72585;
}

.qw-page {
  background: #f5f6fa;
  min-height: calc(100vh - var(--topbar-h, 64px));
  padding: 18px 22px 40px;
  padding-top: calc(var(--topbar-h, 64px) + 18px);
  box-sizing: border-box;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* 页面头部 */
.qw-hero {
  background: linear-gradient(135deg, #4c46d6 0%, #7c3aed 60%, #b24bf3 100%);
  border-radius: 16px;
  color: #fff;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  box-shadow: 0 6px 22px rgba(97, 92, 237, .22);
  position: relative;
  overflow: hidden;
}
.qw-hero::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .2), transparent 65%);
}
.qw-hero .qw-hero-icon {
  width: 46px; height: 46px; border-radius: 13px;
  background: rgba(255, 255, 255, .18);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.qw-hero h1 { font-size: 1.08rem; font-weight: 700; margin: 0; }
.qw-hero p { margin: 2px 0 0; font-size: .78rem; opacity: .88; }
.qw-hero .qw-hero-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qw-hero .qw-pill {
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 18px;
  padding: 4px 12px;
  font-size: .74rem;
  white-space: nowrap;
}

/* 页面头部（参考 /seedance.html 的 workspace-header 样式） */
.qw-page-head {
  background: #fff;
  border-radius: 12px;
  padding: 14px 20px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 14px;
  border: 1px solid #e9ecef;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
  position: relative;
  overflow: hidden;
}
.qw-page-head::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--qw), var(--qw-2));
}
.qw-page-head .qw-head-icon {
  width: 40px; height: 40px; border-radius: 11px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, rgba(97, 92, 237, .14), rgba(155, 92, 246, .18));
  color: var(--qw-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.qw-page-head .qw-head-text { min-width: 0; flex: 1 1 auto; }
.qw-page-head h1 {
  font-size: 1.05rem; font-weight: 700; margin: 0;
  display: flex; align-items: center; gap: 8px; color: #1a1a2e;
  flex-wrap: nowrap; white-space: nowrap; min-width: 0;
}
.qw-page-head h1 > .usage-guide-btn { flex: 0 0 auto; }
.qw-page-head p {
  margin: 3px 0 0; font-size: .78rem; color: #64748b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qw-page-head .qw-head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* 使用说明按钮 */
.usage-guide-btn {
  margin-left: 10px; padding: 3px 10px; font-size: .72rem;
  border: 1px solid var(--qw); color: var(--qw); background: transparent;
  border-radius: 6px; cursor: pointer; font-weight: 600;
  transition: all .15s; vertical-align: middle;
  display: inline-flex; align-items: center; gap: 4px;
}
.usage-guide-btn:hover { background: var(--qw); color: #fff; }
/* 使用说明弹窗 */
.usage-guide-overlay { position: fixed; inset: 0; z-index: 100000; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; padding: 16px; }
.usage-guide-overlay.show { display: flex; }
.usage-guide-modal { background: #fff; border-radius: 12px; width: 100%; max-width: 1280px; height: 94vh; display: flex; flex-direction: column; box-shadow: 0 16px 64px rgba(0,0,0,.3); overflow: hidden; }
.usage-guide-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid #e9ecef; font-weight: 700; font-size: .95rem; color: var(--qw); flex-shrink: 0; }
.usage-guide-close { width: 28px; height: 28px; border-radius: 50%; border: none; background: #f3f4f6; color: #6b7280; font-size: 1rem; cursor: pointer; line-height: 1; transition: all .15s; }
.usage-guide-close:hover { background: #ef4444; color: #fff; }
.usage-guide-modal iframe { flex: 1; width: 100%; border: 0; }
@media (max-width: 768px) {
  .qw-page-head { flex-wrap: wrap; }
  .qw-page-head p { white-space: normal; }
  .usage-guide-overlay { padding: 0; }
  .usage-guide-modal { max-width: none; height: 100vh; border-radius: 0; }
}
/* 不可用提示 */
.qw-banner {
  display: none;
  align-items: center;
  gap: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #b45309;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: .84rem;
  margin-bottom: 14px;
}

/* 布局 */
.qw-layout { display: flex; gap: 16px; align-items: flex-start; }
.qw-layout > .qw-col-left { flex: 0 0 420px; min-width: 0; }
.qw-layout > .qw-col-right { flex: 1 1 auto; min-width: 0; }
@media (max-width: 1024px) {
  .qw-layout { flex-direction: column; }
  .qw-layout > .qw-col-left { flex: 1 1 auto; width: 100%; }
}

.qw-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .05);
  border: 1px solid #eef0f6;
  margin-bottom: 14px;
}
.qw-card:last-child { margin-bottom: 0; }
.qw-card-title {
  font-weight: 700;
  font-size: .9rem;
  color: #1a1a2e;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.qw-card-title i { color: var(--qw); }
.qw-card-title .qw-title-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.qw-card-title small { font-weight: 400; color: #9aa3b2; font-size: .74rem; }

/* 表单 */
.qw-label { font-size: .8rem; font-weight: 600; color: #475569; margin-bottom: 5px; display: block; }
.qw-input, .qw-select, .qw-textarea {
  width: 100%;
  border: 1.5px solid #e6e8f0;
  border-radius: 9px;
  padding: 8px 11px;
  font-size: .85rem;
  background: #fbfbfe;
  color: #1a1a2e;
  transition: border-color .15s, box-shadow .15s;
}
.qw-textarea { resize: vertical; min-height: 120px; line-height: 1.75; }
.qw-input:focus, .qw-select:focus, .qw-textarea:focus {
  outline: none;
  border-color: var(--qw);
  box-shadow: 0 0 0 3px rgba(97, 92, 237, .12);
  background: #fff;
}
.qw-row { display: flex; gap: 10px; flex-wrap: wrap; }
.qw-row > div { flex: 1 1 120px; min-width: 0; }
.qw-help { font-size: .72rem; color: #9aa3b2; margin-top: 4px; }
.qw-counter { font-size: .72rem; color: #9aa3b2; text-align: right; margin-top: 4px; }

/* 按钮 */
.qw-btn {
  border: none;
  border-radius: 10px;
  padding: 9px 20px;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, opacity .15s, box-shadow .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.qw-btn:disabled { opacity: .6; cursor: not-allowed; }
.qw-btn-primary {
  background: linear-gradient(135deg, var(--qw-dark), var(--qw-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(97, 92, 237, .26);
}
.qw-btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.qw-btn-ghost {
  background: #fff;
  border: 1.5px solid #e2e5ee;
  color: #475569;
}
.qw-btn-ghost:hover:not(:disabled) { border-color: var(--qw); color: var(--qw); }
.qw-btn-sm { padding: 5px 12px; font-size: .76rem; border-radius: 8px; }
.qw-btn-block { width: 100%; }
.qw-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* 模型选择器 */
.qw-model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 2px;
}
.qw-model-card {
  border: 1.5px solid #e8eaf2;
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  background: #fff;
  transition: all .15s;
}
.qw-model-card:hover { border-color: rgba(97, 92, 237, .45); }
.qw-model-card.selected {
  border-color: var(--qw);
  background: rgba(97, 92, 237, .06);
  box-shadow: 0 0 0 2px rgba(97, 92, 237, .1);
}
.qw-model-card .qmc-head { display: flex; align-items: center; gap: 5px; }
.qw-model-card .qmc-name { font-size: .82rem; font-weight: 600; color: #1a1a2e; }
.qw-model-card .qmc-tag {
  font-size: .62rem; background: #f1f2f6; color: #8b95a5; border-radius: 6px; padding: 0 5px;
}
.qw-model-card .qmc-id { font-size: .68rem; color: #8b95a5; font-family: Consolas, monospace; margin-top: 1px; word-break: break-all; }
.qw-model-card .qmc-caps { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 3px; }
.qw-model-card .qmc-rate { font-size: .68rem; color: #7c8494; margin-top: 4px; }
.qw-model-card.selected .qmc-name { color: var(--qw-dark); }
.qw-cap {
  font-size: .62rem;
  border-radius: 8px;
  padding: 0 6px;
  background: rgba(67, 97, 238, .1);
  color: #3a56c5;
  white-space: nowrap;
}
.qw-empty-model {
  font-size: .8rem;
  color: #b45309;
  background: #fff7ed;
  border: 1px dashed #fed7aa;
  border-radius: 10px;
  padding: 12px;
}

/* 结果区 */
.qw-result-text {
  border: 1px solid #e8eaf2;
  border-radius: 12px;
  padding: 14px;
  background: #fbfbfe;
  font-size: .88rem;
  line-height: 1.85;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 260px;
  max-height: 620px;
  overflow-y: auto;
}
.qw-result-text:empty::before {
  content: '生成结果将显示在这里…';
  color: #b6bdc9;
}
.qw-placeholder {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #b6bdc9;
  font-size: .85rem;
  gap: 8px;
}
.qw-placeholder i { font-size: 2rem; opacity: .5; }
.qw-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .72rem;
  color: #7c8494;
  margin-top: 10px;
}
.qw-meta-bar span {
  background: #f4f5fa;
  border-radius: 8px;
  padding: 2px 8px;
}
.qw-reasoning {
  border-left: 3px solid #c7c4f5;
  background: #f7f6ff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: .8rem;
  color: #5b5877;
  line-height: 1.75;
  white-space: pre-wrap;
  margin-bottom: 10px;
  max-height: 220px;
  overflow-y: auto;
}

/* 图片网格 */
.qw-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.qw-image-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #f4f5fa;
  border: 1px solid #e8eaf2;
  cursor: zoom-in;
  aspect-ratio: 1;
}
.qw-image-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qw-image-item .qw-img-actions {
  position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s;
}
.qw-image-item:hover .qw-img-actions { opacity: 1; }
.qw-image-item .qw-img-actions a {
  width: 28px; height: 28px; border-radius: 8px; background: rgba(15, 23, 42, .62); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: .8rem;
}

/* 参考图上传 */
.qw-ref-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.qw-ref-item {
  width: 76px; height: 76px; border-radius: 10px; overflow: hidden; position: relative;
  border: 1px solid #e8eaf2; background: #f4f5fa;
}
.qw-ref-item img { width: 100%; height: 100%; object-fit: cover; }
.qw-ref-item .qw-ref-del {
  position: absolute; right: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(15, 23, 42, .65); color: #fff; font-size: .62rem; border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.qw-ref-add {
  width: 76px; height: 76px; border-radius: 10px; border: 1.5px dashed #d6d9e6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #9aa3b2; font-size: .68rem; cursor: pointer; gap: 2px; background: #fbfbfe;
}
.qw-ref-add:hover { border-color: var(--qw); color: var(--qw); }

/* 进度条 */
.qw-progress {
  height: 6px; border-radius: 3px; background: #eef0f6; overflow: hidden; margin-top: 8px;
}
.qw-progress > div {
  height: 100%; width: 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--qw), var(--qw-accent));
  transition: width .3s ease;
}
.qw-status-line { font-size: .78rem; color: #7c8494; margin-top: 6px; display: flex; align-items: center; gap: 6px; }

/* 音色列表 */
.qw-voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.qw-voice-item {
  border: 1.5px solid #e8eaf2; border-radius: 9px; padding: 7px 10px; cursor: pointer; font-size: .78rem;
  background: #fff; transition: all .15s;
}
.qw-voice-item:hover { border-color: rgba(97, 92, 237, .4); }
.qw-voice-item.selected { border-color: var(--qw); background: rgba(97, 92, 237, .06); color: var(--qw-dark); font-weight: 600; }
.qw-voice-item small { display: block; color: #9aa3b2; font-weight: 400; font-size: .68rem; }

/* 结果操作 */
.qw-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* 轻提示 */
.qw-hint-inline { font-size: .76rem; color: #7c8494; }
.qw-cost-hint { font-size: .78rem; color: #b45309; margin-top: 8px; }
.qw-divider { height: 1px; background: #eef0f6; margin: 14px 0; }
.qw-badge { font-size: .68rem; border-radius: 8px; padding: 1px 7px; background: rgba(16, 185, 129, .12); color: #0d9668; }
.qw-badge.warn { background: rgba(245, 158, 11, .14); color: #b45309; }

/* 大图预览 */
.qw-lightbox {
  position: fixed; inset: 0; background: rgba(10, 14, 25, .86); z-index: 12000;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.qw-lightbox.show { display: flex; }
.qw-lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.qw-lightbox .qw-lb-close {
  position: absolute; right: 20px; top: 16px; color: #fff; font-size: 1.6rem; background: none; border: none; cursor: pointer;
}
/* ────────────────────────────────────────────────
   剧本创作（mediasi-text.html 剧本模式）
   ──────────────────────────────────────────────── */
.qw-mode-tabs {
  display: inline-flex; gap: 4px; background: #eef0f7; border-radius: 10px; padding: 3px;
}
.qw-mode-tabs button {
  border: none; background: transparent; color: #5b6472; font-size: .8rem; font-weight: 600;
  padding: 5px 14px; border-radius: 8px; cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 5px;
}
.qw-mode-tabs button.active {
  background: #fff; color: #615ced; box-shadow: 0 1px 4px rgba(20, 30, 60, .12);
}

.qw-script {
  display: flex; flex-direction: column; gap: 10px;
}
.qw-script-meta {
  border: 1px solid #e6e8f0; border-radius: 12px; padding: 14px 16px; background: #fafbff;
}
.qw-script-meta h4 {
  margin: 0 0 6px; font-size: 1rem; font-weight: 700; color: #1f2937;
}
.qw-script-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.qw-script-chip {
  font-size: .72rem; color: #4b5563; background: #fff; border: 1px solid #e2e6f0;
  border-radius: 999px; padding: 2px 10px;
}
.qw-script-chip.tag { color: #615ced; border-color: #d9d6fb; background: #f5f4ff; }
.qw-script-overview {
  font-size: .82rem; line-height: 1.7; color: #4b5563; white-space: pre-wrap;
}
.qw-script-overview b { color: #374151; }

.qw-seg {
  border: 1px solid #e6e8f0; border-radius: 12px; overflow: hidden; background: #fff;
}
.qw-seg-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer;
  background: linear-gradient(180deg, #fbfcff, #f5f7fd); user-select: none;
}
.qw-seg-head:hover { background: #f0f2fb; }
.qw-seg-idx {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 7px; background: #615ced; color: #fff;
  font-size: .72rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.qw-seg-title { flex: 1; font-size: .86rem; font-weight: 600; color: #1f2937; }
.qw-seg-dur {
  font-size: .72rem; color: #6b7280; background: #fff; border: 1px solid #e5e9f2;
  border-radius: 999px; padding: 1px 9px;
}
.qw-seg-caret { color: #9aa3b2; transition: transform .18s; }
.qw-seg.open .qw-seg-caret { transform: rotate(90deg); }
.qw-seg-body {
  display: none; padding: 12px 14px 14px; border-top: 1px dashed #e8ebf4;
  font-size: .82rem; line-height: 1.75; color: #374151; white-space: pre-wrap;
}
.qw-seg.open .qw-seg-body { display: block; }
.qw-seg-body .kw { color: #615ced; font-weight: 600; }

.qw-script-empty {
  padding: 26px 16px; text-align: center; color: #9aa3b2; font-size: .84rem;
}

/* ═══ 创作页计费模式切换 ═══ */
.qw-mode-switch {
  display: inline-flex; gap: 3px; background: rgba(255,255,255,.18);
  border-radius: 10px; padding: 3px; vertical-align: middle;
}
.qw-mode-switch .qw-mode-tab {
  border: none; background: transparent; color: #fff; font-size: .76rem; font-weight: 600;
  padding: 4px 12px; border-radius: 8px; cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; opacity: .82;
}
.qw-mode-switch .qw-mode-tab:hover { opacity: 1; background: rgba(255,255,255,.12); }
.qw-mode-switch .qw-mode-tab.active {
  background: #fff; color: #615ced; opacity: 1; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.qw-mode-switch .qw-mode-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #fbbf24;
}

/* ═══ 音色分组（多语种/精品中文/英文/角色） ═══ */
.qw-voice-group { margin-bottom: 14px; }
.qw-voice-group:last-child { margin-bottom: 0; }
.qw-voice-group-title {
  font-size: .76rem; font-weight: 700; color: #4b5563; margin-bottom: 7px;
  display: flex; align-items: center; gap: 6px;
}
.qw-voice-group-title .cnt {
  font-weight: 500; font-size: .7rem; color: #615ced; background: #f1f0ff;
  border-radius: 999px; padding: 1px 8px;
}
.qw-voice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

/* ═══ 音色选择区：固定高度 + 搜索/分组筛选 ═══ */
.qw-voice-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.qw-voice-search { flex: 1; min-width: 0; font-size: .78rem; padding: 6px 10px; }
.qw-voice-group-filter { flex: 0 0 104px; font-size: .78rem; padding: 6px 8px; }
.qw-voice-scroll {
  max-height: 232px; overflow-y: auto; padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: #d5d9e4 transparent;
}
.qw-voice-scroll::-webkit-scrollbar { width: 6px; }
.qw-voice-scroll::-webkit-scrollbar-thumb { background: #d5d9e4; border-radius: 3px; }
.qw-voice-scroll::-webkit-scrollbar-track { background: transparent; }
.qw-voice-scroll .qw-voice-grid { grid-template-columns: 1fr; gap: 5px; }
.qw-voice-scroll .qw-voice-item { padding: 6px 9px; font-size: .76rem; }
.qw-voice-scroll .qw-voice-item small { font-size: .64rem; }
.qw-voice-group { margin-bottom: 10px; }
.qw-voice-group:last-child { margin-bottom: 0; }
.qw-voice-group-title {
  font-size: .72rem; font-weight: 700; color: #6b7280; margin-bottom: 5px;
  position: sticky; top: 0; background: #fff; padding: 3px 0; z-index: 1;
  display: flex; align-items: center; gap: 6px;
}
.qw-voice-group-title .cnt {
  font-weight: 500; font-size: .66rem; color: #615ced; background: #f1f0ff;
  border-radius: 999px; padding: 0 7px;
}
