/* ============================================================
   SCI_Manager — 深蓝 #162A46 · 暖白 #F8F6F2 · 暖灰 #D8D0C1
   设计风格：pic 玻璃拟态 + 圆角卡片
   ============================================================ */

:root {
  /* ── 主色：深蓝 ── */
  --navy-950: #0b1826;
  --navy-900: #0f2035;
  --navy-800: #162A46;   /* ★ 主色 */
  --navy-700: #1e3a5f;
  --navy-600: #254e80;
  --navy-500: #2c639f;
  --navy-400: #4a84be;
  --navy-200: #b0c8e8;
  --navy-100: #daeaf8;
  --navy-50:  #eef5fc;

  /* ── 暖白 & 暖灰 ── */
  --warm-white: #F8F6F2;   /* ★ 背景白 */
  --warm-gray:  #D8D0C1;   /* ★ 边框/分割 */
  --warm-gray-dark: #b8ae9c;
  --warm-gray-light: #ece8e1;

  /* ── 错误色：红 ── */
  --red-600: #dc2626;
  --red-500: #ef4444;
  --red-50:  #fef2f2;

  /* ── 语义别名 ── */
  --brand:        var(--navy-800);
  --brand-hover:  var(--navy-900);
  --brand-light:  var(--navy-50);
  --accent:       var(--red-600);
  --accent-hover: #b91c1c;
  --accent-light: var(--red-50);

  --border:       var(--warm-gray);
  --border-soft:  rgba(216, 208, 193, 0.5);
  --text:         var(--navy-900);
  --text-muted:   #6b7280;

  --bg-page:      var(--warm-white);
  --bg-panel:     rgba(255, 253, 249, 0.88);

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-soft:  0 4px 24px rgba(22, 42, 70, 0.07);
  --shadow-panel: 0 8px 40px rgba(22, 42, 70, 0.11);

  --ctrl-h: 40px;
}

.dark {
  --border:       rgba(255, 255, 255, 0.08);
  --border-soft:  rgba(255, 255, 255, 0.05);
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --bg-page:      #07111e;
  --bg-panel:     rgba(14, 26, 46, 0.78);
  --brand-light:  rgba(22, 42, 70, 0.4);
  --accent-light: rgba(220, 38, 38, 0.12);
  --warm-gray:    rgba(255,255,255,0.1);
}

/* ── 全局基础 ── */
body {
  font-family: 'Noto Sans SC', 'JetBrains Mono', system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--text);
}
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* ── 背景光晕 ── */
.app-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.app-bg-blob {
  position: absolute; border-radius: 50%; filter: blur(110px);
}
.app-bg-blob.navy {
  background: rgba(22, 42, 70, 0.18);
  width: 580px; height: 580px; top: -15%; left: -8%; opacity: 0.9;
}
.app-bg-blob.warm {
  background: rgba(216, 208, 193, 0.35);
  width: 500px; height: 500px; bottom: -12%; right: -6%; opacity: 0.7;
}
.app-bg-blob.mid {
  background: rgba(248, 246, 242, 0.7);
  width: 380px; height: 380px; top: 38%; left: 30%; opacity: 0.5;
}
.dark .app-bg-blob.navy  { background: rgba(22, 42, 70, 0.45); opacity: 1; }
.dark .app-bg-blob.warm  { opacity: 0.15; }
.dark .app-bg-blob.mid   { opacity: 0.04; }

/* ── 玻璃效果 ── */
.glass-panel {
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}

/* ─────────────────────────────────────────
   顶栏 (header)
───────────────────────────────────────── */
header.app-header {
  flex-shrink: 0;
  background: rgba(22, 42, 70, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  position: relative; z-index: 40;
}
.app-header .header-logo-box {
  width: 26px; height: 26px; border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.app-header .header-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.app-header .header-title {
  font-size: 13px; font-weight: 700;
  color: #fff; letter-spacing: -0.01em;
}
.app-header .header-sub {
  font-size: 10px; color: rgba(255,255,255,0.45);
}
.app-header .credit-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; font-weight: 700; color: var(--warm-white);
}
.app-header .credit-val.credit-val-low { color: #fca5a5; }
.app-header .credit-num { color: var(--warm-white); font-weight: 700; }
.app-header .credit-hint {
  font-size: 10px; color: rgba(255,255,255,0.42);
}
.app-header .tab-credit-hint {
  color: rgba(255,255,255,0.42);
}
.app-header .user-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 3px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px; cursor: pointer; transition: border-color 0.2s;
  background: rgba(255,255,255,0.05);
}
.app-header .user-btn:hover { border-color: rgba(255,255,255,0.28); }
.app-header .user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-600), var(--navy-800));
  border: 1.5px solid rgba(255,255,255,0.2);
  color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.app-header .user-name {
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.85);
}

/* ── Tab 栏 ── */
.tab-bar {
  display: flex; align-items: center;
  padding: 0 12px; gap: 2px;
  background: rgba(14, 28, 52, 0.95);
  border-top: 1px solid rgba(255,255,255,0.05);
}
.tab-bar-btn {
  padding: 7px 14px; font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.45); border: none; background: transparent;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.2s; margin-bottom: -1px;
  white-space: nowrap;
}
.tab-bar-btn:hover { color: rgba(255,255,255,0.75); }
.tab-bar-btn.active {
  color: var(--warm-gray);
  border-bottom-color: var(--warm-gray);
}

/* ── 状态 Banner ── */
.status-strip {
  padding: 8px 16px; font-size: 11px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(22,42,70,0.06); border-bottom: 1px solid var(--border-soft);
  color: var(--navy-700);
}
.dark .status-strip { background: rgba(22,42,70,0.3); color: #cbd5e1; }
.status-strip.announce {
  background: var(--accent-light); border-color: rgba(220,38,38,0.2);
  color: var(--accent-hover);
}

/* ─────────────────────────────────────────
   Tab 内容区
───────────────────────────────────────── */
.tab-content {
  height: calc(100vh - 72px);   /* header 40px + tabbar 32px */
  padding: 6px;
  gap: 6px;
  display: none !important;
  background: var(--bg-page);
  min-height: 0;
  overflow: hidden;
}
.tab-content.active {
  display: flex !important;
}

/* ─────────────────────────────────────────
   左控制面板 — 玻璃卡
   HTML 结构：aside.left-panel > div.left-panel-header/body/footer
───────────────────────────────────────── */
.left-panel {
  width: 300px; flex-shrink: 0;
  display: flex; flex-direction: column;
  height: 100%; padding: 6px 0 10px 6px;
  position: relative;
  min-height: 0;
}

/* aside 本身当玻璃卡 */
aside.left-panel {
  border-radius: var(--radius-xl);
  background: rgba(255,253,249,0.9);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--warm-gray);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.dark aside.left-panel {
  background: rgba(18, 30, 54, 0.88);
  border-color: rgba(255,255,255,0.07);
}

/* 如果用 div.left-panel > div.left-panel-inner 结构 */
.left-panel-inner {
  height: 100%; display: flex; flex-direction: column;
  border-radius: var(--radius-xl);
  background: rgba(255,253,249,0.9);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--warm-gray);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.dark .left-panel-inner {
  background: rgba(18, 30, 54, 0.88);
  border-color: rgba(255,255,255,0.07);
}

.left-panel-header { padding: 20px 20px 10px; }
.left-panel-body   { flex: 1; overflow-y: auto; padding: 8px 20px 16px; }
.left-panel-footer {
  flex-shrink: 0;
  padding: 14px 20px 22px;
  border-top: 1px solid var(--border-soft);
  background: rgba(236,232,225,0.55);
}
.dark .left-panel-footer { background: rgba(0,0,0,0.18); }

.section-title {
  font-size: 15px; font-weight: 700; color: var(--navy-800);
  letter-spacing: -0.02em;
}
.dark .section-title { color: #f1f5f9; }
.left-panel-header p { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── 紧凑左栏（科研出图） ── */
.left-panel-compact .left-panel-header { padding: 10px 14px 4px; }
.left-panel-compact .left-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.left-panel-compact .left-panel-footer { padding: 8px 14px 12px; }
.left-panel-compact .section-title { font-size: 14px; }
.left-panel-compact .field-label { margin-bottom: 4px; font-size: 10px; }
.left-panel-compact .panel-block { display: flex; flex-direction: column; gap: 4px; }
.left-panel-compact .panel-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.left-panel-compact .textarea-compact { min-height: 68px; padding: 8px 10px; line-height: 1.45; }
.left-panel-compact .select-base { height: 34px; font-size: 12px; }
.left-panel-compact .select-sm { height: 32px; font-size: 11px; padding-right: 28px; }
.left-panel-compact .seg-btn { height: 30px; font-size: 10px; }
.left-panel-compact .btn-compact { height: 30px; font-size: 11px; padding: 0 10px; }
.left-panel-compact .btn-primary { height: 38px; font-size: 13px; }
.left-panel-compact .upload-zone-compact {
  min-height: 52px;
  padding: 8px;
}
.left-panel-compact .context-bar { margin-bottom: 0; padding: 6px 10px; font-size: 11px; }

.ref-preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.ref-preview-row:empty { display: none; }
.ref-preview-row .ref-thumb {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--warm-gray);
}
.ref-preview-row .ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref-preview-row .ref-thumb button {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  color: #fff; border: none; opacity: 0;
  cursor: pointer; font-size: 14px;
}
.ref-preview-row .ref-thumb:hover button { opacity: 1; }

/* ─────────────────────────────────────────
   主画布区
   HTML 结构：div.flex-1.flex.flex-col (现有) → 已有样式兼容
───────────────────────────────────────── */
.main-canvas {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  height: 100%; padding: 6px 6px 6px 6px;
}
.main-canvas-inner {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  border-radius: var(--radius-xl);
  background: rgba(255,253,249,0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--warm-gray);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.dark .main-canvas-inner {
  background: rgba(15,30,55,0.85);
  border-color: rgba(255,255,255,0.07);
}

/* 主画布区（HTML 中需添加 canvas-area 类） */
.canvas-area {
  margin: 6px 6px 6px 0;
  border-radius: var(--radius-xl);
  background: rgba(255,253,249,0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--warm-gray);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  min-height: 0;
}
.dark .canvas-area {
  background: rgba(15,30,55,0.85);
  border-color: rgba(255,255,255,0.07);
}

/* ─────────────────────────────────────────
   按钮
───────────────────────────────────────── */
.btn-primary {
  height: 44px; padding: 0 20px; border-radius: 999px;
  background: linear-gradient(135deg, #162A46, #1e3a5f);
  color: #F8F6F2; font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.2s; border: none; cursor: pointer; width: 100%;
  box-shadow: 0 4px 20px rgba(22, 42, 70, 0.35);
  letter-spacing: 0.01em;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(22, 42, 70, 0.48);
  background: linear-gradient(135deg, #0f2035, #162A46);
}
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  background: var(--warm-white); color: var(--navy-800);
  border: 1px solid var(--warm-gray);
  font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(22, 42, 70, 0.06);
}
.btn-secondary:hover {
  border-color: var(--navy-500);
  background: var(--navy-50);
  color: var(--navy-800);
}
.dark .btn-secondary {
  background: rgba(255,255,255,0.06); color: #e2e8f0;
  border-color: rgba(255,255,255,0.1);
}
.dark .btn-secondary:hover { background: rgba(255,255,255,0.1); }

.btn-ghost {
  height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); font-size: 12px;
  border: none; cursor: pointer; transition: color 0.15s;
}
.btn-ghost:hover { color: var(--navy-800); }
.btn-ghost.text-red { color: var(--red-500); }
.dark .btn-ghost {
  color: #cbd5e1;
}
.dark .btn-ghost:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}
.dark .history-zone .btn-ghost {
  color: #e2e8f0;
  font-weight: 600;
}
.dark .history-zone .btn-ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* ─────────────────────────────────────────
   表单控件
───────────────────────────────────────── */
.input-base, .textarea-base, .select-base {
  border-radius: var(--radius-sm);
  border: 1px solid var(--warm-gray);
  background: rgba(255, 253, 249, 0.9);
  color: var(--text); font-size: 13px; outline: none; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dark .input-base, .dark .textarea-base, .dark .select-base {
  background: rgba(0, 0, 0, 0.2); color: #f1f5f9;
  border-color: rgba(255,255,255,0.1);
}
.input-base { height: var(--ctrl-h); padding: 0 14px; }
.textarea-base { padding: 12px 14px; resize: vertical; line-height: 1.55; min-height: 100px; }
.textarea-base:focus, .input-base:focus, .select-base:focus {
  border-color: var(--navy-500);
  box-shadow: 0 0 0 3px rgba(22, 42, 70, 0.1);
}

.select-base {
  -webkit-appearance: none; appearance: none;
  height: 36px; padding: 0 32px 0 12px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23162A46' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select-base.select-lg {
  height: 44px; font-weight: 600; font-size: 13px; border-radius: var(--radius-md);
}

.field-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 6px; display: block;
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* ── 分段按钮 ── */
.seg-btn {
  flex: 1; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--warm-gray);
  background: rgba(255,253,249,0.8);
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: all 0.2s;
}
.seg-btn.active {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: var(--warm-white);
  box-shadow: 0 2px 8px rgba(22, 42, 70, 0.3);
}
.seg-btn:hover:not(.active) {
  border-color: var(--navy-400);
  color: var(--navy-700);
}
.dark .seg-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
}
.dark .seg-btn.active {
  background: var(--navy-600);
  border-color: rgba(147, 197, 253, 0.35);
  color: #f8fafc;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.dark .seg-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(147, 197, 253, 0.35);
  color: #f1f5f9;
}

/* ── 上传区 ── */
.upload-zone {
  border: 1.5px dashed var(--warm-gray);
  border-radius: var(--radius-md);
  min-height: 112px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 20px;
  cursor: pointer; transition: all 0.2s; text-align: center;
  background: rgba(248,246,242,0.6);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--navy-500);
  background: var(--navy-50);
}
.upload-zone.disabled { opacity: 0.5; pointer-events: none; }
.dark .upload-zone {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.16);
}
.dark .upload-zone:hover,
.dark .upload-zone.dragover {
  background: rgba(22, 42, 70, 0.45);
  border-color: rgba(147, 197, 253, 0.45);
}
.dark .upload-zone p,
.dark .upload-zone .text-zinc-400,
.dark .upload-zone .text-zinc-700 {
  color: #cbd5e1 !important;
}
.dark .upload-zone svg { color: #94a3b8 !important; opacity: 0.9; }

.file-card {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border: 1px solid var(--warm-gray); border-radius: var(--radius-sm);
  font-size: 12px; background: var(--warm-gray-light);
}
.dark .file-card { background: rgba(255,255,255,0.05); }

.cost-tag { font-size: 11px; color: var(--text-muted); }
.cost-tag strong {
  color: var(--navy-700);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
.dark .cost-tag strong { color: #e2e8f0; }
.dark .field-label { color: #cbd5e1; }

/* ─────────────────────────────────────────
   进度条
───────────────────────────────────────── */
.progress-panel {
  padding: 14px 20px; border-bottom: 1px solid var(--border-soft);
  background: rgba(248,246,242,0.7);
}
.dark .progress-panel { background: rgba(0,0,0,0.15); }
.progress-bar-track {
  height: 4px; background: var(--warm-gray); border-radius: 99px;
  margin-top: 10px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy-800), var(--navy-500));
  border-radius: 99px; transition: width 0.4s ease; width: 0%;
}
.progress-panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── 通用转圈加载 ── */
@keyframes ui-spin { to { transform: rotate(360deg); } }

.ui-spinner {
  display: inline-block;
  flex-shrink: 0;
  border-radius: 999px;
  border: 2px solid rgba(22, 42, 70, 0.12);
  border-top-color: var(--navy-600);
  animation: ui-spin 0.85s linear infinite;
}
.dark .ui-spinner {
  border-color: rgba(255, 255, 255, 0.12);
  border-top-color: #93c5fd;
}
.ui-spinner-xs { width: 12px; height: 12px; border-width: 1.5px; }
.ui-spinner-sm { width: 16px; height: 16px; }
.ui-spinner-lg {
  width: 44px;
  height: 44px;
  border-width: 3px;
  border-top-color: var(--navy-600);
}

.task-loading-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 280px;
  padding: 48px 24px;
  gap: 14px;
}
.task-loading-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy-800);
}
.dark .task-loading-title { color: #f1f5f9; }
.task-loading-hint {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.55;
}

.btn-primary.is-loading,
.btn-secondary.is-loading,
.chapter-gen-btn:disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0.88;
  cursor: wait;
}
.chapter-status.status-processing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ─────────────────────────────────────────
   结果区 & 历史区
───────────────────────────────────────── */
.result-zone { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }

/* 科研出图：生成历史约占画布 1/5 高度 */
#tab-generate .canvas-area {
  display: flex;
  flex-direction: column;
}
#tab-generate .history-zone {
  flex: 0 0 20%;
  max-height: 20%;
  min-height: 96px;
  border-top: 1px solid var(--border-soft);
  overflow: hidden;
  padding: 10px 16px 12px;
  background: rgba(248,246,242,0.5);
  display: flex;
  flex-direction: column;
}
.dark #tab-generate .history-zone {
  background: rgba(255, 255, 255, 0.04);
}
.dark #tab-generate .history-zone .text-zinc-600,
.dark #tab-generate .history-zone .font-semibold {
  color: #e2e8f0 !important;
}
.dark #tab-generate .gen-history-card {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
.dark #tab-generate .gen-history-card img {
  background: rgba(255, 255, 255, 0.04);
}
#tab-generate .history-zone .gen-history-grid {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: stretch;
  padding-bottom: 2px;
}
#tab-generate .gen-history-card {
  position: relative;
  flex: 0 0 auto;
  width: auto;
  height: 72px;
  max-height: 72px;
  aspect-ratio: auto;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--warm-gray);
  background: var(--warm-gray-light);
  cursor: pointer;
}
#tab-generate .gen-history-card img {
  display: block;
  height: 72px;
  width: auto;
  max-width: none;
  object-fit: contain;
  background: var(--warm-gray-light);
}
#tab-generate .gen-history-card-overlay {
  inset: auto 0 0 0;
  height: 26px;
  padding: 0 4px 4px;
  flex-direction: row;
  align-items: center;
  justify-content: stretch;
  background: linear-gradient(to top, rgba(22, 42, 70, 0.88) 0%, rgba(22, 42, 70, 0.55) 70%, transparent 100%);
}
#tab-generate .gen-history-card-actions {
  display: flex;
  gap: 4px;
  width: 100%;
}
#tab-generate .gen-history-act-btn {
  flex: 1;
  min-width: 0;
  height: 20px;
  padding: 0 6px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy-800);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
#tab-generate .gen-history-act-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}
#tab-generate .gen-history-act-btn:active {
  transform: translateY(0);
}

.history-zone {
  flex: 0 0 auto;
  max-height: min(42vh, 320px);
  min-height: 0;
  border-top: 1px solid var(--border-soft);
  overflow-y: auto;
  padding: 14px 20px 18px;
  background: rgba(248,246,242,0.5);
}
.dark .history-zone { background: rgba(255, 255, 255, 0.04); }
.dark .history-zone .text-xs.font-semibold,
.dark .history-zone > .flex > span {
  color: #e2e8f0 !important;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  padding: 48px 24px; color: var(--text-muted);
}
.empty-state svg { opacity: 0.18; margin-bottom: 18px; color: var(--navy-600); }
.empty-state h4 {
  font-size: 18px; font-weight: 700;
  color: var(--navy-800); margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.dark .empty-state h4 { color: #f1f5f9; }
.empty-state p { font-size: 13px; max-width: 300px; line-height: 1.65; }

.history-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  transition: background 0.15s; border: 1px solid transparent;
}
.history-item:hover {
  background: rgba(22,42,70,0.05); border-color: var(--border-soft);
}
.dark .history-item:hover { background: rgba(255,255,255,0.05); }

/* ── 出图结果网格（对齐 pic：占位卡 + 计时 + 完成图） ── */
.gen-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-bottom: 8px;
}
@media (min-width: 640px) {
  .gen-results-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .gen-results-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.gen-loading-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(22, 42, 70, 0.18);
  background: linear-gradient(135deg, rgba(248, 246, 242, 0.95), rgba(22, 42, 70, 0.04));
  box-shadow: var(--shadow-soft);
}
.dark .gen-loading-card {
  border-color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(22, 42, 70, 0.2));
}
.gen-loading-card .gen-loading-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}
.gen-loading-spinner {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.gen-loading-spinner::before,
.gen-loading-spinner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
}
.gen-loading-spinner::before {
  border: 2px solid rgba(22, 42, 70, 0.12);
}
.gen-loading-spinner::after {
  border-top: 2px solid var(--navy-500);
  animation: gen-spin 0.9s linear infinite;
}
@keyframes gen-spin { to { transform: rotate(360deg); } }
.gen-loading-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(22, 42, 70, 0.08);
  overflow: hidden;
}
.dark .gen-loading-track { background: rgba(255, 255, 255, 0.08); }
.gen-loading-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--navy-500), #3b82f6);
  transition: width 1s ease;
}
.gen-loading-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-muted);
}
.gen-loading-meta .gen-loading-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gen-loading-meta .gen-loading-time {
  flex-shrink: 0;
  font-family: ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.gen-image-card {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--warm-gray);
  cursor: pointer;
  background: var(--warm-gray-light);
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s, box-shadow 0.2s;
}
.gen-image-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-panel);
}
.gen-image-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--warm-gray-light);
}
.gen-image-card-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 10px;
  padding: 8px 10px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gen-image-card-dl,
.gen-image-card-action {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  text-decoration: none;
  transition: opacity 0.2s;
  border: none;
  cursor: pointer;
}
.gen-image-card-action-dl { top: 64px; }
.gen-image-card-action-ref { top: 36px; }
.gen-image-card:hover .gen-image-card-dl,
.gen-image-card:hover .gen-image-card-action { opacity: 1; }

/* ── 生成历史缩略图 ── */
.gen-history-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 900px) {
  .gen-history-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.gen-history-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--warm-gray);
  background: var(--warm-gray-light);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.gen-history-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}
.gen-history-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--warm-gray-light);
}
.gen-history-card-overlay {
  position: absolute;
  inset: auto 0 0 0;
  height: 32px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: stretch;
  padding: 0 6px 6px;
  background: linear-gradient(to top, rgba(22, 42, 70, 0.82) 0%, rgba(22, 42, 70, 0.4) 75%, transparent 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.gen-history-card:hover .gen-history-card-overlay {
  opacity: 1;
  pointer-events: auto;
}
.gen-history-card-actions {
  display: flex;
  gap: 6px;
  width: 100%;
}
.gen-history-card-actions .gen-history-act-btn {
  flex: 1;
  min-width: 0;
  height: 22px;
  padding: 0 8px;
  border: none;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--navy-800);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s;
}
.gen-history-card-actions .gen-history-act-btn:hover {
  background: #fff;
}

/* ── 章节列表 & 卡片 ── */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(280px, 38vh);
  overflow-y: auto;
  padding-right: 2px;
  margin-top: 4px;
}

.chapter-card {
  border: 1px solid var(--warm-gray);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: rgba(255, 253, 249, 0.95);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.dark .chapter-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}
.chapter-card.is-processing {
  border-color: var(--navy-500);
  box-shadow: 0 0 0 1px rgba(30, 58, 95, 0.15);
}
.chapter-card.is-done {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.12);
}
.chapter-card.is-failed {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.12);
}

.chapter-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}
.chapter-index {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--navy-800);
  color: var(--warm-white);
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.dark .chapter-index { background: rgba(255, 255, 255, 0.14); }

.chapter-title-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-800);
  padding: 2px 0;
  line-height: 1.35;
  outline: none;
}
.chapter-title-input::placeholder { color: var(--text-muted); font-weight: 500; }
.dark .chapter-title-input { color: #f1f5f9; }

.chapter-card-del {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.chapter-card-del:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.chapter-prompt-input {
  display: block;
  width: 100%;
  min-height: 52px;
  max-height: 72px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text);
  border: 1px solid var(--warm-gray);
  border-radius: var(--radius-sm);
  background: rgba(248, 246, 242, 0.6);
  resize: none;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dark .chapter-prompt-input {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}
.chapter-prompt-input:focus {
  border-color: var(--navy-500);
  box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.12);
}

.chapter-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

.chapter-status {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  line-height: 1.2;
  white-space: nowrap;
}
.chapter-status.status-pending {
  background: rgba(148, 163, 184, 0.18);
  color: #64748b;
}
.chapter-status.status-processing {
  background: rgba(30, 58, 95, 0.12);
  color: var(--navy-600);
}
.chapter-status.status-completed {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
}
.chapter-status.status-failed {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}
.dark .chapter-status.status-pending { color: #94a3b8; }
.dark .chapter-status.status-processing { color: #93c5fd; }
.dark .chapter-status.status-completed { color: #4ade80; }
.dark .chapter-status.status-failed { color: #f87171; }

.chapter-gen-btn {
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--warm-gray);
  background: rgba(255, 253, 249, 0.9);
  font-size: 11px;
  font-weight: 600;
  color: var(--navy-700);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chapter-gen-btn:hover {
  background: var(--warm-gray-light);
  border-color: var(--navy-500);
}
.dark .chapter-gen-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}
.dark .chapter-gen-btn:hover { background: rgba(255, 255, 255, 0.1); }

.chapter-card-result {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}
.chapter-thumb {
  flex-shrink: 0;
  width: 56px;
  height: 42px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--warm-gray);
  background: var(--warm-gray-light);
  cursor: zoom-in;
  transition: box-shadow 0.15s, transform 0.15s;
}
.chapter-thumb:hover {
  box-shadow: var(--shadow-soft);
  transform: scale(1.03);
}
.chapter-edit-btn {
  flex: 1;
  min-width: 0;
  height: 26px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  color: var(--navy-600);
  cursor: pointer;
  text-align: left;
  transition: color 0.15s, background 0.15s;
}
.chapter-edit-btn:hover {
  background: rgba(30, 58, 95, 0.06);
  color: var(--navy-800);
}
.dark .chapter-edit-btn { color: #93c5fd; }
.dark .chapter-edit-btn:hover { background: rgba(255, 255, 255, 0.06); }

/* ── 上下文标签条 ── */
.context-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--warm-gray);
  background: var(--warm-gray-light); font-size: 12px; margin-bottom: 8px;
}

/* ── 折叠参数 ── */
.param-group summary {
  font-size: 13px; font-weight: 700; color: var(--navy-800);
  cursor: pointer; padding: 10px 0; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
.param-group summary::-webkit-details-marker { display: none; }
.param-group summary::after { content: '▾'; color: var(--text-muted); font-size: 10px; }
.param-group[open] summary::after { content: '▴'; }

/* ─────────────────────────────────────────
   聊天气泡
───────────────────────────────────────── */
.msg-user {
  background: var(--navy-800); color: var(--warm-white);
  border-radius: 18px 18px 4px 18px; padding: 10px 14px; font-size: 13px;
}
.msg-ai {
  background: rgba(255,253,249,0.95); border: 1px solid var(--warm-gray);
  border-radius: 18px 18px 18px 4px; padding: 10px 14px; font-size: 13px;
  color: var(--text);
}
.dark .msg-ai { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.08); }

.chat-input-bar {
  flex-shrink: 0; padding: 16px 20px;
  border-top: 1px solid var(--border-soft);
  background: rgba(248,246,242,0.8);
  backdrop-filter: blur(12px);
}
.dark .chat-input-bar { background: rgba(0,0,0,0.22); }

/* ─────────────────────────────────────────
   状态点 & EKG 动画
───────────────────────────────────────── */
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.status-dot.ok      { background: var(--navy-500); }
.status-dot.fail    { background: var(--red-500); }
.status-dot.pending { background: var(--navy-400); animation: pulse 1.5s infinite; }
.status-dot.processing {
  width: 10px;
  height: 10px;
  background: transparent;
  border: 2px solid rgba(30, 58, 95, 0.2);
  border-top-color: var(--navy-600);
  animation: ui-spin 0.85s linear infinite;
}
.dark .status-dot.processing {
  border-color: rgba(255, 255, 255, 0.15);
  border-top-color: #93c5fd;
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
@keyframes ekg   { 0%,100%{transform:scaleY(0.3);opacity:0.4} 50%{transform:scaleY(1);opacity:1} }
.ekg-bar { animation: ekg 1s ease-in-out infinite; }

/* ─────────────────────────────────────────
   Modal
───────────────────────────────────────── */
.modal-box {
  background: var(--warm-white);
  border: 1px solid var(--warm-gray);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(22,42,70,0.2);
  max-width: 420px; width: 90vw; padding: 24px;
}
.dark .modal-box {
  background: #0f2035;
  border-color: rgba(255,255,255,0.1);
}

/* ─────────────────────────────────────────
   Toast
───────────────────────────────────────── */
#toast {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#toast.toast-show { opacity: 1; pointer-events: auto; }
#toast.toast-error   { border-left: 3px solid var(--red-500); }
#toast.toast-success { border-left: 3px solid var(--navy-600); }

/* ─────────────────────────────────────────
   Lightbox
───────────────────────────────────────── */
#lightbox {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(9, 18, 38, 0.96);
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img {
  max-width: min(90vw, calc(100% - 120px));
  max-height: calc(100vh - 120px);
  object-fit: contain; border-radius: var(--radius-md);
  cursor: default;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.lightbox-close {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #fff; font-size: 22px; line-height: 1;
  cursor: pointer; transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer; transition: background 0.15s;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }
.lightbox-counter {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px; font-family: ui-monospace, monospace;
}
.lightbox-actions {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 2;
}

/* ── PDF 翻译画布 ── */
#translatePanel {
  position: relative;
  flex-direction: column;
  padding: 24px 20px;
}
.translate-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}
.translate-hero-img {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}
.translate-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 8px;
}
.translate-done-icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 58, 95, 0.1);
  color: var(--navy-800);
  margin-bottom: 12px;
}
.dark .translate-done-icon {
  background: rgba(147, 197, 253, 0.12);
  color: #93c5fd;
}
.translate-done-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-800);
  letter-spacing: -0.02em;
}
.dark .translate-done-title { color: #f1f5f9; }
.translate-done-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.translate-error {
  margin-top: 16px;
  font-size: 13px;
  color: #dc2626;
  text-align: center;
}

.gen-image-card,
.gen-history-card { cursor: zoom-in; }

/* ─────────────────────────────────────────
   结果工具栏
───────────────────────────────────────── */
.result-toolbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(248,246,242,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  padding: 14px 0; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.dark .result-toolbar { background: rgba(15,30,55,0.88); }

/* ─────────────────────────────────────────
   Markdown 排版
───────────────────────────────────────── */
.prose-sm h2 { font-size: 14px; font-weight: 700; margin: 16px 0 8px; color: var(--navy-800); }
.prose-sm h3 { font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.prose-sm ul { list-style: disc; padding-left: 1.25rem; margin: 6px 0; font-size: 13px; }
.prose-sm p  { margin: 6px 0; font-size: 13px; line-height: 1.65; }

/* ─────────────────────────────────────────
   滚动条
───────────────────────────────────────── */
::-webkit-scrollbar         { width: 5px; height: 5px; }
::-webkit-scrollbar-track   { background: transparent; }
::-webkit-scrollbar-thumb   { background: var(--warm-gray); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--warm-gray-dark); }

/* ─────────────────────────────────────────
   章节类型 badge / 数据章
───────────────────────────────────────── */
.chapter-type-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.chapter-type-schematic {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}
.dark .chapter-type-schematic { color: #86efac; }
.chapter-type-data {
  background: rgba(232, 165, 0, 0.18);
  color: #b45309;
}
.dark .chapter-type-data { color: #fcd34d; }
.chapter-card.is-data {
  border-color: rgba(232, 165, 0, 0.35);
  background: rgba(232, 165, 0, 0.04);
}
.dark .chapter-card.is-data {
  background: rgba(232, 165, 0, 0.06);
  border-color: rgba(252, 211, 77, 0.25);
}
.chapter-data-meta {
  color: var(--text-muted);
  padding: 0 10px 4px;
  line-height: 1.4;
}
.chapter-goto-data {
  background: rgba(232, 165, 0, 0.12) !important;
  color: #b45309 !important;
}
.dark .chapter-goto-data { color: #fcd34d !important; }

.chapter-enhanced-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 2px;
}
.chapter-enhanced-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--brand-500, #2c639f);
  cursor: pointer;
}
.dark .chapter-enhanced-toggle { color: rgba(248, 246, 242, 0.65); }

/* ─────────────────────────────────────────
   数据作图 Tab
───────────────────────────────────────── */
.data-section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--navy-800);
}
.dark .data-section-title { color: var(--warm-white); }
.data-profile-report {
  background: var(--warm-white);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px;
  max-height: 240px;
  overflow-y: auto;
}
.dark .data-profile-report {
  background: rgba(15, 30, 55, 0.5);
  border-color: rgba(255,255,255,0.08);
}
.data-recommend-card {
  background: var(--warm-white);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px;
}
.dark .data-recommend-card {
  background: rgba(15, 30, 55, 0.5);
  border-color: rgba(255,255,255,0.08);
}
.data-chart-preview {
  max-width: 100%;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  margin: 8px 0;
  background: #fff;
}
.data-download-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.data-qa-warnings {
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(232, 165, 0, 0.08);
  border: 1px solid rgba(232, 165, 0, 0.2);
}
.history-scroll-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.history-thumb-card {
  flex: 0 0 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  overflow: hidden;
  position: relative;
  background: var(--warm-white);
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.history-thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 9px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  text-align: center;
  padding: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

/* ─────────────────────────────────────────
   首页 Landing（与 /app 同套配色）
───────────────────────────────────────── */
.landing-page {
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

.landing-header {
  position: sticky;
  top: 0;
  z-index: 50;
}

.landing-header-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.landing-header-title {
  font-size: 17px;
  color: #fff;
}

.landing-header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.landing-header-rec {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.625rem;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.landing-header-rec:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
}

.landing-header-rec-tag {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  padding-right: 0.375rem;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}
.landing-header-rec-text {
  color: #F8F6F2;
}
.landing-header-rec-icon {
  width: 12px;
  height: 12px;
  opacity: 0.65;
  flex-shrink: 0;
}
.landing-header-rec:hover .landing-header-rec-icon {
  opacity: 1;
}

@media (max-width: 640px) {
  .landing-header-rec-tag { display: none; }
  .landing-header-rec { padding: 0.3rem 0.5rem; font-size: 11px; }
}

.landing-hero {
  position: relative;
  padding: 4rem 1rem 5rem;
  text-align: center;
}

.landing-hero-inner {
  max-width: 56rem;
  margin: 0 auto;
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--navy-700);
  background: var(--navy-50);
  border: 1px solid var(--border-soft);
  margin-bottom: 1.5rem;
}

.landing-badge-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--navy-600);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.landing-title {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.landing-title-accent {
  background: linear-gradient(135deg, var(--navy-800), var(--navy-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-muted);
  max-width: 42rem;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

.landing-cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.btn-primary--inline {
  width: auto;
  height: 48px;
  padding: 0 2rem;
  font-size: 1rem;
}

.landing-btn-outline {
  height: 48px;
  padding: 0 2rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--navy-800);
  background: var(--warm-white);
  border: 1px solid var(--warm-gray);
  transition: all 0.2s;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(22, 42, 70, 0.06);
}
.landing-btn-outline:hover {
  border-color: var(--navy-500);
  background: var(--navy-50);
}

.landing-note {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.landing-section {
  padding: 5rem 1rem;
}

.landing-section-alt {
  background: var(--warm-gray-light);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.landing-section-inner {
  max-width: 72rem;
  margin: 0 auto;
}

.landing-section-title {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 800;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.landing-section-desc {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 3rem;
}

.landing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 768px) {
  .landing-grid { grid-template-columns: repeat(3, 1fr); }
}

.landing-card {
  background: var(--warm-white);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: box-shadow 0.25s, border-color 0.25s;
  box-shadow: var(--shadow-sm);
}
.landing-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--warm-gray);
}

.landing-feature-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, var(--navy-800), var(--navy-600));
  color: var(--warm-white);
  box-shadow: 0 4px 16px rgba(22, 42, 70, 0.25);
}

.landing-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.landing-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1rem;
}

.landing-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.landing-tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--navy-50);
  color: var(--navy-700);
  border: 1px solid var(--border-soft);
}

.landing-cta-block {
  text-align: center;
  padding: 5rem 1rem;
}

.landing-cta-block h2 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.landing-cta-block p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.landing-footer {
  border-top: 1px solid var(--border-soft);
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.dark .landing-section-alt {
  background: rgba(255, 255, 255, 0.03);
}
.dark .landing-card {
  background: rgba(15, 30, 55, 0.6);
  border-color: rgba(255, 255, 255, 0.08);
}
.dark .landing-badge {
  background: rgba(22, 42, 70, 0.5);
  border-color: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}
.dark .landing-btn-outline {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}
.dark .landing-btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}
.dark .landing-tag {
  background: rgba(22, 42, 70, 0.5);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.08);
}
