/* ============================================================
   组会通 · 应用样式（CSS变量双主题）
   设计令牌：1主色 + 1强调色 + 3级灰；8px栅格；12px圆角
   ============================================================ */

:root {
  --primary: #4f6ef2;
  --primary-hover: #3d5ce0;
  --primary-soft: rgba(79, 110, 242, 0.10);
  --accent: #22b573;
  --danger: #e05252;
  --warning: #e6a23c;

  --bg: #f4f5f8;
  --bg-panel: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-hover: #eef0f6;
  --bg-active: rgba(79, 110, 242, 0.08);
  --bg-inset: #f7f8fb;

  --text-1: #1d2433;
  --text-2: #5a6474;
  --text-3: #9aa3b5;

  --border: #e6e9f0;
  --border-strong: #d5dae5;

  --shadow-card: 0 1px 3px rgba(20, 30, 60, 0.06), 0 4px 16px rgba(20, 30, 60, 0.05);
  --shadow-pop: 0 4px 24px rgba(20, 30, 60, 0.14);

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;

  color-scheme: light;
}

html[data-theme="dark"] {
  --primary: #6d87f7;
  --primary-hover: #859bf9;
  --primary-soft: rgba(109, 135, 247, 0.16);
  --accent: #34c98a;
  --danger: #ef6b6b;
  --warning: #ecb569;

  --bg: #12151d;
  --bg-panel: #1a1f2b;
  --bg-sidebar: #171b26;
  --bg-hover: #232937;
  --bg-active: rgba(109, 135, 247, 0.14);
  --bg-inset: #141824;

  --text-1: #e8ebf2;
  --text-2: #a7b0c2;
  --text-3: #6b7488;

  --border: #272e3d;
  --border-strong: #364050;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-pop: 0 4px 24px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text-1);
  height: 100vh;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { text-decoration: none; color: inherit; }
.hidden { display: none !important; }

/* ============ 布局骨架 ============ */
#app { display: flex; height: 100vh; }

#main { flex: 1; min-width: 0; overflow-y: auto; position: relative; }

.view { padding: 32px 40px; max-width: 1500px; margin: 0 auto; }

.btn-menu { display: none; }

/* ============ 侧边栏 ============ */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  gap: 14px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7a5cf0);
  color: #fff; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }
.brand-tagline { font-size: 11.5px; color: var(--text-3); margin-top: -2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 500;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary); color: #fff;
  padding: 10px 18px;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-new { width: 100%; padding: 11px; font-size: 15px; font-weight: 600; }

.balance-card {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.balance-label { font-size: 13px; color: var(--text-2); }
.balance-label span { font-size: 17px; font-weight: 700; color: var(--text-1); }
.btn-recharge {
  background: var(--primary-soft); color: var(--primary);
  font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px;
  transition: background 0.15s;
}
.btn-recharge:hover { background: var(--primary); color: #fff; }

.history-header {
  font-size: 12px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 4px 6px 0;
}
.history-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; min-height: 60px; }
.history-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 18px 0; }

.history-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.12s;
}
.history-item:hover { background: var(--bg-hover); }
.history-item.active { background: var(--bg-active); }
.hi-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hi-dot.completed { background: var(--accent); }
.hi-dot.failed { background: var(--danger); }
.hi-dot.processing, .hi-dot.queued { background: var(--warning); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.hi-info { min-width: 0; flex: 1; }
.hi-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-id { font-size: 13px; color: var(--text-2); font-weight: 500; }
.user-actions { display: flex; gap: 4px; }
.icon-btn {
  padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
  transition: all 0.12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }

/* ============ 新建任务 ============ */
.new-card {
  max-width: 660px; margin: 4vh auto 0;
  background: var(--bg-panel);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  padding: 36px 40px;
}
.new-title { font-size: 22px; font-weight: 700; }
.new-sub { color: var(--text-2); font-size: 14px; margin: 6px 0 24px; }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center; cursor: pointer;
  transition: all 0.18s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dz-icon { font-size: 34px; margin-bottom: 8px; }
.dz-text { font-size: 15px; color: var(--text-2); }
.dz-text span { font-size: 13px; color: var(--text-3); }

.file-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px; margin-top: 12px;
}
.fc-icon { font-size: 22px; }
.fc-info { flex: 1; min-width: 0; }
.fc-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-meta { font-size: 12.5px; color: var(--text-3); }

.section-label { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 24px 0 10px; }

.service-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.service-card {
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer;
  transition: all 0.15s;
}
.service-card:hover { border-color: var(--primary); }
.service-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary);
}
.sc-head { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.sc-desc { font-size: 12.5px; color: var(--text-2); margin: 5px 0 7px; line-height: 1.5; }
.sc-files { font-size: 12px; color: var(--primary); font-weight: 600; }

.analysis-style { margin-top: 14px; }
.style-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-opt {
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 14px; cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 2px;
}
.style-opt:hover { border-color: var(--primary); }
.style-opt.selected { border-color: var(--primary); background: var(--primary-soft); }
.style-opt b { font-size: 13.5px; }
.style-opt span { font-size: 12px; color: var(--text-3); }

.toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 22px; cursor: pointer; user-select: none; }
.toggle-row input { display: none; }
.toggle-track {
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--border-strong);
  position: relative; transition: background 0.18s; flex-shrink: 0;
}
.toggle-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: left 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle-row input:checked + .toggle-track { background: var(--primary); }
.toggle-row input:checked + .toggle-track::after { left: 20px; }
.toggle-label { font-size: 14px; font-weight: 500; }
.toggle-hint { color: var(--text-3); font-size: 12.5px; font-weight: 400; }

.cost-estimate {
  margin-top: 20px; padding: 11px 14px;
  background: var(--bg-inset); border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--text-2);
}
.cost-estimate b { color: var(--text-1); font-size: 16px; }

.btn-start { width: 100%; margin-top: 20px; padding: 13px; font-size: 16px; font-weight: 600; }

/* ============ 工作区 ============ */
#view-task { padding: 22px 28px 28px; height: 100%; display: flex; flex-direction: column; max-width: none; }

.ws-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 14px; flex-shrink: 0;
}
.ws-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ws-mode-badge {
  font-size: 11px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); border-radius: 999px;
  padding: 3px 10px; flex-shrink: 0; letter-spacing: 0.5px;
}
.ws-filename { font-size: 16.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.status-chip {
  font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 4px 12px;
}
.status-chip.processing { color: var(--warning); background: rgba(230,162,60,0.12); }
.status-chip.completed { color: var(--accent); background: rgba(34,181,115,0.12); }
.status-chip.failed { color: var(--danger); background: rgba(224,82,82,0.12); }
.ws-elapsed { font-size: 13px; color: var(--text-3); }

.ws-progress { flex-shrink: 0; padding-bottom: 14px; }
.progress-track {
  height: 6px; border-radius: 999px; background: var(--bg-inset);
  border: 1px solid var(--border); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #7a5cf0);
  transition: width 0.6s ease;
}
.progress-info { display: flex; justify-content: space-between; margin-top: 7px; font-size: 13px; color: var(--text-2); }
.progress-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

.ws-error {
  display: flex; align-items: center; gap: 16px;
  background: rgba(224,82,82,0.07); border: 1px solid rgba(224,82,82,0.25);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 14px; flex-shrink: 0;
}
.err-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--danger); color: #fff; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.err-title { font-weight: 700; font-size: 15px; }
.err-msg { font-size: 13px; color: var(--text-2); max-height: 40px; overflow: auto; }
.err-refund { font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 2px; }

/* 双栏主体（中间为可拖拽分隔条） */
.ws-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(300px, 44%) 6px 1fr; gap: 16px 6px;
}
.doc-pane, .output-pane {
  background: transparent;
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}

/* 左栏：原文/译文 */
.pane-tabs {
  display: flex; gap: 4px; padding: 10px 12px 0; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.pane-tab {
  font-size: 13.5px; font-weight: 600; color: var(--text-3);
  padding: 8px 14px 10px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex; align-items: center; gap: 6px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.pane-tab:hover { color: var(--text-1); }
.pane-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.pane-zoom { margin-left: auto; align-self: center; padding-bottom: 8px; }
.pane-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.pane-dot.translating { background: var(--warning); animation: pulse 1.4s infinite; }
.pane-dot.done { background: var(--accent); }
.pane-dot.failed { background: var(--danger); }

.pane-content { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* 缩放视口：普通滚轮=原生滚动；Ctrl+滚轮=缩放；>100%时拖拽=平移 */
.pz-viewport { flex: 1; min-height: 0; overflow: auto; padding: 8px 10px; }
.pz-content { min-width: 100%; }
.pz-viewport.panning, .tab-content.panning { cursor: grabbing; user-select: none; }
.pz-viewport.zoomed { cursor: grab; }
.pz-viewport.zoomed.panning { cursor: grabbing; }
.doc-pane, .output-pane { position: relative; }

/* 缩放比例气泡（右下角，自动隐藏，点击复位） */
.zoom-chip {
  position: absolute; right: 16px; bottom: 16px; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 5px 6px 5px 14px;
  box-shadow: var(--shadow-card); font-size: 12.5px; color: var(--text-2);
  opacity: 0; pointer-events: none; transition: opacity 0.18s;
}
.zoom-chip.show { opacity: 1; pointer-events: auto; }
.zoom-chip button {
  border: none; border-radius: 999px; cursor: pointer;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12px; padding: 3px 10px; font-weight: 600;
}
.pdf-loading { color: var(--text-3); font-size: 13.5px; text-align: center; padding: 30px 0; }
.pdf-page-wrap { margin: 0 auto 14px; position: relative; }
.pdf-page-wrap canvas { display: block; width: 100%; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
.pdf-page-num {
  position: absolute; top: 8px; right: 8px;
  background: rgba(20,25,40,0.65); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
}

.trans-status {
  font-size: 13px; color: var(--text-2);
  padding: 10px 12px; margin-bottom: 14px;
  background: var(--bg-inset); border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 8px;
}
.trans-status .spin { width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: rot 0.8s linear infinite; flex-shrink: 0; }
@keyframes rot { to { transform: rotate(360deg); } }
.trans-text p { font-size: 14.5px; line-height: 1.85; margin-bottom: 12px; text-align: justify; }
.trans-text .trans-h {
  font-size: 16px; font-weight: 700; color: var(--text-1);
  margin: 22px 0 10px; padding-left: 10px;
  border-left: 3px solid var(--primary);
}
.trans-text .trans-h:first-child { margin-top: 4px; }
.trans-text table.trans-table {
  width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13.5px;
}
.trans-text .trans-table th, .trans-text .trans-table td {
  border: 1px solid var(--border-strong); padding: 6px 10px; text-align: left;
}
.trans-text .trans-table th { background: var(--bg-inset); font-weight: 600; }
.trans-download { margin-top: 18px; }

/* ============ 侧栏收展把手（信封舌片，贴在侧栏与主区分界线上） ============ */
#app { position: relative; }
#sidebar { transition: margin-left 0.22s ease; }
#app.sb-collapsed #sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.sidebar-handle {
  position: absolute; left: calc(var(--sidebar-w) - 1px); top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 156px; z-index: 60;
  background: var(--bg-panel);
  border: 1px solid var(--border); border-left: none;
  border-radius: 0 14px 14px 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 18px; cursor: pointer;
  box-shadow: 2px 1px 8px rgba(20,30,60,0.07);
  transition: left 0.22s ease, color 0.12s, background 0.12s;
}
.sidebar-handle:hover { color: var(--primary); background: var(--bg-active); }
#app.sb-collapsed .sidebar-handle { left: 0; }

/* ============ 工作区左右分隔条 ============ */
.ws-splitter { position: relative; cursor: col-resize; border-radius: 3px; }
.ws-splitter::after {
  content: ""; position: absolute; left: 2px; top: 34%; bottom: 34%;
  width: 2px; border-radius: 2px; background: var(--border-strong);
  transition: background 0.12s;
}
.ws-splitter:hover::after, .ws-splitter.dragging::after { background: var(--primary); }

/* ============ PPT预览：逐段落渲染 ============ */
.ppt-slide .shape-text .ppt-para { white-space: pre-wrap; word-break: break-word; }

/* ============ 报告工具栏缩放按钮（iframe内无法接管Ctrl+滚轮） ============ */
.tc-toolbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.tc-zoom { display: flex; gap: 4px; }
.tc-zoom button {
  min-width: 32px; height: 28px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--bg-panel); color: var(--text-2);
  font-size: 13px; cursor: pointer; transition: all 0.12s;
}
.tc-zoom button:hover { border-color: var(--primary); color: var(--primary); }

/* 右栏：产出Tab */
.output-tabs {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px 0; flex-shrink: 0;
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.otab {
  font-size: 13.5px; font-weight: 500; color: var(--text-3);
  padding: 9px 14px 11px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex; align-items: center; gap: 7px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
}
.otab:hover { color: var(--text-1); background: var(--bg-hover); }
.otab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.otab .ot-state { font-size: 12px; }
.otab[data-state="ready"] .ot-state { color: var(--accent); }
.otab[data-state="generating"] .ot-state { color: var(--warning); }
.otab[data-state="pending"] .ot-state { color: var(--text-3); }
.otab[data-state="failed"] .ot-state { color: var(--danger); }

.tab-content { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; }

/* Tab内容状态 */
.tc-pending, .tc-generating {
  height: 100%; min-height: 220px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-3); gap: 10px; text-align: center;
}
.tc-generating .spin { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: rot 0.8s linear infinite; }
.tc-generating .tc-stage { font-size: 14px; color: var(--text-2); }
.tc-pending .lock { font-size: 24px; opacity: 0.5; }

.tc-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; flex-shrink: 0;
}
.tc-toolbar-title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.btn-download {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary); color: #fff;
  font-size: 13.5px; font-weight: 600;
  padding: 8px 16px; border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.btn-download:hover { background: var(--primary-hover); }

.report-frame {
  flex: 1; min-height: 300px; width: 100%;
  border: 1px solid var(--border);
  background: #fff;
}
/* 报告tab：iframe铺满内容区去掉双重边界，配合去壳CSS让内容贴边显示 */
.tab-content.tc-report { padding: 0; }
.tab-content.tc-report .report-frame { border: none; }

/* PPT预览 */
.ppt-scroll { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.ppt-slide-wrap { width: 100%; position: relative; }
.ppt-slide {
  position: relative; width: 100%;
  background: #fff; border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.13);
  overflow: hidden;
}
.ppt-slide .shape-text {
  position: absolute; overflow: visible;   /* PowerPoint不裁剪溢出文本，保持一致 */
  white-space: pre-wrap; word-break: break-word;
  display: flex; flex-direction: column; justify-content: center;
}
.ppt-slide .shape-img { position: absolute; object-fit: fill; }
.ppt-slide table.ppt-table {
  position: absolute; border-collapse: collapse; table-layout: fixed;
  background: #fff;
}
.ppt-slide table.ppt-table td {
  /* 边框黑色实线；字号/内边距用em随表格字号(见app.js按PPT的20pt等比缩放)自适应 */
  border: 1px solid #000000; padding: 0.18em 0.36em;
  font-size: inherit; line-height: 1.35; vertical-align: middle;
  word-break: break-all; text-align: center;   /* 与PPT表格一致：单元格居中 */
}
.ppt-slide table.ppt-table tr:first-child td {
  background: #fff; color: #333; font-weight: 600; text-align: center;
}
.ppt-page-badge {
  position: absolute; top: -22px; left: 0;
  font-size: 11.5px; color: var(--text-3); font-weight: 600;
}

/* ============ 文章梳理子步骤进度 ============ */
.ar-progress { margin-top: 12px; }
.ar-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.ar-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-panel);
  transition: all 0.3s ease;
}
.ar-icon { font-size: 14px; line-height: 1; }
.ar-label { white-space: nowrap; }
.ar-pending { color: var(--text-3); opacity: 0.6; }
.ar-running {
  color: var(--primary); border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.ar-running .ar-icon { animation: ar-spin 1s linear infinite; display: inline-block; }
.ar-done {
  color: #22a06b; border-color: #22a06b;
  background: color-mix(in srgb, #22a06b 8%, transparent);
}
.ar-failed {
  color: var(--danger); border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}
@keyframes ar-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============ Toast ============ */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: var(--text-1); color: var(--bg-panel);
  padding: 10px 22px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow-pop); z-index: 200;
  transition: transform 0.3s ease; pointer-events: none;
  max-width: 80vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.sidebar-mask { display: none; }

/* ============ 响应式（基础适配） ============ */
@media (max-width: 1080px) {
  .btn-menu {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 14px; left: 14px; z-index: 150;
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--bg-panel); box-shadow: var(--shadow-card);
    font-size: 17px;
  }
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 120;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: var(--shadow-pop);
  }
  #sidebar.open { transform: translateX(0); }
  .sidebar-mask.show {
    display: block; position: fixed; inset: 0; z-index: 110;
    background: rgba(10,14,25,0.45);
  }
  .view { padding: 20px 16px; padding-top: 66px; }
  .new-card { padding: 24px 20px; margin-top: 0; }
  .service-cards, .style-options { grid-template-columns: 1fr; }
  #view-task { padding: 16px 12px 16px; padding-top: 64px; }
  .ws-body { grid-template-columns: 1fr !important; grid-template-rows: minmax(320px, 45%) 1fr; }
  .report-frame { height: 60vh; }
  .sidebar-handle, .ws-splitter { display: none; }
  /* 移动端侧栏是抽屉式，不受桌面端收起负边距影响 */
  #app.sb-collapsed #sidebar { margin-left: 0; }
}

/* ============ AI问答（左栏pane-chat） ============ */
#pane-chat { padding: 0; }
.chat-messages {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-bubble {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
.chat-user {
  align-self: flex-end;
  background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-ai {
  align-self: flex-start;
  background: var(--bg-inset); color: var(--text-1);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* AI回复markdown排版（.chat-md由marked渲染）：
   覆盖pre-wrap避免HTML源码换行产生多余空行；配色全部用主题变量，暗色模式自适应 */
.chat-ai.chat-md { white-space: normal; }
.chat-md > :first-child { margin-top: 0; }
.chat-md > :last-child { margin-bottom: 0; }
.chat-md p { margin: 6px 0; }
.chat-md h1, .chat-md h2, .chat-md h3, .chat-md h4 {
  margin: 12px 0 6px; line-height: 1.4; color: var(--text-1);
}
.chat-md h1 { font-size: 17px; }
.chat-md h2 { font-size: 16px; }
.chat-md h3 { font-size: 15px; }
.chat-md h4 { font-size: 14px; }
.chat-md ul, .chat-md ol { margin: 6px 0; padding-left: 22px; }
.chat-md li { margin: 3px 0; }
.chat-md blockquote {
  margin: 8px 0; padding: 6px 12px;
  border-left: 3px solid var(--primary);
  background: var(--bg-panel);
  border-radius: 0 8px 8px 0;
  color: var(--text-2);
}
.chat-md code {
  font-family: ui-monospace, Consolas, monospace; font-size: 13px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}
.chat-md pre {
  margin: 8px 0; padding: 10px 12px; overflow-x: auto;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px;
}
.chat-md pre code { background: none; border: none; padding: 0; }
.chat-md table {
  border-collapse: collapse; margin: 8px 0; max-width: 100%;
  display: block; overflow-x: auto;   /* 气泡窄，宽表格横向滚动 */
  font-size: 13px;
}
.chat-md th, .chat-md td {
  border: 1px solid var(--border); padding: 5px 9px; text-align: left;
}
.chat-md th { background: var(--bg-panel); font-weight: 600; }
.chat-md hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.chat-md a { color: var(--primary); }
.chat-input-row {
  flex-shrink: 0;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 12px 12px;
}
.chat-input {
  flex: 1; min-height: 0;
  resize: none;
  font: inherit; font-size: 14px; line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 8px 10px;
}
.chat-input:focus { outline: none; border-color: var(--primary); }
.chat-input:disabled { opacity: 0.6; }
.chat-send { flex-shrink: 0; padding: 8px 18px; }

/* 问答附件按钮（点击后把PPT草稿/演讲稿随请求发给AI）
   样式：蓝色字+白底/浅蓝底的胶囊按钮，未选白底、选中浅蓝底+✓ */
.chat-attach-row {
  flex-shrink: 0;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 0 12px 2px;
}
.chat-attach-row.hidden { display: none; }
.chat-attach-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font: inherit; font-size: 13px;
  cursor: pointer; user-select: none;
  color: var(--primary);
  background: var(--bg-panel);
  border: 1px solid rgba(79, 110, 242, 0.40);
  border-radius: 999px;
  padding: 4px 14px;
  transition: color .15s, border-color .15s, background .15s;
}
.chat-attach-chip:hover {
  border-color: var(--primary);
  background: var(--bg-active);
}
.chat-attach-chip.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}
.chip-icon { font-size: 12px; line-height: 1; }

/* ============ 历史任务右键菜单 ============ */
.ctx-menu {
  position: fixed;
  z-index: 1000;
  min-width: 128px;
  padding: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}
.ctx-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-1);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.ctx-danger { color: var(--danger); }
.ctx-item.ctx-danger:hover { background: rgba(224, 82, 82, 0.08); }
