/* Credmex 剧本生成器 — 白底 + #6743FF / #C5FB00 */

:root {
  --purple: #6743ff;
  --purple-hover: #5634e6;
  --green: #c5fb00;
  --green-hover: #b0e000;
  --bg: #ffffff;
  --surface: #f8f9fc;
  --border: #e8eaf2;
  --text: #1a1d26;
  --text-muted: #5c6378;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(103, 67, 255, 0.06);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

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

html {
  font-size: 15px;
  overflow-anchor: none;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.app-header {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.app-header .sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.lang-toggle button {
  border: none;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
}

.lang-toggle button.active {
  background: var(--purple);
  color: #fff;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-switcher {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.mode-tab {
  border: none;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  white-space: nowrap;
}

.mode-tab.active {
  background: var(--purple);
  color: #fff;
}

/* 代理模式：中间创意区仍隐藏；左侧参数栏改为「可见但毛玻璃遮光」提示 AI 主导 */
body.workflow-agent .manual-params-hide {
  display: none !important;
}

body.workflow-agent #leftManualParams.manual-params-hide {
  display: block !important;
  position: relative;
  margin-top: 10px;
  max-height: min(52vh, 520px);
  overflow: auto;
  overflow-anchor: none;
  border-radius: var(--radius);
  border: 1px dashed rgba(103, 67, 255, 0.28);
  opacity: 0.88;
  filter: grayscale(0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

body.workflow-agent #leftManualParams.manual-params-hide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
}

.agent-left-blurb {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(103, 67, 255, 0.28);
  background: rgba(103, 67, 255, 0.07);
}

.agent-left-blurb-title {
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--purple);
  font-size: 0.8rem;
}

.agent-preset-list {
  margin: 0;
  padding-left: 1.1rem;
}

.agent-left-blurb-foot {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* 方案卡：与手动侧边栏语义对应的参数徽章（代理/手动三方案共用） */
.variant-param-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 10px;
  border-bottom: 1px solid #f0f2f8;
  background: #fafbff;
}

.variant-param-badges[hidden] {
  display: none !important;
}

.variant-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  padding: 4px 8px;
  box-sizing: border-box;
}

.variant-tag--muted {
  background: #eef0f6;
  color: #4d5571;
}

.variant-tag--format {
  background: #6743ff;
  color: #fff;
}

.variant-tag--benefit {
  background: #c5fb00;
  color: #1a1d26;
}

/* 代理模式：方案卡参数条复用手动侧栏 chip 观感 */
.variant-param-badges--agent-mirror {
  flex-wrap: wrap;
}

.sb-mirror-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid #e3e6f0;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.72rem;
  line-height: 1.2;
  font-weight: 600;
  color: #3d4560;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.sb-mirror-chip--format {
  border-color: #6743ff;
  box-shadow: inset 0 0 0 1px #6743ff;
  color: #5634e6;
  background: #f8f6ff;
}

.sb-mirror-chip--benefit {
  border-color: #b8e020;
  background: #f4ffe8;
  color: #1a1d26;
}

.agent-thinking-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(32, 36, 50, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.agent-thinking-overlay[hidden] {
  display: none !important;
}

.agent-thinking-card {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 28px 32px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(103, 67, 255, 0.22);
  box-shadow: 0 16px 48px rgba(103, 67, 255, 0.2);
  max-width: min(360px, 92vw);
}

.agent-thinking-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    115deg,
    transparent 35%,
    rgba(103, 67, 255, 0.14) 48%,
    rgba(197, 251, 0, 0.12) 52%,
    transparent 65%
  );
  background-size: 200% 200%;
  animation: agent-card-aurora 2.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.agent-thinking-card > * {
  position: relative;
  z-index: 1;
}

@keyframes agent-card-aurora {
  0% {
    transform: translate(-8%, -8%) rotate(0deg);
    background-position: 0% 50%;
  }
  50% {
    transform: translate(4%, 4%) rotate(4deg);
    background-position: 100% 50%;
  }
  100% {
    transform: translate(-8%, -8%) rotate(0deg);
    background-position: 0% 50%;
  }
}

.agent-thinking-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(103, 67, 255, 0.2);
  border-top-color: var(--purple);
  animation: agent-thinking-spin 0.85s linear infinite;
}

@keyframes agent-thinking-spin {
  to {
    transform: rotate(360deg);
  }
}

.agent-thinking-label {
  margin: 16px 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.95fr) minmax(560px, 1.9fr) minmax(280px, 1.1fr);
  gap: 0;
  min-height: calc(100vh - 52px);
  max-width: 1600px;
  margin: 0 auto;
}

.panel {
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  max-height: calc(100vh - 52px);
}

.panel:last-of-type {
  border-right: none;
  border-left: 1px solid var(--border);
}

.panel-inner {
  padding: 16px 14px 100px;
}

.panel-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.section-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: none;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  text-align: left;
}

.section.collapsed .section-head {
  border-radius: var(--radius);
}

.section-head .chev {
  color: var(--purple);
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.section.collapsed .chev {
  transform: rotate(-90deg);
}

.section-body {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border);
}

.section.collapsed .section-body {
  display: none;
}

.option-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

@media (min-width: 400px) {
  .option-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
  }
}

.chip {
  display: block;
  width: 100%;
}

.chip input {
  accent-color: var(--purple);
  flex-shrink: 0;
  margin-top: 3px;
}

.chip label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
  line-height: 1.45;
  font-weight: 500;
}

.chip label .opt-text {
  flex: 1;
  min-width: 0;
}

.dur-chip label {
  font-weight: 500;
}

.section-head .label,
.chip label .opt-text {
  font-weight: 500;
}

.radio-row,
.check-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.center-col {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.center-inner {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overflow-anchor: none;
  max-height: calc(100vh - 52px);
}

.center-control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}

.center-mode-switcher {
  flex: 0 0 auto;
}

.center-trigger-row {
  margin-left: auto;
}

.prompt-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

#promptInput {
  width: 100%;
  min-height: 100px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
}

#promptInput:focus {
  outline: 2px solid rgba(103, 67, 255, 0.35);
  outline-offset: 1px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* —— 生成进度：条形 + 三阶段图标 —— */
.generate-progress {
  margin-top: 4px;
  padding: 14px 14px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.progress-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple) 0%, #8f74ff 50%, var(--purple) 100%);
  background-size: 200% 100%;
  transition: width 0.55s cubic-bezier(0.33, 1, 0.68, 1);
  position: relative;
  overflow: hidden;
}

.generate-progress.is-running .progress-bar-fill {
  animation: progress-shimmer 1.35s ease-in-out infinite;
}

/* 代理模式生成：进度条额外紫色流光与光晕 */
.generate-progress.is-running.is-agent-gen .progress-bar-fill {
  animation:
    progress-shimmer 1s linear infinite,
    agent-bar-glow 1.8s ease-in-out infinite;
  box-shadow:
    0 0 12px rgba(103, 67, 255, 0.35),
    0 0 28px rgba(103, 67, 255, 0.2);
}

.generate-progress.is-running.is-agent-gen .progress-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 45%,
    rgba(143, 116, 255, 0.5) 50%,
    rgba(255, 255, 255, 0.45) 55%,
    transparent 100%
  );
  background-size: 220% 100%;
  animation: agent-sheen 1.25s linear infinite;
  pointer-events: none;
}

@keyframes agent-sheen {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@keyframes agent-bar-glow {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.12);
  }
}

.generate-progress.is-done .progress-bar-fill {
  background: linear-gradient(90deg, #5a9a00, var(--green));
  animation: none;
}

.generate-progress.is-error .progress-bar-fill {
  background: linear-gradient(90deg, #c45c5c, #e08080);
  animation: none;
}

@keyframes progress-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.progress-steps {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}

.p-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  min-width: 0;
}

.p-step-connector {
  flex: 0 0 12px;
  height: 2px;
  margin-top: 17px;
  background: var(--border);
  border-radius: 1px;
  align-self: flex-start;
  transition: background 0.35s ease;
}

.p-step-connector.is-lit {
  background: linear-gradient(90deg, var(--purple), rgba(197, 251, 0, 0.85));
}

.generate-progress.is-done .p-step-connector.is-lit {
  background: var(--green);
}

.p-step-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-muted);
  transition:
    border-color 0.25s,
    background 0.25s,
    color 0.25s,
    box-shadow 0.25s,
    transform 0.25s;
}

.p-step-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.25;
  transition: color 0.25s;
}

.p-step.is-active .p-step-icon {
  border-color: var(--purple);
  color: var(--purple);
  background: rgba(103, 67, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(103, 67, 255, 0.12);
  animation: step-pulse 1.4s ease-in-out infinite;
}

.p-step.is-active .p-step-label {
  color: var(--purple);
  font-weight: 600;
}

.p-step.is-done .p-step-icon {
  border-color: rgba(197, 251, 0, 0.65);
  background: rgba(197, 251, 0, 0.22);
  color: #3d5c00;
  animation: none;
  box-shadow: none;
}

.p-step.is-done .p-step-label {
  color: var(--text);
  font-weight: 500;
}

.generate-progress.is-done .p-step.is-done .p-step-icon {
  border-color: var(--green);
  background: rgba(197, 251, 0, 0.35);
  color: #2d4500;
}

.generate-progress.is-done .p-step.is-done .p-step-label {
  color: var(--text);
}

.generate-progress.is-error .p-step.is-active .p-step-icon {
  border-color: #c45c5c;
  color: #c45c5c;
  background: rgba(196, 92, 92, 0.08);
  animation: none;
}

@keyframes step-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

.generate-status-detail {
  margin: 12px 0 0;
  min-height: 1.25em;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.generate-progress.is-running .generate-status-detail {
  color: var(--purple);
}

.generate-progress.is-done .generate-status-detail {
  color: var(--text);
}

.generate-progress.is-error .generate-status-detail {
  color: #b54747;
}

.generate-progress.is-error .p-step-connector.is-lit {
  background: rgba(196, 92, 92, 0.45);
}

.btn-primary {
  background: var(--purple);
  color: #fff;
  border: none;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(103, 67, 255, 0.35);
}

.btn-primary:hover {
  background: var(--purple-hover);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--green);
  color: #1a1d26;
  border: none;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
}

.btn-secondary:hover {
  background: var(--green-hover);
}

.btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.api-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.api-row input[type="password"] {
  flex: 1;
  min-width: 160px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
}

.preview-block {
  flex: 1;
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 14px;
  overflow: auto;
}

.preview-block h3 {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--purple);
  font-weight: 600;
}

.preview-block pre {
  margin: 0 0 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  line-height: 1.6;
}

.preview-block pre:last-child {
  margin-bottom: 0;
}

.empty-hint {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.right-col .product-card {
  background: linear-gradient(135deg, rgba(103, 67, 255, 0.06), rgba(197, 251, 0, 0.12));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text);
}

.right-col .panel-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.right-chat-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.right-chat-card .prompt-label {
  display: block;
  padding: 12px 14px 0;
}

.right-chat-card #promptInput {
  border: none;
  border-top: 1px solid #f0f2f8;
  border-radius: 0 0 14px 14px;
  min-height: 120px;
}

.refine-script-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(103, 67, 255, 0.05), rgba(197, 251, 0, 0.08));
  padding: 12px 14px 14px;
}

.refine-card-title {
  margin: 0 0 6px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--purple);
}

.refine-card-hint {
  margin: 0 0 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.refine-chat-log {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #eceef5;
  font-size: 0.78rem;
}

.refine-chat-msg {
  margin-bottom: 10px;
}

.refine-chat-msg:last-child {
  margin-bottom: 0;
}

.refine-chat-msg-role {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.refine-chat-msg--user .refine-chat-msg-role {
  color: var(--purple);
}

.refine-chat-msg--assistant .refine-chat-msg-role {
  color: #3d7a1a;
}

.refine-chat-msg-body {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.45;
}

.refine-input-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.refine-chat-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e3e6f0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.84rem;
  resize: vertical;
  min-height: 72px;
  margin-bottom: 10px;
}

.refine-chat-input:focus {
  outline: 2px solid rgba(103, 67, 255, 0.35);
  outline-offset: 1px;
}

.refine-actions {
  margin-top: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.refine-actions .btn-primary,
.refine-actions .btn-secondary {
  flex: 1 1 auto;
  min-width: 120px;
}

.api-row-model {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.llm-model-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.llm-model-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e3e6f0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  background: #fff;
}

.llm-model-select:focus {
  outline: 2px solid rgba(103, 67, 255, 0.35);
  outline-offset: 1px;
}

.api-hint-block {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.right-col .product-card-toggle-title {
  color: var(--purple);
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}

.product-card-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0 10px;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: 0;
}

.product-collapsible.collapsed .product-card-toggle {
  padding-bottom: 2px;
  border-bottom: none;
}

.product-card-toggle:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.product-card-toggle-chev {
  flex-shrink: 0;
  color: var(--purple);
  font-size: 0.68rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.product-collapsible.collapsed .product-card-toggle-chev {
  transform: rotate(-90deg);
}

.product-card-body {
  padding-top: 10px;
}

.product-collapsible.collapsed .product-card-body {
  display: none;
}

.right-col ul {
  margin: 0;
  padding-left: 1.1rem;
}

.fab-export {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  background: var(--purple);
  color: #fff;
  border: none;
  padding: 14px 22px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 8px 28px rgba(103, 67, 255, 0.45);
}

.fab-export:hover {
  background: var(--purple-hover);
}

.fab-export:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.fab-export:disabled:hover {
  background: var(--purple);
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel,
  .panel:last-of-type {
    border-right: none;
    border-left: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
  }

  .center-inner {
    max-height: none;
  }

  .fab-export {
    right: 16px;
    bottom: 16px;
  }
}

/* ===== Screenshot-style visual override ===== */
body {
  background: #f3f4f8;
  color: #202432;
}

.app-header {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #eceef6;
  padding: 0 14px;
}

.app-header h1 {
  font-size: 1rem;
  font-weight: 700;
}

.app-header .sub {
  display: none;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-tab {
  padding: 5px 8px;
  font-size: 0.68rem;
}

.lang-toggle {
  background: #f2f3f8;
  border: 1px solid #e5e8f1;
}

.lang-toggle button {
  min-width: 40px;
  padding: 4px 10px;
  font-size: 0.8rem;
}

.layout {
  max-width: 100%;
  min-height: calc(100vh - 56px);
  grid-template-columns: minmax(220px, 0.9fr) minmax(560px, 1.9fr) minmax(300px, 1.15fr);
  gap: 8px;
  padding: 8px;
}

.panel {
  background: transparent;
  border: none;
  max-height: calc(100vh - 72px);
}

.left-col {
  overflow-anchor: none;
}

/* 避免勾选场景/利益点时浏览器把标签滚进视口导致整页跳动 */
.left-col #sceneGrid .chip label,
.left-col #benefitGrid .chip label {
  scroll-margin-block: 0;
  scroll-margin-inline: 0;
}

.panel:last-of-type {
  border: none;
}

.panel-inner {
  padding: 8px 6px 88px;
}

.panel-title {
  font-size: 0.72rem;
  margin-bottom: 8px;
}

.left-col .section {
  border: none;
  box-shadow: none;
  background: transparent;
  margin-bottom: 8px;
}

.left-col .section-head {
  background: transparent;
  padding: 4px 2px;
  font-size: 0.82rem;
  color: #4d5571;
}

.left-col .section-body {
  border: none;
  padding: 6px 0 4px;
}

.left-col .section-head .chev {
  font-size: 0.62rem;
}

.chip label {
  gap: 0;
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip .opt-text {
  display: block;
  width: 100%;
  border: 1px solid #e3e6f0;
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.2;
  color: #3d4560;
  transition: all 0.15s ease;
}

.chip input:checked + .opt-text {
  border-color: #6743ff;
  box-shadow: inset 0 0 0 1px #6743ff;
  color: #5634e6;
  background: #f8f6ff;
  font-weight: 600;
}

.radio-row,
.check-row {
  gap: 6px;
}

.option-grid {
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.option-grid .opt-text {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.72rem;
  text-align: center;
}

.center-col .center-inner,
.right-col .panel-inner {
  padding-top: 8px;
}

.center-inner > * {
  background: #fff;
  border: 1px solid #e8eaf3;
  border-radius: 14px;
}

#panelEditorTitle,
.prompt-label {
  background: transparent;
  border: none;
  border-radius: 0;
}

#panelEditorTitle {
  margin: 2px 0 0;
}

.prompt-label {
  padding: 14px 14px 0;
  font-size: 0.8rem;
}

.center-control-bar {
  padding: 10px 12px;
}

.center-control-bar .mode-tab {
  padding: 6px 12px;
  font-size: 0.76rem;
}

.center-trigger-row .btn-primary {
  min-width: 132px;
}

#promptInput {
  min-height: 78px;
  border: none;
  border-top: 1px solid #f0f2f8;
  border-radius: 0 0 14px 14px;
}

.api-row {
  border: 1px solid #e8eaf3;
  border-radius: 12px;
  background: #fff;
  padding: 8px 12px;
}

.btn-row {
  background: transparent;
  border: none;
  padding: 0;
}

.btn-primary,
.btn-secondary {
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.84rem;
  font-weight: 700;
}

.btn-secondary {
  background: var(--green);
}

.generate-progress,
.product-card {
  border-radius: 14px;
  border: 1px solid #e8eaf3;
  box-shadow: none;
}

.preview-block.preview-block-compare {
  background: #fff;
  border: 1px solid #eceef4;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.preview-block {
  min-height: 390px;
}

.right-col .product-card {
  background: #fff;
}

.right-col .product-card-toggle {
  border-bottom-color: #e8eaf3;
}

#exportHint {
  font-size: 0.72rem !important;
  line-height: 1.45;
}

.fab-export {
  right: 24px;
  bottom: 18px;
  border-radius: 14px;
  font-size: 0.88rem;
  padding: 12px 18px;
}

/* —— DIY Ghost + 多方案 Tab —— */
.chip-diy-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.btn-diy-ghost {
  align-self: flex-start;
  margin: 0;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.4;
  color: var(--purple);
  background: transparent;
  border: 1px solid rgba(103, 67, 255, 0.45);
  border-radius: 6px;
  cursor: pointer;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.btn-diy-ghost:hover {
  color: var(--purple-hover);
  border-color: var(--purple);
  background: rgba(103, 67, 255, 0.06);
}

.btn-diy-under {
  margin-top: 2px;
}

.diy-section-actions {
  margin-top: 10px;
  margin-bottom: 2px;
}

.diy-extra-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.diy-tag-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(103, 67, 255, 0.08);
  border: 1px solid rgba(103, 67, 255, 0.2);
  font-size: 0.78rem;
  max-width: 100%;
}

.diy-tag-label {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  /* 演员 DIY 文案基准（场景/利益/形态 DIY 与之对齐） */
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.45;
  font-weight: 400;
}

.diy-tag-remove {
  padding: 0 4px;
  min-width: 24px;
  border: none;
  font-size: 1rem;
  line-height: 1;
}

/* DIY 删除钮：与演员区一致（ghost + 图标，覆盖 ghost 的描边与字重） */
.chip-diy-remove.btn-diy-ghost.diy-tag-remove {
  align-self: center;
  margin: 0;
  padding: 0;
  min-width: 22px;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 0;
  font-weight: 400;
  color: #b8bcc8;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition:
    color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.chip-diy-remove.btn-diy-ghost.diy-tag-remove:hover {
  color: #6743ff;
  background: rgba(103, 67, 255, 0.08);
  border-color: transparent;
}

.chip-diy-remove.btn-diy-ghost.diy-tag-remove:active {
  transform: scale(0.92);
}

.chip-diy-remove.btn-diy-ghost.diy-tag-remove svg {
  flex-shrink: 0;
}

.diy-tag-item .chip-diy-remove.btn-diy-ghost.diy-tag-remove {
  margin: 0;
}

/* 场景 / 利益点 / 拍摄形态 DIY：整体与演员 diy-tag-item 药丸一致 */
#sceneGrid .chip.chip-diy-custom,
#benefitGrid .chip.chip-diy-custom,
.left-col .section[data-section="format"] .radio-row .chip.chip-diy-custom {
  display: inline-flex;
  width: auto;
  max-width: 100%;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 8px;
  border-radius: 8px;
  background: rgba(103, 67, 255, 0.08);
  border: 1px solid rgba(103, 67, 255, 0.2);
  font-size: 0.78rem;
  box-sizing: border-box;
}

#sceneGrid .chip.chip-diy-custom:has(input:checked),
#benefitGrid .chip.chip-diy-custom:has(input:checked),
.left-col .section[data-section="format"] .radio-row .chip.chip-diy-custom:has(input:checked) {
  background: rgba(103, 67, 255, 0.14);
  border-color: rgba(103, 67, 255, 0.35);
}

#sceneGrid .chip.chip-diy-custom label,
#benefitGrid .chip.chip-diy-custom label,
.left-col .section[data-section="format"] .radio-row .chip.chip-diy-custom label {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1.45;
  font-weight: 400;
  color: var(--text);
}

#sceneGrid .chip.chip-diy-custom .opt-text,
#benefitGrid .chip.chip-diy-custom .opt-text,
.left-col .section[data-section="format"] .radio-row .chip.chip-diy-custom .opt-text {
  display: block;
  width: auto;
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text);
  font-weight: 400;
  word-break: break-word;
}

#sceneGrid .chip.chip-diy-custom input:checked + .opt-text,
#benefitGrid .chip.chip-diy-custom input:checked + .opt-text,
.left-col .section[data-section="format"] .radio-row .chip.chip-diy-custom input:checked + .opt-text {
  border: none;
  box-shadow: none;
  background: transparent;
  color: var(--text);
  font-weight: 400;
}

.diy-chip-removing {
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.diy-chip-removing.diy-chip-removing--active {
  opacity: 0;
  transform: scale(0.94);
}

.diy-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.diy-modal[hidden] {
  display: none !important;
}

.diy-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 29, 38, 0.35);
}

.diy-modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 18px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(103, 67, 255, 0.15);
}

.diy-modal-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--text);
}

.diy-modal-hint {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.diy-modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  margin-bottom: 14px;
}

.diy-modal-actions {
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  gap: 10px;
}

/* DIY 弹窗底栏：取消 / 添加共用尺寸与动效，仅配色区分 */
.diy-modal-btn {
  flex: 1 1 0;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 16px;
  font-size: 0.84rem;
  line-height: 1.25;
  font-weight: 700;
  font-family: inherit;
  border-radius: 10px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.diy-modal-btn:hover {
  transform: scale(1.02);
}

.diy-modal-btn:active {
  transform: scale(0.98);
}

.diy-modal-btn:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.diy-modal-btn--secondary {
  background: #eef0f6;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.diy-modal-btn--secondary:hover {
  background: #e3e6f0;
  border-color: #d5dae6;
  color: var(--text);
}

.diy-modal-btn--primary {
  background: var(--purple);
  color: #fff;
  border: 1px solid transparent;
  box-shadow: 0 4px 14px rgba(103, 67, 255, 0.35);
}

.diy-modal-btn--primary:hover {
  background: var(--purple-hover);
  box-shadow: 0 5px 16px rgba(103, 67, 255, 0.4);
}

.diy-modal-btn--primary:active {
  box-shadow: 0 2px 10px rgba(103, 67, 255, 0.3);
}

.diy-modal-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.diy-modal-btn:disabled:hover,
.diy-modal-btn:disabled:active {
  transform: none;
}

.preview-block-compare {
  overflow: visible;
}

.variant-compare-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

@media (max-width: 960px) {
  .variant-compare-grid {
    grid-template-columns: 1fr;
  }
}

.script-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: #fff;
  border: 2px solid #e8eaf3;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.script-card--selected {
  border-color: #6743ff;
  box-shadow: 0 0 0 2px rgba(103, 67, 255, 0.22);
}

.script-card-focus-badge {
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.35;
  color: #6743ff;
  background: rgba(103, 67, 255, 0.09);
  border-bottom: 1px solid rgba(103, 67, 255, 0.15);
  word-break: break-word;
}

.script-card-scroll {
  flex: 1 1 auto;
  min-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.script-card-scroll .preview-pre:last-child {
  margin-bottom: 0;
}

.script-card-footer {
  padding: 10px 12px 12px;
  border-top: 1px solid #eceef6;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.script-card--dirty {
  border-style: dashed;
  border-color: rgba(103, 67, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(103, 67, 255, 0.12);
}

.script-card--dirty.script-card--selected {
  border-color: rgba(103, 67, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(103, 67, 255, 0.18);
}

.variant-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variant-edit-actions[hidden] {
  display: none !important;
}

.btn-variant-confirm,
.btn-variant-revert {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid #c5e8a8;
  background: rgba(197, 251, 0, 0.35);
  color: #1a3d0a;
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn-variant-revert {
  border-color: #e0d4f5;
  background: rgba(103, 67, 255, 0.08);
  color: var(--purple);
}

.btn-variant-confirm:hover,
.btn-variant-revert:hover {
  filter: brightness(0.97);
}

.preview-pre.preview-pre--editable {
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 2.5em;
}

.preview-pre.preview-pre--editable:focus {
  outline: 2px solid rgba(103, 67, 255, 0.28);
  outline-offset: 1px;
}

.btn-select-script {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  border-radius: 10px;
  border: 2px solid #6743ff;
  background: #fff;
  color: #6743ff;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease;
}

.btn-select-script:hover {
  background: rgba(103, 67, 255, 0.08);
}

.script-card--selected .btn-select-script {
  background: #6743ff;
  color: #fff;
}

.script-card-selected-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
  color: #6743ff;
  background: rgba(103, 67, 255, 0.08);
  border-radius: 10px;
  border: 2px solid #6743ff;
  box-sizing: border-box;
}

.script-card-selected-mark[hidden] {
  display: none !important;
}

.script-card-check-icon {
  flex-shrink: 0;
  color: #6743ff;
}

.preview-subtitle {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--purple);
  font-weight: 600;
}

/* 方案卡内：镜头标题紫色加粗；台词区块标题绿色高亮标签 */
.script-card-scroll .preview-subtitle:first-of-type {
  color: #6743ff;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.script-card-scroll .preview-subtitle:nth-of-type(2) {
  display: inline-block;
  margin-top: 4px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #1a1d26;
  background: #c5fb00;
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.preview-pre {
  margin: 0 0 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  line-height: 1.6;
}

.export-confirm-hint {
  margin: 12px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.export-confirm-hint.is-confirmed {
  color: var(--purple);
  font-weight: 600;
}
