/* ============================================
   Mars Variables — CSS 变量与主题系统
   设计原则：
   - 大面积背景极低饱和度，接近中性白，只留极淡色相倾向
   - 色彩人格靠小元素承载（accent 按钮、pill、hover 态）
   - 气泡与聊天背景亮度差 ≥ 5%（ΔL ≥ 5）
   - 区域边界清晰（bg / sidebar-bg / chat-bg 有可感知差异）
   ============================================ */

/* 注册可动画的 CSS 变量 — 切换 accent 时只需过渡根元素的变量，性能远优于给所有元素加 transition */
@property --bg { syntax: '<color>'; inherits: true; initial-value: #faf7f0; }
@property --bg2 { syntax: '<color>'; inherits: true; initial-value: #f3ede2; }
@property --text { syntax: '<color>'; inherits: true; initial-value: #2d261a; }
@property --muted { syntax: '<color>'; inherits: true; initial-value: #6b5e48; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #e0a020; }
@property --accent2 { syntax: '<color>'; inherits: true; initial-value: #e8786a; }
@property --accent-text { syntax: '<color>'; inherits: true; initial-value: #3a2c14; }
@property --card { syntax: '<color>'; inherits: true; initial-value: rgba(255, 253, 248, .68); }
@property --cardBorder { syntax: '<color>'; inherits: true; initial-value: rgba(210, 160, 60, .10); }
@property --pillBg { syntax: '<color>'; inherits: true; initial-value: rgba(255, 253, 248, .68); }
@property --pillBorder { syntax: '<color>'; inherits: true; initial-value: rgba(210, 160, 60, .12); }
@property --divider { syntax: '<color>'; inherits: true; initial-value: rgba(180, 140, 60, .10); }
@property --hover-bg { syntax: '<color>'; inherits: true; initial-value: rgba(224, 160, 32, .05); }
@property --active-bg { syntax: '<color>'; inherits: true; initial-value: rgba(224, 160, 32, .09); }
@property --sigil { syntax: '<color>'; inherits: true; initial-value: rgba(224, 160, 32, .12); }
@property --chat-bg { syntax: '<color>'; inherits: true; initial-value: #f5f1ea; }
@property --sidebar-bg { syntax: '<color>'; inherits: true; initial-value: #f8f5ee; }
@property --bubble-sent { syntax: '<color>'; inherits: true; initial-value: #eddcc0; }
@property --bubble-sent-text { syntax: '<color>'; inherits: true; initial-value: #3a2c14; }
@property --user-bubble { syntax: '<color>'; inherits: true; initial-value: #faf6f2; }
@property --user-bubble-text { syntax: '<color>'; inherits: true; initial-value: #4a3220; }
@property --input-bg { syntax: '<color>'; inherits: true; initial-value: rgba(250, 247, 240, .80); }
@property --shimmer-base { syntax: '<color>'; inherits: true; initial-value: rgba(210, 160, 60, .06); }
@property --shimmer-highlight { syntax: '<color>'; inherits: true; initial-value: rgba(255, 255, 255, .22); }

:root {
  --bg: #faf7f0;
  --bg2: #f3ede2;
  --text: #2d261a;
  --muted: #6b5e48;
  --accent: #e0a020;
  --accent2: #e8786a;
  --card: rgba(255, 253, 248, .68);
  --cardBorder: rgba(210, 160, 60, .10);
  --pillBg: rgba(255, 253, 248, .68);
  --pillBorder: rgba(210, 160, 60, .12);
  --shadow: 0 16px 50px rgba(40, 30, 10, .05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.05);
  --blur: blur(10px);
  --radius: 22px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-cute: cubic-bezier(.34, 1.56, .64, 1); /* 弹性回弹（果冻 hover / 可爱打字态） */
  --sigil: rgba(224, 160, 32, .12);
  --grain: .06;
  --font-display: "Nunito", "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", ui-sans-serif, system-ui, -apple-system;

  /* 聊天专属变量 */
  --chat-bg: #f5f1ea;
  --sidebar-bg: #f8f5ee;
  --sidebar-width: 300px;
  --bubble-sent: #eddcc0;
  --bubble-sent-text: #3a2c14;
  --user-bubble: #faf6f2;
  --user-bubble-text: #4a3220;
  --input-bg: rgba(250, 247, 240, .80);
  --divider: rgba(180, 140, 60, .10);
  --hover-bg: rgba(224, 160, 32, .05);
  --active-bg: rgba(224, 160, 32, .09);
  --accent-text: #3a2c14;

  /* Shimmer 骨架屏 */
  --shimmer-base: rgba(210, 160, 60, .06);
  --shimmer-highlight: rgba(255, 255, 255, .22);
}

/* ============================================
   Accent Variants — Mars 配色扩展
   每个 accent 独立控制完整色板
   大面积背景极低饱和，色相靠小元素表达
   ============================================ */

/* ── Honey（暖橙·默认）── */
html[data-accent="honey"] {
  --bg: #faf7f0;
  --bg2: #f3ede2;
  --chat-bg: #f5f1ea;
  --sidebar-bg: #f8f5ee;
  --accent: #e0a020;
  --accent2: #e8786a;
  --cardBorder: rgba(210, 160, 60, .10);
  --pillBorder: rgba(210, 160, 60, .12);
  --divider: rgba(180, 140, 60, .10);
  --hover-bg: rgba(224, 160, 32, .05);
  --active-bg: rgba(224, 160, 32, .09);
  --sigil: rgba(224, 160, 32, .12);
  --bubble-sent: #eddcc0;
  --bubble-sent-text: #3a2c14;
  --user-bubble: #faf6f2;
  --user-bubble-text: #4a3220;
  --input-bg: rgba(250, 247, 240, .80);
  --accent-text: #3a2c14;
  --shimmer-base: rgba(210, 160, 60, .06);
  --shimmer-highlight: rgba(255, 255, 255, .22);
}

/* ── Teal（青绿·清爽）── */
html[data-accent="teal"] {
  --bg: #f0f6f3;
  --bg2: #e4ece8;
  --chat-bg: #eaf0ed;
  --sidebar-bg: #ecf2ef;
  --text: #1a302c;
  --muted: #4a7068;
  --accent: #26a69a;
  --accent2: #26c6da;
  --accent-text: #f0fef8;
  --card: rgba(234, 246, 240, .68);
  --cardBorder: rgba(38, 166, 154, .10);
  --pillBg: rgba(234, 246, 240, .68);
  --pillBorder: rgba(38, 166, 154, .12);
  --shadow: 0 16px 50px rgba(10, 60, 50, .05);
  --divider: rgba(38, 130, 120, .08);
  --hover-bg: rgba(38, 166, 154, .05);
  --active-bg: rgba(38, 166, 154, .09);
  --sigil: rgba(38, 166, 154, .10);
  --sigil2: rgba(38, 198, 218, .06);
  --bubble-sent: #d0e2da;
  --bubble-sent-text: #1a3a32;
  --user-bubble: #f2f8f6;
  --user-bubble-text: #1e3832;
  --input-bg: rgba(240, 246, 243, .80);
  --shimmer-base: rgba(38, 166, 154, .06);
  --shimmer-highlight: rgba(255, 255, 255, .22);
}

/* ── Rose（粉红·柔和）── */
html[data-accent="rose"] {
  --bg: #f9f5f7;
  --bg2: #f0e8ec;
  --chat-bg: #f3eff1;
  --sidebar-bg: #f5f1f3;
  --text: #3a222c;
  --muted: #886078;
  --accent: #d06090;
  --accent2: #e878a0;
  --accent-text: #fef0f4;
  --card: rgba(248, 242, 246, .68);
  --cardBorder: rgba(208, 96, 144, .10);
  --pillBg: rgba(248, 242, 246, .68);
  --pillBorder: rgba(208, 96, 144, .12);
  --shadow: 0 16px 50px rgba(80, 30, 40, .05);
  --divider: rgba(180, 80, 120, .08);
  --hover-bg: rgba(208, 96, 144, .05);
  --active-bg: rgba(208, 96, 144, .09);
  --sigil: rgba(208, 96, 144, .10);
  --sigil2: rgba(232, 120, 160, .06);
  --bubble-sent: #e8d0da;
  --bubble-sent-text: #3a1a28;
  --user-bubble: #faf4f7;
  --user-bubble-text: #4a2030;
  --input-bg: rgba(249, 245, 247, .80);
  --shimmer-base: rgba(208, 96, 144, .06);
  --shimmer-highlight: rgba(255, 255, 255, .22);
}

/* ── Purple（紫罗兰·安静）── */
html[data-accent="purple"] {
  --bg: #f4f1fa;
  --bg2: #e9e4ef;
  --chat-bg: #eeebf3;
  --sidebar-bg: #f0edf5;
  --text: #282040;
  --muted: #686090;
  --accent: #7c4dff;
  --accent2: #c080fc;
  --accent-text: #f0e8ff;
  --card: rgba(242, 238, 252, .68);
  --cardBorder: rgba(124, 77, 255, .10);
  --pillBg: rgba(242, 238, 252, .68);
  --pillBorder: rgba(124, 77, 255, .12);
  --shadow: 0 16px 50px rgba(40, 20, 80, .05);
  --divider: rgba(100, 60, 180, .08);
  --hover-bg: rgba(124, 77, 255, .05);
  --active-bg: rgba(124, 77, 255, .09);
  --sigil: rgba(124, 77, 255, .10);
  --sigil2: rgba(192, 128, 252, .06);
  --bubble-sent: #ddd0ec;
  --bubble-sent-text: #261a3a;
  --user-bubble: #f6f3fa;
  --user-bubble-text: #36204a;
  --input-bg: rgba(244, 241, 250, .80);
  --shimmer-base: rgba(124, 77, 255, .06);
  --shimmer-highlight: rgba(255, 255, 255, .22);
}

/* 切 accent 时的全局过渡 — 给所有元素加颜色过渡，!important 覆盖组件内 transition */
html.accent-transitioning,
html.accent-transitioning * {
  transition: background-color .35s var(--ease),
              color .35s var(--ease),
              border-color .35s var(--ease),
              fill .35s var(--ease),
              stroke .35s var(--ease) !important;
}

@media (prefers-reduced-motion: reduce) {
  html.accent-transitioning,
  html.accent-transitioning * { transition: none !important; }
}

/* ============================================================
   Accent 圆形揭幕 — View Transition (v1.13)
   点击 accent 圆点时：以点击点为圆心，clip-path circle 从 0 扩散到 150%
   揭幕新配色。不支持 VT 或用户偏好减动效时，由 JS 退回扁平过渡。
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  /* 仅 accent 圆形揭幕模式：关闭默认交叉淡入，改由 clip-path 控制揭幕。
     注意：必须限定在 html[data-vt-circle] 下，否则会连带禁用语言切换的
     默认 crossfade（约 250ms）——实测会让语言切换变成生硬瞬切。 */
  html[data-vt-circle]::view-transition-old(root),
  html[data-vt-circle]::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
  }
  /* 旧视图沉底，新视图在上层被圆形裁切揭幕（仅 accent 模式） */
  html[data-vt-circle]::view-transition-old(root) { z-index: 1; }
  html[data-vt-circle]::view-transition-new(root) {
    z-index: 9999;
    clip-path: circle(0% at var(--vt-x, 50%) var(--vt-y, 50%));
    animation: mars-accent-reveal 0.7s var(--ease) forwards;
  }
  @keyframes mars-accent-reveal {
    to { clip-path: circle(150% at var(--vt-x, 50%) var(--vt-y, 50%)); }
  }
}
/* ============================================
   Mars Layout — 基础布局
   ============================================ */

/* ---------- 全局 ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  overflow: hidden;
}
body, .app-loader, .chat-sidebar, .chat-main {
  transition: color .3s var(--ease), background-color .3s var(--ease), border-color .2s var(--ease), border-radius .35s var(--ease), box-shadow .2s var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  body, .app-loader, .chat-sidebar, .chat-main { transition: none; }
  .aurora-orb { animation: none !important; }
  .bg-motes { animation: none !important; }
  .sidebar-avatar::after { animation: none !important; }
  .msg-bubble { animation: none !important; }
  .shimmer { animation: none !important; }
  .typing-indicator { animation: none !important; }
  .typing-dot { animation: none !important; }
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px;
}
button { font-family: var(--font-display); cursor: pointer; border: none; background: none; }

/* ---------- 加载器 ---------- */
.app-loader {
  position: fixed; inset: 0; z-index: 99999;
  background-color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .5s ease-out, visibility .5s ease-out;
}
.app-loader.fade-out { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-content { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 240px; }

/* ---------- 鸭子 mascot（Loading 屏） ---------- */
.loader-duck { margin-bottom: 4px; line-height: 0; }
.loader-duck .duck-fill  { fill: var(--accent); }
.loader-duck .duck-beak  { fill: var(--accent2); }
.loader-duck .duck-wing  { fill: var(--accent-text); opacity: .10; }
.loader-duck .duck-eye   { fill: var(--accent-text); }
.loader-duck .duck-cheek { fill: var(--accent2); opacity: .32; }
.loader-duck .duck-shadow { fill: var(--accent-text); opacity: .10; transform-box: fill-box; transform-origin: center; animation: mars-duck-shadow 1.8s var(--ease) infinite; }
.loader-duck .duck-body-g {
  transform-box: fill-box; transform-origin: 50% 90%;
  animation: mars-duck-bob 1.8s var(--ease) infinite;
}
@keyframes mars-duck-bob {
  0%, 100% { transform: translateY(0) rotate(-2.5deg); }
  50%      { transform: translateY(-6px) rotate(2.5deg); }
}
@keyframes mars-duck-shadow {
  0%, 100% { transform: scaleX(1);   opacity: .10; }
  50%      { transform: scaleX(.82); opacity: .05; }
}
@media (prefers-reduced-motion: reduce) {
  .loader-duck .duck-body-g,
  .loader-duck .duck-shadow { animation: none !important; }
}
.loader-track {
  position: relative;            /* 让 shimmer 段绝对定位扫光 */
  width: 100%; height: 4px;
  background: var(--divider); border-radius: 99px; overflow: hidden;
}
/* 不确定 shimmer：一段高光在轨道里来回扫过，不声称具体百分比
   （替代 v1.13.2 及之前的"假进度条"随机爬升——旧版误导用户以为已加载 99%） */
.loader-bar {
  position: absolute; top: 0; left: -45%;
  height: 100%; width: 45%;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent2), transparent);
  box-shadow: 0 0 10px rgba(224, 160, 32, .25);
  animation: mars-loader-shimmer 1.1s var(--ease) infinite;
  will-change: left;
}
/* 完成态：停 shimmer，实心填满（真实任务全部完成才触发） */
.loader-bar.is-done {
  animation: none;
  left: 0; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .3s var(--ease), background .3s var(--ease);
}
@keyframes mars-loader-shimmer {
  0%   { left: -45%; }
  100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  /* 减动效：不扫光，静态占位条；完成时实心填满 */
  .loader-bar {
    animation: none; transition: none;
    left: 0; width: 65%; opacity: .55;
  }
  .loader-bar.is-done { width: 100%; opacity: 1; transition: none; }
}
.loader-text {
  font-size: 12px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--muted); opacity: .7; min-width: 160px; text-align: center;
}

/* ---------- 背景渐变光晕 ---------- */
.bg-aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  isolation: isolate;
  transform: translateZ(0);
}
.aurora-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  will-change: transform;
  contain: strict;
  backface-visibility: hidden;
}
/* honey warm orange, teal mint, rose pink, purple lavender */
html[data-accent="honey"]  .orb-1 { background: hsla(38, 80%, 58%, 0.10); }
html[data-accent="honey"]  .orb-2 { background: hsla(48, 70%, 55%, 0.08); }
html[data-accent="honey"]  .orb-3 { background: hsla(28, 75%, 60%, 0.06); }
html[data-accent="teal"]   .orb-1 { background: hsla(170, 60%, 50%, 0.10); }
html[data-accent="teal"]   .orb-2 { background: hsla(185, 55%, 48%, 0.08); }
html[data-accent="teal"]   .orb-3 { background: hsla(160, 65%, 52%, 0.06); }
html[data-accent="rose"]   .orb-1 { background: hsla(340, 60%, 58%, 0.10); }
html[data-accent="rose"]   .orb-2 { background: hsla(350, 55%, 55%, 0.08); }
html[data-accent="rose"]   .orb-3 { background: hsla(330, 65%, 60%, 0.06); }
html[data-accent="purple"] .orb-1 { background: hsla(265, 65%, 58%, 0.10); }
html[data-accent="purple"] .orb-2 { background: hsla(275, 60%, 55%, 0.08); }
html[data-accent="purple"] .orb-3 { background: hsla(255, 70%, 60%, 0.06); }

.orb-1 {
  width: 500px; height: 500px;
  animation: orbDrift1 26s ease-in-out infinite;
}
.orb-2 {
  width: 420px; height: 420px;
  animation: orbDrift2 32s ease-in-out infinite;
}
.orb-3 {
  width: 560px; height: 560px;
  animation: orbDrift3 38s ease-in-out infinite;
}

@keyframes orbDrift1 {
  0%   { transform: translate(-10vw, -10vh) scale(1); }
  20%  { transform: translate(65vw, 20vh) scale(1.15); }
  40%  { transform: translate(30vw, 70vh) scale(0.9); }
  60%  { transform: translate(80vw, 50vh) scale(1.1); }
  80%  { transform: translate(15vw, 40vh) scale(0.85); }
  100% { transform: translate(-10vw, -10vh) scale(1); }
}
@keyframes orbDrift2 {
  0%   { transform: translate(80vw, 70vh) scale(1); }
  25%  { transform: translate(20vw, 30vh) scale(1.12); }
  50%  { transform: translate(60vw, -5vh) scale(0.88); }
  75%  { transform: translate(5vw, 65vh) scale(1.08); }
  100% { transform: translate(80vw, 70vh) scale(1); }
}
@keyframes orbDrift3 {
  0%   { transform: translate(40vw, 50vh) scale(1); }
  33%  { transform: translate(-5vw, 15vh) scale(1.1); }
  66%  { transform: translate(70vw, 75vh) scale(0.92); }
  100% { transform: translate(40vw, 50vh) scale(1); }
}

.bg-motes {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .10;
  background: none;
  animation: motesDrift 14s ease-in-out infinite alternate;
}
html[data-accent="honey"] .bg-motes {
  background:
    radial-gradient(circle at 18% 32%, rgba(224,160,32,.09) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 18%, rgba(232,120,160,.06) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 68%, rgba(224,160,32,.07) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 78%, rgba(38,166,154,.05) 0 1px, transparent 2px);
}
html[data-accent="teal"] .bg-motes {
  background:
    radial-gradient(circle at 18% 32%, rgba(38,166,154,.09) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 18%, rgba(26,198,218,.06) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 68%, rgba(38,166,154,.07) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 78%, rgba(38,166,154,.05) 0 1px, transparent 2px);
}
html[data-accent="rose"] .bg-motes {
  background:
    radial-gradient(circle at 18% 32%, rgba(208,96,144,.09) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 18%, rgba(232,120,160,.06) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 68%, rgba(208,96,144,.07) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 78%, rgba(208,96,144,.05) 0 1px, transparent 2px);
}
html[data-accent="purple"] .bg-motes {
  background:
    radial-gradient(circle at 18% 32%, rgba(124,77,255,.09) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 18%, rgba(192,128,252,.06) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 68%, rgba(124,77,255,.07) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 78%, rgba(124,77,255,.05) 0 1px, transparent 2px);
}
@keyframes motesDrift {
  0%   { transform: translateY(0) translateX(0); }
  33%  { transform: translateY(-8px) translateX(5px); }
  66%  { transform: translateY(-4px) translateX(-4px); }
  100% { transform: translateY(-12px) translateX(3px); }
}

/* ---------- 聊天应用容器 ---------- */
.chat-app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100svh;
  height: 100dvh; /* 动态视口：键盘弹起时随可视区收缩，底部输入栏不被遮挡 */
  overflow: hidden;
  opacity: 0;
  pointer-events: none; /* loader 期间禁止交互穿透 */
  transition: opacity .5s var(--ease);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.chat-app.is-visible { opacity: 1; pointer-events: auto; }

/* ---------- 侧边栏 ---------- */
.chat-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  height: 100svh;
  will-change: transform;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--divider);
  overflow: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--divider);
}
.sidebar-avatar {
  position: relative;
  width: 42px; height: 42px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-avatar::after {
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: .22;
  animation: avatarGlow 3.2s ease-in-out infinite alternate;
  pointer-events: none; z-index: -1;
}
@keyframes avatarGlow {
  from { opacity: .15; transform: scale(1); }
  to   { opacity: .28; transform: scale(1.08); }
}
.sidebar-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity .35s var(--ease);
  opacity: 0;
}
.sidebar-avatar .live-badge {
  position: absolute;
  bottom: 2px; left: 50%;
  transform: translateX(-50%);
  background: #ff2a5d; color: white;
  font-size: 9px; font-weight: 800;
  padding: 1px 6px; border-radius: 99px;
  letter-spacing: .04em;
  display: none;
}
.chibi.is-live .live-badge { display: block; }

.sidebar-user { flex: 1; min-width: 0; }
.sidebar-name { font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar-bio { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ---------- Accent 配色选择器 ---------- */
.accent-picker {
  display: flex;
  gap: 7px;
  align-items: center;
}
.accent-dot {
  /* W27 修复：button 视觉 24×24，用 padding 扩命中区到 44×44，negative margin 拉回布局占位 */
  width: 24px; height: 24px;
  padding: 10px;  /* 命中区 = 24 + 10*2 = 44px */
  margin: -10px;  /* 拉回 padding 占用空间，布局占位仍为 24×24 */
  box-sizing: content-box;
  border-radius: 50%;
  border: none;
  transition: opacity .18s var(--ease);
  cursor: pointer;
  flex-shrink: 0;
  opacity: .6;
  position: relative;
  background: transparent;
}
.accent-dot::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  border-radius: 50%;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.accent-dot[data-accent="honey"]::before { background: #e0a020; }
.accent-dot[data-accent="teal"]::before  { background: #26a69a; }
.accent-dot[data-accent="rose"]::before  { background: #d06090; }
.accent-dot[data-accent="purple"]::before{ background: #7c4dff; }
.accent-ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: .25;
  animation: rippleExpand .5s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleExpand {
  from { transform: scale(0); opacity: .3; }
  to   { transform: scale(3); opacity: 0; }
}
.accent-dot:hover {
  opacity: .88;
}
.accent-dot:hover::before {
  transform: translate(-50%, -50%) scale(1.15);
}
.accent-dot.active {
  opacity: 1;
}
.accent-dot.active::before {
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4px var(--accent);
}
.accent-dot:active::before { transform: translate(-50%, -50%) scale(.9); }

/* 侧边栏关闭按钮（移动端显示） */
.sidebar-close-btn {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.sidebar-close-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}

/* 侧边栏底部 */
.sidebar-footer {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--divider);
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar-music {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
}
.music-toggle-mini {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.music-toggle-mini:hover { background: var(--hover-bg); color: var(--text); }
.sidebar-music.is-playing .music-toggle-mini { color: var(--accent); }
.sidebar-music-label {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 120px;
  transition: color .15s ease;
}
.sidebar-music.is-playing .sidebar-music-label { color: var(--text); }
.music-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  flex-shrink: 0;
  transition: opacity .3s ease;
}
.sidebar-music.is-playing .music-dot {
  opacity: 1;
  animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: .4; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1); }
}
.sidebar-clock {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
  opacity: .75;
}
.sidebar-lang {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid var(--divider);
}
.lang-btn {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  transition: background .2s var(--ease), color .2s var(--ease);
  letter-spacing: .02em;
  font-family: var(--font-display);
}
.lang-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}
.lang-btn.active {
  background: var(--active-bg);
  color: var(--accent);
}
/* ---------- 聊天主区域 ---------- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  background: color-mix(in srgb, var(--chat-bg) 55%, transparent);
  min-width: 0;
  position: relative;
  transform: translateZ(0);
}

/* 聊天顶栏 */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  background: var(--sidebar-bg);
  background: color-mix(in srgb, var(--sidebar-bg) 65%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.chat-profile-btn {
  display: none;
  width: 42px; height: 42px;
  padding: 0;
  align-items: center; justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.chat-profile-btn:hover { background: var(--hover-bg); }
.profile-btn-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  overflow: hidden;
}
.profile-btn-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-title { font-size: 16px; font-weight: 700; color: var(--text); display: block; }
.chat-subtitle { font-size: 12px; color: var(--muted); }
.chat-header-actions { display: flex; gap: 6px; }
.chat-header-actions .icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: color .15s var(--ease), background .15s var(--ease);
}
.chat-header-actions .icon:hover {
  color: var(--text);
  background: var(--hover-bg);
}
.chat-header-actions .icon.discord-badge {
  position: relative;
}
.chat-header-actions .icon.discord-badge .discord-dot {
  position: absolute;
  top: 6px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ba55d;
  border: 2px solid var(--card);
  opacity: 0;
  transform: scale(0);
  transition: opacity .25s ease, transform .25s ease;
}
.chat-header-actions .icon.discord-badge.is-live .discord-dot {
  opacity: 1;
  transform: scale(1);
}

/* CLS 修复：为动态内容预留最小高度，避免加载后布局抖动 */
.sidebar-name { min-height: 1.15em; }
.sidebar-bio  { min-height: 1em; }
.chat-title    { min-height: 1.2em; }
.chat-subtitle { min-height: 1.15em; }
.link-card-title { min-height: 1.25em; }
.link-card-desc  { min-height: 1.15em; }

/* 消息区域 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}

/* 聊天区微噪点纹理（单层，降低 GPU 压力） */
.chat-main::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain);
  background-image:
    repeating-linear-gradient(0deg, rgba(0,0,0,.02) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.015) 0 1px, transparent 1px 8px);
}

/* 滚动条 */
.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: var(--divider) transparent;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--divider);
  border-radius: 99px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ---------- 移动端横屏适配 ---------- */
@media (max-width: 860px) and (orientation: landscape) and (pointer: coarse) {
  .chat-header { padding: 6px 12px; }
  .chat-title { font-size: 14px; }
  .chat-subtitle { font-size: 10px; }
  .chat-messages { padding: 8px 12px 20px 12px; gap: 4px; }

  .chat-sidebar {
    width: 240px;
    min-width: 240px;
  }
  .sidebar-header { padding: 10px 12px 8px; }
  .sidebar-avatar { width: 34px; height: 34px; }
  .sidebar-name { font-size: 13px; }
  .sidebar-bio { font-size: 10px; }
  .sidebar-footer { padding: 6px 12px 10px; }
  .sidebar-clock { font-size: 10px; }

  .chat-pills-bar { padding: 4px 10px 6px; gap: 5px; }
  .chat-pill { padding: 5px 12px; font-size: 10px; }

  .msg-row { max-width: 82%; }
  .msg-bubble { padding: 7px 10px; font-size: 12px; }
  .msg-avatar { width: 26px; height: 26px; min-width: 26px; min-height: 26px; }

  .user-bubble { padding: 6px 10px; font-size: 12px; }
  .msg-link-card { padding: 8px 10px; gap: 8px; }
  .link-card-icon { width: 30px; height: 30px; border-radius: 8px; }
  .link-card-icon svg { width: 15px; height: 15px; }
  .link-card-title { font-size: 12px; }
  .link-card-desc { font-size: 10px; white-space: normal; word-break: break-word; }

  .shimmer-row { gap: 8px; }
  .shimmer-avatar { width: 26px; height: 26px; min-width: 26px; }
  .shimmer-line { height: 9px; }
}

/* 更小屏幕横屏（iPhone SE / 小屏机） */
@media (max-width: 700px) and (orientation: landscape) and (pointer: coarse) {
  .chat-sidebar { width: 200px; min-width: 200px; }
  .sidebar-header { padding: 6px 10px; }
  .chat-messages { padding: 6px 10px 18px 10px; }
  .chat-pills-bar { padding: 3px 8px 5px; }
  .chat-pill { padding: 4px 10px; font-size: 9px; }
  .chat-disclaimer { font-size: 9px; padding: 0 10px 4px; }
}

/* ============================================
   Mars Chat — 气泡、卡片、Pills、响应式
   ============================================ */

/* ---------- 消息气泡 ---------- */
.msg-row {
  display: flex;
  gap: 10px;
  max-width: 76%;
  opacity: 0;
  margin-bottom: 10px;
}
.msg-row.typing-row {
  animation: typingSlideIn .38s var(--ease) both;
}
.msg-row.msg-animate {
  animation: msgSlideIn .4s var(--ease) both;
}
.msg-row.msg-revealed {
  opacity: 1;
}
.msg-row.msg-exit,
.msg-system.msg-exit,
.msg-divider.msg-exit,
.msg-pinned.msg-exit,
.connect-mini.msg-exit,
.user-row.msg-exit {
  animation: msgSlideOut .25s var(--ease) both;
}
.msg-avatar {
  width: 32px; height: 32px;
  min-width: 32px; min-height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  align-self: center;
}
.msg-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.msg-bubble {
  background: var(--bubble-sent);
  color: var(--bubble-sent-text);
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease;
}
.msg-bubble:hover {
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent), transparent 92%), var(--shadow-sm);
}

/* 消息时间戳 tooltip */
.msg-timestamp {
  position: absolute;
  bottom: -16px;
  right: 6px;
  font-size: 10px;
  color: var(--muted);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
  white-space: nowrap;
}
.msg-row:hover .msg-timestamp,
.msg-row:focus-within .msg-timestamp {
  opacity: .5;
}

/* 链接卡片（嵌入气泡内） */
.msg-link-card {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--cardBorder);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform .32s var(--ease-cute), box-shadow .15s var(--ease), background .15s var(--ease);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.msg-link-card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 20px var(--hover-bg);
  border-color: var(--accent);
}
.msg-link-card:active { transform: translateY(0) scale(.98); }
.msg-link-card:hover .link-card-icon {
  transform: rotate(6deg) scale(1.1);
  transition: transform .35s var(--ease-cute);
}

.link-card-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.link-card-icon svg { width: 20px; height: 20px; }
.link-card-body { flex: 1; min-width: 0; }
.link-card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.link-card-desc {
  font-size: 12px; color: var(--muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.link-card-arrow {
  color: var(--muted);
  font-size: 16px;
  opacity: .6;
  flex-shrink: 0;
  align-self: center;
}

/* ---------- 系统消息 ---------- */
.msg-system {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  opacity: 0;
  padding: 8px 0;
}
.msg-system.msg-animate {
  animation: msgSystemIn .15s var(--ease) both;
}

/* ---------- iframe 嵌入卡片 ---------- */
.msg-row.iframe-row {
  max-width: 100%;
  width: 100%;
  justify-content: center;
  margin: 10px 0;
}
.msg-iframe-wrap {
  width: 100%;
  max-width: 520px;
  height: 480px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--cardBorder);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.msg-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
@media (max-width: 760px) {
  .msg-iframe-wrap {
    max-width: 100%;
    height: 65vh;
    border-radius: 14px;
  }
}

.msg-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: 0;
  padding: 12px 0;
}
.msg-divider-icon {
  font-size: 7px;
  opacity: .45;
  margin-right: 4px;
  display: inline-block;
  transform: translateY(-1px);
}
.msg-divider::before,
.msg-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--divider);
}
.msg-divider.msg-animate {
  animation: msgDividerIn .12s var(--ease) both;
}

/* 群公告 */
.msg-pinned {
  background: var(--card);
  border: 1px solid var(--cardBorder);
  border-radius: 14px;
  padding: 14px 16px;
  max-width: 80%;
  margin: 0 auto;
  opacity: 0;
  box-shadow: var(--shadow-sm);
}
.msg-pinned.msg-animate {
  animation: msgFadeSlide .35s var(--ease) both;
}
.msg-pinned-title {
  font-size: 13px; font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.msg-pinned-list { list-style: none; padding: 0; margin: 0; }
.msg-pinned-list li {
  font-size: 13px; color: var(--text);
  line-height: 1.65;
  padding: 3px 0;
  padding-left: 12px;
  position: relative;
}
.msg-pinned-list li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Connect 卡片 ---------- */
.msg-connect-grid {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 8px;
  max-width: 85%;
}
.connect-mini {
  background: var(--card);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  transition: transform .15s var(--ease);
  opacity: 0;
  box-shadow: var(--shadow-sm);
}
.connect-mini.msg-animate {
  animation: msgSlideIn .4s var(--ease) both;
}
.connect-mini.msg-revealed {
  opacity: 1;
}
.connect-mini:hover { transform: translateY(-1px); }
.connect-mini-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.connect-mini-body { flex: 1; min-width: 0; }
.connect-mini-title { font-size: 13px; font-weight: 700; }
.connect-mini-desc { font-size: 11px; color: var(--muted); margin-top: 1px; word-break: break-word; overflow-wrap: break-word; }
.connect-mini-arrow { color: var(--muted); font-size: 16px; opacity: .6; }

/* ---------- Pills 话题选择栏 ---------- */
.chat-pills-bar {
  padding: 8px 16px 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  min-height: 40px;
  scrollbar-width: none;
}
.chat-pills-bar::-webkit-scrollbar { display: none; }
.chat-disclaimer {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  opacity: .65;
  padding: 0 16px 8px;
  line-height: 1.3;
  user-select: none;
}
.chat-pill {
  padding: 7px 16px;
  border-radius: 99px;
  background: var(--pillBg);
  border: 1px solid var(--pillBorder);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .32s var(--ease-cute);
  flex-shrink: 0;
  user-select: none;
}
.chat-pill:hover {
  background: var(--hover-bg);
  border-color: var(--accent);
  transform: translateY(-2px) scale(1.05);
}
.chat-pill:active { transform: translateY(0) scale(.94); }
.chat-pill.home-pill {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 7px 10px;
}
.chat-pill.home-pill:hover {
  background: var(--hover-bg);
  color: var(--text);
  border-color: var(--pillBorder);
}

/* ---------- 侧边栏 Discord 卡片 ---------- */
.sidebar-discord-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 8px 16px;
  background: var(--card);
  border: 1px solid var(--cardBorder);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .32s var(--ease-cute);
}
.sidebar-discord-card:hover {
  background: var(--hover-bg);
  border-color: var(--accent);
  transform: translateY(-2px) scale(1.015);
}
.sidebar-discord-card:active {
  transform: scale(.97);
}
.sidebar-discord-card-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.sidebar-discord-card-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sidebar-discord-card-title {
  font-size: 13px;
  font-weight: 600;
}
.sidebar-discord-card-sub {
  font-size: 11px;
  color: var(--muted);
}
.sidebar-discord-card-arrow {
  color: var(--muted);
  opacity: .5;
  font-size: 14px;
}

/* ---------- 用户消息（右侧） ---------- */
.user-row {
  display: flex;
  justify-content: flex-end;
  max-width: 100%;
  align-self: flex-end;
  opacity: 0;
}
.user-row.msg-animate {
  animation: msgSlideIn .4s var(--ease) both;
}
.user-bubble {
  width: fit-content;
  min-width: 80px;
  max-width: 100%;
  background: var(--bubble-sent);
  color: var(--bubble-sent-text);
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}
.typing-indicator {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 0;
}
/* 可爱打字态：accent 泡泡 + 弹性上浮（果冻感） */
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .55;
  transform-origin: center bottom;
  animation: typingPop 1.3s var(--ease-cute) infinite;
}
.typing-dot:nth-child(2) { animation-delay: .16s; }
.typing-dot:nth-child(3) { animation-delay: .32s; }
/* 打字气泡轻微呼吸挂在内层 indicator：morph 展开只动外层 .msg-bubble，
   两层 transform 物理隔离，避免新版 breathing 与旧版展开动画抢同一元素 */
.typing-indicator { animation: typingBreathe 1.9s var(--ease) infinite; }

/* ---------- 彩蛋 toast ---------- */
.egg-toast {
  position: fixed;
  top: 50%; left: 50%;
  background: var(--card);
  border: 1px solid var(--cardBorder);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: 14px;
  padding: 12px 24px;
  font-size: 15px; font-weight: 700;
  color: var(--text);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.egg-toast.show {
  animation: toastBounce .6s var(--ease) both;
}
.egg-toast.hide {
  animation: toastFadeOut .45s var(--ease) both;
}

/* ---------- 生日彩屑 ---------- */
.birthday-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
  opacity: 0;
  transition: opacity .8s var(--ease);
}
.birthday-confetti.visible { opacity: 1; }
.birthday-confetti.fading { opacity: 0; }

/* ---------- Shimmer 骨架屏 ---------- */
.chat-messages .shimmer-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 0;
  opacity: 1;
  transition: opacity .35s var(--ease);
}
.chat-messages .shimmer-wrap.fade-out {
  opacity: 0;
}
.shimmer-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.shimmer-avatar {
  width: 32px; height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--shimmer-base);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.shimmer-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}
.shimmer-line {
  height: 12px;
  border-radius: 6px;
  background: var(--shimmer-base);
  position: relative;
  overflow: hidden;
}
.shimmer-line:nth-child(1) { width: 62%; }
.shimmer-line:nth-child(2) { width: 88%; }
.shimmer-line:nth-child(3) { width: 42%; }

.shimmer-avatar::after,
.shimmer-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--shimmer-highlight) 50%,
    transparent 100%
  );
  animation: shimmerSweep 1.2s ease-in-out infinite;
}

/* 移动端缩小一点 */
@media (max-width: 760px) {
  .shimmer-line { height: 10px; }
  .shimmer-line:nth-child(1) { width: 55%; }
  .shimmer-line:nth-child(2) { width: 80%; }
  .shimmer-line:nth-child(3) { width: 38%; }
}

/* ---------- 移动端适配（M1-M2）---------- */
@media (max-width: 760px) {
  .chat-sidebar {
    width: 100%;
    min-width: 100%;
    border-right: none;
    position: absolute;
    z-index: 10;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .28s var(--ease);
  }
  .chat-sidebar.show {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,.15);
  }

  .chat-main {
    z-index: 5;
  }

  .chat-profile-btn { display: flex; }
  .sidebar-close-btn { display: flex; }
  /* viewport-fit=cover 后顶栏需让开刘海/灵动岛安全区 */
  .chat-header { padding-top: calc(12px + env(safe-area-inset-top)); }
  .sidebar-header { padding: 14px 14px 10px; }
  .sidebar-clock { display: none; }
  .sidebar-footer { padding: 8px 14px 12px; }
  .sidebar-discord-card { margin: 6px 14px; }

  .chat-messages { padding: 12px 14px 16px 14px; }
  .chat-main::before { display: none; } /* 移动端关掉噪点纹理省GPU */
  .msg-row { max-width: 86%; }
  .user-row { max-width: 80%; }
  .user-bubble { padding: 8px 12px; font-size: 13px; box-shadow: var(--shadow-sm); }
  .msg-link-card { padding: 10px 12px; gap: 10px; }
  .link-card-icon { width: 36px; height: 36px; border-radius: 10px; }
  .link-card-icon svg { width: 18px; height: 18px; }
  .link-card-title { font-size: 13px; }
  .link-card-desc { font-size: 11px; white-space: normal; word-break: break-word; }

  /* 移动端 pills */
  .chat-pills-bar { padding: 6px 10px 8px; gap: 6px; min-height: 36px; }
  .chat-pill { padding: 10px 14px; font-size: 12px; }
  .chat-pill.home-pill { padding: 10px 10px; }
  .chat-disclaimer { font-size: 9px; padding: 0 10px 6px; opacity: .55; }
  .msg-connect-grid { max-width: 94%; }

  /* 移动端降低毛玻璃 blur，省 GPU */
  .chat-sidebar, .chat-main, .chat-header, .chat-pills-bar,
  .sidebar-discord-card, .chat-pill {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* iOS Safari 输入框聚焦时不缩放页面 */
  .chat-bottom-bar .chat-input-bar textarea {
    font-size: 16px;
  }
  /* 聊天区域 iOS 弹性滚动 */
  .chat-messages {
    -webkit-overflow-scrolling: touch;
  }
  /* 底部按钮触摸目标放大 */
  .chat-bottom-bar .chat-input-bar button {
    width: 40px;
    height: 40px;
  }
  /* 链接卡片触摸目标 */
  .msg-link-card {
    min-height: 44px;
  }
  /* 用户气泡触摸目标 */
  .user-bubble {
    min-height: 44px;
  }
}

/* ============================================
   Mars Animations — 关键帧
   ============================================ */

/* 减弱动效偏好 */
@media (prefers-reduced-motion: reduce) {
  html.accent-transitioning,
  html.accent-transitioning *,
  html.accent-transitioning *::before,
  html.accent-transitioning *::after,
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 打字气泡入场 */
@keyframes typingSlideIn {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* 消息滑入（新元素入场） */
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 分隔线淡入 */
@keyframes msgDividerIn {
  from { opacity: 0; }
  to   { opacity: .55; }
}

/* 系统消息淡入 */
@keyframes msgSystemIn {
  from { opacity: 0; }
  to   { opacity: .65; }
}

/* 公告淡入滑入 */
@keyframes msgFadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 打字圆点弹跳（AI 聊天沿用） */
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: .8; }
}
/* 可爱打字态：果冻上浮 — 上跳时略微压扁再弹起 */
@keyframes typingPop {
  0%, 70%, 100% { transform: translateY(0) scale(1);            opacity: .5; }
  20%           { transform: translateY(-6px) scale(1.18, .9);  opacity: 1;  }
  35%           { transform: translateY(0) scale(.92, 1.08);    opacity: .8; }
}
/* 打字气泡呼吸 */
@keyframes typingBreathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}
@media (prefers-reduced-motion: reduce) {
  .typing-bubble { animation: none !important; }
}

/* 彩蛋 toast 弹跳 */
@keyframes toastBounce {
  0%   { transform: translate(-50%, -50%) scale(.7); opacity: 0; }
  55%  { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  75%  { transform: translate(-50%, -50%) scale(.96); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* toast 退场 */
@keyframes toastFadeOut {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to   { transform: translate(-50%, -50%) scale(.95); opacity: 0; }
}

/* 生日彩屑下落 */
@keyframes birthdayFall {
  0%   { transform: translateY(-30px) translateX(0); opacity: 0; }
  6%   { opacity: 1; }
  100% { transform: translateY(105vh) translateX(45px) rotate(720deg); opacity: 0; }
}
@keyframes birthdayFall2 {
  0%   { transform: translateY(-30px) translateX(0); opacity: 0; }
  6%   { opacity: 1; }
  100% { transform: translateY(105vh) translateX(-50px) rotate(-600deg); opacity: 0; }
}
@keyframes birthdayFall3 {
  0%   { transform: translateY(-30px) translateX(0); opacity: 0; }
  6%   { opacity: 1; }
  40%  { transform: translateY(40vh) translateX(25px) rotate(300deg); }
  80%  { transform: translateY(80vh) translateX(-20px) rotate(600deg); }
  100% { transform: translateY(105vh) translateX(10px) rotate(720deg); opacity: 0; }
}

/* 上浮星点 */
@keyframes sparkleFloat {
  0%   { transform: translateY(0) translateX(0) scale(.4); opacity: 0; }
  15%  { opacity: .9; }
  85%  { opacity: .6; }
  100% { transform: translateY(-110vh) translateX(40px) scale(1); opacity: 0; }
}
@keyframes sparkleFloat2 {
  0%   { transform: translateY(0) translateX(0) scale(.3); opacity: 0; }
  15%  { opacity: .8; }
  100% { transform: translateY(-110vh) translateX(-30px) scale(1.1); opacity: 0; }
}

/* 消息退场：下滑淡出 */
@keyframes msgSlideOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}

/* Shimmer 光扫动画 */
@keyframes shimmerSweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* ---------- Chat Bottom Bar (input + pills) ---------- */
.chat-bottom-bar {
  border-top: 1px solid var(--divider);
  background: var(--sidebar-bg);
  padding-bottom: calc(4px + env(safe-area-inset-bottom));
}

.chat-bottom-bar .chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 16px;
  border-bottom: 1px solid var(--divider);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.chat-bottom-bar .chat-input-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}

.chat-bottom-bar .chat-input-bar textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.5;
  padding: 2px 4px;
  resize: none;
  overflow-y: hidden;
  max-height: 120px;
  min-height: 20px;
}

.chat-bottom-bar .chat-input-bar textarea::placeholder {
  color: var(--muted);
  opacity: .6;
}

.chat-bottom-bar .chat-input-bar button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .32s var(--ease-cute), opacity .15s var(--ease), background .2s var(--ease);
  padding: 0;
}

.chat-bottom-bar .chat-input-bar button svg {
  display: block;
  flex-shrink: 0;
  margin: 0;
}

.chat-bottom-bar .chat-input-bar button:hover {
  transform: scale(1.14);
  background: var(--accent2);
}

.chat-bottom-bar .chat-input-bar button:active {
  transform: scale(.9);
}

.chat-bottom-bar .chat-input-bar button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

/* 输入框各主题 focus */
html[data-accent="teal"] .chat-bottom-bar .chat-input-bar:focus-within { box-shadow: 0 1px 0 0 var(--accent); }
html[data-accent="rose"] .chat-bottom-bar .chat-input-bar:focus-within { box-shadow: 0 1px 0 0 var(--accent); }
html[data-accent="purple"] .chat-bottom-bar .chat-input-bar:focus-within { box-shadow: 0 1px 0 0 var(--accent); }

/* ---------- AI Chat Typing (uses msg-row + msg-bubble) ---------- */
.msg-bubble.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  min-height: 40px;
}

.msg-bubble .typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .4;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.msg-bubble .typing-dot:nth-child(2) { animation-delay: .15s; }
.msg-bubble .typing-dot:nth-child(3) { animation-delay: .3s; }

@media (max-width: 760px) {
  .chat-bottom-bar .chat-input-bar {
    margin: 0 12px;
    padding: 8px 12px;
  }
}

/* ============================================
   v1.12 — SVG Icons & Entrance Animations
   ============================================ */

/* SVG 图标统一尺寸与风格 */
.icon-svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  display: block;
}

.icon-svg.is-fill {
  fill: currentColor;
  stroke: none;
}

/* 小尺寸图标（侧边栏 footer 等） */
.icon-svg.icon-sm {
  width: 18px;
  height: 18px;
}

.icon-svg.icon-xs {
  width: 16px;
  height: 16px;
}

/* 入场动画基础类 */
.anim-entering {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
  pointer-events: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.anim-entering.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.anim-entering.slide-left {
  transform: translateX(-28px);
}

.anim-entering.slide-left.is-visible {
  transform: translateX(0);
}

.anim-entering.scale-in {
  transform: scale(.9);
}

.anim-entering.scale-in.is-visible {
  transform: scale(1);
}

/* 侧边栏元素入场延迟 */
.sidebar-avatar.anim-entering { transition-delay: 80ms; }
.sidebar-user.anim-entering { transition-delay: 160ms; }
.accent-picker.anim-entering { transition-delay: 240ms; }
.sidebar-discord-card.anim-entering { transition-delay: 320ms; }
.sidebar-footer.anim-entering { transition-delay: 400ms; }

/* 聊天区元素入场延迟 */
.chat-header.anim-entering { transition-delay: 120ms; }
.chat-messages.anim-entering { transition-delay: 220ms; }
.chat-input-bar.anim-entering { transition-delay: 360ms; }
.chat-pills-bar.anim-entering { transition-delay: 460ms; }

/* GSAP 接管入场动画时（html.gsap 由 mars-gsap.js 注入），禁用 CSS transition，
   避免与 GSAP 逐帧内联更新产生双重缓动/jank。
   is-visible 仍用于 pointer-events 与 avatarBreath 触发，不受此影响。 */
html.gsap .chat-app,
html.gsap .anim-entering {
  transition: none;
}

/* 头像微缩放呼吸 */
@keyframes avatarBreath {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.sidebar-avatar.is-visible .chibi img {
  animation: avatarBreath 4s ease-in-out infinite;
  animation-delay: .8s;
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  .anim-entering,
  .anim-entering.is-visible {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .sidebar-avatar.is-visible .chibi img {
    animation: none;
  }

  * {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
