﻿/* ================================================================
   PRD Workshop - 完整样式表
   三栏布局：侧边栏 260px | 聊天区 flex | 预览面板 0~480px
   配色：明亮浅色主调 + 蓝色强调，注重可读性
   ================================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #f9fafc;
  --bg-secondary: #f0f2f7;
  --bg-sidebar: #eaecf2;
  --bg-card: #ffffff;
  --bg-input: #f2f4f9;
  --bg-hover: #e4e7f0;
  --bg-preview: #fcfdff;
  --border: #ccd0db;
  --text-primary: #12122e;
  --text-secondary: #3d3d5c;
  --text-muted: #5c5c80;
  --accent: #3d6df5;
  --accent-hover: #5a82f7;
  --accent-dim: #d6e0fc;
  --success: #3ab870;
  --warning: #e69530;
  --danger: #d94560;
  --user-msg-bg: #e3ecff;
  --ai-msg-bg: #f5f5fa;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
  --transition: 0.2s ease;
  /* 左/中/右三栏底部白框统一高度（含 padding）— 略紧凑 */
  --col-footer-height: 84px;
  --col-footer-pad-top: 8px;
  --col-footer-pad-bottom: 10px;
  --col-footer-control-h: 40px;
  --col-footer-hint-mt: 4px;
  --col-footer-hint-lh: 12px;
}

html, body {
  height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button {
  cursor: pointer; border: none; outline: none;
  font-family: inherit; font-size: inherit;
}

input, textarea {
  font-family: inherit; font-size: inherit;
  outline: none; border: none;
}

ul { list-style: none; }

/* ---- Auth Overlay ---- */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.auth-card {
  width: 400px; max-width: 90vw;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-header h1 { font-size: 28px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: #404060; }
.auth-device-hint {
  margin: 12px auto 0;
  max-width: 320px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary, #5a5a78);
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  text-align: left;
}
.auth-device-hint strong { color: #0f766e; font-weight: 600; }

.auth-tabs {
  display: flex; gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1; padding: 10px 0;
  background: transparent; color: var(--text-muted);
  font-size: 15px; font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.auth-form .form-group { margin-bottom: 16px; }
.auth-form label {
  display: block; font-size: 12px; color: #1a1a35;
  margin-bottom: 6px; font-weight: 500;
}
.auth-form input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: var(--transition);
  font-size: 14px;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61,109,245,0.10); }

.auth-error { font-size: 12px; color: var(--danger); min-height: 18px; margin-bottom: 12px; }

.auth-submit {
  width: 100%; padding: 12px;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600;
  border-radius: var(--radius);
  transition: var(--transition);
}
.auth-submit:hover { background: var(--accent-hover); }
.auth-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}
.btn-guest-login {
  margin-top: 10px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-guest-login:hover {
  background: var(--bg-secondary, #e8eaf2);
  color: var(--text-primary);
}
.auth-error.is-visible {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- App Shell ---- */
/* 预留底部固定页脚高度，避免与 footer 重叠 */
.app-shell {
  display: flex;
  height: calc(100vh - 28px);
  width: 100vw;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 260px; min-width: 260px;
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  transition: width var(--transition), min-width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: 0; min-width: 0; border-right: none; }

.sidebar-new { padding: 16px; }
.btn-new-project {
  width: 100%; padding: 10px 0;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 600;
  border-radius: var(--radius);
  transition: var(--transition);
}
.btn-new-project:hover { background: var(--accent-hover); }

.sidebar-history { flex: 1; overflow-y: auto; padding: 0 12px; min-height: 0; }
.sidebar-section-title {
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 8px 4px; margin-top: 4px;
}

.project-list { display: flex; flex-direction: column; gap: 2px; }
.project-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}
.project-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.project-item.active { background: var(--accent); color: #fff; }
.project-item.active .project-item-name { color: #fff; }
.project-item.active .project-item-meta { color: rgba(255,255,255,0.9); }
.project-item.active .btn-rename-project { color: rgba(255,255,255,0.7); opacity: 1; }
.project-item.active .btn-rename-project:hover { color: #fff; }
.project-item-icon {
  width: 28px; height: 28px; min-width: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border-radius: 6px;
  font-size: 12px; font-weight: 700;
}
.project-item.active .project-item-icon { background: rgba(255,255,255,0.2); }
.project-item-info { overflow: hidden; }
.project-item-name {
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.empty-hint {
  font-size: 13px; color: var(--text-muted); text-align: center;
  padding: 24px 8px;
}

/* 任务 6.4：侧栏示例入口 */
.sidebar-examples {
  flex-shrink: 0;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--border);
  max-height: 42%;
  overflow-y: auto;
}
.example-template-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.example-template-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: var(--transition);
}
.example-template-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim, rgba(61, 109, 245, 0.06));
}
.example-template-name {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}
.example-template-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}
/* 欢迎页示例卡片 */
.welcome-screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}
.welcome-lead {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  margin: 8px 0 18px;
}
.welcome-template-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
@media (max-width: 640px) {
  .welcome-template-cards {
    grid-template-columns: 1fr;
  }
}
.welcome-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.welcome-card .welcome-card-cta {
  margin-top: auto;
}
.example-template-btn-home {
  border-style: dashed;
  background: rgba(15, 118, 110, 0.04);
  opacity: 0.72;
  transition: var(--transition, 0.15s ease);
}
.example-template-btn-home:disabled {
  cursor: default;
  opacity: 0.55;
}
/* 进入项目/示例后：高亮「返回首页引导」，避免用户注意不到 */
.example-template-btn-home.is-active {
  opacity: 1;
  border-style: solid;
  border-color: #0f766e;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.16), rgba(13, 148, 136, 0.12));
  box-shadow: 0 2px 10px rgba(15, 118, 110, 0.2);
}
.example-template-btn-home.is-active .example-template-name {
  color: #0f766e;
  font-weight: 700;
}
.example-template-btn-home.is-active .example-template-hint {
  color: #0f766e;
  opacity: 0.9;
}
.example-template-btn-home.is-active:hover {
  filter: brightness(1.03);
}
.welcome-card-full {
  border-color: rgba(15, 118, 110, 0.35);
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.06), var(--bg-card));
}
.welcome-card-tour_full {
  border-color: rgba(3, 105, 161, 0.3);
}
.welcome-card-draft {
  border-color: rgba(180, 83, 9, 0.28);
}
.welcome-card-blank {
  border-style: dashed;
}
.welcome-card-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #0f766e;
  background: rgba(15, 118, 110, 0.1);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.welcome-card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text-primary);
  line-height: 1.35;
}
.welcome-card-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 12px;
}
.welcome-card-cta {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #0f766e, #0d9488);
  color: #fff;
}
.welcome-card-cta:hover { filter: brightness(1.05); }
.welcome-card-cta:disabled { opacity: 0.6; cursor: wait; }
.welcome-card-cta-blank {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.welcome-or-hint {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* 任务 6.3：轻 Agent 开关 + 说明 + Enter 提示（同一水平线） */
.agent-mode-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 10px;
  padding: 0 2px;
  margin-top: var(--col-footer-hint-mt);
  min-height: var(--col-footer-hint-lh);
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.agent-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  line-height: var(--col-footer-hint-lh);
}
.agent-mode-toggle input {
  width: 14px;
  height: 14px;
  accent-color: #0f766e;
  flex-shrink: 0;
}
.agent-mode-hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: var(--col-footer-hint-lh);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-trail {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  background: rgba(15, 118, 110, 0.06);
  font-size: 12.5px;
}
.agent-trail-title {
  font-weight: 700;
  color: #0f766e;
  margin-bottom: 6px;
  font-size: 12px;
}
.agent-trail-steps {
  margin: 0;
  padding-left: 1.2em;
  list-style: none;
}
.agent-step {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin: 4px 0;
  line-height: 1.4;
  color: var(--text-secondary);
}
.agent-step-mark {
  font-weight: 700;
  min-width: 1em;
  color: #0f766e;
}
.agent-step-running .agent-step-mark { color: #0369a1; }
.agent-step-failed .agent-step-mark { color: #b91c1c; }
.agent-step-skipped .agent-step-mark { color: #a3a3a3; }
.agent-step-label { font-weight: 600; color: var(--text-primary); }
.agent-step-detail {
  flex: 1 1 100%;
  padding-left: 1.4em;
  font-size: 11.5px;
  color: var(--text-muted);
}
.agent-status-line {
  margin-top: 6px;
  font-size: 12.5px;
  color: #0f766e;
  font-weight: 600;
}
.agent-conclusion {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

/* Sidebar Footer — 与中/右底栏同高 */
/* 试用额度便签（侧栏底部上方空位） */
.guest-quota-banner {
  flex-shrink: 0;
  margin: 0 12px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(180, 83, 9, 0.45);
  background: rgba(255, 247, 237, 0.95);
  color: #9a3412;
  font-size: 12px;
  line-height: 1.45;
}
.guest-quota-banner.is-error {
  border-style: solid;
  border-color: rgba(220, 38, 38, 0.4);
  background: rgba(254, 242, 242, 0.98);
  color: #991b1b;
}
.guest-quota-banner-title {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 4px;
}
.guest-quota-banner-body {
  opacity: 0.95;
  word-break: break-word;
  white-space: pre-wrap;
}
.guest-quota-banner-btn {
  margin-top: 8px;
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #ea580c;
  color: #fff;
}
.guest-quota-banner-btn:hover { filter: brightness(1.05); }
.guest-quota-banner.is-error .guest-quota-banner-btn {
  background: #dc2626;
}

.sidebar-footer {
  box-sizing: border-box;
  height: var(--col-footer-height);
  min-height: var(--col-footer-height);
  max-height: var(--col-footer-height);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: var(--col-footer-pad-top) 12px var(--col-footer-pad-bottom);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
}
.user-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 2px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.user-zone:hover { background: var(--bg-hover); }
.user-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.user-avatar {
  width: 30px; height: 30px; min-width: 30px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.25;
}
.user-level {
  font-size: 12px;
  color: var(--warning);
  font-weight: 600;
  line-height: 1.25;
}
.user-points {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
}
.sidebar-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 10px;
  margin-top: 0;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1.2;
  width: 100%;
  text-align: center;
}
.sidebar-link {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.sidebar-link:hover { color: var(--text-secondary); }
.link-logout { color: var(--danger); }

/* ---- Main Area ---- */
.main-area {
  flex: 1; display: flex; flex-direction: column;
  min-width: 320px;
  max-width: 100%;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* Chat Header */
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.btn-toggle-sidebar {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.btn-toggle-sidebar:hover { background: var(--bg-hover); color: var(--text-primary); }
.chat-header-info { flex: 1; min-width: 0; }
.project-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  width: 100%;
}
.project-title {
  font-size: 16px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin: 0;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 55%;
}
/* 标题右侧进度提示：弱样式文字，避免被当成可点按钮 */
.project-phase-hint {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  cursor: help;
}
.project-phase-hint::before {
  content: "进度：";
  font-weight: 400;
  color: #8a8aa8;
}
/* 生成中：更大更醒目；绿框仅包裹文字，不向左拉满到项目名 */
.project-phase-hint.is-generating {
  flex: 0 1 auto;
  width: fit-content;
  max-width: min(100%, 22em);
  margin-left: auto;
  color: #0f766e;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.12);
  border: 1px solid rgba(15, 118, 110, 0.28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-phase-hint.is-generating::before {
  content: "生成中 · ";
  color: #0f766e;
  font-weight: 700;
  font-size: 15px;
}

.btn-toggle-preview {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  transition: var(--transition);
}
.btn-toggle-preview:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-toggle-preview.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* Chat Messages */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column;
  gap: 16px;
}

.welcome-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 10px;
  color: var(--text-secondary); text-align: center;
}
.welcome-icon { margin-bottom: 8px; color: var(--accent); }
.welcome-screen h3 {
  font-size: 28px; color: var(--text-primary); font-weight: 700;
  line-height: 1.4;
}
.welcome-screen p {
  font-size: 17px; line-height: 1.7; color: var(--text-secondary);
}

/* Message Bubbles */
.message { display: flex; gap: 10px; max-width: 85%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.assistant { align-self: flex-start; }

.msg-avatar {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.message.user .msg-avatar { background: var(--accent); color: #fff; }
.message.assistant .msg-avatar { background: var(--bg-card); color: var(--accent); border: 1px solid var(--border); }

.msg-body {
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 14.5px;
  color: var(--text-primary);
}
.message.user .msg-body {
  background: var(--user-msg-bg);
  border-bottom-right-radius: 4px;
}
.message.assistant .msg-body {
  background: var(--ai-msg-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Markdown content inside message bubbles */
.msg-body h2 { font-size: 16px; margin: 12px 0 6px; color: var(--text-primary); }
.msg-body h3 { font-size: 14px; margin: 10px 0 4px; color: var(--text-primary); }
.msg-body p { margin: 4px 0; }
.msg-body ul, .msg-body ol { padding-left: 20px; margin: 4px 0; }
.msg-body li { margin: 2px 0; }
.msg-body code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.msg-body pre { background: rgba(0,0,0,0.05); padding: 10px; border-radius: 6px; overflow-x: auto; margin: 8px 0; font-size: 12px; }
.msg-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; margin: 6px 0; color: var(--text-secondary); }
.msg-body strong { color: var(--text-primary); font-weight: 700; }

/* Typing Indicator */
.typing-indicator { display: flex; gap: 4px; padding: 5px 0; }
.typing-indicator span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.4s ease-in-out infinite both;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- Input Area（与左/右底栏同高） ---- */
.chat-input-area {
  box-sizing: border-box;
  height: var(--col-footer-height);
  min-height: var(--col-footer-height);
  max-height: var(--col-footer-height);
  display: flex;
  flex-direction: column;
  /* 略偏下：上边距稍大，避免输入框视觉上贴顶 */
  justify-content: flex-start;
  padding: 12px 20px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
  position: relative;
  z-index: 5;
  max-width: 100%;
  overflow: hidden;
}
/* 引用/改写模式：需露出引用条与取消按钮，允许底栏略增高 */
.chat-input-area.has-citation {
  height: auto;
  max-height: none;
  min-height: var(--col-footer-height);
  overflow: visible;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 8px;
}

/* 引用条：在输入框上方正常占位（勿 absolute+overflow 裁切，否则无法点 × 取消） */
.citation-bar {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  display: none;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  margin: 0;
  background: var(--accent-dim, rgba(61, 109, 245, 0.08));
  color: var(--accent);
  border-radius: var(--radius-sm, 6px);
  font-size: 12px;
  border: 1px solid var(--accent);
  z-index: 6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}
.citation-bar[data-mode="spec_rewrite"] {
  border-color: rgba(180, 83, 9, 0.45);
  background: rgba(180, 83, 9, 0.08);
  color: #b45309;
}
.citation-label {
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
  padding-top: 1px;
}
.citation-text {
  flex: 1;
  min-width: 0;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  line-height: 1.4;
  max-height: 2.8em;
  opacity: 0.9;
  font-size: 12px;
  word-break: break-word;
}
.btn-citation-clear {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0.75;
}
.btn-citation-clear:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 100%;
  flex-shrink: 0;
  min-height: var(--col-footer-control-h);
}
.chat-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: none;
  height: var(--col-footer-control-h);
  min-height: var(--col-footer-control-h);
  max-height: var(--col-footer-control-h);
  line-height: 1.35;
  font-size: 13px;
  transition: var(--transition);
  overflow-y: auto;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61,109,245,0.08); }
.chat-input::placeholder { color: #8b8b9e; }

.btn-send {
  width: var(--col-footer-control-h);
  height: var(--col-footer-control-h);
  min-width: var(--col-footer-control-h);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  border-radius: var(--radius);
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint {
  font-size: 12px;
  line-height: var(--col-footer-hint-lh);
  color: var(--text-muted);
  margin: 0 0 0 auto;
  min-height: var(--col-footer-hint-lh);
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ---- Chat Header Module Indicators (tag pills) ---- */
.chat-module-indicators {
  display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap;
}
.cmi-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: 11px; font-weight: 500;
  line-height: 1.5;
  border-radius: 10px;
  background: #e8eaf2;
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
}
.cmi-tag.filled {
  background: var(--accent-dim); color: var(--accent); font-weight: 600;
}
.cmi-tag.blinking {
  animation: tagBlink 0.5s ease-in-out 3;
}
@keyframes tagBlink {
  0%, 100% { background: #d6f0e2; color: #217a4a; border-color: #a3dcba; }
  50% { background: #3ab870; color: #fff; border-color: #3ab870; }
}

/* ---- Preview Module Indicators (tag pills) ---- */
.preview-module-indicators {
  display: flex; gap: 3px; padding: 8px 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.pmi-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: 11px; font-weight: 500;
  line-height: 1.5;
  border-radius: 10px;
  background: #e8eaf2;
  color: var(--text-secondary);
  transition: var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
}
.pmi-tag.filled {
  background: #d6f0e2;
  color: #217a4a;
  border-color: #a3dcba;
}
.pmi-tag.blink {
  animation: tagBlink 0.5s ease-in-out 3;
}
.pmi-tag:hover {
  background: #d8dce8;
  color: var(--text-secondary);
}
.pmi-tag.filled:hover {
  background: #bfe8cf;
  color: #1a5f3a;
}

/* ---- Preview Panel ---- */
.preview-panel {
  width: 0; min-width: 0;
  background: var(--bg-preview);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width 0.3s ease, min-width 0.3s ease;
  overflow: hidden;
  position: relative;
  padding-bottom: 0;
}
.preview-panel.open { width: 460px; min-width: 380px; }

.preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.preview-header h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.preview-actions { display: flex; gap: 4px; align-items: center; }
.btn-preview-action {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: none;
  cursor: pointer;
  padding: 0;
}
.btn-preview-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-preview-action.is-ok { color: var(--success, #2ea55e); }

/* 任务 3.4：下载下拉 */
.export-dropdown {
  position: relative;
  display: inline-flex;
}
.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 168px;
  padding: 6px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.export-menu[hidden] {
  display: none !important;
}
.export-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.export-menu-item:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.05));
  color: var(--accent, #3b82f6);
}

/* 任务 5.1：PRD / 质量评估 Tab */
.preview-view-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.preview-view-tab {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
}
.preview-view-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.preview-view-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- Vertical Preview Content ---- */
.preview-content {
  flex: 1; overflow-y: auto; padding: 20px;
  line-height: 1.7;
  color: var(--text-primary);
  min-height: 0;
}
.preview-empty {
  font-size: 14px; color: var(--text-muted); text-align: center;
  padding-top: 60px;
}
.preview-quality-body {
  font-size: 14px;
  line-height: 1.65;
}
.quality-agenda-actions {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}
.quality-agenda-micro {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-line;
}
.quality-agenda-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-quality-agenda-start,
.btn-quality-strengthen,
.btn-quality-agenda-exit {
  flex: 1 1 calc(50% - 4px);
  min-width: 140px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.35;
  white-space: normal;
}
.btn-quality-agenda-start {
  background: #0f766e;
  color: #fff;
}
.btn-quality-agenda-start:hover { filter: brightness(1.05); }
.btn-quality-strengthen {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  color: #fff;
}
.btn-quality-strengthen:hover { filter: brightness(1.05); }
.btn-quality-strengthen:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-quality-agenda-exit {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-quality-agenda-exit:hover { background: var(--bg-primary); }
.quality-filled-actions,
.quality-gap-actions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quality-section-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 4px 0 2px;
}
.quality-filled-actions .gap-action-row,
.quality-gap-actions .gap-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
}
.quality-filled-actions .gap-action-row button,
.quality-gap-actions .gap-action-row button {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: auto;
}
.quality-filled-actions .gap-action-row button:hover,
.quality-gap-actions .gap-action-row button:hover {
  border-color: var(--accent);
}
/* 预览正文恢复列表符号（全局 ul 被重置） */
.prd-module-section ul,
.preview-quality-body ul,
.preview-content ul {
  list-style: disc;
  padding-left: 1.4em;
  margin: 6px 0;
}
.prd-module-section ol,
.preview-quality-body ol,
.preview-content ol {
  list-style: decimal;
  padding-left: 1.4em;
  margin: 6px 0;
}
.prd-module-section li,
.preview-quality-body li,
.preview-content li {
  margin: 3px 0;
  display: list-item;
}
.quality-agenda-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
  border-bottom: 1px solid rgba(15, 118, 110, 0.2);
}
.quality-agenda-banner.is-on { display: flex; }
.quality-agenda-banner button {
  border: none;
  background: transparent;
  color: #0f766e;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.preview-quality-body h1 {
  font-size: 18px;
  margin: 0 0 12px;
}
.preview-quality-body h2 {
  font-size: 15px;
  margin: 18px 0 8px;
  color: var(--text-primary);
}
.preview-quality-body h3 {
  font-size: 14px;
  margin: 12px 0 4px;
}
.preview-quality-body p,
.preview-quality-body li {
  color: var(--text-secondary);
}
.preview-quality-body ul {
  padding-left: 1.2em;
  margin: 6px 0;
}
.btn-quality-eval {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: #0f766e;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-quality-eval:hover { filter: brightness(1.06); }
.btn-quality-eval:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
/* 竖版PRD模块区块 */
#preview-modules-container {
  display: flex; flex-direction: column; gap: 20px;
  padding: 4px 0;
}
.prd-module-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-card);
  transition: all 0.3s ease;
}
.prd-module-section .module-section-title {
  font-size: 15px; font-weight: 700; color: var(--accent);
  margin-bottom: 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.prd-module-section.blink-section {
  animation: sectionBlink 0.6s ease-in-out 3;
}
@keyframes sectionBlink {
  0%, 100% { border-color: var(--border); box-shadow: none; }
  50% { border-color: var(--success); box-shadow: 0 0 18px rgba(58,184,112,0.35); }
}

/* ---- 任务 6.1 Mermaid 流程图 ---- */
.mermaid-wrap {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
  overflow-x: auto;
}
.mermaid-label {
  font-size: 11px;
  font-weight: 700;
  color: #0f766e;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.mermaid-wrap pre.mermaid {
  margin: 0;
  background: transparent;
  border: none;
  text-align: center;
}
.mermaid-wrap pre.mermaid-error {
  color: #b45309;
  font-size: 12px;
  white-space: pre-wrap;
  text-align: left;
}
.mermaid-wrap svg {
  max-width: 100%;
  height: auto;
}

/* ---- AI 推测标注 ---- */
.spec-block {
  margin: 10px 0;
  padding: 10px 12px 8px;
  border-radius: var(--radius);
  border: 1px dashed #e0a84a;
  background: #fff9ef;
  position: relative;
}
.spec-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.spec-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #a66a00;
  background: #ffe6b8;
  border: 1px solid #f0c878;
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}
.spec-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-spec-confirm,
.btn-spec-rewrite {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.btn-spec-confirm {
  border-color: rgba(58, 184, 112, 0.45);
  color: #1f8a4c;
  background: #eefaf3;
}
.btn-spec-confirm:hover {
  background: #d9f5e6;
}
.btn-spec-rewrite {
  border-color: rgba(61, 109, 245, 0.35);
  color: var(--accent);
  background: #f3f6ff;
}
.btn-spec-rewrite:hover {
  background: var(--accent-dim);
}
.spec-body { min-width: 0; }
/* 聊天气泡内联推测 */
.message .spec-inline,
.msg-body .spec-inline {
  background: #fff3d6;
  border-bottom: 1px dashed #d4a017;
  padding: 0 2px;
  border-radius: 2px;
}
/* 流式输出中的 AI 气泡 */
.message.assistant.streaming .msg-body {
  min-height: 1.5em;
}
.message.assistant.streaming .msg-body::after {
  content: "▍
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: streamCaret 0.9s step-end infinite;
}
@keyframes streamCaret {
  50% { opacity: 0; }
}

/* 可引用块：p / li / 标题 / 表格单元等 */
.prd-module-section .prd-paragraph {
  position: relative;
  padding: 4px 28px 4px 8px;
  margin: 6px -8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.prd-module-section li.prd-paragraph {
  margin-left: 0;
  list-style-position: outside;
}
.prd-module-section .prd-paragraph:hover { background: var(--bg-hover); }
.prd-module-section .prd-paragraph .cite-btn {
  display: none;
  position: absolute;
  right: 4px;
  top: 4px;
  z-index: 2;
  width: 26px;
  height: 26px;
  padding: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: var(--transition);
  cursor: pointer;
  border: none;
}
.prd-module-section .prd-paragraph:hover .cite-btn,
.prd-module-section .prd-paragraph:focus-within .cite-btn {
  display: flex;
}
.prd-module-section .prd-paragraph .cite-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
}

/* Preview Markdown styling */
.preview-content h2 {
  font-size: 18px; margin: 18px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border); color: var(--text-primary);
}
.preview-content h3 { font-size: 15px; margin: 14px 0 6px; color: var(--text-primary); }
.preview-content p { margin: 6px 0; }
.preview-content ul, .preview-content ol { padding-left: 22px; margin: 4px 0; }
.preview-content li { margin: 3px 0; }
.preview-content code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.preview-content pre { background: rgba(0,0,0,0.05); padding: 10px; border-radius: 6px; overflow-x: auto; margin: 8px 0; font-size: 12px; }
.preview-content blockquote { border-left: 3px solid var(--accent); padding-left: 12px; margin: 8px 0; color: var(--text-secondary); }
.preview-content strong { color: var(--accent); }
.preview-content table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 12px; }
.preview-content th, .preview-content td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
}
.preview-content th { background: var(--bg-secondary); }

/* 预览底栏 — 结构对齐中栏：上行控件 = 发送键中点；下行 = input-hint */
.preview-footer-bar {
  box-sizing: border-box;
  height: var(--col-footer-height);
  min-height: var(--col-footer-height);
  max-height: var(--col-footer-height);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--col-footer-pad-top) 12px var(--col-footer-pad-bottom);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  z-index: 2;
  overflow: hidden;
}
.preview-footer-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
}
.btn-optimize-all,
.btn-quality-eval {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  margin: 0;
  height: var(--col-footer-control-h);
  min-height: var(--col-footer-control-h);
  max-height: var(--col-footer-control-h);
  padding: 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: var(--transition);
  border: none;
  cursor: pointer;
  color: #fff;
  white-space: nowrap;
}
.btn-optimize-all {
  background: linear-gradient(135deg, var(--success), #2ea55e);
  box-shadow: 0 2px 10px rgba(46, 165, 94, 0.22);
}
.btn-quality-eval {
  background: linear-gradient(135deg, #0f766e, #0d9488);
  box-shadow: 0 2px 10px rgba(15, 118, 110, 0.22);
}
.btn-optimize-all:hover,
.btn-quality-eval:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-optimize-all:disabled,
.btn-quality-eval:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---- 任务 3.1：外部检索条（消息区与输入区之间） ---- */
.research-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 6px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary, var(--bg-card));
  min-height: 0;
}
.btn-research {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--accent, #3b82f6);
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition, 0.15s ease);
  white-space: nowrap;
}
.btn-research:hover {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.45);
}
.btn-research:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-research.active {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.1);
  border-color: rgba(15, 118, 110, 0.35);
}
.btn-research-clear {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  background: transparent;
  border: 1px dashed var(--border, #e5e7eb);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition, 0.15s ease);
}
.btn-research-clear:hover {
  color: var(--danger, #dc2626);
  border-color: rgba(220, 38, 38, 0.4);
}
.btn-research-clear:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-research-clear.is-restore {
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.4);
  border-style: solid;
  background: rgba(15, 118, 110, 0.08);
  font-weight: 600;
}
.btn-research-clear.is-restore:hover {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.14);
  border-color: rgba(15, 118, 110, 0.55);
}

/* ---- 任务 3.2：上传参考材料 ---- */
.materials-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}
.btn-upload-materials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.28);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition, 0.15s ease);
  white-space: nowrap;
}
.btn-upload-materials:hover {
  background: rgba(124, 58, 237, 0.14);
  border-color: rgba(124, 58, 237, 0.45);
}
.btn-upload-materials.is-busy {
  opacity: 0.55;
  pointer-events: none;
}
.materials-status {
  font-size: 12px;
  color: #6d28d9;
  line-height: 1.35;
}
.materials-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-top: 2px;
}
.material-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 8px 3px 10px;
  font-size: 11px;
  color: var(--text-secondary, #4b5563);
  background: rgba(124, 58, 237, 0.06);
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 999px;
}
.material-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.material-chip-meta {
  color: var(--text-muted, #8b8b9e);
  flex-shrink: 0;
}
.btn-material-del {
  border: none;
  background: transparent;
  color: var(--text-muted, #8b8b9e);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.btn-material-del:hover {
  color: var(--danger, #dc2626);
}
.research-status {
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  line-height: 1.35;
  flex: 1 1 auto;
  min-width: 120px;
}
.research-status.has-data {
  color: #0f766e;
}

/* 对话内检索卡片 */
.message.research-msg {
  max-width: 92%;
}
.message.research-msg .msg-body {
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 12px;
  max-width: 100%;
}
.research-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.research-card-head strong {
  font-size: 14px;
  color: var(--text-primary);
}
.research-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.4;
}
.research-badge.active {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.12);
}
.research-badge.idle {
  color: var(--text-secondary, #6b7280);
  background: rgba(107, 114, 128, 0.12);
}
.research-query {
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 10px;
}
.research-source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.research-source-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary, rgba(0, 0, 0, 0.02));
}
.research-source-item.is-disabled {
  opacity: 0.55;
}
.research-source-main {
  flex: 1 1 auto;
  min-width: 0;
}
.research-source-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}
.research-source-snip {
  font-size: 12px;
  color: var(--text-secondary, #6b7280);
  line-height: 1.45;
  margin-bottom: 4px;
}
.research-source-url {
  font-size: 11px;
  color: var(--accent, #3b82f6);
  word-break: break-all;
  text-decoration: none;
}
.research-source-url:hover {
  text-decoration: underline;
}
.research-source-toggles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.btn-src-toggle {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary, #6b7280);
  cursor: pointer;
  line-height: 1.3;
  white-space: nowrap;
}
.btn-src-toggle:hover {
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--accent, #3b82f6);
}
.btn-src-toggle.active {
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.4);
  background: rgba(15, 118, 110, 0.1);
  font-weight: 600;
}
.btn-src-toggle.active.off {
  color: #b45309;
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(180, 83, 9, 0.08);
}
.research-card-footer {
  font-size: 12.5px;
  color: var(--text-secondary, #4b5563);
  line-height: 1.5;
}
.research-card-footer p {
  margin: 0 0 6px;
}
.research-usage-sub {
  font-size: 12px;
  color: var(--text-muted, #8b8b9e);
}
.research-next-hint {
  margin-top: 8px !important;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-primary);
  font-weight: 500;
}
.research-card-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-research-restore {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
  cursor: pointer;
}
.btn-research-restore:hover {
  background: rgba(15, 118, 110, 0.16);
}
.btn-research-deactivate {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(180, 83, 9, 0.4);
  background: rgba(180, 83, 9, 0.08);
  color: #b45309;
  cursor: pointer;
}
.btn-research-deactivate:hover {
  background: rgba(180, 83, 9, 0.14);
}
.btn-src-toggle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* 说明行：对齐中栏 .input-hint（「按 Enter 发送」） */
.preview-footer-hint {
  font-size: 11px;
  line-height: var(--col-footer-hint-lh);
  margin-top: var(--col-footer-hint-mt);
  min-height: var(--col-footer-hint-lh);
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  padding: 0 2px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.modal-card {
  width: 420px; max-width: 90vw;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 28px 30px;
  box-shadow: var(--shadow);
}
.modal-card h3 { font-size: 16px; margin-bottom: 20px; color: var(--text-primary); }
.modal-card .form-group { margin-bottom: 20px; }
.modal-card label {
  display: block; font-size: 12px; color: var(--text-secondary);
  margin-bottom: 6px; font-weight: 500;
}
.modal-card input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px;
}
.modal-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61,109,245,0.08); }

.modal-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header-row h3 { margin-bottom: 0; }
.modal-close-x {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-muted);
  font-size: 18px; border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
  border: none; outline: none;
}
.modal-close-x:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-primary {
  padding: 8px 20px;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600;
  border-radius: var(--radius);
  transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary {
  padding: 8px 20px;
  background: var(--bg-hover); color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius);
  transition: var(--transition);
}
.btn-secondary:hover { background: #d0d4e0; color: var(--text-primary); }

/* Rename / delete buttons in project list */
.project-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}
.btn-rename-project,
.btn-delete-project {
  width: 26px; height: 26px; min-width: 26px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: var(--transition); border: none; outline: none;
  opacity: 0;
}
.project-item:hover .btn-rename-project,
.project-item:hover .btn-delete-project { opacity: 1; }
.project-item.active .btn-rename-project,
.project-item.active .btn-delete-project { color: rgba(255,255,255,0.75); opacity: 1; }
.project-item.active .btn-rename-project:hover,
.project-item.active .btn-delete-project:hover { color: #fff; background: rgba(255,255,255,0.15); }
.btn-rename-project:hover { background: var(--bg-hover); color: var(--accent); }
.btn-delete-project:hover { background: rgba(220, 38, 38, 0.12); color: #dc2626; }
.project-item.active .btn-delete-project:hover { background: rgba(255,255,255,0.18); color: #fff; }

/* Delete confirm modal */
.modal-card-danger h3 { color: #b91c1c; }
.modal-delete-message {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
  margin: 0 0 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.modal-delete-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 18px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  word-break: break-word;
}
.btn-danger {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: #dc2626;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- 个人主页 ---- */
.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
}
.profile-panel {
  width: min(420px, 100vw);
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  animation: profile-slide-in 0.2s ease-out;
}
@keyframes profile-slide-in {
  from { transform: translateX(12px); opacity: 0.85; }
  to { transform: translateX(0); opacity: 1; }
}
.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.profile-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.profile-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 14px 0;
  flex-shrink: 0;
}
.profile-tab {
  flex: 1;
  padding: 8px 10px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.profile-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.profile-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: transparent;
}
.profile-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 28px;
}
.profile-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.profile-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}
.profile-dl { margin: 0; }
.profile-dl-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.profile-dl-row:last-of-type { border-bottom: none; }
.profile-dl-row dt {
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}
.profile-dl-row dd {
  margin: 0;
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}
.profile-hint {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}
.profile-points-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.profile-points-summary > div:last-child {
  grid-column: 1 / -1;
}
.profile-points-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.profile-points-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.profile-points-level {
  font-size: 16px;
  font-weight: 700;
  color: var(--warning);
}
.profile-points-checkin {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.profile-subhead {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 16px 0 8px;
}
.profile-rules-list,
.profile-levels-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-rules-list li,
.profile-levels-list li {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12.5px;
  line-height: 1.45;
}
.profile-rule-title {
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.profile-rule-pts {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}
.profile-rule-desc {
  color: var(--text-secondary);
}
.profile-level-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  color: var(--text-primary);
}
.profile-level-row span:last-child {
  color: var(--text-muted);
  font-weight: 500;
}
.profile-level-row.is-current {
  color: var(--accent);
}
.profile-level-row.is-current span:last-child {
  color: var(--accent);
}

/* ---- 任务 4.5：设置 / 隐私 / 协议 ---- */
.legal-overlay {
  position: fixed;
  inset: 0;
  z-index: 520;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.legal-panel {
  width: min(560px, 100%);
  max-height: min(88vh, 720px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: legal-fade-in 0.18s ease-out;
}
@keyframes legal-fade-in {
  from { opacity: 0.85; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.legal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.legal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.legal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 22px;
}
.legal-doc {
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.65;
}
.legal-lead {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
}
.legal-doc h3 {
  margin: 16px 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.legal-doc ul {
  margin: 0 0 8px;
  padding-left: 1.25em;
}
.legal-doc li {
  margin: 0 0 6px;
  color: var(--text-secondary);
}
.legal-doc li strong {
  color: var(--text-primary);
  font-weight: 600;
}
.legal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}
.btn-legal-link {
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-legal-link:hover {
  border-color: var(--accent);
  background: var(--accent-dim, rgba(61, 109, 245, 0.08));
}
.legal-meta {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8cdd8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a8b8; }

/* ---- Site Footer ---- */
.site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  z-index: 300;
  font-size: 11px;
  color: var(--text-secondary);
}
.site-footer strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* Bottom padding for footer */


/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar { width: 220px; min-width: 220px; }
  .preview-panel.open { width: 100%; min-width: 100%; position: fixed; right: 0; top: 0; bottom: 0; z-index: 100; }
}
@media (max-width: 640px) {
  .sidebar { width: 0; min-width: 0; border: none; }
  .sidebar.mobile-open { width: 260px; min-width: 260px; position: fixed; left: 0; top: 0; bottom: 0; z-index: 200; border-right: 1px solid var(--border); }
  .chat-messages { padding: 12px; }
  .message { max-width: 95%; }
}
