:root {
  --pri: #2f7d6d;
  --pri-l: #e6f2ef;
  --bg: #f6f5f1;
  --card: #fff;
  --text: #24302d;
  --muted: #8a938f;
  --line: #e7e5df;
  --warn: #c0613a;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; background: var(--bg); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: var(--pri); color: #fff; }
.child-btn { background: rgba(255,255,255,.15); border: 0; border-radius: 20px; padding: 6px 14px; font-weight: 600; color: #fff; }
.icon-btn { background: transparent; border: 0; color: #fff; font-size: 20px; padding: 4px 8px; }
main { flex: 1; overflow: hidden; position: relative; }
.view { display: none; height: 100%; overflow-y: auto; padding: 12px; }
.view.active { display: block; }
#view-chat.active { display: flex; flex-direction: column; padding: 0; }
.tabbar { display: flex; border-top: 1px solid var(--line); background: #fff; padding-bottom: var(--safe-b); }
.site-record { flex: none; text-align: center; background: #fff; font-size: 11px; line-height: 20px; }
.site-record a { color: #66736e; text-decoration: none; }
.tabbar button { flex: 1; border: 0; background: none; padding: 6px 0 4px; font-size: 18px; display: flex; flex-direction: column; align-items: center; color: var(--muted); }
.tabbar button span { font-size: 11px; }
.tabbar button.active { color: var(--pri); }

.messages { flex: 1; overflow-y: auto; padding: 14px 12px 6px; }
.msg { margin: 0 0 14px; display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 88%; padding: 10px 13px; border-radius: var(--radius); background: var(--card);
  box-shadow: 0 1px 2px rgba(0,0,0,.04); word-break: break-word; }
.msg.user .bubble { background: var(--pri); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.message-time { display: block; margin-top: 3px; text-align: right; font-size: 10px; line-height: 1.3; color: rgba(255,255,255,.76); }
.msg.assistant .bubble { border-bottom-left-radius: 4px; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { font-size: 15px; margin: 10px 0 4px; }
.bubble p { margin: 6px 0; }
.bubble ul, .bubble ol { margin: 4px 0; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.bubble code { background: #f0efe9; padding: 1px 4px; border-radius: 4px; font-size: 13px; }
.bubble hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.bubble table { border-collapse: collapse; font-size: 13px; }
.bubble td, .bubble th { border: 1px solid var(--line); padding: 3px 6px; }
.tools { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tool-chip { font-size: 11px; background: var(--pri-l); color: var(--pri); padding: 1px 8px; border-radius: 10px; }
.tool-chip.running::after { content: " …"; }
.typing::after { content: "▍"; animation: blink 1s infinite; color: var(--pri); }
@keyframes blink { 50% { opacity: 0; } }

.welcome { text-align: center; color: var(--muted); padding: 30px 16px; }
.welcome h2 { color: var(--text); margin: 0 0 6px; font-size: 18px; }
.composer { display: flex; gap: 8px; padding: 8px 12px 10px; background: var(--bg); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 18px; padding: 8px 14px; max-height: 140px; background: #fff; outline: none; }
.composer textarea:focus { border-color: var(--pri); }
.composer button { border: 0; background: var(--pri); color: #fff; border-radius: 18px; padding: 8px 16px; font-weight: 600; }
.composer button.stop { background: var(--warn); }

.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.card h3 { margin: 0; font-size: 16px; }
.muted { color: var(--muted); }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.form label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.form input, .form textarea, .form select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fcfcfa; outline: none; }
.form textarea { min-height: 60px; resize: vertical; }
.form .hint { font-size: 12px; color: var(--muted); }
.btn { border: 0; background: var(--pri); color: #fff; border-radius: 10px; padding: 9px 14px; font-weight: 600; width: 100%; margin-top: 14px; }
.btn.ghost { background: transparent; color: var(--warn); border: 1px solid var(--line); }
.mem-form { display: flex; gap: 6px; margin-top: 10px; }
.mem-form select { border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fcfcfa; }
.mem-form input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.mem-form button { border: 0; background: var(--pri); color: #fff; border-radius: 8px; padding: 0 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 2px 10px; font-size: 12px; }
.chips button.on { background: var(--pri); color: #fff; border-color: var(--pri); }
.item { background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; position: relative; }
.item .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 0 7px; border-radius: 8px; background: var(--pri-l); color: var(--pri); }
.tag.trigger, .tag.ineffective { background: #fbeae3; color: var(--warn); }
.tag.effective { background: #e3f4e6; color: #2e7d3a; }
.item .del { position: absolute; right: 8px; top: 6px; border: 0; background: none; color: var(--muted); font-size: 16px; }
.event-fields div { font-size: 14px; margin: 2px 0; }
.event-fields b { color: var(--pri); font-weight: 600; margin-right: 4px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet.hidden { display: none; }
.sheet-body { background: #fff; width: 100%; max-width: 720px; max-height: 75vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + var(--safe-b)); }
.sheet-body h3 { margin: 4px 0 10px; font-size: 16px; }
.list-btn { display: block; width: 100%; text-align: left; border: 0; background: #f7f7f4; border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; }
.list-btn.on { background: var(--pri-l); color: var(--pri); font-weight: 600; }
.list-btn small { color: var(--muted); display: block; font-weight: 400; }

.mem-form { flex-wrap: wrap; }
.mem-form input { flex-basis: 55%; }
.record-details { font-size: 12px; margin: 6px 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.record-details summary { cursor: pointer; color: var(--pri); }
.text-btn { margin-top: 8px; padding: 5px 0; border: 0; background: transparent; color: var(--pri); font-size: 13px; }
.report-import { margin: 0; font-weight: 600; }
.report-form [hidden] { display: none; }
.report-form .report-check { display: flex; gap: 9px; align-items: baseline; color: var(--text); }
.report-form input[type="checkbox"] { width: auto; flex: none; accent-color: var(--pri); }
.report-candidate { padding: 9px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.report-quote { display: block; white-space: pre-wrap; margin-top: 4px; }
.report-status { margin: 6px 0; font-size: 13px; overflow-wrap: anywhere; }
.event-fields div { overflow-wrap: anywhere; }
.event-fields b { display: inline-block; }
[role="alert"] { color: var(--warn); font-size: 13px; }

/* 待反馈建议卡片（闭环） */
.followups:empty { display: none; }
.followups { padding: 8px 12px 0; }
.followup-card { background: #fff8ea; border: 1px solid #f0dfb8; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.followup-card.done { background: var(--pri-l); border-color: transparent; color: var(--pri); }
.fu-title { font-weight: 600; margin-bottom: 2px; }
.fu-strategy { color: var(--text); margin: 2px 0 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fu-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fu-actions button { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 4px 12px; font-size: 13px; }
.fu-actions button[data-o="tried_effective"] { border-color: var(--pri); color: var(--pri); }
.fu-actions button:disabled { opacity: .5; }
.fu-note { width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 13px; background: #fff; }
.fu-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 回答评价与折叠 */
.rating { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.rating button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 0 8px; font-size: 13px; line-height: 22px; filter: grayscale(1); opacity: .7; }
.rating button.on { filter: none; opacity: 1; border-color: var(--pri); background: var(--pri-l); }
.body.collapsed { max-height: 420px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }
.check-row { display: flex !important; align-items: center; gap: 6px; color: var(--text) !important; }
.check-row input { width: auto !important; }
