:root {
  --bg: #f3ece1;
  --bg-soft: #e8dfd0;
  --ink: #3a3229;
  --ink-soft: #7d7161;
  --bubble-her: #ffffff;
  --bubble-me: #cfe0d4;
  --accent: #a8552f;
  --line: #d9cdba;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #efe6d8, #e9dfcf);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c0b5a3; flex: none; }
.dot.on { background: #4c8f63; }
.dot.bad { background: #b4553c; }
.name { font-weight: 600; letter-spacing: .02em; }
.sub { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; gap: 4px; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-size: 16px;
  padding: 6px 9px;
}
.ghost.active { background: #fff; border-color: var(--accent); color: var(--accent); }

/* 对话区 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15.5px;
  box-shadow: 0 1px 2px rgba(58, 50, 41, .08);
}
.bubble.her { align-self: flex-start; background: var(--bubble-her); border-bottom-left-radius: 4px; }
.bubble.me  { align-self: flex-end; background: var(--bubble-me); border-bottom-right-radius: 4px; }
.bubble.her::before { content: ""; }
.meta { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
.bubble.proactive { border-left: 3px solid var(--accent); }
.bubble.pending { opacity: .55; }
.divider { align-self: center; font-size: 11.5px; color: var(--ink-soft); padding: 4px 0; }

.hint {
  margin: 0 12px 8px;
  padding: 9px 12px;
  background: #fff6e5;
  border: 1px solid #e7d3a8;
  border-radius: 10px;
  font-size: 13px;
}
.hidden { display: none !important; }

/* 输入栏 */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
  background: #efe6d8;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 9px 13px;
  font: inherit;
  font-size: 15.5px;
  line-height: 1.5;
  max-height: 120px;
  background: #fff;
  color: var(--ink);
}
.composer textarea:focus { outline: 2px solid #cbb99d; }
.round {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 18px;
  line-height: 1;
}
.round.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-size: 20px; }
.round.listening { background: #f2c9b4; border-color: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* 设置面板 */
.panel {
  position: fixed;
  inset: 0;
  background: rgba(58, 50, 41, .38);
  display: flex;
  justify-content: flex-end;
  z-index: 20;
}
.panel-inner {
  width: min(420px, 92vw);
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel h2 { margin: 0 0 4px; font-size: 17px; }
.panel label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--ink-soft); }
.panel label.row { flex-direction: row; align-items: center; gap: 8px; }
.panel input[type="text"], .panel input[type="password"], .panel select {
  font: inherit;
  font-size: 15px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.panel-actions { display: flex; gap: 8px; margin-top: 4px; }
.panel-actions button {
  flex: 1;
  padding: 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}
.panel-actions .danger { color: #a4342a; border-color: #dcb3ab; }
.tiny { font-size: 12px; color: var(--ink-soft); line-height: 1.6; }

/* 她的思考（网页上可折叠的小块） */
.thinking { margin: 6px 0 10px; padding: 6px 10px; border-left: 3px solid #d0d0d0; background: #f6f6f6; border-radius: 6px; font-size: 13px; color: #667; }
.thinking summary { cursor: pointer; color: #8a8a8a; }
.thinking-body { white-space: pre-wrap; line-height: 1.55; margin-top: 6px; }
