/* ============================================
   Mars Variables — CSS 变量与主题系统
   设计原则：
   - 大面积背景极低饱和度，接近中性白，只留极淡色相倾向
   - 色彩人格靠小元素承载（accent 按钮、pill、hover 态）
   - 气泡与聊天背景亮度差 ≥ 5%（ΔL ≥ 5）
   - 区域边界清晰（bg / sidebar-bg / chat-bg 有可感知差异）
   ============================================ */

: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);
  --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 时的全局过渡 — 只在 html.accent-transitioning 下激活，不影响日常操作 */
html.accent-transitioning,
html.accent-transitioning * {
  transition: background .4s var(--ease),
              background-color .4s var(--ease),
              border-color .4s var(--ease),
              color .4s var(--ease),
              box-shadow .4s var(--ease) !important;
}

/* 减少动画偏好：全局过渡一律禁用，优先级高于 accent 切换 */
@media (prefers-reduced-motion: reduce) {
  html.accent-transitioning,
  html.accent-transitioning * {
    transition: none !important;
  }
}

/* 移动端禁用 accent 过渡 — backdrop-filter 重算导致 GPU 闪烁 */
@media (pointer: coarse) {
  html.accent-transitioning,
  html.accent-transitioning * {
    transition: none !important;
  }
}
/* ============================================
   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-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; }
.loader-track {
  width: 100%; height: 4px;
  background: var(--divider); border-radius: 99px; overflow: hidden;
}
.loader-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%; border-radius: 99px;
  box-shadow: 0 0 10px rgba(224, 160, 32, .25);
  transition: width .2s linear;
}
.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.22); }
html[data-accent="honey"]  .orb-2 { background: hsla(48, 70%, 55%, 0.18); }
html[data-accent="honey"]  .orb-3 { background: hsla(28, 75%, 60%, 0.15); }
html[data-accent="teal"]   .orb-1 { background: hsla(170, 60%, 50%, 0.22); }
html[data-accent="teal"]   .orb-2 { background: hsla(185, 55%, 48%, 0.18); }
html[data-accent="teal"]   .orb-3 { background: hsla(160, 65%, 52%, 0.15); }
html[data-accent="rose"]   .orb-1 { background: hsla(340, 60%, 58%, 0.22); }
html[data-accent="rose"]   .orb-2 { background: hsla(350, 55%, 55%, 0.18); }
html[data-accent="rose"]   .orb-3 { background: hsla(330, 65%, 60%, 0.15); }
html[data-accent="purple"] .orb-1 { background: hsla(265, 65%, 58%, 0.22); }
html[data-accent="purple"] .orb-2 { background: hsla(275, 60%, 55%, 0.18); }
html[data-accent="purple"] .orb-3 { background: hsla(255, 70%, 60%, 0.15); }

.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: .30;
  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,.18) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 18%, rgba(232,120,160,.12) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 68%, rgba(224,160,32,.14) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 78%, rgba(38,166,154,.10) 0 1px, transparent 2px);
}
html[data-accent="teal"] .bg-motes {
  background:
    radial-gradient(circle at 18% 32%, rgba(38,166,154,.18) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 18%, rgba(26,198,218,.12) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 68%, rgba(38,166,154,.14) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 78%, rgba(38,166,154,.10) 0 1px, transparent 2px);
}
html[data-accent="rose"] .bg-motes {
  background:
    radial-gradient(circle at 18% 32%, rgba(208,96,144,.18) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 18%, rgba(232,120,160,.12) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 68%, rgba(208,96,144,.14) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 78%, rgba(208,96,144,.10) 0 1px, transparent 2px);
}
html[data-accent="purple"] .bg-motes {
  background:
    radial-gradient(circle at 18% 32%, rgba(124,77,255,.18) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 18%, rgba(192,128,252,.12) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 68%, rgba(124,77,255,.14) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 78%, rgba(124,77,255,.10) 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;
  overflow: hidden;
  opacity: 0;
  pointer-events: none; /* loader 期间禁止交互穿透 */
  transition: opacity .5s var(--ease);
}
.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);
  background: color-mix(in srgb, var(--sidebar-bg) 55%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  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 {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: none;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), opacity .18s var(--ease);
  cursor: pointer;
  flex-shrink: 0;
  opacity: .6;
  position: relative;
  overflow: hidden;
  background: transparent;
  padding: 0;
}
.accent-dot::before {
  content: '';
  position: absolute;
  top: 5px; left: 5px;
  width: 14px; height: 14px;
  border-radius: 50%;
}
.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;
  transform: scale(1.15);
}
.accent-dot.active {
  opacity: 1;
  transform: scale(1.2);
  box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4px var(--accent);
}
.accent-dot:active { transform: scale(.9); }

/* 搜索栏（装饰） */
.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--divider);
  color: var(--muted);
  opacity: .5;
}
.sidebar-search input {
  flex: 1; border: none; background: none;
  font-family: var(--font-display);
  font-size: 13px; color: var(--muted);
  outline: none;
  pointer-events: none;
}
.sidebar-search input::placeholder { color: var(--muted); opacity: .5; }

/* 侧边栏关闭按钮（移动端显示） */
.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-weather {
  display: none;
}

/* ---------- 聊天主区域 ---------- */

/* ---------- 聊天主区域 ---------- */
.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-search { display: none; }
  .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 .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.msg-link-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--hover-bg);
  border-color: var(--accent);
}
.msg-link-card:hover .link-card-icon {
  transform: rotate(5deg) scale(1.04);
  transition: transform .25s var(--ease);
}

.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 .12s ease;
  flex-shrink: 0;
  user-select: none;
}
.chat-pill:hover {
  background: var(--hover-bg);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.chat-pill:active { transform: scale(.96); }
.chat-pill.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.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);
}

/* ---------- 侧边栏 Milestones 按钮 ---------- */
.sidebar-milestones-btn {
  padding: 6px 12px;
  flex-shrink: 0;
}
.sidebar-milestones-btn button {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--hover-bg);
  background: color-mix(in srgb, var(--hover-bg) 50%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--pillBorder);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .12s ease;
}
.sidebar-milestones-btn button:hover {
  background: var(--hover-bg);
  border-color: var(--accent);
}
.sidebar-milestones-btn button:active {
  transform: scale(.98);
}
.sidebar-milestones-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-milestones-label {
  flex: 1;
}
.sidebar-milestones-arrow {
  color: var(--muted);
  opacity: .5;
  font-size: 14px;
}
.sidebar-discord-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 6px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--hover-bg);
  background: color-mix(in srgb, var(--hover-bg) 50%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--pillBorder);
  color: var(--text);
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.sidebar-discord-card:hover {
  background: var(--hover-bg);
  border-color: var(--accent);
}
.sidebar-discord-card:active {
  transform: scale(.98);
}
.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: 76%;
  align-self: flex-end;
  opacity: 0;
}
.user-row.msg-animate {
  animation: msgSlideIn .4s var(--ease) both;
}
/* user-bubble defined below at .user-row section */
.typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 0;
}
.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .4;
  animation: typingBounce 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

/* ---------- 彩蛋 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%; }
}

/* ---------- 响应式 ---------- */
@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; }
  .sidebar-header { padding: 14px 14px 10px; }
  .sidebar-search { display: none; }
  .sidebar-clock { display: none; }
  .sidebar-footer { padding: 8px 14px 12px; }
  .sidebar-milestones-btn { padding: 6px 14px; }
  .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-milestones-btn button, .sidebar-discord-card, .chat-pill {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* ============================================
   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); }
}

/* 打字指示器淡入 */
@keyframes typingIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 打字圆点弹跳 */
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: .8; }
}

/* 彩蛋 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(--card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  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 .15s var(--ease), 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.08);
  background: var(--accent2);
}

.chat-bottom-bar .chat-input-bar button:active {
  transform: scale(.94);
}

.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; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 760px) {
  .chat-bottom-bar .chat-input-bar {
    margin: 0 12px;
    padding: 8px 12px;
  }
}

.user-row {
  display: flex;
  justify-content: flex-end;
  max-width: 100%;
}

.user-bubble {
  background: var(--bubble-sent);
  color: var(--bubble-sent-text);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  min-width: 80px;
  width: fit-content;
  white-space: pre-wrap;
}
