/* ============================================================
   人文故事选题研究台 · 样式
   设计: 现代内容编辑部 + Notion + 卡片数据库
   气质: 简洁、人文、阅读舒适、不过度商务、无廉价AI风
   ============================================================ */

:root {
  --bg: #faf8f4;
  --bg-soft: #f4f1ea;
  --card: #ffffff;
  --border: #e8e3da;
  --border-strong: #d8d1c4;
  --text: #2b2a26;
  --text-soft: #6b665c;
  --text-faint: #9a9488;
  --accent: #8a6d3b;        /* 温暖的赭石色，人文气质 */
  --accent-deep: #6f5730;
  --accent-soft: #f0e8db;
  --red: #b5452e;
  --green: #4a7c59;
  --amber: #c98a2b;
  --shadow: 0 1px 3px rgba(60, 50, 30, 0.06), 0 4px 14px rgba(60, 50, 30, 0.05);
  --shadow-lg: 0 8px 30px rgba(60, 50, 30, 0.12);
  --radius: 10px;
  --radius-sm: 7px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", -apple-system, "Segoe UI", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", Georgia, serif;
}

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

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

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

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s ease;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-ghost {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text-soft);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.danger { color: var(--red); border-color: #e5c4bb; }
.danger:hover { background: #fbecea; border-color: var(--red); color: var(--red); }

.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg-soft); }

/* ---------- 输入 ---------- */
.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
  transition: border .15s, box-shadow .15s;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select {
  width: auto;
  min-width: 110px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b665c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
textarea.input { resize: vertical; min-height: 80px; }
.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin: 12px 0 4px;
  font-weight: 500;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f7f4ee 0%, #efe9dd 100%);
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-mark { font-size: 44px; margin-bottom: 8px; }
.login-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text);
}
.login-sub { font-size: 13px; color: var(--text-faint); margin: 8px 0 24px; }
.login-form { text-align: left; }
.login-form .field-label { text-align: left; }
.login-form .input { text-align: left; }
.login-form .btn { margin-top: 20px; }
.login-error {
  background: #fbecea;
  color: var(--red);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.brand-mark { font-size: 20px; }
.brand-name {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  white-space: nowrap;
}
.nav { display: flex; gap: 2px; flex: 1; }
.nav-item {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-soft);
  transition: all .15s;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- 主区 ---------- */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.view { display: none; }
.view.active { display: block; }

.page-head { margin-bottom: 24px; }
.page-head.row-between { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text);
}
.page-sub { font-size: 14px; color: var(--text-faint); margin-top: 4px; }

/* ---------- 快速灵感条 ---------- */
.quick-bar {
  position: fixed;
  top: 66px;
  right: 24px;
  z-index: 90;
  display: flex;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px 12px;
  width: 360px;
}
.quick-input { flex: 1; border: none; outline: none; font-size: 14px; font-family: var(--font); }

/* ---------- 仪表盘 ---------- */
.dash-section { margin-bottom: 32px; }
.dash-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dash-section-title .count {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 400;
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

/* ---------- 卡片 ---------- */
.topic-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  cursor: pointer;
  transition: all .18s ease;
  position: relative;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.topic-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.topic-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.topic-card-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  flex: 1;
}
.topic-card-hook {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 8px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}
.topic-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* 标签 chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  background: var(--bg-soft);
  color: var(--text-soft);
  border: 1px solid transparent;
}
.chip-domain { background: #eef2f4; color: #4a6572; }
.chip-motif { background: var(--accent-soft); color: var(--accent-deep); }

/* 评分 */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  border-radius: 50%;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.score-high { background: #e8f0e9; color: #3a6b48; }
.score-mid { background: #f7efdb; color: #a07820; }
.score-low { background: #f6e7e3; color: #a34a36; }
.score-none { background: var(--bg-soft); color: var(--text-faint); }

/* 状态点 */
.status-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-soft); }
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.status-inspiration::before { background: #b0a896; }
.status-todo::before { background: #8a9aad; }
.status-researching::before { background: #6a8fae; }
.status-done::before { background: #4a7c59; }
.status-drafting::before { background: #c98a2b; }
.status-written::before { background: #8a6d3b; }
.status-published::before { background: #2e7d32; }
.status-shelved::before { background: #9a9488; }
.status-abandoned::before { background: #c62828; }

/* 星标收藏 */
.fav-star { color: var(--text-faint); font-size: 16px; cursor: pointer; transition: color .15s; }
.fav-star.on { color: #d4a017; }

/* ---------- 列表视图 ---------- */
.topics-list.card-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.topics-list.list-view { display: flex; flex-direction: column; gap: 8px; }
.topics-list.list-view .topic-card {
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
}
.topics-list.list-view .topic-card-title { flex: 1; }
.topics-list.list-view .topic-card-hook { flex: 1.5; margin-top: 0; -webkit-line-clamp: 1; }
.topics-list.list-view .topic-card-tags { flex: 1.2; margin-top: 0; }
.topics-list.list-view .topic-card-footer { flex: 0 0 auto; border: none; margin: 0; padding: 0; gap: 12px; }

.view-toggle { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.toggle-btn {
  padding: 6px 12px;
  background: #fff;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-faint);
}
.toggle-btn.active { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search-input { flex: 1; min-width: 220px; }
.score-input { width: 90px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 24px; }

/* ---------- 灵感箱 ---------- */
.inspiration-input-wrap { display: flex; gap: 10px; margin-bottom: 20px; }
.inspiration-input { flex: 1; }
.inspiration-list { display: flex; flex-direction: column; gap: 8px; }
.inspiration-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.inspiration-item .content { flex: 1; font-size: 14px; }
.inspiration-item .time { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.inspiration-item.processed { opacity: 0.55; }
.inspiration-item.processed .content { text-decoration: line-through; }

/* ---------- 标签管理 ---------- */
.tags-manage { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.tag-col { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.tag-col-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.tag-add-row { display: flex; gap: 8px; margin-bottom: 16px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-manage-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.tag-manage-item .tag-count { font-size: 11px; color: var(--text-faint); }
.tag-manage-item .tag-actions { display: flex; gap: 2px; }
.tag-manage-item .tag-actions button { font-size: 13px; padding: 0 3px; color: var(--text-faint); background: none; border: none; cursor: pointer; }
.tag-manage-item .tag-actions button:hover { color: var(--red); }

/* ---------- 设置 ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.settings-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.settings-card-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.settings-card .muted { font-size: 13px; color: var(--text-soft); margin-bottom: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.file-input { font-size: 13px; margin-bottom: 10px; }

/* ---------- 抽屉(详情) ---------- */
.drawer { position: fixed; inset: 0; z-index: 200; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(40, 35, 25, 0.35); }
.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 680px;
  max-width: 96vw;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head {
  padding: 12px 20px;
  display: flex;
  justify-content: flex-end;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 24px 28px 60px; }

/* ---------- 详情页内容 ---------- */
.detail-title { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.35; }
.detail-hook {
  font-size: 15px;
  color: var(--text-soft);
  margin-top: 10px;
  font-style: italic;
  line-height: 1.6;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.detail-section { margin-top: 28px; }
.detail-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-deep);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-text { font-size: 14px; line-height: 1.75; color: var(--text); white-space: pre-wrap; }
.detail-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.detail-list li { font-size: 14px; line-height: 1.6; padding-left: 16px; position: relative; }
.detail-list li::before { content: '·'; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }

/* 钩子条目 */
.hook-item {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
}

/* 事实核查 */
.fact-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
}
.fact-A { background: #e8f0e9; border-left: 3px solid #2e7d32; }
.fact-B { background: #fbf5e6; border-left: 3px solid #f9a825; }
.fact-C { background: #fdf0e7; border-left: 3px solid #ef6c00; }
.fact-D { background: #f9e7e5; border-left: 3px solid #c62828; }
.fact-badge {
  font-weight: 700;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 4px;
  color: #fff;
  flex-shrink: 0;
  margin-top: 1px;
}
.fact-A .fact-badge { background: #2e7d32; }
.fact-B .fact-badge { background: #f9a825; color: #4a3b00; }
.fact-C .fact-badge { background: #ef6c00; }
.fact-D .fact-badge { background: #c62828; }

/* 来源 */
.source-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 13px;
}
.source-item .src-name { font-weight: 600; font-size: 14px; }
.source-item .src-title { color: var(--accent); }
.source-item .src-meta { color: var(--text-faint); font-size: 12px; margin-top: 4px; }
.source-item.key { border-left: 3px solid var(--accent); }
.source-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-soft);
  margin-right: 6px;
}

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(40, 35, 25, 0.4); }
.modal-panel {
  position: relative;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 720px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h2 { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.modal-body { padding: 22px 24px; overflow-y: auto; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-full { grid-column: 1 / -1; }
.form-section-title { grid-column: 1 / -1; font-size: 14px; font-weight: 600; color: var(--accent-deep); margin-top: 16px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }

/* 评分星级 */
.score-stars { display: flex; gap: 12px; flex-wrap: wrap; }
.star-group { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.star-group .star-label { font-size: 11px; color: var(--text-soft); }
.star-row { display: flex; gap: 2px; }
.star { font-size: 20px; cursor: pointer; color: #ddd; transition: color .1s; }
.star.on { color: #d4a017; }

/* 标签选择器 */
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag-picker .chip { cursor: pointer; }
.tag-picker .chip.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 可编辑列表(人物/地点/作品等) */
.dyn-list { display: flex; flex-direction: column; gap: 6px; }
.dyn-list-row { display: flex; gap: 6px; align-items: center; }
.dyn-list-row .input { flex: 1; }
.dyn-list-row .rm-btn { color: var(--red); background: none; border: none; cursor: pointer; font-size: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #2b2a26;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 500;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 60px 20px;
  font-size: 14px;
}
.empty .empty-mark { font-size: 40px; margin-bottom: 12px; }

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .topbar-inner { padding: 0 12px; gap: 10px; }
  .brand-name { display: none; }
  .nav { overflow-x: auto; }
  .nav-item { padding: 6px 10px; font-size: 13px; }
  .topbar-actions { gap: 2px; }
  .btn-add { padding: 6px 10px; font-size: 13px; }
  .main { padding: 20px 14px 80px; }
  .page-title { font-size: 23px; }
  .form-grid { grid-template-columns: 1fr; }
  .tags-manage { grid-template-columns: 1fr; }
  .drawer-panel { width: 100vw; max-width: 100vw; }
  .quick-bar { left: 14px; right: 14px; width: auto; }
  .topics-list.list-view .topic-card { flex-wrap: wrap; }
  .topics-list.list-view .topic-card-hook { flex: 1 1 100%; }
}
