:root {
  /* 默认浅色（用户选择"保持当前浅色"）。深色由 prefers-color-scheme: dark 覆盖。 */
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #4f7cff;
  --accent-2: #2fbf71;
  --warn: #e08a1e;
  --red: #e0533d;
  --blue: #3b82f6;
  --border: #e3e6ea;
  --radius: 12px;
  --sidebar-bg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #181b22;
    --panel-2: #20242d;
    --text: #e7e9ee;
    --muted: #9aa0aa;
    --border: #2a2f3a;
    --sidebar-bg: #14171d;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }

.muted { color: var(--muted); font-size: 13px; }
.warn { color: var(--warn); }
code {
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
}
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ====== 登录页 ====== */
.login-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card form { text-align: left; margin-top: 18px; }

/* ====== 主布局：侧栏 + 内容 ====== */
.portal-layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 0 18px 14px;
  font-weight: 700;
  font-size: 17px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--text);
}
.sidebar .user-info { padding: 0 18px 12px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.sidebar .user-name { font-weight: 600; font-size: 14px; }
.sidebar .user-email { font-size: 12px; color: var(--muted); }
.channel-select {
  margin: 0 14px 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.nav { display: flex; flex-direction: column; flex: 1; }
.nav a {
  padding: 10px 18px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--accent); border-left-color: var(--accent); }
.nav a.logout { margin-top: auto; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.nav a.logout:hover { color: var(--red); }

.content { flex: 1; padding: 26px 30px; overflow-y: auto; }
.content h2 { margin: 0 0 18px; font-size: 21px; }
.content h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); }

/* ====== 统计卡片 ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--accent); }
.stat-card .lbl { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ====== 图表卡片 ====== */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.chart-card h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.chart-card canvas { max-height: 240px; }

/* ====== 标签云 ====== */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  background: var(--panel-2);
  padding: 3px 11px;
  border-radius: 14px;
  font-size: 13px;
}

/* ====== 卡片通用 ====== */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 13px;
}
.panel.clickable { cursor: pointer; }
.panel.clickable:hover { border-color: var(--accent); }
.panel-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.badge {
  background: var(--panel-2);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}
.badge.imp { background: rgba(47,191,113,0.15); color: var(--accent-2); }
.badge.kt { background: rgba(79,124,255,0.15); color: var(--accent); }

/* ====== 金句卡 ====== */
.quote-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warn);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 13px;
}
.quote-stars { color: var(--warn); font-size: 14px; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.quote-source { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.quote-text { font-size: 16px; line-height: 1.7; }

/* ====== 筛选栏 ====== */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input, .search-bar input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.filter-bar input, .search-bar input { flex: 1; min-width: 180px; }
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; }

/* ====== 生成表单 ====== */
.gen-form { max-width: 640px; }
.gen-form label { display: block; margin-bottom: 14px; font-size: 14px; }
.gen-form input, .gen-form textarea, .gen-form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.gen-form textarea { min-height: 90px; resize: vertical; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ====== 结果 pre（大纲/复用/脚本等长文本） ====== */
.result-pre {
  background: var(--panel-2);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.7;
  max-height: 560px;
  overflow-y: auto;
  font-family: inherit;
}

/* ====== 任务状态徽标 ====== */
.job-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
}
.job-status.running { background: rgba(224,138,30,0.15); color: var(--warn); }
.job-status.done { background: rgba(47,191,113,0.15); color: var(--accent-2); }
.job-status.failed { background: rgba(224,83,61,0.15); color: var(--red); }
.spinner {
  width: 13px; height: 13px; border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== 矛盾 / 草稿检测结论条 ====== */
.verdict { padding: 14px 18px; border-radius: 8px; font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.verdict.ok { background: rgba(47,191,113,0.12); border-left: 4px solid var(--accent-2); color: var(--accent-2); }
.verdict.warn { background: rgba(224,138,30,0.12); border-left: 4px solid var(--warn); color: var(--warn); }
.verdict.bad { background: rgba(224,83,61,0.12); border-left: 4px solid var(--red); color: var(--red); }
.summary-row { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 0; font-size: 14px; color: var(--muted); }
.summary-row strong { color: var(--text); }

/* 矛盾/草稿卡片（类型色块） */
.finding-card { margin-top: 11px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.finding-card .q { margin: 8px 0; padding: 9px 12px; background: var(--panel-2); border-left: 3px solid var(--border); border-radius: 4px; color: var(--muted); font-size: 13px; font-style: italic; white-space: pre-wrap; word-break: break-word; }
.finding-card .reason { font-size: 13.5px; line-height: 1.7; }
.finding-card .fix { margin-top: 8px; font-size: 13.5px; color: var(--blue); line-height: 1.7; }
.type-pill { padding: 2px 9px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.type-pill.red { background: rgba(224,83,61,0.15); color: var(--red); }
.type-pill.orange { background: rgba(224,138,30,0.15); color: var(--warn); }
.type-pill.yellow { background: rgba(226,196,30,0.18); color: #b7900f; }
.type-pill.green { background: rgba(47,191,113,0.15); color: var(--accent-2); }

/* ====== 爆款 Hook 卡 ====== */
.hook-card { border-left: 4px solid var(--warn); }
.hook-card .hook-title { font-size: 16px; font-weight: 600; line-height: 1.5; margin-bottom: 7px; }
.hook-card .hook-why { font-size: 13px; line-height: 1.7; color: var(--muted); }

/* ====== 系列企划 ====== */
.series-ep { border: 1px solid var(--border); border-radius: 10px; padding: 15px 17px; margin-bottom: 12px; background: var(--panel); }
.series-ep:hover { border-color: var(--accent); }
.series-ep .ep-num { font-size: 12px; color: var(--accent-2); font-weight: 600; margin-bottom: 4px; }
.series-ep .ep-title { font-size: 16px; font-weight: 600; margin-bottom: 7px; }
.series-ep .field { font-size: 13px; color: var(--muted); line-height: 1.7; }

/* ====== 信念网络容器 ====== */
#belief-graph-canvas { width: 100%; height: 600px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }

/* ====== 页脚 ====== */
.footer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 9px 20px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.empty-hint { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

@media (max-width: 768px) {
  .portal-layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { border-left: none; border-bottom: 3px solid transparent; padding: 8px 12px; }
  .nav a.active { border-bottom-color: var(--accent); }
  .nav a.logout { margin-top: 0; border-top: 0; }
  .content { padding: 18px; }
}
