:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --ink: #23201d;
  --muted: #8a847d;
  --line: #e9e6e1;
  --brand: #4f46e5;
  --brand-soft: #eef0fe;
  --warm: #c26a4a;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 24px rgba(0,0,0,.04);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: #c0392b; }
button {
  font: inherit; cursor: pointer; border: none; border-radius: 12px;
  background: var(--brand); color: #fff; padding: 13px 18px; font-weight: 600;
  transition: transform .06s ease, opacity .2s;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: var(--brand-soft); color: var(--brand); }
button.mini { padding: 7px 12px; border-radius: 9px; font-size: 14px; }
input, textarea {
  font: inherit; width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; background: #fff; color: var(--ink); outline: none;
}
input:focus, textarea:focus { border-color: var(--brand); }
a { color: inherit; text-decoration: none; }

/* 登录门 */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.gate-card { width: 100%; max-width: 360px; text-align: center; }
.gate-logo { font-size: 48px; }
.gate-card h1 { margin: 8px 0 4px; font-size: 24px; }
.gate-card input { margin: 18px 0 12px; }
.gate-card button { width: 100%; }

/* 布局 */
.app { min-height: 100vh; }
#view { max-width: 720px; margin: 0 auto; padding: 18px 16px calc(96px + var(--safe-b)); }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.page-head h2 { font-size: 20px; margin: 0; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 9px; font-size: 11px; color: var(--muted);
}
.tabbar a .ico { font-size: 20px; filter: grayscale(1) opacity(.7); }
.tabbar a.active { color: var(--brand); }
.tabbar a.active .ico { filter: none; }

/* 记录页 */
.composer textarea {
  min-height: 46vh; resize: none; font-size: 17px; line-height: 1.7;
  box-shadow: var(--shadow); border: none;
}
.composer .row { display: flex; gap: 10px; margin-top: 12px; }
.composer .row button { flex: 1; }
.mic { flex: 0 0 auto !important; width: 52px; background: var(--brand-soft); color: var(--brand); font-size: 20px; padding: 0; }
.mic.recording { background: var(--warm); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.55;} }

/* 卡片 */
.card {
  background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.card .date { font-size: 12px; color: var(--muted); }
.card .excerpt { margin-top: 4px; }
.tag {
  display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); margin-left: 8px; vertical-align: middle;
}

/* 详情：分区块 */
.block { margin-bottom: 14px; }
.block h3 {
  font-size: 13px; color: var(--muted); margin: 0 0 6px; letter-spacing: .05em;
  text-transform: uppercase; font-weight: 700;
}
.block .raw { white-space: pre-wrap; background: #fbfaf8; border-left: 3px solid var(--line); padding: 10px 12px; border-radius: 8px; }
.block.guidance .body { background: var(--brand-soft); padding: 14px; border-radius: 12px; line-height: 1.75; }
.block ul { margin: 0; padding-left: 20px; }
.block li { margin: 3px 0; }
.block.emotion .body { color: var(--warm); }

/* 趋势图 */
.chart-wrap { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); overflow-x: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* 空状态 / 加载 */
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 处理中提示 */
.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 14px 0; }
.thinking .spinner { margin: 0; width: 18px; height: 18px; border-width: 2px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%);
  background: #23201d; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  z-index: 50; box-shadow: var(--shadow); max-width: 90%;
}

.link { color: var(--brand); font-weight: 600; }
.back { background: none; color: var(--brand); padding: 4px 0; font-weight: 600; }
.chip { font-size: 12px; color: var(--muted); }
.offline-banner { background: #fff3cd; color: #7a5b00; text-align: center; padding: 6px; font-size: 13px; }
.danger-link { display: block; width: 100%; margin: 18px 0 8px; background: none; color: #c0392b; border: 1px solid #f0d0cb; }
.danger-link:active { background: #fbeae7; }

/* 时间线左滑删除 */
.swipe-row { position: relative; overflow: hidden; border-radius: 16px; margin-bottom: 12px; background: #c0392b; }
.swipe-row .swipe-delete {
  position: absolute; top: 0; right: 0; height: 100%; width: 88px;
  border-radius: 0; background: #c0392b; color: #fff; font-weight: 600; font-size: 15px;
}
.swipe-card {
  display: block; position: relative; margin-bottom: 0 !important;
  transform: translateX(0); will-change: transform; touch-action: pan-y;
}

/* 单篇追问对话 */
.convo { margin-top: 18px; }
.convo-title { font-size: 14px; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
.convo-empty { font-size: 14px; padding: 8px 0 4px; }
.msg { display: flex; margin-bottom: 10px; }
.msg .bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 14px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; font-size: 15px;
}
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { justify-content: flex-start; }
.msg.assistant .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.dots { color: var(--muted); }
.tool-note { font-size: 12px; color: var(--muted); margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
/* 记录页角色选择 chips */
.persona-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.persona-hint { font-size: 13px; color: var(--muted); width: 100%; }
.persona-chip {
  background: #fff; color: var(--muted); border: 1px solid var(--line);
  padding: 6px 13px; border-radius: 999px; font-size: 14px; font-weight: 500;
}
.persona-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* 三角色标签页 */
.role-tabs { display: flex; gap: 6px; margin-bottom: 14px; background: #efece7; padding: 4px; border-radius: 12px; }
.role-tab {
  flex: 1; background: none; color: var(--muted); padding: 9px 6px; border-radius: 9px;
  font-size: 14px; font-weight: 600;
}
.role-tab.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.kickoff { text-align: center; padding: 20px 8px 8px; }
.kickoff .muted { margin: 0 0 14px; font-size: 14px; }
.kickoff button { width: 100%; }
.convo-input { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.convo-input textarea { flex: 1; resize: none; }
.convo-input button { flex: 0 0 auto; }
