/* ================= 个人信息管家 · 样式 ================= */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --border: #e6e8ec;
  --border-strong: #d3d7de;
  --text: #1c2024;
  --text-2: #5b6470;
  --text-3: #8b94a1;
  --accent: #3b5bfd;
  --accent-soft: #eef1ff;
  --accent-hover: #2f4ce0;
  --green: #17a673;
  --green-soft: #e6f7f0;
  --amber: #c77a0a;
  --amber-soft: #fdf3e2;
  --purple: #7c4ddb;
  --purple-soft: #f2ecfd;
  --red: #d64545;
  --red-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 32px rgba(16, 24, 40, .12);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 启动兜底屏 ---------- */
.boot-screen {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  font-size: 13px; color: var(--text-2); text-align: center; padding: 24px;
}
.boot-screen.boot-failed { background: #fff; }
.boot-error-mark {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--red-soft); color: var(--red);
  font-size: 26px; font-weight: 700; line-height: 48px; text-align: center;
}
.boot-error-title { font-size: 16px; font-weight: 600; color: var(--text); }
.boot-error-msg { font-size: 13px; color: var(--text-2); max-width: 420px; line-height: 1.7; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.btn-wechat { background: #07c160; color: #fff; }
.btn-wechat:hover:not(:disabled) { background: #06ad56; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; display: block; }

/* ---------- 表单 ---------- */
.text-input, .select-input, .capture-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.text-input:focus, .select-input:focus, .capture-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 91, 253, .1);
}
.select-input { cursor: pointer; }
.field-label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; min-height: 0; }

/* ---------- 登录 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, #eef1ff 0%, #f6f7f9 55%, #e9f5f0 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff; font-size: 22px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark.small { width: 32px; height: 32px; font-size: 16px; border-radius: 9px; }
.login-brand h1 { font-size: 17px; font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--text-3); letter-spacing: .08em; }

.login-tabs { display: flex; gap: 6px; background: var(--bg); padding: 3px; border-radius: 9px; margin-bottom: 14px; }
.login-tab {
  flex: 1; border: none; background: transparent; padding: 7px;
  font-size: 13px; font-family: inherit; color: var(--text-2);
  border-radius: 7px; cursor: pointer; transition: all .15s;
}
.login-tab.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow); }
.login-hint { font-size: 12px; color: var(--text-3); margin-bottom: 16px; }
#loginForm > div { margin-bottom: 12px; }
#codeRow { display: flex; gap: 8px; align-items: center; }
#codeRow .btn { flex-shrink: 0; }
#codeRow .text-input { flex: 1; }
.login-error { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }
.login-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-3); font-size: 12px; margin: 16px 0;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 216px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; }
.sidebar-brand strong { display: block; font-size: 13px; font-weight: 600; }
.sidebar-user {
  display: block; font-size: 11px; color: var(--text-3);
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  border: none; background: transparent; padding: 9px 11px;
  font-size: 13px; font-family: inherit; color: var(--text-2);
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-icon { width: 16px; text-align: center; font-size: 14px; }
.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--border); }

.main { flex: 1; overflow-y: auto; padding: 28px 32px 60px; }
.view { display: none; max-width: 860px; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 20px; }
.view-head h2 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.view-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.section-title {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin: 26px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}

/* ---------- 记录 ---------- */
.capture-input { resize: vertical; min-height: 100px; line-height: 1.7; }
.capture-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; gap: 12px;
}
.capture-hint { font-size: 12px; color: var(--text-3); }

.capture-result {
  background: var(--accent-soft); border: 1px solid #d9dffd;
  border-radius: var(--radius); padding: 14px 16px; margin-top: 14px;
  animation: fade .2s ease;
}
.capture-result h4 { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.result-grid { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 12px; }
.result-grid div { color: var(--text-2); }
.result-grid b { color: var(--text); font-weight: 500; }
.result-summary {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed #c3cdf7;
  font-size: 13px; color: var(--text);
}
.result-related { margin-top: 8px; font-size: 12px; color: var(--text-2); }
.result-related a { color: var(--accent); cursor: pointer; text-decoration: none; }
.result-related a:hover { text-decoration: underline; }

/* ---------- 条目卡片 ---------- */
.entry-list { display: flex; flex-direction: column; gap: 10px; }
.entry-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.entry-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.entry-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.entry-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.entry-content {
  font-size: 13px; color: var(--text-2); white-space: pre-wrap; word-break: break-word;
  max-height: 90px; overflow: hidden; position: relative;
}
.entry-content.clamped::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 30px;
  background: linear-gradient(transparent, var(--surface));
}
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.entry-actions { display: flex; gap: 6px; flex-shrink: 0; }

.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.tag.type { font-weight: 500; }
.tag.type-idea { background: var(--accent-soft); color: var(--accent); border-color: #d9dffd; }
.tag.type-material { background: var(--green-soft); color: var(--green); border-color: #c5ead9; }
.tag.type-todo_source { background: var(--amber-soft); color: var(--amber); border-color: #f5e2c0; }
.tag.type-insight { background: var(--purple-soft); color: var(--purple); border-color: #e0d2f7; }
.tag.cat { background: var(--surface-2); }
.tag.star { background: transparent; border-color: var(--border); color: var(--amber); padding: 2px 6px; }
.tag.time { background: transparent; border-color: transparent; color: var(--text-3); }

.entry-expand { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.entry-summary { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.entry-points { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--text-2); }
.entry-points li { margin-bottom: 3px; }
.entry-related { margin-top: 10px; font-size: 12px; }
.entry-related-item {
  padding: 7px 10px; background: var(--surface-2); border-radius: 6px;
  margin-top: 5px; cursor: pointer; border: 1px solid var(--border);
}
.entry-related-item:hover { border-color: var(--accent); }

.empty {
  text-align: center; padding: 44px 20px; color: var(--text-3); font-size: 13px;
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius);
}

/* ---------- 筛选 ---------- */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar .select-input { width: auto; min-width: 116px; }
.filter-bar .text-input { flex: 1; min-width: 160px; }

/* ---------- 检索问答 ---------- */
.search-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.mode-btn {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); padding: 6px 13px; font-size: 12px;
  font-family: inherit; border-radius: 20px; cursor: pointer; transition: all .15s;
}
.mode-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.search-actions .btn { margin-left: auto; }

.search-results { margin-top: 16px; }
.result-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
}
.result-item mark { background: #fff3c4; padding: 0 2px; border-radius: 2px; }
.result-item h4 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.result-item p { font-size: 12px; color: var(--text-2); }
.result-count { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }

.ask-panel { margin-top: 16px; }
.ask-answer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 12px;
  font-size: 13.5px; line-height: 1.75; min-height: 60px;
}
.ask-answer:empty::after { content: '等待提问…'; color: var(--text-3); }
.ask-answer h3 { font-size: 14px; margin: 14px 0 6px; font-weight: 600; }
.ask-answer h3:first-child { margin-top: 0; }
.ask-answer p { margin-bottom: 9px; }
.ask-answer ul, .ask-answer ol { margin: 0 0 9px 20px; }
.ask-answer li { margin-bottom: 4px; }
.ask-answer strong { font-weight: 600; }
.ask-answer code {
  background: var(--bg); padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
.ask-cite { font-size: 11px; color: var(--text-3); margin-top: 6px; font-style: italic; }
.ask-input-row { display: flex; gap: 8px; align-items: flex-end; }
.ask-input-row .text-input { resize: vertical; }
.typing::after {
  content: '▍'; color: var(--accent);
  animation: blink 1s steps(2) infinite; margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 待办 ---------- */
.todo-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.todo-stats { display: flex; gap: 18px; font-size: 12px; color: var(--text-2); }
.todo-stats b { font-size: 17px; font-weight: 600; color: var(--text); margin-right: 4px; }
.todo-toolbar-actions { display: flex; gap: 8px; }

.advice-box {
  background: var(--purple-soft); border: 1px solid #e0d2f7;
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.advice-box h4 { font-size: 13px; font-weight: 600; color: var(--purple); margin-bottom: 8px; }
.advice-box ol { margin-left: 18px; font-size: 13px; color: var(--text); }
.advice-box li { margin-bottom: 6px; }
.advice-box p { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }

.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo-group-title {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  margin: 14px 0 2px; display: flex; align-items: center; gap: 6px;
}
.todo-group-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.todo-item {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.todo-item:hover { border-color: var(--border-strong); }
.todo-check {
  width: 17px; height: 17px; border: 1.5px solid var(--border-strong);
  border-radius: 5px; cursor: pointer; flex-shrink: 0; margin-top: 2px;
  transition: all .15s; background: var(--surface);
}
.todo-check:hover { border-color: var(--accent); }
.todo-item.done .todo-check { background: var(--green); border-color: var(--green); }
.todo-item.done .todo-check::after {
  content: '✓'; color: #fff; font-size: 11px;
  display: block; text-align: center; line-height: 14px;
}
.todo-body { flex: 1; min-width: 0; }
.todo-title { font-size: 13.5px; font-weight: 500; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--text-3); }
.todo-detail { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.todo-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.prio { font-size: 11px; padding: 1px 7px; border-radius: 4px; font-weight: 500; }
.prio-1 { background: var(--red-soft); color: var(--red); }
.prio-2 { background: var(--amber-soft); color: var(--amber); }
.prio-3 { background: var(--bg); color: var(--text-3); }
.prio-over { background: var(--red); color: #fff; }

/* ---------- 阶段总结 ---------- */
.digest-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; }
.digest-toolbar .select-input { width: auto; min-width: 130px; }
.digest-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.digest-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.digest-period { font-size: 12px; color: var(--text-3); margin-bottom: 16px; }
.digest-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 18px; }
.digest-stat b { display: block; font-size: 21px; font-weight: 600; color: var(--accent); line-height: 1.2; }
.digest-stat span { font-size: 11px; color: var(--text-3); }
.digest-section { margin-bottom: 18px; }
.digest-section:last-child { margin-bottom: 0; }
.digest-section h4 {
  font-size: 13px; font-weight: 600; margin-bottom: 9px;
  display: flex; align-items: center; gap: 6px;
}
.digest-section ul { margin-left: 19px; font-size: 13px; }
.digest-section li { margin-bottom: 6px; }
.digest-body {
  font-size: 13px; line-height: 1.75; color: var(--text-2);
  padding-top: 14px; border-top: 1px dashed var(--border);
}
.digest-body h3 { font-size: 13.5px; color: var(--text); margin: 12px 0 5px; }
.digest-body ul { margin: 0 0 9px 19px; }
.digest-history { display: flex; flex-direction: column; gap: 8px; }
.digest-history-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.digest-history-item:hover { border-color: var(--accent); }
.digest-history-item strong { font-size: 13px; font-weight: 500; }
.digest-history-item span { font-size: 11px; color: var(--text-3); flex-shrink: 0; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1c2024; color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 13px; z-index: 200;
  box-shadow: var(--shadow-lg); max-width: 80vw; text-align: center;
  animation: toastIn .2s ease;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.busy {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(246, 247, 249, .72); backdrop-filter: blur(2px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  font-size: 13px; color: var(--text-2);
}
.spinner {
  width: 30px; height: 30px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; }
  .sidebar-brand { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { border: none; padding: 0; }
  .sidebar-foot .btn { white-space: nowrap; }
  .main { padding: 18px 16px 40px; }
  .todo-toolbar { flex-direction: column; align-items: stretch; }
}