:root {
  --bg: #f5f2ec; --card: #fffdfa; --ink: #282621; --muted: #817c73;
  --line: #e7e1d8; --brand: #536b5e; --brand-dark: #3e5448;
  --brand-soft: #eaf0eb; --warm: #b46c4f; --danger: #b94b43;
  --shadow: 0 12px 36px rgba(57,49,39,.07);
  --shadow-hover: 0 18px 46px rgba(57,49,39,.12);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  background: radial-gradient(circle at 80% 0%, rgba(185,202,188,.24), transparent 30rem), var(--bg);
  color: var(--ink); font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  line-height: 1.65; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; } .muted { color: var(--muted); } .error { color: var(--danger); }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button {
  border: 0; border-radius: 13px; padding: 12px 18px; cursor: pointer; background: var(--brand);
  color: #fff; font-weight: 650; transition: transform .16s, background .16s, box-shadow .16s, opacity .16s;
}
button:hover { background: var(--brand-dark); box-shadow: 0 8px 20px rgba(62,84,72,.18); }
button:active { transform: translateY(1px) scale(.99); }
button:disabled { opacity: .52; cursor: default; box-shadow: none; }
button.ghost { background: var(--brand-soft); color: var(--brand-dark); }
button.mini { padding: 9px 15px; border-radius: 11px; font-size: 14px; }
input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px;
  background: rgba(255,253,250,.95); color: var(--ink); outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input:focus, textarea:focus { border-color: #8ba091; background: #fff; box-shadow: 0 0 0 4px rgba(83,107,94,.11); }
:focus-visible { outline: 3px solid rgba(83,107,94,.25); outline-offset: 2px; }

/* 登录 */
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; overflow-y: auto; background: radial-gradient(circle at 50% 10%, #e4ece6, var(--bg) 45%); }
.gate-card { width: min(100%,410px); padding: 42px 38px; text-align: center; background: rgba(255,253,250,.88); border: 1px solid #fff; border-radius: 28px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.gate-logo { display: grid; place-items: center; width: 64px; height: 64px; margin: auto; border-radius: 20px; background: var(--brand); color: #fff; font-size: 30px; }
.gate-card h1 { margin: 18px 0 4px; font: 700 26px Georgia,"Songti SC",serif; }
.gate-card input { margin: 20px 0 12px; } .gate-card button { width: 100%; }
.config-card { width: min(100%,480px); padding-block: 32px; text-align: left; }
.config-card h1,.config-card>p { text-align: center; }
.config-card label { display: block; margin-top: 13px; color: var(--muted); font-size: 12px; font-weight: 650; }
.config-card label input { margin: 5px 0 0; color: var(--ink); font-size: 14px; font-weight: 400; }
.config-card #config-submit { margin-top: 18px; }
.config-card #config-cancel { margin-top: 8px; }
.config-tip { margin: 12px 0 0; color: var(--muted); font-size: 11px; }

/* 框架和导航 */
.app { min-height: 100vh; } .mobile-header { display: none; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 244px; padding: 30px 22px 24px; display: flex; flex-direction: column; background: rgba(251,249,245,.88); border-right: 1px solid var(--line); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; }
.brand-mark, .mobile-brand>span { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 14px; background: var(--brand); color: #fff; font: 700 20px Georgia,"Songti SC",serif; }
.brand strong { display: block; font: 700 19px Georgia,"Songti SC",serif; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.tabbar { display: flex; flex-direction: column; gap: 6px; }
.tabbar a { display: flex; align-items: center; gap: 13px; padding: 11px 13px; border-radius: 13px; color: var(--muted); font-size: 14px; transition: background .18s,color .18s,transform .18s; }
.tabbar a:hover { color: var(--ink); background: rgba(83,107,94,.06); transform: translateX(2px); }
.tabbar a.active { color: var(--brand-dark); background: var(--brand-soft); font-weight: 650; }
.tabbar .ico { width: 23px; text-align: center; font-size: 20px; line-height: 1; }
.sidebar-note { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sidebar-note span { display: block; padding: 8px 4px 0; }
.settings-link { width: 100%; padding: 8px 10px; background: transparent; color: var(--muted); text-align: left; font-size: 12px; }
.settings-link:hover { background: var(--brand-soft); color: var(--brand-dark); box-shadow: none; }
#view { max-width: 1260px; min-height: 100vh; margin-left: 244px; padding: 48px clamp(30px,5vw,72px) 80px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-head h2 { margin: 0; font: 700 clamp(23px,2.3vw,32px) Georgia,"Songti SC",serif; letter-spacing: -.02em; }
.page-kicker { margin: 0 0 5px; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .16em; }
.page-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 14px; }

/* 记录页 */
.record-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(360px,.85fr); gap: 24px; align-items: start; }
.record-layout > * { min-width: 0; }
.composer { padding: 20px; background: rgba(255,253,250,.72); border: 1px solid rgba(231,225,216,.85); border-radius: 24px; box-shadow: var(--shadow); }
.composer textarea { display: block; min-height: 430px; resize: vertical; border: 0; padding: 18px 19px; font-size: 17px; line-height: 1.85; background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.composer textarea:focus { box-shadow: inset 0 0 0 1px #8ba091,0 0 0 4px rgba(83,107,94,.1); }
.draft-meta { display: flex; justify-content: space-between; margin: 9px 2px 0; color: var(--muted); font-size: 12px; }
.composer .row { display: flex; gap: 10px; margin-top: 14px; }
.composer .row #submit { flex: 1; min-height: 48px; }
.mic { flex: 0 0 48px; width: 48px; padding: 0; background: var(--brand-soft); color: var(--brand); font-size: 19px; }
.mic.recording { background: var(--warm); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
#result:empty::before { content: "写下此刻，整理结果会出现在这里"; display: grid; min-height: 320px; place-items: center; padding: 30px; border: 1px dashed #d8d0c5; border-radius: 24px; color: #aaa298; font-size: 14px; }
#result .result-card { margin: 0; }
.persona-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.persona-hint { width: 100%; color: var(--muted); font-size: 12px; }
.persona-chip { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); font-size: 13px; font-weight: 500; }
.persona-chip:hover { background: var(--brand-soft); color: var(--brand-dark); box-shadow: none; }
.persona-chip.active { border-color: var(--brand); background: var(--brand); color: #fff; }

/* 卡片 */
.card { position: relative; margin-bottom: 14px; padding: 19px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
a.card { transition: transform .2s,box-shadow .2s,border-color .2s; }
a.card:hover { transform: translateY(-3px); border-color: #d5cec3; box-shadow: var(--shadow-hover); }
.card .date { color: var(--muted); font-size: 12px; }
.card .excerpt { margin-top: 8px; line-height: 1.7; }
.tag { display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11px; vertical-align: middle; }
.block { margin-bottom: 17px; } .block:last-child { margin-bottom: 0; }
.block h3 { margin: 0 0 7px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .1em; }
.block .raw { padding: 14px 16px; border-left: 3px solid #b7c5ba; border-radius: 8px; background: #f8f6f1; white-space: pre-wrap; }
.block.guidance .body { padding: 16px; border-radius: 14px; background: var(--brand-soft); line-height: 1.8; }
.block ul { margin: 0; padding-left: 20px; } .block li { margin: 5px 0; }
.block.emotion .body { color: var(--warm); }

/* 时间线 */
#tl { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.swipe-row { position: relative; min-width: 0; overflow: visible; border-radius: 20px; background: var(--danger); }
.swipe-card { display: block; height: 100%; margin: 0; transform: translateX(0); will-change: transform; touch-action: pan-y; }
.swipe-row .swipe-delete { display: none; }
.timeline-delete { position: absolute; top: 12px; right: 12px; z-index: 3; width: 32px; height: 32px; padding: 0; border: 1px solid #ead5d1; border-radius: 10px; background: #fff; color: var(--danger); opacity: 0; }
.swipe-row:hover .timeline-delete { opacity: 1; }
.timeline-delete:hover { background: #fff0ed; box-shadow: none; }

/* 搜索和画像 */
.search-box { display: flex; gap: 10px; max-width: 760px; padding: 10px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,253,250,.76); box-shadow: var(--shadow); }
.search-box input { border: 0; background: transparent; box-shadow: none; }
.search-box input:focus { box-shadow: none; }
.search-box button { flex: 0 0 auto; min-width: 76px; }
#hits { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-top: 18px; }
#hits .card { display: block; margin: 0; }
#view[data-page="profile"] > .card { max-width: 820px; padding: clamp(20px,3vw,34px); }

/* 详情和对话 */
.detail-layout { display: grid; grid-template-columns: minmax(0,.8fr) minmax(420px,1.2fr); gap: 24px; align-items: start; }
.detail-main,.detail-chat { min-width: 0; }
.convo { padding: 20px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,253,250,.68); box-shadow: var(--shadow); }
.convo-title { margin: 0 0 12px; color: var(--ink); font-size: 15px; }
.msg { display: flex; margin-bottom: 11px; }
.msg .bubble { max-width: 82%; padding: 11px 14px; border-radius: 16px; line-height: 1.68; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.msg.user { justify-content: flex-end; } .msg.user .bubble { border-bottom-right-radius: 5px; background: var(--brand); color: #fff; }
.msg.assistant .bubble { border: 1px solid var(--line); border-bottom-left-radius: 5px; background: #fff; box-shadow: 0 5px 18px rgba(57,49,39,.05); }
.tool-note { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); color: var(--muted); font-size: 11px; }
.role-tabs { display: flex; gap: 5px; margin-bottom: 14px; padding: 4px; border-radius: 13px; background: #ebe7df; }
.role-tab { flex: 1; padding: 8px 5px; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; }
.role-tab:hover { background: rgba(255,255,255,.55); color: var(--brand); box-shadow: none; }
.role-tab.active { background: #fff; color: var(--brand-dark); box-shadow: 0 3px 10px rgba(57,49,39,.08); }
.kickoff { padding: 24px 8px 12px; text-align: center; } .kickoff .muted { margin: 0 0 14px; } .kickoff button { width: 100%; }
.convo-input { display: flex; align-items: flex-end; gap: 9px; margin-top: 12px; }
.convo-input textarea { min-height: 48px; max-height: 160px; resize: vertical; }
.convo-input button { flex: 0 0 auto; min-height: 46px; }

/* 状态和图表 */
.chart-wrap { overflow-x: auto; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.legend { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 14px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; } .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.empty { padding: 70px 16px; color: var(--muted); text-align: center; }
.spinner { width: 23px; height: 23px; margin: 50px auto; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.thinking { display: flex; align-items: center; gap: 10px; padding: 16px; color: var(--muted); }
.thinking .spinner { width: 18px; height: 18px; margin: 0; border-width: 2px; }
.toast { position: fixed; left: calc(50% + 122px); bottom: 28px; z-index: 60; transform: translateX(-50%); max-width: 90%; padding: 10px 18px; border-radius: 999px; background: #282621; color: #fff; box-shadow: var(--shadow); font-size: 13px; }
.link { color: var(--brand-dark); font-weight: 650; }
.back { padding: 5px 0; background: transparent; color: var(--brand-dark); } .back:hover { background: transparent; box-shadow: none; }
.chip { color: var(--muted); font-size: 12px; }
.offline-banner { padding: 7px; background: #fff0cc; color: #745c20; text-align: center; font-size: 12px; }
.danger-link { display: block; width: 100%; margin: 16px 0 8px; border: 1px solid #ead5d1; background: transparent; color: var(--danger); }
.danger-link:hover { background: #fff0ed; box-shadow: none; }

@media (max-width: 900px) {
  body { background: var(--bg); }
  .sidebar { display: contents; }
  .sidebar > .brand, .sidebar-note { display: none; }
  .mobile-header { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; height: 58px; padding: 8px 16px; border-bottom: 1px solid rgba(231,225,216,.8); background: rgba(245,242,236,.88); backdrop-filter: blur(16px); }
  .mobile-brand { display: flex; align-items: center; gap: 9px; }
  .mobile-brand>span { width: 34px; height: 34px; border-radius: 11px; font-size: 16px; }
  .mobile-brand strong { font: 700 17px Georgia,"Songti SC",serif; }
  .mobile-settings { width: 36px; height: 36px; padding: 0; border-radius: 11px; background: transparent; color: var(--brand); font-size: 18px; }
  .mobile-settings:hover { background: var(--brand-soft); box-shadow: none; }
  .status-dot { width: 8px; height: 8px; border-radius: 50%; background: #68a374; box-shadow: 0 0 0 4px rgba(104,163,116,.13); }
  #view { min-height: calc(100vh - 58px); margin-left: 0; padding: 24px 18px calc(92px + var(--safe-b)); }
  .tabbar { position: fixed; inset: auto 0 0; z-index: 30; display: flex; flex-direction: row; gap: 0; padding: 5px 5px calc(6px + var(--safe-b)); border-top: 1px solid var(--line); background: rgba(255,253,250,.94); backdrop-filter: blur(18px); }
  .tabbar a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 1px; padding: 6px 1px; border-radius: 10px; font-size: 10px; white-space: nowrap; }
  .tabbar a:hover { transform: none; } .tabbar a.active { background: transparent; } .tabbar .ico { width: auto; font-size: 20px; }
  .record-layout,.detail-layout { display: block; } #result { margin-top: 15px; } #result:empty { display: none; }
  .composer { padding: 14px; border-radius: 20px; } .composer textarea { min-height: 42vh; resize: none; }
  .composer .row #submit { min-width: 0; }
  #tl { grid-template-columns: 1fr; } .timeline-delete { display: none; }
  #hits { grid-template-columns: 1fr; }
  .swipe-row { overflow: hidden; margin-bottom: 0; }
  .swipe-row .swipe-delete { display: block; position: absolute; inset: 0 0 0 auto; width: 88px; padding: 0; border-radius: 0; background: var(--danger); color: #fff; }
  .detail-chat { margin-top: 18px; } .toast { left: 50%; bottom: calc(78px + var(--safe-b)); }
}
@media (max-width: 520px) {
  #view { padding: 20px 14px calc(88px + var(--safe-b)); }
  .page-head { align-items: center; margin-bottom: 16px; } .page-head h2 { font-size: 23px; } .page-subtitle { font-size: 12px; }
  .composer textarea { min-height: 46vh; padding: 15px; font-size: 16px; }
  .search-box { padding: 7px; } .search-box button { min-width: 66px; padding-inline: 13px; }
  .card { padding: 16px; border-radius: 17px; } .msg .bubble { max-width: 88%; }
  .convo { padding: 14px; border-radius: 18px; } .gate-card { padding: 34px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
