/* ============================================================
   微信半自动记忆回复助手 - 玻璃拟态双主题
   设计规范：玻璃拟态卡片、CSS 变量、浅色(默认) + 深色可切换
   ============================================================ */
:root {
  /* 浅色主题（默认） */
  --bg: #eef1f6;
  --bg2: #ffffff;
  --card: rgba(255, 255, 255, 0.72);
  --input: rgba(255, 255, 255, 0.9);
  --border: rgba(15, 23, 42, 0.09);
  --text: #1f2733;
  --muted: #667085;
  --accent1: #6366f1;
  --accent2: #8b5cf6;
  --danger: #e5484d;
  --success: #2f9e63;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);

  /* 语义补充变量 */
  --text-strong: #111827;
  --text-soft: #475467;
  --card-soft: rgba(255, 255, 255, 0.6);
  --border-soft: rgba(15, 23, 42, 0.07);
  --border-input: rgba(15, 23, 42, 0.14);
  --bg-soft: rgba(15, 23, 42, 0.02);
  --on-accent: #ffffff;
  --scrollbar: rgba(15, 23, 42, 0.18);
  --glow1: rgba(99, 102, 241, 0.10);
  --glow2: rgba(139, 92, 246, 0.08);

  /* 实色面板（不能用 --card，那是半透明玻璃叠在body渐变上会透出色差） */
  --panel: #ffffff;
  --panel-2: #f7f9f8;
  --disabled-bg: #f4f6f5;
  --hairline: rgba(0, 0, 0, 0.06);
  /* 提示条（暖黄）：底 + 字 */
  --warn-bg: #fdf4e6;
  --warn-fg: #8a5a12;
  --warn-border: #f0d9ae;
  /* 绿标（内置方案徽章等）：底 + 字 + 边 */
  --mark-bg: #eef4f0;
  --mark-fg: #18794e;
  --mark-border: #cfe0d5;
  /* 品牌绿：深色主题要提亮，否则深底上对比度不够 */
  --accent: #18794e;
  /* 蓝系链接：与品牌绿分开，避免引用 --accent 时被染绿 */
  --link-blue: #3b6fd4;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg2: #11161d;
  --card: rgba(22, 27, 34, 0.72);
  --input: #1c2330;
  --border: #2a3340;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent1: #6366f1;
  --accent2: #8b5cf6;
  --danger: #f85149;
  --success: #3fb950;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);

  --text-strong: #ffffff;
  --text-soft: #c9d1d9;
  --card-soft: rgba(255, 255, 255, 0.05);
  --border-soft: rgba(255, 255, 255, 0.08);
  --border-input: rgba(255, 255, 255, 0.15);
  --bg-soft: rgba(255, 255, 255, 0.02);
  --on-accent: #ffffff;
  --scrollbar: #3a4757;
  --glow1: rgba(99, 102, 241, 0.16);
  --glow2: rgba(139, 92, 246, 0.12);

  /* 实色面板（深色主题下必须给真实暗色，不能沿用 #fff） */
  --panel: #161b22;
  --panel-2: #1c2330;
  --disabled-bg: #141a21;
  --hairline: rgba(255, 255, 255, 0.08);
  --warn-bg: #2b2417;
  --warn-fg: #e3b341;
  --warn-border: #4a3d1c;
  --mark-bg: #16261c;
  --mark-fg: #4ade80;
  --mark-border: #245034;
  --accent: #2ea56a;
  --link-blue: #6ea3ff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

body {
  background:
    radial-gradient(1200px 600px at 20% -10%, var(--glow1), transparent 60%),
    radial-gradient(1000px 500px at 90% 110%, var(--glow2), transparent 60%),
    var(--bg);
  transition: background 0.3s ease;
}

.hidden { display: none !important; }

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

/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ============ 登录视图 ============ */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.glass {
  background: var(--card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
}

.auth-logo {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 22px;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.tab-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.auth-form { display: flex; flex-direction: column; gap: 12px; }

input, textarea, select {
  width: 100%;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.75; }

/* ============ 按钮 ============ */
/* 全局字体统一：防止个别控件回退到等宽字体 */
button, select, input, textarea { font-family: inherit; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s, transform 0.1s, opacity 0.2s;
}
.btn-primary:hover { filter: brightness(1.12); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary.danger { background: linear-gradient(135deg, #f85149, #d63d3d); }
.btn-primary.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-primary.is-loading::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn-primary.is-loading::after { animation-duration: 1.5s; }
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-ghost:hover { background: var(--input); border-color: #3a4757; }
.btn-ghost:disabled { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: var(--input);
  color: var(--accent1);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}
.icon-btn:hover { background: var(--border); }

.btn-block { width: 100%; margin-top: 4px; }

/* ============ 主布局 ============ */
.main-view {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-top {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.logo {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.current-user {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-family: inherit;
}

.sidebar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1px;
}

.friend-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.friend-item:hover { background: var(--card); }
.friend-item.active {
  background: var(--card);
  border-color: var(--accent1);
}
.friend-avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
}
.friend-meta {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.friend-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.friend-remark {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-empty {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 24px 0;
}

.sidebar-nav {
  padding: 10px 8px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  line-height: 1.2;
  font-family: inherit;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--card); color: var(--text); font-weight: 600; }

.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ============ 聊天工作台 ============ */
.empty-tip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 18px;
  gap: 16px;
  padding: 24px 16px;
  text-align: center;
}
.empty-tip span { font-size: 13px; }
.empty-hint { max-width: 320px; padding: 0 6px; }
.empty-new-btn { width: 100%; max-width: 240px; min-height: 44px; }
.empty-hint { font-size: 13px; color: var(--muted); line-height: 1.6; }

.chat-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chat-nickname { font-size: 17px; font-weight: 700; }
.chat-remark {
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
  background: var(--input);
  padding: 3px 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-style: normal;
}
.chat-header-actions { display: flex; gap: 8px; }
.danger-btn { color: var(--danger); border-color: rgba(248, 81, 73, 0.4); }
.danger-btn:hover { background: rgba(248, 81, 73, 0.12); border-color: var(--danger); }

.msg-list {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-empty {
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  margin: auto;
}

.msg-row { display: flex; flex-direction: column; max-width: 82%; }
.msg-row.them { align-self: flex-start; align-items: flex-start; }
.msg-row.me { align-self: flex-end; align-items: flex-end; }
.msg-time { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.msg-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.them .msg-bubble { background: var(--input); border-bottom-left-radius: 4px; }
.msg-row.me .msg-bubble {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: var(--on-accent);
  border-bottom-right-radius: 4px;
}
/* 分条发送的后续气泡：收紧与上一条的间距，看起来像连着发出去的几条 */
.msg-row.msg-follow { margin-top: -6px; }
/* 回复区「共 N 条」提示（分条发送开启时出现） */
.split-count {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.85;
}

.chat-input-area {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.chat-input-area textarea {
  background: transparent;
  border: none;
  resize: none;
  min-height: 60px;
  padding: 4px;
}
.chat-input-area textarea:focus { box-shadow: none; }
.chat-input-area textarea::placeholder {
  color: var(--muted, var(--muted));
  opacity: 0.95;
  font-size: 13px;
  line-height: 1.5;
  padding: 2px 0;
}
.input-actions .btn-primary { flex-shrink: 0; padding: 10px 16px; }
.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.input-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.reply-area {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.reply-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.reply-area textarea {
  background: var(--input);
  resize: vertical;
  min-height: 74px;
}
.reply-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* ============ JEV 判断 ============ */
.jev-tip { font-size: 12px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.love-picks-tools { display: flex; align-items: center; gap: 12px; margin: 6px 0 4px; font-size: 12px; }
.love-picks-tools .link-btn { background: none; border: none; color: var(--link-blue, #5b9dff); cursor: pointer; padding: 2px 4px; font-size: 12px; }
.love-picks-tools .link-btn:hover { text-decoration: underline; }
.love-picks-tools .love-picks-count { color: var(--muted); }
.love-picks-grid { display: flex; flex-direction: column; gap: 2px 0; font-size: 13px; color: var(--text); max-height: 460px; overflow-x: auto; overflow-y: auto; padding: 6px 0; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft, rgba(0,0,0,0.02)); }
.love-picks-grid label { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-radius: 6px; cursor: pointer; line-height: 1.5; white-space: nowrap; width: 100%; box-sizing: border-box; }
.love-picks-grid label:hover { background: var(--card-soft); }
.love-picks-grid input[type="checkbox"] { margin-top: 0; flex-shrink: 0; width: 16px; height: 16px; min-width: 16px; }
.love-picks-grid .picks-name { flex: 0 0 auto; min-width: auto; white-space: nowrap; }
.love-picks-grid .picks-group-title { width: 100%; box-sizing: border-box; font-weight: 600; color: var(--link-blue, #5b9dff); font-size: 13px; padding: 10px 0 4px; border-bottom: 1px solid var(--border); margin-bottom: 6px; white-space: nowrap; }
.jev-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.jev-toggle input { width: auto; margin: 0; }

/* 汉堡菜单按钮 */
#btn-settings-menu { font-size: 17px; line-height: 1; padding: 9px 12px; }

/* 参数设置浮层（汉堡菜单）：相对聊天输入区定位，向上弹出（避免超出可视区被裁剪） */
.settings-menu {
  position: absolute;
  top: auto;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* 宽度：340px 装不下现在的 4 个分区（打赏那几行右侧文字被裁掉了）。
     放宽到 420px，并用 min() 保证窄屏不撑破视口。 */
  width: min(420px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  /* 内容变长后必须能滚：max-height 用视口兜底，避免顶部被裁 */
  max-height: min(70vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card, #1e2733);
  border: 1px solid var(--border, #2d3748);
  border-radius: var(--radius, 10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  padding: 12px 14px;
}
.settings-menu .settings-menu-title {
  font-size: 11px;
  color: var(--muted, var(--muted));
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.settings-menu .jev-toggle { padding: 2px 0; }
.settings-menu .slider-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  width: 100%;
  white-space: nowrap;
}
.settings-menu .slider-item input[type="range"] { flex: 1; min-width: 0; }

/* 统一滑块：两行等宽、轨道/拇指一致、可滑到底 */
.settings-menu .slider-item input[type="range"] {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 16px;
  margin: 0;
  padding: 0;
  background: transparent;
  accent-color: var(--primary, #4f8cff);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.settings-menu .slider-item input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--primary, #4f8cff) 0%, var(--primary, #4f8cff) var(--slider-fill, 50%), var(--border, #2d3748) var(--slider-fill, 50%), var(--border, #2d3748) 100%);
}
.settings-menu .slider-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--primary, #4f8cff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.settings-menu .slider-item input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border, #2d3748);
}
.settings-menu .slider-item input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--primary, #4f8cff);
}
.settings-menu .slider-item input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--primary, #4f8cff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.settings-menu .slider-item .slider-value {
  min-width: 66px;
  text-align: right;
}

/* 人设浓度 / 温度滑块：中置参数区，与两侧按钮组用分隔线隔开 */
.style-sliders {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0 14px;
  margin: 0 2px;
}
.slider-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.slider-item .slider-label { color: var(--muted); }
.slider-item .slider-hint {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.75;
  letter-spacing: 0;
}
.slider-item input[type="range"] {
  flex: 1;
  min-width: 74px;
  width: auto;
  height: 14px;
  margin: 0;
  accent-color: var(--primary, #4f8cff);
  cursor: pointer;
}
.slider-item .slider-value {
  min-width: 30px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.jev-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(360px, 100vw - 32px);
  z-index: 9999;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 10px 12px;
  max-height: 70vh;
  overflow-y: auto;
}
.jev-panel-body { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.jev-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--input);
  font-size: 12px;
  line-height: 1.4;
}
.jev-row.jev-error { color: var(--danger); }
.jev-label { color: var(--muted); font-size: 11px; }
.jev-value { font-weight: 600; word-break: break-all; }
.jev-panel .btn-ghost, .jev-panel .btn-primary { padding: 5px 10px; font-size: 12px; }

/* 情绪提示：检测到对方情绪低落时询问操作者 */
.emotion-prompt {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(380px, 100vw - 32px);
  z-index: 9999;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning, #e0a800);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  padding: 10px 12px;
  max-height: 72vh;
  overflow-y: auto;
}
.emotion-prompt .emotion-hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin: 4px 0 10px;
}
.emotion-prompt .emotion-panel-body { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.emotion-prompt .btn-ghost, .emotion-prompt .btn-primary { padding: 6px 12px; font-size: 13px; }
.emotion-prompt .emotion-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--warning, #e0a800);
  /* 深色主题下 --warning 偏亮，固定深色字会糊成一片（对比度 1.01:1，等于看不见）。
     用 color-mix 跟着底色走：底亮则字深，两种主题都够清晰；
     不支持 color-mix 的旧浏览器整条声明失效，回落到继承的深浅色。 */
  color: color-mix(in srgb, var(--warning, #e0a800) 20%, #000);
  font-weight: 600;
  margin-left: 6px;
}

/* ============ 档案 / 待办 / 设置 ============ */
.profile-panel, .todos-panel, .settings-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 16px;
}

.view-title { font-size: 20px; font-weight: 700; margin-bottom: 18px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.form-grid label.full { grid-column: 1 / -1; }
/* 勾选行：整行占满但内部横向排列（复选框 + 说明文字） */
.form-grid label.check-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.form-grid label.check-row input[type="checkbox"] { width: auto; margin: 0; flex: none; }
.form-grid textarea { resize: vertical; }

.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.todo-new {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.todo-new input[type="text"] { flex: 1; min-width: 0; }
.todo-new input[type="date"],
.todo-new input[type="datetime-local"] { width: 190px; flex: none; }

.todo-list { display: flex; flex-direction: column; gap: 8px; }

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.todo-item.done .todo-content { text-decoration: line-through; color: var(--muted); }
.todo-check {
  width: 20px;
  height: 20px;
  min-width: 20px;
  accent-color: var(--success);
  cursor: pointer;
}
.todo-body { flex: 1; min-width: 0; }
.todo-content { font-size: 14px; word-break: break-word; }
.todo-due { font-size: 12px; color: var(--muted); margin-top: 3px; }
.todo-due.overdue { color: var(--danger); font-weight: 600; }
.todo-due.today { color: var(--danger); font-weight: 600; }
.todo-source { font-size: 12px; color: var(--accent1); margin-top: 2px; }
.todo-del {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 8px;
}
.todo-del:hover { color: var(--danger); background: var(--input); }

.settings-status {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}
.settings-status .ok { color: var(--success); }
.settings-status .no { color: var(--danger); }

.usage-title { margin: 24px 0 10px; font-size: 15px; }
.usage-list {
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.9;
  font-size: 13px;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}
.modal h3 { font-size: 17px; margin-bottom: 10px; }
.modal-tip { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.modal input {
  margin-bottom: 10px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.todo-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.todo-modal-item .todo-modal-content {
  flex: 1;
  border: none;
  background: transparent;
  padding: 2px;
}
.todo-modal-item input[type="date"],
.todo-modal-item input[type="datetime-local"] { width: 150px; flex: none; }
.todo-modal-item .todo-modal-check { width: 18px; height: 18px; accent-color: var(--accent1); }

/* ============ Toast ============ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.25s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent1); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ 响应式 ============ */
/* 桌面端隐藏移动端顶栏（移动端媒体查询内 display:flex 覆盖） */
.mobile-topbar { display: none; }

@media (max-width: 900px) {
  .sidebar { width: 72px; min-width: 72px; }
  .sidebar-top .logo, .current-user, .section-head span,
  .friend-name, .friend-remark, .nav-item {
    font-size: 0;
  }
  .nav-item { justify-content: center; font-size: 18px; padding: 10px; }
  .section-head { justify-content: center; }
  .friend-item { justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
  .todo-new { flex-direction: column; }
  .todo-new input[type="date"],
  .todo-new input[type="datetime-local"] { width: 100%; }
}

/* ============ 聊天图片（历史渲染 + 发送预览） ============ */
.msg-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-img {
  max-width: 180px;
  max-height: 180px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  cursor: pointer;
}
.image-preview-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  background: var(--input);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.img-preview-item {
  position: relative;
  width: 64px;
  height: 64px;
}
.img-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.img-preview-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: var(--on-accent);
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}
.img-preview-del:hover { filter: brightness(1.15); }

/* ============ 权限管理视图样式 ============ */
.admin-panel { padding: 20px; }
.invite-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.invite-tip { color: var(--muted, var(--muted)); font-size: 13px; }
.invite-list { display: flex; flex-direction: column; gap: 10px; }
.invite-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 10px 14px; font-size: 14px;
}
.invite-code { font-family: Consolas, monospace; font-weight: 700; font-size: 15px; letter-spacing: 1px; color: var(--text-strong); }
.invite-meta { color: var(--muted); font-size: 12px; }
.invite-used { color: #f08c8c; font-size: 12px; }
.invite-fresh { color: #7fd88f; font-size: 12px; }
.admin-user-list { display: flex; flex-direction: column; gap: 10px; }
.admin-user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 12px 14px;
}
.admin-user-info { flex: 1; min-width: 220px; }
.admin-user-name { font-size: 15px; font-weight: 700; color: var(--text-strong); }
.admin-role { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.admin-user-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.admin-user-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chatlog-filters { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.chatlog-filters select {
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 180px;
}
.chatlog-list { display: flex; flex-direction: column; gap: 10px; }
.chatlog-row {
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 12px 14px; font-size: 14px; line-height: 1.6;
}
.chatlog-head { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.chatlog-in { color: var(--text); }
.chatlog-out { color: #7fa8ff; margin-top: 4px; }

/* ===== 新增：好友搜索 / 聊天搜索 / 空间管理 / 用户管理搜索 / 聊天记录关键字 ===== */
.sidebar-search {
  width: 100%; box-sizing: border-box; margin-bottom: 10px;
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
/* 新建好友按钮与搜索框同行、垂直居中 */
.sidebar-search-row { position: relative; margin-bottom: 10px; }
.sidebar-search-row .sidebar-search { margin-bottom: 0; padding-right: 40px; }
.btn-new-friend {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--accent1);
  font-size: 18px;
}
.chat-search-bar { padding: 8px 16px; border-bottom: 1px solid var(--border-soft); }
.chat-search-bar input {
  width: 100%; box-sizing: border-box;
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
.usage-panel {
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 18px;
}
.usage-bar {
  height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden;
}
.usage-bar-inner {
  height: 100%; width: 0%; background: linear-gradient(90deg, #5b8cff, #7fd88f);
  border-radius: 4px; transition: width 0.3s;
}
.usage-bar-inner.warn { background: linear-gradient(90deg, #f5b04c, #f08c8c); }
.usage-meta { color: var(--muted); font-size: 13px; margin: 8px 0; }
.admin-user-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-user-toolbar input {
  flex: 1; min-width: 200px;
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
.chatlog-filters input {
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 180px; flex: 1;
}
.quota-badge { color: #7fd88f; font-size: 12px; }
.quota-badge.warn { color: #f08c8c; }

/* ===== 新增：统一搜索（好友+聊天记录）/ 代看模式 / 全局聊天记录跳转高亮 ===== */
.super-view-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(127,168,255,0.12); border: 1px solid rgba(127,168,255,0.35);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; color: #7fa8ff;
  margin-bottom: 10px;
}
.super-view-bar .btn-ghost { font-size: 12px; padding: 2px 8px; }
.super-view-tip {
  background: rgba(127,168,255,0.12); border: 1px solid rgba(127,168,255,0.35);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; color: #7fa8ff;
  margin-bottom: 10px;
}
.search-results { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.search-group-title {
  font-size: 12px; color: var(--muted); font-weight: 700;
  margin: 4px 0 2px; padding: 4px 6px;
  background: var(--card-soft); border-radius: 6px;
}
.search-friend-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.search-friend-item:hover { background: rgba(255,255,255,0.1); }
.search-friend-item .friend-avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%; background: linear-gradient(135deg, #5b8cff, #7fd88f);
  color: var(--on-accent); display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
}
.search-friend-item .friend-name { font-size: 14px; font-weight: 600; color: var(--text); }
.search-friend-item .friend-remark { font-size: 12px; color: var(--muted); }
.search-msg-item {
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.search-msg-item:hover { background: rgba(255,255,255,0.1); }
.search-msg-head { font-size: 12px; color: #7fa8ff; margin-bottom: 3px; }
.search-msg-snippet {
  font-size: 13px; color: var(--text-soft); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.search-empty { color: var(--muted); font-size: 12px; padding: 6px 2px; }

.msg-row.msg-highlight .msg-bubble {
  box-shadow: 0 0 0 2px #7fa8ff;
  animation: msg-flash 2s ease;
}
@keyframes msg-flash {
  0% { background: rgba(127,168,255,0.45); }
  100% { background: var(--input); }
}
.msg-row.me.msg-highlight .msg-bubble { animation-name: msg-flash-me; }
@keyframes msg-flash-me {
  0% { background: rgba(127,168,255,0.55); }
  100% { background: linear-gradient(135deg, var(--accent1), var(--accent2)); }
}

.chatlog-jump { cursor: pointer; transition: background 0.15s; }
.chatlog-jump:hover { background: rgba(127,168,255,0.12); border-color: rgba(127,168,255,0.35); }
.chatlog-tip { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

/* ============ 手机端适配（≤768px） ============ */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  body { -webkit-text-size-adjust: 100%; }

  /* 移动端紧凑页头 */
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 90;
    height: 48px;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-sizing: border-box;
  }
  .mobile-menu-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 22px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    flex: none;
  }
  .mobile-topbar-title {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-topbar-side { width: 44px; flex: none; }

  /* 主视图：为固定页头让位 */
  .main-view {
    height: 100vh;
    height: 100dvh;
    padding-top: 48px;
    box-sizing: border-box;
  }

  /* 侧边栏 → 抽屉（覆盖 ≤900px 的图标模式） */
  .sidebar {
    position: fixed;
    left: 0; top: 48px; bottom: 0;
    z-index: 120;
    width: min(280px, 84vw);
    min-width: 0;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: none;
    border-right: 1px solid var(--border);
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5); }
  .sidebar-top .logo { font-size: 18px; }
  .current-user { font-size: 12px; }
  .section-head { justify-content: space-between; }
  .section-head span { font-size: 12px; }
  .friend-name { font-size: 14px; }
  .friend-remark { font-size: 12px; }
  .nav-item {
    justify-content: flex-start;
    font-size: 14px;
    padding: 12px;
    min-height: 44px;
  }
  .friend-item {
    justify-content: flex-start;
    min-height: 52px;
    padding: 9px 10px;
  }
  .sidebar-nav { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

  /* 抽屉遮罩 */
  .sidebar-mask {
    position: fixed;
    inset: 48px 0 0 0;
    z-index: 110;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  body.sidebar-open .sidebar-mask { opacity: 1; pointer-events: auto; }

  /* 主内容区全宽 */
  .main-content { width: 100%; min-width: 0; }

  /* 聊天面板：紧凑 + 输入区固定底部 */
  .chat-panel {
    max-width: 100%;
    padding: 8px;
    gap: 8px;
  }
  .chat-header {
    padding: 8px 10px;
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .chat-nickname { font-size: 16px; }
  .chat-remark { font-size: 11px; margin-left: 6px; }
  .chat-header-actions { gap: 4px; flex-wrap: wrap; }
  .chat-header-actions .btn-ghost { padding: 6px 10px; font-size: 12px; min-height: 36px; }

  .chat-search-bar { padding: 6px 8px; }
  .chat-search-bar input { font-size: 16px; min-height: 40px; }

  /* 消息区：触控滚动、气泡限宽、字号缩放 */
  .msg-list {
    padding: 10px 8px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .msg-row { max-width: 80%; }
  .msg-bubble { font-size: 15px; line-height: 1.5; padding: 10px 12px; }
  .msg-time { font-size: 10px; }
  .msg-img { max-width: 140px; max-height: 140px; }

  /* 输入区 / 回复区：触手可及 */
  .chat-input-area { border-radius: 10px; padding: 8px 10px; }
  .chat-input-area textarea { min-height: 44px; font-size: 15px; }
  .input-actions { gap: 6px; }
  .input-actions-left { gap: 4px; }
  .input-actions .btn-primary, .input-actions .btn-ghost { min-height: 40px; padding: 8px 14px; font-size: 14px; }
  /* 窄屏：滑块区换行占满整行，隐藏档位提示防挤压 */
  .style-sliders {
    flex-basis: 100%;
    order: 3;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 8px 0 0;
    margin: 4px 0 0;
    justify-content: flex-start;
  }
  .slider-item .slider-hint { display: none; }
  .reply-area { border-radius: 10px; padding: 10px; }
  .reply-area textarea { min-height: 60px; font-size: 15px; }
  .reply-actions .btn-primary, .reply-actions .btn-ghost { min-height: 40px; font-size: 14px; }

  /* 列表 / 表单页 */
  .profile-panel, .todos-panel, .settings-panel, .admin-panel {
    max-width: 100%;
    padding: 12px 10px;
  }
  .love-picks-grid { grid-template-columns: 1fr; }
  .view-title { font-size: 17px; margin-bottom: 12px; }
  .form-grid { gap: 10px; }
  .form-grid label { font-size: 14px; }
  .form-grid input, .form-grid textarea, .form-grid select,
  .modal input, .modal textarea, .modal select { font-size: 16px; }
  .profile-actions { gap: 8px; }
  .profile-actions .btn-primary, .profile-actions .btn-ghost { min-height: 42px; font-size: 14px; }

  /* 触控目标 ≥44px */
  .search-friend-item, .search-msg-item, .todo-item, .invite-row, .admin-user-row, .chatlog-row {
    min-height: 44px;
  }
  .search-friend-item, .search-msg-item { padding: 12px 10px; }
  .todo-item { padding: 12px 10px; }
  .todo-check { width: 24px; height: 24px; min-width: 24px; }
  .todo-del { padding: 10px 12px; font-size: 18px; }
  .admin-user-info { min-width: 0; }
  .admin-user-actions { gap: 6px; }
  .admin-user-actions .btn-ghost { padding: 6px 10px; font-size: 12px; min-height: 36px; }
  .invite-toolbar, .chatlog-filters, .admin-user-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .chatlog-filters select, .chatlog-filters input, .admin-user-toolbar input {
    min-width: 0;
    width: 100%;
    font-size: 16px;
  }

  /* 弹窗 → 底部全屏抽屉 */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    animation: modal-up 0.22s ease;
  }
  .modal h3 { font-size: 16px; }
  .modal-tip { font-size: 13px; }
  .modal-actions {
    position: sticky;
    bottom: 0;
    gap: 8px;
    padding-top: 12px;
    background: inherit;
  }
  .modal-actions .btn-primary, .modal-actions .btn-ghost { min-height: 42px; font-size: 14px; }
  .todo-modal-item { flex-wrap: wrap; }
  .todo-modal-item input[type="date"],
  .todo-modal-item input[type="datetime-local"] { width: 100%; }
  @keyframes modal-up {
    from { transform: translateY(60px); opacity: 0.6; }
    to { transform: none; opacity: 1; }
  }

  /* 登录页 */
  .auth-view { min-height: 100vh; min-height: 100dvh; padding: 16px; }
  .auth-card { padding: 26px 20px; }
  .auth-logo { font-size: 22px; }
  .auth-sub { font-size: 12px; margin: 6px 0 18px; }
  .auth-form input { font-size: 16px; padding: 11px 12px; }
  .auth-form .btn-primary { min-height: 44px; font-size: 15px; }

  /* 通用触控优化 */
  .friend-list, .profile-panel, .todos-panel, .settings-panel, .admin-panel {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .sidebar-search { font-size: 16px; min-height: 40px; }
  .search-group-title { font-size: 13px; }
  .super-view-bar { flex-wrap: wrap; }
  #toast-container { top: 56px; right: 12px; left: 12px; }
  .toast { min-width: 0; max-width: 100%; width: 100%; font-size: 14px; }
}

/* ===== 预设回复人设（设置页区块 + 好友档案下拉） ===== */
.preset-pick-label { color: var(--muted); font-size: 13px; }
.preset-pick-label select {
  width: 100%; margin-top: 6px;
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
.preset-tip { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }

.preset-new {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px;
}
.preset-new input,
.preset-new textarea {
  width: 100%; box-sizing: border-box;
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.preset-list { display: flex; flex-direction: column; gap: 10px; }
.preset-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 12px 14px; font-size: 14px;
}
.preset-info { flex: 1; min-width: 200px; }
.preset-name { font-size: 15px; font-weight: 700; color: var(--text-strong); }
.preset-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.preset-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== 长期记忆（好友档案：补充记忆 / 已有记忆） ===== */
.memory-section {
  margin-top: 18px;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}
.view-subtitle {
  font-size: 14px; font-weight: 700; color: var(--text); margin: 0 0 8px;
}
.memory-add {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.memory-add input {
  flex: 1; min-width: 0;
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; font-family: inherit;
}
.memory-add .btn-primary { white-space: nowrap; }
.memory-list { display: flex; flex-direction: column; gap: 8px; }
.memory-row {
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.memory-content { color: var(--text); line-height: 1.5; word-break: break-word; }
.memory-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap;
}
.memory-tag {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
}
.memory-tag-manual { background: rgba(64,145,255,0.15); color: #6db0ff; }
.memory-tag-auto { background: rgba(52,199,123,0.15); color: #4fd08c; }
/* P0：主题键 + 「已被新说法取代」标记。被顶掉的行压暗但仍可看/可删。 */
.memory-tag-subject { background: rgba(255,255,255,0.07); color: var(--muted); }
.memory-tag-superseded { background: rgba(255,180,80,0.14); color: #e0a458; }
/* owner：这条记忆是谁的事——对方 / 我 / 我们（双方对称记忆的可见性） */
.memory-tag-owner { background: rgba(168,120,255,0.16); color: #b79bff; }
.memory-row-superseded { opacity: 0.55; }
.memory-row-superseded .memory-content { text-decoration: line-through; text-decoration-thickness: 1px; }
.memory-time { color: var(--muted); font-size: 12px; }
.memory-meta .memory-del { margin-left: auto; padding: 4px 10px; font-size: 12px; }
.memory-meta .acted-del { margin-left: auto; padding: 4px 10px; font-size: 12px; }

/* ===== 关系时间线 ===== */
.timeline-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.timeline-head {
  color: var(--text); font-weight: 600; font-size: 14px;
  padding: 6px 12px; background: rgba(24,121,78,0.10);
  border: 1px solid rgba(24,121,78,0.20); border-radius: 8px;
}
.timeline-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 7px 12px; font-size: 13px;
}
.timeline-label {
  flex-shrink: 0; font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: rgba(64,145,255,0.15); color: #6db0ff;
}
.timeline-date { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.timeline-content { color: var(--text); line-height: 1.5; word-break: break-word; }


/* ===== 记忆编辑（行内） ===== */
.memory-meta .memory-edit { padding: 4px 10px; font-size: 12px; }
.memory-edit-input {
  width: 100%; box-sizing: border-box;
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; font-family: inherit;
}
.memory-meta .memory-edit-save, .memory-meta .memory-edit-cancel {
  padding: 4px 12px; font-size: 12px;
}

/* ===== 公告管理（设置页 super-only） ===== */
.ann-new { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ann-new input, .ann-new textarea {
  width: 100%; box-sizing: border-box;
  background: var(--input); color: var(--text); border: 1px solid var(--border-input);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; font-family: inherit; resize: vertical;
}
.ann-new .ann-actions { display: flex; gap: 8px; }
.ann-edit-hint { color: #ffc860; font-size: 12px; }
.announcement-list { display: flex; flex-direction: column; gap: 10px; }
.announcement-row {
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 12px 14px; font-size: 14px;
}
.announcement-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.announcement-row-head .announcement-title { font-weight: 700; color: var(--text-strong); }
.announcement-status { font-size: 12px; padding: 1px 8px; border-radius: 999px; }
.announcement-status.ok { background: rgba(52,199,123,0.15); color: #4fd08c; }
.announcement-status.no { background: rgba(248,81,73,0.15); color: #f85149; }
.announcement-row .announcement-content { color: var(--text-soft); line-height: 1.5; margin: 6px 0 0; word-break: break-word; }
.announcement-row .memory-meta .ann-edit, .announcement-row .memory-meta .ann-toggle,
.announcement-row .memory-meta .ann-del { padding: 4px 10px; font-size: 12px; }

/* ===== 公告弹窗 ===== */
.announcement-modal-body { margin: 12px 0; }
.announcement-item { display: flex; flex-direction: column; gap: 6px; }
.announcement-item .announcement-title { font-size: 17px; font-weight: 700; color: var(--text-strong); }
.announcement-item .announcement-time { color: var(--muted); font-size: 12px; }
.announcement-item .announcement-content {
  color: var(--text); line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  background: var(--card-soft); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 12px 14px;
}

/* ===== 新手引导 ===== */
.guide-modal { max-width: 480px; }
.guide-steps { margin: 12px 0; }
.guide-step-title { font-size: 17px; font-weight: 700; color: var(--text-strong); margin-bottom: 8px; }
.guide-step-text { color: var(--text-soft); line-height: 1.7; }
.guide-dots { display: flex; justify-content: center; gap: 6px; margin: 12px 0 4px; }
.guide-dot { width: 8px; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.2); }
.guide-dot.active { background: #4d7cf6; width: 20px; }

/* ===== 帮助弹窗 ===== */
.help-modal { max-width: 640px; }
.help-content {
  max-height: 60vh; overflow-y: auto; margin: 12px 0; padding-right: 6px;
  display: flex; flex-direction: column; gap: 10px;
}
.help-content h4 { font-size: 15px; font-weight: 700; color: var(--text-strong); margin: 6px 0 4px; }
.help-content p { color: var(--text-soft); line-height: 1.7; margin: 0; font-size: 14px; }
.help-content code {
  background: var(--border-soft); border-radius: 4px; padding: 1px 5px;
  font-size: 12px; color: #6db0ff;
}

/* ===== 移动端帮助按钮 ===== */
.mobile-help-btn {
  background: transparent; border: none; color: var(--text);
  font-size: 18px; cursor: pointer; padding: 4px 6px; line-height: 1;
}

/* ============ 首屏欢迎页（首次登录） ============ */
.welcome-mask {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 20px;
}
.welcome-card {
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px 24px;
}
/* 欢迎页主按钮：限宽居中，避免横向贯穿整个卡片 */
.welcome-card .btn-block {
  width: 100%;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
  min-height: 44px;
  font-family: inherit;
}
.welcome-logo {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.welcome-desc {
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 18px;
}
.welcome-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.welcome-step { display: flex; gap: 12px; align-items: flex-start; }
.welcome-step-num {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: var(--on-accent);
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.welcome-step b { font-size: 14px; color: var(--text-strong); }
.welcome-step p { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin-top: 3px; }

/* ============ 高亮分步引导（box-shadow 遮罩定位真实按钮） ============ */
.spotlight-mask {
  position: fixed;
  inset: 0;
  z-index: 110;
}
.spotlight-highlight {
  position: fixed;
  border-radius: 12px;
  border: 2px solid var(--accent1);
  box-shadow: 0 0 0 9999px rgba(5, 8, 12, 0.58);
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 110;
}
.spotlight-card {
  position: fixed;
  z-index: 111;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 18px 18px 14px;
}
.spotlight-step-title { font-size: 16px; font-weight: 700; color: var(--text-strong); margin-bottom: 8px; }
.spotlight-step-text { font-size: 13px; color: var(--text-soft); line-height: 1.7; margin-bottom: 10px; }
.spotlight-dots { display: flex; gap: 6px; margin-bottom: 12px; }
.spotlight-dot { width: 8px; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.22); }
.spotlight-dot.active { background: #4d7cf6; width: 20px; }
.spotlight-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.spotlight-card.spotlight-card-center {
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 24px));
  text-align: center;
}
.spotlight-card-center .spotlight-dots,
.spotlight-card-center .spotlight-actions { justify-content: center; }
/* 引导激活时，让新建好友等业务弹窗浮在遮罩之上 */
body.spotlight-active .modal-mask { z-index: 130; }

/* ============ 好友空状态引导卡片 ============ */
.guide-card {
  margin: 8px 4px;
  padding: 14px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.guide-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.guide-card-head b { font-size: 13px; color: var(--text-strong); }
.guide-card-close {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.guide-card-close:hover { background: var(--input); color: var(--text); }
.guide-card-step { font-size: 12.5px; color: var(--text-soft); line-height: 1.7; padding-left: 2px; }
.guide-card-step b { color: var(--accent1); font-weight: 600; }
.guide-card-btn { margin-top: 10px; width: 100%; }

@media (max-width: 768px) {
  .welcome-card { padding: 22px 18px; }
  .welcome-card .btn-block { max-width: none; min-height: 48px; }
  .welcome-logo { font-size: 21px; }
  .spotlight-card { padding: 16px 16px 12px; }
  .spotlight-actions .btn-primary,
  .spotlight-actions .btn-ghost { min-height: 40px; font-size: 14px; }
}

/* ===== Key 管理（超管） ===== */
.keys-section { margin: 12px 0 18px; padding: 12px 14px; border: 1px solid var(--border, rgba(255,255,255,.08)); border-radius: 12px; background: rgba(255,255,255,.03); }
.keys-section h4 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--text, #eee); }
.keys-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.keys-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.04); }
.keys-label { font-weight: 600; color: var(--text, #eee); }
.keys-meta { font-size: 12px; color: var(--muted, #999); }
.keys-row .keys-del { margin-left: auto; }
.keys-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.keys-add input { flex: 1 1 160px; min-width: 140px; }
.keys-add .btn-primary { white-space: nowrap; }

/* ===== 人设生成器 ===== */
.preset-gen-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.preset-gen-bar .btn-primary { white-space: nowrap; }
.persona-gen-modal { max-width: 620px; max-height: 88vh; overflow-y: auto; }
.pg-brief-row { display: flex; gap: 8px; margin: 4px 0 6px; align-items: flex-start; }
.pg-brief-row textarea { flex: 1; resize: vertical; }
.pg-brief-row .btn-primary { white-space: nowrap; }
.pg-form-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pg-form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text, #eee); }
.pg-form-grid textarea { min-height: 44px; resize: vertical; }
.status-loading { color: var(--accent1, #4ea1ff); font-size: 13px; }
.status-ok { color: #34d399; font-size: 13px; }
.pg-inline-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.pg-inline-bar .btn-ghost { white-space: nowrap; }
.pg-inline-bar .preset-tip { margin: 0; }

/* ===== 恋爱军师命中展示 ===== */
.love-hits {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}
.love-hit-label { color: var(--muted); }
.love-hit-tag {
  background: rgba(139, 92, 246, 0.14);
  color: var(--accent2);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(139, 92, 246, 0.28);
}
.love-hit-more { color: var(--muted); font-size: 12px; }

/* ===== 未配置 Key 跳转设置页时的高亮提示 ===== */
.target-flash {
  animation: targetFlash 1s ease-in-out 2;
  border-radius: 8px;
}
@keyframes targetFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
  50% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.45); }
}

/* ===== 参数设置浮层（优化后） ===== */
.settings-menu .pg-group-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  margin: 8px 0 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.settings-menu .pg-group-label:first-of-type { border-top: none; margin-top: 0; }
/* 滚动容器里，分组标题吸顶会盖住上一组内容，这里改成随内容滚动即可，
   但吸顶能让长面板的结构始终可辨——用 sticky 且留出背景色。 */
.settings-menu .pg-group-label {
  position: sticky;
  top: -12px;
  z-index: 1;
  background: var(--card, #1e2733);
  padding: 6px 0 4px;
}
.settings-menu .jev-toggle { padding: 3px 0; }
.settings-menu .opt-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.75;
}
.settings-menu .opt-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
.settings-menu .opt-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.settings-menu .opt-block-head .slider-label {
  color: var(--text);
  /* 标题不被右侧长文案挤掉 */
  flex: 0 0 auto;
  white-space: nowrap;
}
.settings-menu .opt-block-head .slider-value {
  font-variant-numeric: tabular-nums;
  color: var(--accent1);
  font-weight: 500;
  /* 右侧值（如「跟随账号默认」）允许换行，不再把标题挤出可视区 */
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}
.settings-menu .opt-block input[type="range"] { width: 100%; }
.settings-menu .opt-block input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--primary, #4f8cff) 0%, var(--primary, #4f8cff) var(--slider-fill, 50%), var(--border) var(--slider-fill, 50%), var(--border) 100%);
  cursor: pointer;
}
.settings-menu .opt-block input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary, #4f8cff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.settings-menu .opt-desc { font-size: 11px; color: var(--muted); opacity: 0.7; }

/* 设置页「分条碎度」滑块块：复用浮层 opt-block 的视觉，独立作用域 */
.split-level-set-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0 2px;
}
.split-level-set-block .opt-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.split-level-set-block .opt-block-head .slider-label { color: var(--text); font-weight: 600; }
.split-level-set-block .opt-block-head .slider-value {
  font-variant-numeric: tabular-nums;
  color: var(--accent1);
  font-weight: 500;
}
.split-level-set-block input[type="range"] { width: 100%; }
.split-level-set-block input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--primary, #4f8cff) 0%, var(--primary, #4f8cff) var(--slider-fill, 50%), var(--border) var(--slider-fill, 50%), var(--border) 100%);
  cursor: pointer;
}
.split-level-set-block input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary, #4f8cff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.split-level-set-block .opt-desc { font-size: 11px; color: var(--muted); opacity: 0.7; }
.split-level-set-block.is-disabled { opacity: 0.45; pointer-events: none; }

/* ---------- 知识库 ---------- */
.kb-panel {
  padding: 24px 28px 40px;
  max-width: 900px;
  overflow-y: auto;
  height: 100%;
  box-sizing: border-box;
}
.kb-tip {
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0 0 18px;
}
.kb-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 22px 0 10px;
}
.kb-new {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.kb-new input[type="text"] { flex: 1; min-width: 180px; }
.kb-paste {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.kb-paste input[type="text"] { flex: 1; min-width: 0; }

.kb-status {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  padding: 9px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  word-break: break-word;
}
.kb-status.busy { color: var(--accent1); border-color: var(--accent1); }
.kb-status.err { color: var(--danger); border-color: var(--danger); }
.kb-status.ok { color: var(--success); border-color: var(--success); }

.kb-draft {
  margin-top: 16px;
  border: 1px solid var(--accent1);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--card);
}
.kb-draft-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.kb-draft textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  line-height: 1.7;
}

.kb-test-row {
  display: flex;
  gap: 10px;
}
.kb-test-row input[type="text"] { flex: 1; min-width: 0; }
.kb-test-out {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.kb-test-out .kb-reason { color: var(--muted); }

.kb-list { display: flex; flex-direction: column; gap: 10px; }
.kb-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 13px 15px;
}
.kb-item.off { opacity: 0.5; }
.kb-item-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.kb-item-topic { font-size: 15px; font-weight: 600; }
.kb-item-ver {
  font-size: 12px;
  color: var(--accent1);
  border: 1px solid var(--accent1);
  border-radius: 10px;
  padding: 1px 8px;
}
.kb-item-scope { font-size: 12px; color: var(--muted); }
.kb-item-kw {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  word-break: break-word;
}
.kb-item-body {
  font-size: 13px;
  line-height: 1.8;
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.kb-item-src {
  font-size: 12px;
  margin-top: 6px;
  word-break: break-all;
}
.kb-item-src a { color: var(--accent1); }
.kb-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.kb-mini {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.kb-mini:hover { color: var(--text); border-color: var(--text); }
.kb-mini.danger:hover { color: var(--danger); border-color: var(--danger); }
.kb-empty { font-size: 13px; color: var(--muted); padding: 8px 0; }

/* ============ 回复规则（☰ 面板：预设下拉 + 自定义区间） ============ */
.settings-menu select { padding: 7px 10px; font-size: 12px; }
.rp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-top: 8px;
}
.rp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.rp-field input { padding: 6px 9px; font-size: 12px; }

/* ---------- 打赏机制：今日进度 + 手动记到账 ---------- */
.tr-today-line {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.tr-today-line b { color: var(--text); font-size: 13px; }
.tr-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.tr-btn {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--border, #dce3de);
  background: var(--accent, #18794e);
  color: #fff;
  cursor: pointer;
}
.tr-btn:hover { opacity: .88; }
.tr-btn-ghost {
  background: transparent;
  color: var(--muted);
}
.tr-log {
  margin-top: 8px;
  max-height: 120px;
  overflow-y: auto;
  font-size: 11px;
  color: var(--muted);
}
.tr-log-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--hairline);
}
.tr-log-item span:first-child { flex: 1; }
.tr-log-del {
  border: 0;
  background: transparent;
  color: #b44832;
  cursor: pointer;
  font-size: 11px;
}

.tr-income-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.tr-income-row input { width: 96px; padding: 5px 8px; font-size: 12px; }
.tr-income-row select { padding: 5px 6px; font-size: 12px; }
.tr-income-row.hidden { display: none; }

.tr-income-row input[type="text"] { width: 130px; }
.tr-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  width: 100%;
}
.tr-chip {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 10px;
  border: 1px solid var(--border, #dce3de);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tr-chip:hover { color: var(--accent, #18794e); border-color: var(--accent, #18794e); }

/* 降级提示条：连续被拒到阈值后，界面要明确告诉用户"系统已自动收手" */
.tr-hint {
  margin-top: 6px;
  padding: 6px 9px;
  font-size: 11.5px;
  line-height: 1.55;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid var(--warn-border);
}
.tr-hint.hidden { display: none; }

/* ---------- 语境判读结论 ----------
   单独一套样式：它是「AI 读到了什么」，属于信息展示而不是警告，
   复用 .tr-hint 的黄底会让人以为出了什么问题。 */
.ctx-read-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text, inherit);
}
.ctx-read-row {
  padding: 2px 0;
  line-height: 1.5;
  word-break: break-word;
}
.ctx-read-row b {
  display: inline-block;
  min-width: 4.5em;
  margin-right: 6px;
  font-weight: 600;
  opacity: 0.75;
}

/* ---------- 打赏模块管理器 ---------- */
.tm-list { display: flex; flex-direction: column; gap: 6px; }
.tm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border, #dce3de);
  border-radius: 8px;
  background: var(--panel, #fff);
  cursor: pointer;
}
.tm-item:hover { border-color: var(--accent, #18794e); }
.tm-item.active {
  border-color: var(--accent, #18794e);
  background: var(--mark-bg);
}
.tm-item-main { flex: 1; min-width: 0; }
.tm-item-name { font-size: 13px; font-weight: 500; color: var(--text, #24382d); }
.tm-item-meta { font-size: 11px; color: var(--muted, #68776f); margin-top: 2px; }
.tm-item-tag {
  flex: none;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 9px;
  border: 1px solid var(--border, #dce3de);
  color: var(--muted, #68776f);
}
.tm-item-tag.builtin { border-color: var(--mark-border); color: var(--mark-fg); }

.tm-editor {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border, #dce3de);
  border-radius: 10px;
  background: var(--panel, #fff);
}
.tm-editor.hidden { display: none; }
.tm-editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tm-editor-head input[type="text"] {
  flex: 1;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 500;
}
.tm-editor-head input:disabled { background: var(--disabled-bg); color: var(--muted, #68776f); }
.tm-badge {
  flex: none;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 9px;
  background: var(--mark-bg);
  color: var(--mark-fg);
}
.tm-editor-tip {
  margin-bottom: 10px;
  padding: 7px 10px;
  font-size: 11.5px;
  line-height: 1.55;
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid var(--warn-border);
}
.tm-editor-tip.hidden { display: none; }

.tm-groups { display: flex; flex-direction: column; gap: 12px; }
.tm-group {
  border: 1px solid var(--border, #dce3de);
  border-radius: 8px;
  padding: 10px 12px;
}
.tm-group-head {
  font-size: 12px;
  font-weight: 500;
  color: var(--mark-fg);
  margin-bottom: 8px;
}
.tm-field { margin-bottom: 10px; }
.tm-field:last-child { margin-bottom: 0; }
.tm-field-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.tm-field-label { font-size: 12px; font-weight: 500; color: var(--text, #24382d); }
.tm-field-count { font-size: 10.5px; color: var(--muted, #68776f); margin-left: auto; }
.tm-field-count.over { color: #b44832; }
.tm-field-hint { font-size: 11px; color: var(--muted, #68776f); margin-bottom: 4px; line-height: 1.5; }
.tm-field textarea {
  width: 100%;
  min-height: 56px;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
  font-family: inherit;
}
.tm-field textarea.tall { min-height: 96px; }
/* 内置方案字段是只读的，要看得清而不是"灰掉一片" */
.tm-field textarea:disabled {
  background: var(--disabled-bg);
  color: var(--text-soft);
  -webkit-text-fill-color: var(--text-soft);
  opacity: 1;
}

.tm-preview { margin-top: 12px; }
.tm-preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted, #68776f);
  margin-bottom: 5px;
}
.btn-mini { padding: 3px 9px; font-size: 11px; }
.tm-preview-body {
  margin: 0;
  padding: 10px 12px;
  max-height: 260px;
  overflow: auto;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--panel-2);
  border: 1px solid var(--border, #dce3de);
  border-radius: 6px;
  color: var(--text, #24382d);
}

/* ============ 事实同步（B 组）：消息状态标记 / 编辑 / 补录 ============ */
/* 我方消息下的状态行：右侧对齐，和气泡拉开一点点距离 */
.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}
.msg-state {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
}
/* 已发=中性；草稿=暖黄提醒（它还没进上下文）；已取消=灰掉（不再出现在任何地方） */
.msg-state-sent { color: var(--muted); }
.msg-state-draft { color: var(--warn-fg); background: var(--warn-bg); border-color: var(--warn-border); }
.msg-state-cancelled { color: var(--muted); background: var(--bg-soft); text-decoration: line-through; }
.msg-edit {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.msg-edit:hover { color: var(--accent1); border-color: var(--accent1); }

/* 删除按钮：跟「编辑」同一排，但用危险色——删不可恢复，一眼看得出轻重 */
.msg-del {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.msg-del:hover { color: var(--danger, #b44832); border-color: var(--danger, #b44832); }
/* 对方那条上的 meta（只有「没我方回复」的记录才有删除按钮）：
   不加宽度约束的话 flex 容器会被按钮顶开，气泡和对齐一起变形。 */
.msg-row.them .msg-meta { margin-top: 4px; }

/* 多选删除（2026-10-10）——操作条与勾选框 */
.msg-pick-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin: 4px 0 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.msg-pick-hint { color: var(--muted); }
.msg-pick-count { color: var(--accent1); font-weight: 600; }
.msg-pick-bar .btn-primary { margin-left: auto; }
.msg-pick-bar .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* 勾选框平时藏在气泡左侧，多选模式下才露出来——
   不然平时每条消息左边都挂一个方框，界面会变得很噪。 */
.msg-pick { display: none; }
.msg-list.pick-mode .msg-pick {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  align-self: center;
}
.msg-list.pick-mode .msg-row.them > .msg-pick {
  order: -1;                 /* 时间戳之后、气泡之前 */
}
.msg-pick-box { cursor: pointer; width: 15px; height: 15px; accent-color: var(--accent1); }
/* 多选时点气泡＝勾选，光标要变成手型，不然用户以为只有那个小方框能点 */
.msg-list.pick-mode .msg-row.them .msg-bubble { cursor: pointer; }

/* 行内编辑块：盖在被编辑的那几条气泡原来的位置上 */
.msg-edit-box {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  margin: 6px 0;
  padding: 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--panel-2);
}
.msg-edit-input {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  font-family: inherit;
}
.msg-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* 补录表单：贴在输入框下面，默认收起 */
.backfill-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--panel-2);
}
.backfill-title { font-size: 12.5px; color: var(--muted); }
.backfill-form textarea {
  width: 100%;
  min-height: 54px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  font-family: inherit;
}
.backfill-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.backfill-actions input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  font-size: 13px;
}
.backfill-hint { font-size: 12px; color: var(--muted); }
