/* ============================================================
   enhance.css —— PChat 0.10.0「灵动增强包」
   ============================================================
   本文件只做「增量」：不修改 theme.css 里任何既有类，
   新类统一以 enh- 前缀命名，配色通过覆盖 CSS 变量实现，
   因此关掉本文件也不会破坏原有界面。
   加载顺序：必须在 theme.css 之后（index.html 中已如此）。
   ============================================================ */

/* ============================================================
   1. 主题配色（6 套）
   ------------------------------------------------------------
   每套配色分成「两个色阶」，各自有明确用途，保证任何一套下
   文字都满足 WCAG AA（正文 4.5:1，气泡内文字 ≥ 7:1）：

     深色阶  --primary-gradient / --primary-hover / --accent-text
             → 主按钮、发送键、登录标题（白字压在深色渐变上）
     浅色阶  --bubble-sent / --bubble-sent-text
             → 我发出的气泡（深墨字压在浅色气泡上，8~10:1）
     强调色  --enh-accent / --enh-accent-soft
             → 小圆点、代码块、链接式文字（在浅灰底上 ≥ 4.7:1）

   0.11.0 修正：0.10.0 把「按钮用的深色」和「气泡用的色」混成一套，
   浅色端点配白字只有 1.9~2.5:1 —— 本次拆成两套色阶解决。
   ============================================================ */

:root {
  --enh-accent: #333333;
  --enh-accent-soft: rgba(0, 0, 0, 0.08);
  --enh-msg-font: 0.95rem;
  --enh-msg-line: 1.6;
  --enh-msg-gap: 2px;
  --enh-msg-pad-y: 9px;
  --enh-msg-pad-x: 13px;
  --enh-msg-time-gap: 14px;
}

/* ---- 樱粉 ---- */
[data-accent="sakura"] {
  /* 深色：按钮 / 渐变标题 / 强调文字（纯白字对比 4.8~7.2） */
  --primary-gradient: linear-gradient(135deg, #d23066 0%, #a1234d 100%);
  --primary-hover: #881e41;
  --accent-text: #ffffff;
  /* 浅色：我发出的气泡（深墨字对比 8~10） */
  --bubble-sent: linear-gradient(135deg, #ebc4d1 0%, #e4adbf 100%);
  --bubble-sent-text: #3b1623;
  --enh-accent: #be3764;
  --enh-accent-soft: rgba(190, 55, 100, 0.14);
}
[data-theme="dark"][data-accent="sakura"] {
  --primary-gradient: linear-gradient(135deg, #f4aec6 0%, #dd86a6 100%);
  --primary-hover: #f8c3d5;
  --accent-text: #2b1019;
  --bubble-sent: linear-gradient(135deg, #f4aec6 0%, #dd86a6 100%);
  --bubble-sent-text: #2b1019;
  --enh-accent: #eba2bd;
  --enh-accent-soft: rgba(235, 162, 189, 0.18);
}

/* ---- 海蓝 ---- */
[data-accent="ocean"] {
  --primary-gradient: linear-gradient(135deg, #2d71cb 0%, #22569b 100%);
  --primary-hover: #1c4882;
  --accent-text: #ffffff;
  --bubble-sent: linear-gradient(135deg, #bccfe9 0%, #a5bfe1 100%);
  --bubble-sent-text: #16263b;
  --enh-accent: #346cb4;
  --enh-accent-soft: rgba(52, 108, 180, 0.14);
}
[data-theme="dark"][data-accent="ocean"] {
  --primary-gradient: linear-gradient(135deg, #93bff0 0%, #5f93dd 100%);
  --primary-hover: #a8ccf5;
  --accent-text: #0d1c2e;
  --bubble-sent: linear-gradient(135deg, #93bff0 0%, #5f93dd 100%);
  --bubble-sent-text: #0d1c2e;
  --enh-accent: #8fbcf0;
  --enh-accent-soft: rgba(143, 188, 240, 0.18);
}

/* ---- 森绿 ---- */
[data-accent="forest"] {
  --primary-gradient: linear-gradient(135deg, #1c8252 0%, #16623e 100%);
  --primary-hover: #125234;
  --accent-text: #ffffff;
  --bubble-sent: linear-gradient(135deg, #96dcbb 0%, #7fd4ac 100%);
  --bubble-sent-text: #163b2a;
  --enh-accent: #237951;
  --enh-accent-soft: rgba(35, 121, 81, 0.14);
}
[data-theme="dark"][data-accent="forest"] {
  --primary-gradient: linear-gradient(135deg, #9bdcb6 0%, #62ad86 100%);
  --primary-hover: #b0e6c6;
  --accent-text: #0c1f16;
  --bubble-sent: linear-gradient(135deg, #9bdcb6 0%, #62ad86 100%);
  --bubble-sent-text: #0c1f16;
  --enh-accent: #98d9b3;
  --enh-accent-soft: rgba(152, 217, 179, 0.18);
}

/* ---- 暮橙 ---- */
[data-accent="sunset"] {
  --primary-gradient: linear-gradient(135deg, #a36324 0%, #7b4b1b 100%);
  --primary-hover: #663e16;
  --accent-text: #ffffff;
  --bubble-sent: linear-gradient(135deg, #e4c9af 0%, #ddba98 100%);
  --bubble-sent-text: #3b2916;
  --enh-accent: #94602b;
  --enh-accent-soft: rgba(148, 96, 43, 0.14);
}
[data-theme="dark"][data-accent="sunset"] {
  --primary-gradient: linear-gradient(135deg, #f5c48d 0%, #e09a58 100%);
  --primary-hover: #f8d2a4;
  --accent-text: #2a1a0b;
  --bubble-sent: linear-gradient(135deg, #f5c48d 0%, #e09a58 100%);
  --bubble-sent-text: #2a1a0b;
  --enh-accent: #f2bc83;
  --enh-accent-soft: rgba(242, 188, 131, 0.18);
}

/* ---- 紫藤 ---- */
[data-accent="violet"] {
  --primary-gradient: linear-gradient(135deg, #8954d9 0%, #6d2dcd 100%);
  --primary-hover: #5b26ab;
  --accent-text: #ffffff;
  --bubble-sent: linear-gradient(135deg, #d6c8ed 0%, #c5b1e5 100%);
  --bubble-sent-text: #25163b;
  --enh-accent: #814fcc;
  --enh-accent-soft: rgba(129, 79, 204, 0.14);
}
[data-theme="dark"][data-accent="violet"] {
  --primary-gradient: linear-gradient(135deg, #cbb8f5 0%, #9b80e4 100%);
  --primary-hover: #d8c9f8;
  --accent-text: #1c1230;
  --bubble-sent: linear-gradient(135deg, #cbb8f5 0%, #9b80e4 100%);
  --bubble-sent-text: #1c1230;
  --enh-accent: #c3adf2;
  --enh-accent-soft: rgba(195, 173, 242, 0.18);
}

/* ============================================================
   1.5 组件基元（统一管理页 studio.html 复用）
   ------------------------------------------------------------
   0.11.0：色板/选项行等「设置面板专用」样式已迁到 studio.css，
   这里只保留两个页面共用的开关与强调样式。
   ============================================================ */

/* 开关（label 包裹，整行可点 —— 0.10.0 只有小方块可点，容易被当成没反应） */
.enh-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 0.86rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}
.enh-switch-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.enh-switch-label small {
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.5;
}
.enh-switch input[type="checkbox"] {
  width: 40px;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
  margin: 0;
}
.enh-switch input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform var(--transition-fast), background var(--transition-fast);
}
.enh-switch input[type="checkbox"]:checked {
  background: var(--enh-accent-soft);
  border-color: var(--enh-accent);
}
.enh-switch input[type="checkbox"]:checked::after {
  transform: translateX(18px);
  background: var(--enh-accent);
}
.enh-switch input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--enh-accent);
  outline-offset: 2px;
}

/* ============================================================
   2. 阅读舒适度：字号 / 行距 / 气泡留白 / 消息间距
   ------------------------------------------------------------
   0.11.0 修正：0.10.0 的「密度」只改了 2px 的消息外间距，
   肉眼看不出差别（被当成「没效果」）—— 现在同时改
   气泡内边距、行高、时间标签间距，三档差异一眼可辨。
   ============================================================ */
[data-fontsize="small"] { --enh-msg-font: 0.86rem; }
[data-fontsize="normal"] { --enh-msg-font: 0.95rem; }
[data-fontsize="large"] { --enh-msg-font: 1.08rem; }
[data-fontsize="xlarge"] { --enh-msg-font: 1.22rem; }

.msg-bubble {
  font-size: var(--enh-msg-font);
  line-height: var(--enh-msg-line);
  padding: var(--enh-msg-pad-y) var(--enh-msg-pad-x);
}

.msg-time-label {
  margin: var(--enh-msg-time-gap) auto;
}

[data-density="compact"] {
  --enh-msg-line: 1.42;
  --enh-msg-pad-y: 5px;
  --enh-msg-pad-x: 10px;
  --enh-msg-time-gap: 8px;
}
[data-density="compact"] .message {
  margin-bottom: 0;
}
[data-density="compact"] .msg-row {
  padding: 0;
}

[data-density="cozy"] {
  --enh-msg-line: 1.8;
  --enh-msg-pad-y: 13px;
  --enh-msg-pad-x: 17px;
  --enh-msg-time-gap: 20px;
}
[data-density="cozy"] .message {
  margin-bottom: 10px;
}

/* ============================================================
   3. 氛围粒子画布（樱花 / 星尘 / 细雨 / 飘雪 / 爱心爆破）
   z-index 3：覆盖聊天区但在弹窗(1000)、右键菜单(10000)之下
   ============================================================ */
#enh-ambience {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  opacity: 0.9;
}

/* ============================================================
   4. 联系人置顶
   ============================================================ */
.enh-pin-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}
.contact-item:hover .enh-pin-btn,
.enh-pin-btn:focus-visible {
  opacity: 0.75;
}
.enh-pin-btn:hover {
  color: var(--enh-accent);
  transform: scale(1.15);
}
.contact-item.enh-pinned .enh-pin-btn {
  opacity: 1;
  color: var(--enh-accent);
}
.contact-item.enh-pinned .contact-name::after {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--enh-accent);
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
}

/* ============================================================
   5. /me 动作气泡（斜体、无底色）
   ============================================================ */
.msg-action-text {
  /* 0.11.0：0.10.0 用的 --text-secondary（#8b8b8b）在浅底上只有 3.3:1，
     低于 AA。改为主文字色 + 透明度，实测 5.3:1 以上。 */
  color: var(--text-primary);
  opacity: 0.72;
  font-style: italic;
  font-size: 0.92em;
  letter-spacing: 0.01em;
}
.message:has(.msg-action-text) .msg-bubble,
.message.sent:has(.msg-action-text) .msg-bubble,
.message.received:has(.msg-action-text) .msg-bubble {
  background: transparent;
  border: none;
  box-shadow: none;
  padding-left: 2px;
  padding-right: 2px;
}
.message:has(.msg-action-text) .msg-avatar {
  opacity: 0.45;
}

/* 气泡内的强调/链接：跟随气泡文字色，避免蓝字压在彩色气泡上
   （#2563eb 落在浅粉/浅蓝气泡上只有 2~3:1） */
.message.sent .message-text .ai-em {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.message.sent .message-text a {
  color: inherit;
  text-decoration: underline;
}

/* ============================================================
   6. 「正在思考」三点跳动
   ============================================================ */
.streaming-badge::after {
  content: '···';
  display: inline-block;
  margin-left: -2px;
  letter-spacing: 1px;
  animation: enhDots 1.1s ease-in-out infinite;
}
@keyframes enhDots {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50%      { opacity: 1;    transform: translateY(-1px); }
}

/* ============================================================
   7. 命令面板（Ctrl+Shift+P）
   ============================================================ */
.enh-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  opacity: 0;
  transition: opacity 0.16s ease-out;
}
.enh-palette-overlay.show {
  opacity: 1;
}
.enh-palette {
  width: min(580px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-10px) scale(0.985);
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
  display: flex;
  flex-direction: column;
  max-height: 68vh;
}
.enh-palette-overlay.show .enh-palette {
  transform: none;
}
.enh-palette-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}
.enh-palette-head i {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.enh-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  padding: 4px 0;
}
.enh-palette-input::placeholder {
  color: var(--text-tertiary);
}
.enh-palette-esc {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px 6px;
}
.enh-palette-list {
  overflow-y: auto;
  padding: 6px;
}
.enh-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.35;
}
.enh-palette-item i {
  width: 18px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.86rem;
  flex-shrink: 0;
}
.enh-palette-item.active,
.enh-palette-item:hover {
  background: var(--hover-bg);
}
.enh-palette-item.active i {
  color: var(--enh-accent);
}
.enh-palette-item .enh-palette-hint {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.enh-palette-empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
/* 命令分组标题（消息与会话 / 工具 / 外观 …） */
.enh-palette-group {
  padding: 8px 12px 4px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  user-select: none;
}
.enh-palette-foot {
  border-top: 1px solid var(--border-color);
  padding: 8px 16px;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* 标题栏里的「命令面板」按钮 */
#enhPaletteBtn {
  display: inline-flex;
}

/* ============================================================
   8. 会话洞察（数据面板）
   ============================================================ */
.modal .modal-content.enh-insights-content {
  max-width: 560px;
  width: 92%;
}
.enh-insights-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.enh-hero {
  border-radius: 14px;
  padding: 18px 16px;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  text-align: center;
}
.enh-hero-days {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.enh-hero-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.enh-hero-sub {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 8px;
}
.enh-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.enh-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--card-bg);
}
.enh-card-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}
.enh-card-value small {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 3px;
}
.enh-card-label {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.enh-block-title {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.enh-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 62px;
}
.enh-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.enh-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--primary-gradient);
  transition: height 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
  opacity: 0.85;
}
.enh-bar.zero {
  background: var(--hover-bg);
  opacity: 1;
}
.enh-bar-label {
  font-size: 0.6rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.enh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.enh-chip {
  font-size: 0.74rem;
  border-radius: 20px;
  padding: 3px 10px;
  background: var(--hover-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.enh-chip b {
  color: var(--text-primary);
  font-weight: 600;
}
.enh-insights-foot {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-align: center;
  padding-bottom: 4px;
}
.enh-loading {
  padding: 32px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ============================================================
   9. （已迁出）设置面板的配色/氛围/字号/朗读控件
   ------------------------------------------------------------
   0.11.0 起这些控件统一放在 /studio「外观与玩法中心」，
   对应样式见 studio.css；本文件只保留能力所需的最小样式，
   避免两个页面各有一份、越改越不一致。
   ============================================================ */

/* ============================================================
   10. 细节打磨
   ============================================================ */

/* 选中文字用主题色 */
::selection {
  background: var(--enh-accent-soft);
  color: var(--text-primary);
}

/* 键盘焦点环（统一） */
.enh-pin-btn:focus-visible,
.enh-palette-item:focus-visible,
.enh-switch input:focus-visible {
  outline: 2px solid var(--enh-accent);
  outline-offset: 2px;
}

/* 输入框聚焦时主题色描边（不改布局） */
#msgInput:focus {
  border-color: var(--enh-accent);
}

/* 收藏星标跟随主题色 */
.message.favorited .msg-bubble::before {
  color: var(--enh-accent);
}

/* 回到最新消息按钮：主题色描边 */
.jump-bottom-btn:hover {
  border-color: var(--enh-accent);
  color: var(--enh-accent);
}

/* 联系人选中指示条跟随主题色 */
.contact-item.active::before {
  background: var(--enh-accent);
}

/* ============================================================
   11. 本地指令卡片（/help /roll /coin /pick /time）
   ============================================================ */
.enh-local-card {
  display: flex;
  justify-content: center;
  margin: 6px 0;
}
/* 选择器带上 .message.system 前缀，确保优先级高于 theme.css 的
   `.message.system .message-text`（系统消息胶囊样式） */
.message.system.enh-local-card .message-text {
  max-width: 86%;
  background: var(--card-bg);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: left;
  animation: enhCardIn 0.24s ease-out;
}
@keyframes enhCardIn {
  from { opacity: 0; transform: translateY(4px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}
.enh-cmd-title {
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.enh-cmd-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.enh-cmd-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.enh-cmd-row code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.74rem;
  background: var(--hover-bg);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--enh-accent);
  white-space: nowrap;
  flex-shrink: 0;
}
.enh-cmd-row span {
  color: var(--text-secondary);
  font-size: 0.76rem;
}
.enh-cmd-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  font-size: 0.7rem;
  color: var(--text-tertiary);
}
.enh-dice {
  font-size: 1rem;
  color: var(--text-primary);
}
.enh-dice b {
  color: var(--enh-accent);
  font-size: 1.15em;
}
.enh-dice i {
  color: var(--enh-accent);
  margin-right: 4px;
}
.enh-cmd-sub {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  word-break: break-word;
}

/* 减少动态效果：尊重系统设置 */
@media (prefers-reduced-motion: reduce) {
  .message,
  .contact-item {
    animation: none !important;
  }
  #enh-ambience {
    display: none !important;
  }
  .enh-palette,
  .enh-palette-overlay {
    transition: none;
  }
}

/* 窄屏：命令面板贴顶、洞察面板单列 */
@media (max-width: 560px) {
  .enh-palette-overlay {
    padding-top: 6vh;
  }
  .enh-palette {
    max-height: 78vh;
  }
  .enh-grid {
    grid-template-columns: 1fr;
  }
  .enh-hero-days {
    font-size: 1.8rem;
  }
}

/* ============================================================
   12. 聊天背景（0.12.0）
   ------------------------------------------------------------
   背景图由 enhance.js 写到 <html> 的 --enh-bg-image 变量里，
   这里只负责把它铺到消息区；遮罩（dim）已经合进同一个变量，
   所以调整浓度不需要额外元素，也不会挡文字。
   ============================================================ */
.message-area {
  background-image: var(--enh-bg-image, none);
  background-size: var(--enh-bg-size, cover);
  background-position: center;
  background-attachment: fixed;
  background-repeat: var(--enh-bg-repeat, no-repeat);
}
/* 有背景时给消息区一点内阴影，避免气泡和背景糊在一起 */
.message-area.enh-has-bg {
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.06);
}

/* ============================================================
   13. 气泡形状 / 行宽 / 头像大小（0.12.0）
   ============================================================ */
[data-bubble="round"] .message.sent .msg-bubble,
[data-bubble="round"] .message.received .msg-bubble {
  border-radius: 18px;
}
[data-bubble="square"] .message.sent .msg-bubble,
[data-bubble="square"] .message.received .msg-bubble {
  border-radius: 4px;
}
[data-bubble="square"] .msg-avatar {
  border-radius: 3px;
}

.msg-avatar {
  width: var(--enh-avatar-size, 38px);
  height: var(--enh-avatar-size, 38px);
}

/* 舒适行宽：把消息区两侧留白做成均分，内容居中在 900px 内 */
[data-maxw="comfort"] .message-area {
  padding-left: max(14px, calc((100% - 900px) / 2));
  padding-right: max(14px, calc((100% - 900px) / 2));
}
[data-maxw="comfort"] .msg-bubble {
  max-width: min(68%, 640px);
}

/* ============================================================
   14. 消息入场动画（0.12.0）
   ============================================================ */
@keyframes enhMsgFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes enhMsgSlideLeft {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes enhMsgSlideRight {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: none; }
}

[data-anim="fade"] .message {
  animation: enhMsgFadeIn 0.22s ease-out !important;
}
[data-anim="slide"] .message.received {
  animation: enhMsgSlideLeft 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) !important;
}
[data-anim="slide"] .message.sent {
  animation: enhMsgSlideRight 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) !important;
}
[data-anim="none"] .message,
[data-anim="none"] .contact-item {
  animation: none !important;
}

/* ============================================================
   15. 性能模式（0.12.0）
   ------------------------------------------------------------
   一键关掉所有动画 / 粒子 / 过渡：老设备、投屏、录屏时更稳。
   ============================================================ */
[data-perf="1"] *,
[data-perf="1"] *::before,
[data-perf="1"] *::after {
  animation-duration: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0s !important;
}
[data-perf="1"] .message,
[data-perf="1"] .contact-item,
[data-perf="1"] .streaming-badge::after {
  animation: none !important;
}
[data-perf="1"] #enh-ambience {
  display: none !important;
}
[data-perf="1"] .message-area {
  background-attachment: scroll;
}

/* 背景开启后：时间标签与操作按钮需要"实底"，否则压在彩色背景上会发虚 */
.message-area.enh-has-bg .msg-time-label {
  background: var(--container-bg);
  color: var(--text-secondary);
  border-radius: 20px;
  padding: 2px 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.message-area.enh-has-bg .ai-action-btn {
  background: var(--card-bg);
}
.message-area.enh-has-bg .msg-quote {
  background: var(--card-bg);
}

/* ============================================================
   16. 时光机（0.13.0）
   ============================================================ */
.modal .modal-content.enh-replay-content {
  max-width: 680px;
  width: 94%;
}
.replay-days {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: thin;
}
.replay-chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.replay-chip b {
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
}
.replay-chip:hover {
  background: var(--hover-bg);
}
.replay-chip.active {
  border-color: var(--enh-accent);
  background: var(--enh-accent-soft);
}
.replay-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.replay-hint {
  font-size: 0.76rem;
  color: var(--text-secondary);
}
.replay-stage {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  background: var(--chat-bg);
}
.replay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--card-bg);
  font-size: 0.82rem;
  color: var(--text-primary);
}
.replay-head span {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.replay-list {
  max-height: 46vh;
  overflow-y: auto;
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.replay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
}
.replay-msg {
  animation: enhMsgFadeIn 0.26s ease-out;
}
.replay-time {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  margin: 8px 4px 2px;
}
.replay-msg.sent .replay-time {
  text-align: right;
}
.replay-list .msg-bubble {
  max-width: 76%;
}

/* ============================================================
   17. 分享卡片（0.13.0）
   ============================================================ */
.modal .modal-content.enh-card-content {
  max-width: 720px;
  width: 94%;
}
.enh-card-preview {
  max-height: 56vh;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--hover-bg);
  padding: 10px;
}
.enh-card-preview canvas {
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
