/* 相知 · 样式
 *
 * 一套中性灰阶 + 一个主色，全部走变量，改配色只动 :root。
 * 手机优先：默认单栏，760px 以上才铺开成多栏。
 * 不用外部字体、不用图片、不用渐变堆砌，动效只保留必要的状态过渡。
 */

:root {
  /* 中性灰阶 */
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --line: #e7e6e2;
  --line-strong: #d6d4ce;
  --ink: #23221f;
  --ink-2: #5b5953;
  --ink-3: #8b887f;

  /* 主色：克制的墨绿，用在导航、主按钮、重点标记 */
  --accent: #2f6b5f;
  --accent-ink: #245247;
  --accent-soft: #eef4f1;
  --accent-line: #cfe0da;

  /* 四类认知各自的记号色，都压得比较低饱和，避免花 */
  --fact: #4a4a46;
  --feeling: #9a6b3f;
  --view: #3f6486;
  --inferred: #6b5c8a;
  --warn: #9a6b2f;
  --danger: #a4442f;
  --danger-soft: #fbeeea;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(35, 34, 31, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
  --maxw: 1000px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.4; }
p { margin: 0; }

/* ── 顶栏 ───────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo { color: var(--accent); flex: none; }
.brand-mark { font-size: 17px; font-weight: 600; letter-spacing: 0.04em; }
.brand-sub { font-size: 12px; color: var(--ink-3); }

.nav { display: flex; gap: 4px; margin-right: auto; }
.nav-link {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 14px;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-active { color: var(--accent); background: var(--accent-soft); }

.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.who { font-size: 13px; color: var(--ink-3); }

/* ── 布局 ───────────────────────────────────────────── */

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 16px 64px;
}

.page-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; flex-wrap: wrap; }
.page-title { font-size: 20px; }
.page-sub { font-size: 13px; color: var(--ink-3); }

.grid-2 { display: grid; gap: 14px; }
@media (min-width: 760px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* ── 卡片 / 分区 ────────────────────────────────────── */

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

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.section-title { font-size: 15px; }
.section-hint { font-size: 12px; color: var(--ink-3); }
.section-action { margin-left: auto; }
.section-body { padding: 14px 16px; }
.section-body > * + * { margin-top: 12px; }

/* ── 统计 ───────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-num { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ── 按钮 ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { padding: 3px 8px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 表单 ───────────────────────────────────────────── */

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 13px; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--ink-3); }

.input {
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.input:focus { outline: 2px solid var(--accent-line); outline-offset: 0; border-color: var(--accent); }
.textarea { resize: vertical; min-height: 64px; }
.select { appearance: none; background-image: none; }

.form-actions { display: flex; gap: 8px; align-items: center; }
.form-error {
  margin: 0;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .input { width: auto; min-width: 120px; }
.filters .search { flex: 1 1 180px; min-width: 0; }

/* ── 折叠 ───────────────────────────────────────────── */

.fold { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.fold-summary {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
}
.fold-summary::-webkit-details-marker { display: none; }
.fold-summary::before { content: "▸ "; color: var(--ink-3); }
.fold[open] > .fold-summary::before { content: "▾ "; }
.fold-body { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.fold-body > * + * { margin-top: 12px; }

/* ── 未结线头 ───────────────────────────────────────── */

.loop-group + .loop-group { margin-top: 14px; }
.loop-group-title { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.loop {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
}
.loop:hover { background: var(--accent-soft); }
.loop + .loop { margin-top: 8px; }
.loop-title { display: block; }
.loop-meta { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ── 人物列表 ───────────────────────────────────────── */

.contact-list { display: grid; gap: 10px; }
@media (min-width: 760px) { .contact-list { grid-template-columns: 1fr 1fr; } }

.contact-card {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  color: var(--ink);
}
.contact-card:hover { border-color: var(--accent-line); background: var(--surface-2); }
.contact-card-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.contact-name { font-size: 16px; font-weight: 600; }
.contact-meta { font-size: 12px; color: var(--ink-3); }
.contact-goal {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-2);
  border-left: 2px solid var(--accent-line);
  padding-left: 8px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.contact-ctx { display: block; margin-top: 6px; }
.sep { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.order-note { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.settled { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong); }
.section-note-fact .section-head { border-left: 3px solid var(--fact); }
.section-note-feeling .section-head { border-left: 3px solid var(--feeling); }
.section-note-user_view .section-head { border-left: 3px solid var(--view); }
.section-note-inferred .section-head { border-left: 3px solid var(--inferred); }

.chip {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}
.chip-accent { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }
.chip-muted { color: var(--ink-3); }
.chip-warn { color: var(--warn); border-color: #e8d9bf; background: #fbf6ec; }

/* ── 档案头部 ───────────────────────────────────────── */

.dossier-head { display: flex; flex-direction: column; gap: 10px; }
.dossier-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dossier-name { font-size: 22px; font-weight: 600; }
.defs { display: grid; gap: 8px; }
.def { display: grid; grid-template-columns: 76px 1fr; gap: 10px; font-size: 15px; }
.def-key { color: var(--ink-3); font-size: 13px; padding-top: 2px; }
.def-val { color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── 四类认知 ───────────────────────────────────────── */

.note-kind-hint { font-size: 12px; color: var(--ink-3); }
.note-list { display: grid; gap: 10px; }
.note {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
}
.note-fact { border-left-color: var(--fact); }
.note-feeling { border-left-color: var(--feeling); }
.note-view { border-left-color: var(--view); }
.note-inferred { border-left-color: var(--inferred); background: #fbfaff; }
.note-content { font-size: 15px; overflow-wrap: anywhere; }
.note-foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.note-actions { margin-left: auto; display: flex; gap: 6px; }

.quote {
  margin: 8px 0 0;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
  background: var(--surface-2);
  border-left: 3px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.quote-tag { font-family: var(--font); font-size: 11px; color: var(--ink-3); display: block; margin-bottom: 2px; }

.disclaimer {
  font-size: 13px;
  color: var(--ink-2);
  background: #fbfaff;
  border: 1px dashed #d8d2e6;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

/* ── 时间线 ─────────────────────────────────────────── */

.tl { position: relative; margin: 0; padding: 0 0 0 16px; list-style: none; border-left: 1px solid var(--line-strong); }
.tl-item { position: relative; padding: 0 0 18px 4px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.tl-date { font-size: 13px; color: var(--ink-3); }
.tl-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.tl-seq { font-size: 12px; color: var(--ink-3); }
.tl-summary { font-size: 15px; font-weight: 600; margin-top: 2px; }
.tl-block { margin-top: 8px; }
.tl-key { font-size: 12px; color: var(--ink-3); display: block; }
.tl-val { font-size: 15px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── 建议留档 ───────────────────────────────────────── */

.pass { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.pass + .pass { margin-top: 10px; }
.pass-q { font-size: 15px; font-weight: 600; }
.pass-line { font-size: 14px; margin-top: 6px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.pass-line b { color: var(--ink-3); font-weight: 400; }

/* ── 空状态 / 提示 ──────────────────────────────────── */

.empty { padding: 22px 8px; text-align: center; color: var(--ink-3); font-size: 14px; }
.empty-text { margin: 0; }
.loading { padding: 18px 8px; text-align: center; color: var(--ink-3); font-size: 14px; }

.notice {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 12px);
  max-width: min(90vw, 460px);
  padding: 9px 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 60;
}
.notice-show { opacity: 1; transform: translate(-50%, 0); }
.notice-error { background: var(--danger); }
.notice-ok { background: var(--accent-ink); }

.health { margin-top: 28px; text-align: center; font-size: 12px; color: var(--ink-3); }

/* ── 对话页 ─────────────────────────────────────────── */

.chat-shell { display: flex; flex-direction: column; height: 100vh; }
.chat-body { flex: 1; display: flex; min-height: 0; max-width: 1100px; width: 100%; margin: 0 auto; }

.chat-side {
  display: none;
  flex-direction: column;
  width: 268px;
  flex: none;
  border-right: 1px solid var(--line);
  background: var(--surface);
  min-height: 0;
}
.chat-side-open { display: flex; }
@media (min-width: 860px) {
  .chat-side { display: flex; }
  .side-toggle { display: none; }
}

.side-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.side-title { font-size: 14px; color: var(--ink-2); margin-right: auto; }
.chat-list { overflow-y: auto; padding: 8px; flex: 1; }
.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item-active { background: var(--accent-soft); border-color: var(--accent-line); }
.chat-item-main { min-width: 0; flex: 1; }
.chat-item-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-meta { font-size: 12px; color: var(--ink-3); }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.chat-head-title { font-size: 15px; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.messages { flex: 1; overflow-y: auto; padding: 16px 14px 8px; }
.msg { max-width: 720px; margin: 0 auto 14px; }
.msg-role { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.msg-bubble {
  padding: 10px 13px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  background: var(--surface);
}
.msg-user .msg-bubble { background: var(--accent-soft); border-color: var(--accent-line); }
.msg-error .msg-bubble { background: var(--danger-soft); border-color: #eccdc3; color: var(--danger); }
.msg-tool { max-width: 720px; margin: 0 auto 10px; }
.msg-tool .tool-line {
  font-size: 13px;
  color: var(--ink-3);
  padding: 4px 10px;
  border-left: 2px solid var(--line-strong);
  font-family: var(--mono);
}

.composer { border-top: 1px solid var(--line); background: var(--surface); padding: 10px 14px 14px; }
.composer-inner { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  resize: none;
}
.composer-hint { max-width: 720px; margin: 6px auto 0; font-size: 12px; color: var(--ink-3); }

/* 登录页 */
.login-wrap { max-width: 420px; margin: 0 auto; padding: 40px 16px 60px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 24px; letter-spacing: 0.08em; }
.login-brand p { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 1;
  padding: 7px 0;
  text-align: center;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
}
.tab-active { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }
.login-note { margin-top: 14px; font-size: 12px; color: var(--ink-3); text-align: center; }

/* ── 注册 / 重置密码：步骤、手机号、说明 ─────────────── */

.step-line { margin: 0; font-size: 12px; color: var(--ink-3); }

/* 短信没配好时的退路要让用户看懂"为什么"，不能只把表单换掉 */
.reason {
  margin: 0 0 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2);
  background: #fbf6ec;
  border: 1px solid #e8d9bf;
  border-radius: var(--radius-sm);
}

/* +86 只是视觉前缀：提交的值里没有国家码，所以它不参与校验 */
.phone-field { display: flex; align-items: stretch; }
.phone-prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 15px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.phone-field .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.phone-field .input:focus { outline-offset: -2px; }

/* ── 额度小字（人物库页头） ─────────────────────────── */

.page-quota {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-3);
}

/* ── 等级与用量页 ───────────────────────────────────── */

.plan-now { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.plan-now-name { font-size: 20px; font-weight: 600; }
.plan-now-price { font-size: 14px; color: var(--accent-ink); }

.usage + .usage { margin-top: 16px; }
.usage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.usage-label { font-size: 14px; color: var(--ink-2); }
.usage-num { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.usage-full { color: var(--danger); }
.usage-near { color: var(--warn); }

.bar {
  height: 8px;
  margin-top: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--accent); }
.bar-free { background: var(--accent-line); }
.bar-near { background: var(--warn); }
.bar-full { background: var(--danger); }

.plans { display: grid; gap: 10px; }
@media (min-width: 760px) { .plans { grid-template-columns: 1fr 1fr; } }
.plan-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
}
.plan-current { border-color: var(--accent-line); background: var(--accent-soft); }
.plan-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.plan-name { font-size: 16px; font-weight: 600; }
.plan-price { margin-left: auto; font-size: 14px; color: var(--accent-ink); }
.plan-features { margin: 8px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.9; color: var(--ink-2); }
