/* ══════════════════════════════════════════════════════════
   AI漫剧生产系统 · 深色主题
   ══════════════════════════════════════════════════════════ */
:root {
  --bg: #0b1020;
  --bg-2: #121a2e;
  --panel: #16203a;
  --panel-2: #1b2743;
  --line: #2a3a5c;
  --line-2: #3a4d73;
  --text: #e8eeff;
  --muted: #93a4c8;
  --dim: #6b7fa6;
  --brand: #e94560;
  --brand-2: #7c3aed;
  --blue: #3b82f6;
  --accent: #22d3ee;
  --gold: #fbbf24;
  --ok: #10b981;
  --err: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(233, 69, 96, 0.14), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* ── 顶部 ── */
.header {
  text-align: center;
  margin-bottom: 28px;
  padding: 28px 16px 22px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.header::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
}

.header h1 {
  font-size: 26px;
  margin: 0 0 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(92deg, #ff7a90 0%, var(--brand) 40%, var(--brand-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--brand);
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 1px;
}

/* ── 步骤面板 ── */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-2), var(--brand), transparent);
  opacity: 0.75;
}

.card h2 {
  font-size: 15px;
  color: var(--text);
  margin: 0 0 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h3 {
  font-size: 13px;
  color: var(--gold);
  margin: 0 0 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

/* ── 输入框 ── */
textarea {
  width: 100%;
  min-height: 118px;
  background: rgba(11, 16, 32, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}

textarea::placeholder {
  color: var(--dim);
}

/* ── 按钮 ── */
button {
  background: linear-gradient(135deg, var(--blue), #2563eb);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
  font-family: inherit;
}

button:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.38);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  background: #3a4d73;
  box-shadow: none;
  cursor: not-allowed;
  filter: none;
  opacity: 0.75;
}

#btn-script {
  background: linear-gradient(135deg, var(--brand), #c7324b);
  box-shadow: 0 4px 14px rgba(233, 69, 96, 0.3);
}

#btn-script:hover {
  box-shadow: 0 6px 20px rgba(233, 69, 96, 0.42);
}

#btn-extract {
  background: linear-gradient(135deg, var(--brand-2), var(--blue));
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.32);
}

#btn-extract:hover {
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

#btn-clear {
  background: rgba(58, 77, 115, 0.6) !important;
  color: #cbd5e1 !important;
  box-shadow: none;
}

#btn-clear:hover {
  background: rgba(74, 95, 138, 0.8) !important;
}

/* ── 剧本预览 ── */
.preview {
  background: rgba(11, 16, 32, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 13px;
  min-height: 100px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cdd8f0;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  line-height: 1.75;
}

/* ── 图片 ── */
img {
  max-width: 100%;
  border-radius: 6px;
}

/* ── 卡片网格 ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.card-inner {
  background: rgba(11, 16, 32, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  backdrop-filter: blur(4px);
}

.card-inner h3 {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── 单个卡片 ── */
.card-item {
  background: linear-gradient(180deg, var(--panel-2) 0%, rgba(22, 32, 58, 0.9) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  font-size: 12px;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  animation: cardIn 0.28s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-item:last-child {
  margin-bottom: 0;
}

.card-item:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
}

.card-item strong {
  color: var(--gold);
  display: inline-block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
}

/* 徽标 */
.card-item .badge {
  display: inline-block;
  font-size: 10px;
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.18);
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

/* 描述 */
.card-desc {
  font-size: 11.5px;
  color: #b6c4e0;
  margin-top: 6px;
  line-height: 1.6;
}

/* 提示词（收起） */
.prompt-wrap {
  margin-top: 10px;
  font-size: 11px;
}

.prompt-wrap summary {
  cursor: pointer;
  color: var(--accent);
  list-style: none;
  user-select: none;
  padding: 4px 0;
  font-weight: 600;
  transition: color 0.15s;
}

.prompt-wrap summary::-webkit-details-marker {
  display: none;
}

.prompt-wrap summary::before {
  content: '▸ ';
  color: var(--dim);
}

.prompt-wrap[open] summary::before {
  content: '▾ ';
}

.prompt-wrap summary:hover {
  color: #67e8f9;
}

.prompt-body {
  color: #9fb2d4;
  line-height: 1.6;
  background: rgba(11, 16, 32, 0.8);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 6px;
  padding: 9px 10px;
  margin-top: 6px;
  max-height: 170px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10.5px;
}

.prompt-empty {
  color: var(--dim);
  font-style: italic;
}

/* ── 图片区 ── */
.img-block {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.img-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: #0b1020;
  display: block;
}

.thumb.wide {
  width: 100%;
  height: 104px;
}

/* 占位框 */
.img-slot {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  background:
    repeating-linear-gradient(45deg, rgba(42, 58, 92, 0.25) 0 6px, transparent 6px 12px),
    rgba(11, 16, 32, 0.6);
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--dim);
  text-align: center;
  padding: 4px;
  letter-spacing: 0.5px;
}

.img-slot.wide {
  width: 100%;
  height: 104px;
  flex: 1 1 100%;
}

/* 图片单元 */
.img-cell {
  position: relative;
  flex: 0 0 auto;
}

.img-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  line-height: 1;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: var(--err);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.img-del:hover {
  background: #dc2626;
  transform: scale(1.08);
}

/* 上传/生成按钮（图片框下方）*/
.img-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex: 0 0 auto;
  align-items: center;
  flex-wrap: wrap;
}

.img-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 58px;
  height: 30px;
  padding: 0 10px;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: rgba(58, 77, 115, 0.5);
  color: #d5def2;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  font-family: inherit;
  box-shadow: none;
}

.img-btn:hover {
  background: rgba(74, 95, 138, 0.75);
  border-color: #5570a3;
  color: #fff;
  filter: none;
}

.img-up:hover {
  background: rgba(74, 95, 138, 0.8);
}

.img-gen {
  background: linear-gradient(135deg, var(--brand-2), var(--blue));
  border-color: rgba(124, 58, 237, 0.6);
  color: #fff;
  box-shadow: 0 3px 10px rgba(124, 58, 237, 0.3);
}

.img-gen:hover {
  background: linear-gradient(135deg, #8b5cf6, #60a5fa);
  border-color: rgba(139, 92, 246, 0.7);
  color: #fff;
  box-shadow: 0 5px 16px rgba(124, 58, 237, 0.42);
}

.img-gen:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.35);
}

.img-up {
  position: relative;
  overflow: hidden;
}

/* 透明覆盖的 file input：直接铺满「📤 上传」按钮，点按钮=点 input 本身（全平台可靠）*/
.file-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
  border: 0;
  padding: 0;
  margin: 0;
}

.img-row .thumb.wide {
  width: 100%;
  height: 104px;
}

/* ── 状态提示 ── */
.status {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-top: 14px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.status:empty {
  display: none;
}

.status.success {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.status.error {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.status.loading {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--gold);
}

.status.loading::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.7); }
}

/* ── 滚动条 ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(11, 16, 32, 0.5);
}

::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #5570a3;
}

/* ── 手机端 ── */
@media (max-width: 768px) {
  #app {
    padding: 12px 10px 36px;
  }

  .header {
    padding: 20px 10px 16px;
    margin-bottom: 20px;
  }

  .header h1 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 10px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  table {
    font-size: 11.5px;
  }

  th, td {
    padding: 7px 8px;
  }

  button {
    padding: 9px 14px;
    font-size: 12.5px;
  }

  .img-btn {
    min-width: 54px;
    height: 28px;
    font-size: 10.5px;
    padding: 0 8px;
  }

  .preview {
    font-size: 12px;
    max-height: 320px;
  }
}

/* ══════════════════════════════════════════════════════════════
   图片放大观看（lightbox）—— 2026-09-13 新增
   ══════════════════════════════════════════════════════════════ */
.thumb {
  cursor: zoom-in;
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(4, 7, 16, 0.94);
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.lightbox .lb-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7);
  transition: transform 0.08s linear;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox .lb-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(31, 41, 55, 0.9);
  color: #e5e7eb;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox .lb-close:hover { background: #374151; }

.lightbox .lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 72px;
  border: none;
  border-radius: 8px;
  background: rgba(31, 41, 55, 0.75);
  color: #e5e7eb;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox .lb-nav:hover { background: #374151; }
.lightbox .lb-prev { left: 12px; }
.lightbox .lb-next { right: 12px; }

.lightbox .lb-count {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: #9ca3af;
  font-size: 13px;
  background: rgba(17, 24, 39, 0.8);
  padding: 4px 12px;
  border-radius: 12px;
}

@media (max-width: 640px) {
  .lightbox .lb-nav { width: 38px; height: 60px; font-size: 28px; }
  .lightbox .lb-close { width: 38px; height: 38px; font-size: 22px; }
}

/* ══════════════════════════════════════════════════════════════
   风格选择（两级弹窗 + 参考视频占位）—— 2026-09-13 新增
   ══════════════════════════════════════════════════════════════ */
.style-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
}

.style-pick-btn {
  background: #4b5563;
  color: #f3f4f6;
  border: 1px solid #6b7280;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
.style-pick-btn:hover { background: #6b7280; }
.style-pick-btn #style-current { color: #93c5fd; font-weight: 600; }

.style-hint { font-size: 12px; color: #9ca3af; }

/* 弹窗遮罩 */
.style-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(4, 7, 16, 0.86);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.style-modal-box {
  width: min(920px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 12px;
  overflow: hidden;
}

.style-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #374151;
  font-size: 16px;
}
.style-modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.style-modal-close:hover { color: #f3f4f6; }

.style-storage-note {
  padding: 8px 18px;
  font-size: 12px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  border-bottom: 1px solid #374151;
}

.style-modal-body {
  padding: 14px 18px;
  overflow-y: auto;
  flex: 1;
}

.style-empty { color: #9ca3af; font-size: 13px; }

.style-group { margin-bottom: 18px; }
.style-group-title {
  font-size: 14px;
  font-weight: 700;
  color: #e5e7eb;
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 3px solid #3b82f6;
}

.style-group-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.style-item {
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  background: #0b1020;
  transition: border-color 0.15s, background 0.15s;
}
.style-item:hover { border-color: #6b7280; background: #131a2c; }
.style-item.selected { border-color: #3b82f6; background: rgba(59, 130, 246, 0.12); }

.style-item-name {
  font-size: 13px;
  color: #e5e7eb;
  margin-bottom: 6px;
  text-align: center;
}

.style-ref-video {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
  display: block;
}

.style-ref-slot {
  width: 100%;
  height: 88px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.4;
  background:
    repeating-linear-gradient(45deg, rgba(42, 58, 92, 0.25) 0 6px, transparent 6px 12px),
    rgba(11, 16, 32, 0.6);
  border: 1px dashed #374151;
}

.style-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid #374151;
}
.style-clear, .style-ok {
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
}
.style-clear { background: #374151; color: #e5e7eb; }
.style-ok { background: #2563eb; color: #fff; }
.style-ok:hover { background: #1d4ed8; }

@media (max-width: 640px) {
  .style-group-items { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .style-ref-video, .style-ref-slot { height: 70px; }
}

/* 集数 / 每集时长 */
.episode-picker {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
  margin: 12px 0; padding: 10px 12px;
  border-radius: 10px; background: rgba(31, 41, 55, 0.35);
  border: 1px solid #374151;
}
.ep-label { font-size: 14px; color: #c9d1d9; display: inline-flex; align-items: center; gap: 6px; }
.ep-label input, .ep-label select {
  width: 84px; padding: 5px 8px; border-radius: 6px;
  border: 1px solid #4b5563; background: #0d1117; color: #e6edf3; font-size: 14px;
}
.episode-view { margin: 0 0 10px 0; }
.episode-view .ep-label select { width: auto; min-width: 110px; }

