/* === Kli Shell - Echoes 视觉风格 === */

:root {
  --bg-surface: #e6eef2;
  --card-bg: rgba(255, 255, 255, 0.60);
  --card-bg-hover: rgba(255, 255, 255, 0.80);
  --card-border: rgba(0, 0, 0, 0.04);
  --text-primary: #1a1a2e;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.10);
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* === 皮肤主题（设置页切换） === */
/* 杂志：浅蓝灰 + 靛紫（默认） */
/* 暖黑：深夜 + 暖金 */
:root[data-theme="warm"] {
  --bg-surface: #17181f;
  --card-bg: rgba(42, 44, 58, 0.72);
  --card-bg-hover: rgba(52, 54, 70, 0.85);
  --card-border: rgba(255, 255, 255, 0.06);
  --text-primary: #f2ede3;
  --text-secondary: #b7ad9c;
  --text-muted: #8a8172;
  --accent: #d9a05b;
  --accent-soft: rgba(217, 160, 91, 0.14);
}
/* 樱粉：浅粉 + 玫红 */
:root[data-theme="sakura"] {
  --bg-surface: #fbeef2;
  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(244, 143, 177, 0.15);
  --text-primary: #43222e;
  --text-secondary: #8d5a68;
  --text-muted: #c09aa5;
  --accent: #ec5d8f;
  --accent-soft: rgba(236, 93, 143, 0.12);
}
/* 薄荷：浅绿 + 青 */
:root[data-theme="mint"] {
  --bg-surface: #e9f4ef;
  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(52, 168, 132, 0.15);
  --text-primary: #17352c;
  --text-secondary: #4f7a6c;
  --text-muted: #8fb3a6;
  --accent: #2f9e74;
  --accent-soft: rgba(47, 158, 116, 0.12);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-surface);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* === Shell Container === */
#kli-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

#kli-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.kli-page {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.kli-page.active { display: flex; }

/* 翻页效果：切页时从右滑入 + 淡入，像 App 页面切换 */
/* DESIGN: 翻页过渡——新页面从右滑入，旧页面淡出。Codex 可调时长/缓动曲线。 */
@keyframes kliPageIn {
  from { opacity: 0.4; transform: translateX(24px); }
  to   { opacity: 1;   transform: translateX(0); }
}
.kli-page.active {
  animation: kliPageIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 每个页面差异化背景：不要全都像聊天页 */
/* DESIGN: 聊天=浅蓝灰(默认)、心跳=淡紫渐变、语音=深色氛围、猫窝=暖米色。
   每个页面有自己的视觉身份，切换时一眼能认出来。Codex 可细化各页的渐变/装饰。 */
#kli-page-heartbeat {
  background: linear-gradient(180deg, #ede9fe 0%, var(--bg-surface) 45%);
}
#kli-page-voice {
  background: linear-gradient(180deg, #1e1b4b 0%, #0f172a 60%);
  color: #e2e8f0;
}
#kli-page-home {
  background: linear-gradient(180deg, #fdf6ec 0%, var(--bg-surface) 45%);
}

/* === Chat Page (Echoes iframe) === */
#kli-page-chat {
  padding: 0;
}

#kli-page-chat iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* === Bottom Navigation === */
#kli-nav {
  position: relative;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  flex-shrink: 0;
}

.kli-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.kli-nav-item:active { transform: scale(0.95); }

.kli-nav-item.active {
  color: var(--accent);
  font-weight: 600;
}

.kli-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}

.kli-nav-icon {
  font-size: 22px;
  line-height: 1;
}

.kli-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 14px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid rgba(255,255,255,0.85);
  opacity: 0;
  transition: opacity 0.3s;
}

.kli-nav-badge.visible { opacity: 1; }

/* === Page Header === */
.kli-page-header {
  padding: 20px 20px 12px;
  flex-shrink: 0;
}

.kli-page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.kli-page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* === Heartbeat Page === */
/* DESIGN: 心跳页紧凑化——双卡横排（我的脉/她的心跳）窄一点，欲望指数卡占整行。
   参考 20A 4.1 Heartbeat：左卡=我的脉（模拟），右卡=她的心跳（手表），不混淆。 */
.heartbeat-grid {
  display: grid;
  gap: 12px;
  padding: 0 16px 24px;
}

/* 双卡横排：窄卡并排 */
.heartbeat-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.heartbeat-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid var(--card-border);
  padding: 16px;
  transition: transform 0.2s;
  min-width: 0;
}

/* 脉冲动画（心跳呼应，Codex 可细化） */
@keyframes pulseMine {
  0%   { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.35); }
  100% { box-shadow: 0 0 0 14px rgba(99, 102, 241, 0); }
}
.heartbeat-card .heartbeat-value.pulse {
  animation: pulseMine 0.6s ease-out;
}

.heartbeat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.heartbeat-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.heartbeat-card-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.heartbeat-card-badge.live {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
}

.heartbeat-card-badge.sim {
  background: rgba(99, 102, 241, 0.10);
  color: var(--accent);
}

.heartbeat-value-area {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 12px;
}

.heartbeat-value {
  font-size: 40px;
  font-weight: 200;
  letter-spacing: -1.5px;
  line-height: 1;
}

.heartbeat-unit {
  font-size: 16px;
  color: var(--text-secondary);
}

.heartbeat-wave {
  width: 100%;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0,0,0,0.02);
}

.heartbeat-wave canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.heartbeat-timestamp {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: right;
}

/* 我的脉/她的心跳 补充行 */
.heartbeat-vitals {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.heartbeat-chord {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* === 欲望维度卡 === */
/* DESIGN: 欲望维度——雷达图(四维 drives) + 欲望盒条形列表。
   雷达图参考七宗罪维度图：蜘蛛网 + 每条轴标名字。Codex 可细化发光/渐变/动画。 */

.heartbeat-card-badge.desire-cool { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.heartbeat-card-badge.desire-warm { background: rgba(234, 179, 8, 0.14); color: #d97706; }
.heartbeat-card-badge.desire-hot  { background: rgba(239, 68, 68, 0.14); color: #ef4444; }

/* 雷达图容器：居中，占整行 */
.desire-radar-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 4px 0 8px;
  min-height: 180px;
}

.desire-mood {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-align: center;
}

.desire-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.desire-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}
.desire-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.desire-item.faded { opacity: 0.45; }
.desire-item-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.desire-item-bar {
  width: 60px;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
  flex-shrink: 0;
}
.desire-item-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}
.desire-item-pct {
  width: 34px;
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* === Voice Page === */
.voice-page-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 20px;
  gap: 24px;
}

.voice-call-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4CAF50, #45a049);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.voice-call-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 10px rgba(76, 175, 80, 0.2);
}

.voice-call-btn.connected {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.voice-call-icon {
  font-size: 36px;
  line-height: 1;
}

.voice-status {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

.voice-timer {
  font-size: 32px;
  font-weight: 200;
  letter-spacing: -1px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.voice-controls {
  display: flex;
  gap: 24px;
  margin-top: 8px;
}

.voice-ctrl-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.voice-ctrl-btn:active { transform: scale(0.93); }

/* === Home Page === */
.home-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 20px 24px;
}

.home-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid var(--card-border);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 14px;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  color: inherit;
}

.home-card:active {
  transform: scale(0.98);
  background: var(--card-bg-hover);
}

.home-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.home-card-icon.memory { background: rgba(99, 102, 241, 0.12); }
.home-card-icon.devices { background: rgba(16, 185, 129, 0.12); }
.home-card-icon.settings { background: rgba(245, 158, 11, 0.12); }
.home-card-icon.about { background: rgba(139, 92, 246, 0.12); }

.home-card-body { flex: 1; }
.home-card-title { font-size: 15px; font-weight: 600; }
.home-card-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.home-card-arrow {
  font-size: 16px;
  color: var(--text-muted);
}

/* === Online Device Indicator === */
#kli-device-status {
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 4px 12px;
  border: 1px solid var(--card-border);
  transition: opacity 0.3s;
}

#kli-device-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  transition: background 0.3s;
}

#kli-device-dot.offline { background: #94a3b8; }

/* === 离线提示面板：点聊天顶栏在线点（离线时）弹出 === */
.offline-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(19, 23, 29, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.offline-modal-card {
  width: 100%;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 26px 22px 20px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  text-align: center;
  animation: plusPanelUp .22s ease-out;
}
.offline-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.offline-reason {
  font-size: 13px;
  color: var(--accent);
  margin-top: 8px;
  min-height: 18px;
}
.offline-solutions {
  text-align: left;
  margin: 16px 0 18px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 14px;
}
.offline-solutions p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}
.offline-actions {
  display: flex;
  gap: 10px;
}
.offline-btn {
  flex: 1;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-primary);
  border-radius: 14px;
  padding: 9px 0;
  font-size: 14px;
  cursor: pointer;
}
.offline-btn.primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.28);
}

/* === Toast === */
#kli-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 46, 0.92);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

#kli-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 0; }

/* === Chat Page（自建气泡聊天） === */
/* DESIGN: 整体视觉参考移动端微信/QQ 聊天 + Echoes 的轻盈感。背景延续 --bg-surface（#e6eef2 浅蓝灰）。Codex 可在此基础上细化头像、气泡阴影、动效。 */

/* 戳一戳面板（动作×落点，参考《戳一戳怎么做》） */
/* DESIGN: 双击头像弹出——平时 hidden。两排药丸按钮，选中高亮主色；底部预览+发送。Codex 可加展开动画/震动反馈。 */
.poke-panel {
  padding: 8px 12px 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.poke-panel.hidden { display: none; }

/* 头像双击提示（轻微放大一下，表示"可以戳"） */
.chat-avatar {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s;
}
.chat-avatar:active { transform: scale(0.92); }
.poke-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.poke-opt {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-primary);
  border-radius: 14px;
  padding: 5px 13px;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s;
}
.poke-opt:active { transform: scale(0.94); }
.poke-opt.sel {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-color: transparent;
}
.poke-send-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.poke-preview {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 16px;
}
.poke-send-btn {
  border: none;
  border-radius: 14px;
  padding: 5px 14px;
  font-size: 13px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.poke-send-btn:disabled {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-muted);
  box-shadow: none;
  cursor: default;
}
/* 参考图底部提示：点完看战果 */
.poke-tip {
  font-size: 11px;
  color: var(--text-tertiary, #a7adb5);
  text-align: center;
  padding: 2px 0 8px;
  font-style: italic;
}

#kli-page-chat {
  /* 注意：不能设 display:flex，否则 ID 特异性会覆盖 .kli-page { display:none }，
     导致聊天页永远显示（其他页背景透出输入条）。display 由 .kli-page.active 控制。 */
  flex-direction: column;
  padding: 0;
}

/* 顶栏 */
.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 10;
}

/* DESIGN: 头像圆形，可换成江逾白形象图（未来接 Live2D/静态图）；当前用"逾"字占位。 */
.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-name { font-size: 16px; font-weight: 600; }
.chat-mood { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

/* 在线状态点 */
.chat-online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6);
}
.chat-online-dot.online  { background: #22c55e; }
.chat-online-dot.busy    { background: #eab308; }
.chat-online-dot.dnd     { background: #ef4444; }
.chat-online-dot.offline { background: #94a3b8; }

/* 消息列表 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 欢迎语 */
.chat-welcome {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 20px;
}
.chat-welcome-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  margin: 0 auto 12px;
}

/* 一行消息（含内心戏 + 气泡 + 时间） */
/* DESIGN: 微信式——气泡按内容自适应宽度（不撑满、不齐长），AI 靠左、用户靠右，间距自然。 */
.chat-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  align-self: flex-start; /* AI 靠左 */
  margin-bottom: 10px; /* 行间留白，不挤 */
}
.chat-row.user { align-self: flex-end; align-items: flex-end; }

/* 内心戏小框（CCC 思考卡片：默认折叠，挂消息旁，小） */
/* DESIGN: 参考 CcCompanion "AI 思考卡片"——默认一行小字"💭 心里话 + 摘要"，点击展开全文。
   小、不喧宾夺主，缩在气泡上方/旁边。参考 20A 4.1 Chat 的消息级内心戏。 */
.chat-inner-thought {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 3px 10px;
  margin: 0 4px 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  max-width: 88%;
  align-self: flex-start;
  transition: background 0.2s;
}
.chat-inner-thought:hover { background: rgba(255, 255, 255, 0.8); }
.chat-inner-thought.open { background: rgba(255, 255, 255, 0.9); }
.chat-inner-thought .cit-label { font-size: 10px; opacity: 0.7; }

/* 气泡：微信式——内联块按内容宽，不撑满整行 */
/* DESIGN: 说话气泡 = 正常圆角卡片（AI 白/用户主色渐变）；动作气泡 = 更浅、半透明、可斜体。
   宽度自适应内容（display:inline-block），短句窄、长句宽，不齐长。参考 20A 4.1 Chat。 */
.chat-bubble {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-row.jyb .chat-bubble {
  background: rgba(255, 255, 255, 0.82);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.chat-row.user .chat-bubble {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-bottom-right-radius: 4px;
}
/* 同一条消息分多泡时，相邻气泡间距小一点（像微信连续气泡） */
.chat-row .chat-bubble + .chat-bubble {
  margin-top: 5px;
}
/* 动作气泡：与说话明显区分——文字更淡、字体更小、泡泡更小 */
/* DESIGN: 动作 = 浅色半透明小气泡，斜体，字号小一号（13px vs 15px），内边距小。
   和说话气泡并排时一眼能分出"动作"和"话"。 */
.chat-bubble.action {
  background: rgba(255, 255, 255, 0.32);
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
  padding: 7px 11px;
  border: 1px dashed rgba(0, 0, 0, 0.05);
  border-radius: 13px;
  opacity: 0.85;
}

/* 思考占位动画（CCC：思考进行中有一个转圈，不再对着空屏等） */
/* DESIGN: 一个圆圈 spinner 原地转，像"她在想"。想完转圈消失，有内心戏就变成可展开小卡。 */
.chat-row.thinking {
  align-self: flex-start;
}
.thinking-bubble {
  background: rgba(255, 255, 255, 0.82);
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
}
.thinking-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: thinkingSpin 0.8s linear infinite;
}
@keyframes thinkingSpin {
  to { transform: rotate(360deg); }
}

/* 时间戳小字（可选） */
.chat-time {
  font-size: 10px;
  color: var(--text-faint, #b6c2cf);
  margin: 3px 6px 8px;
}

/* 系统居中提示（微信"拍一拍"样式）：戳一戳/拍一拍的结果，居中灰色小字，不占气泡位 */
/* DESIGN: 参考微信"我拍了拍XX"——整行居中、小字、浅灰，上面可带时间。不是气泡，是系统痕迹。 */
.chat-row.sys {
  align-self: center;
  align-items: center;
  max-width: 90%;
  margin: 8px 0;
}
.chat-row.sys .chat-sys-time {
  text-align: center;
  font-size: 10px;
  color: var(--text-faint, #b6c2cf);
  margin-bottom: 2px;
}
.chat-row.sys .chat-sys-text {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  padding: 0;
  border: none;
}

/* 底部输入条 */
/* DESIGN: 微信式输入条：左侧语音圆钮🎤、中间胶囊输入框（内嵌😊表情钮）、右侧加号圆钮＋。只在聊天页显示。 */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}
.chat-voice-btn, .chat-more-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s, background 0.2s;
}
.chat-voice-btn:active, .chat-more-btn:active { transform: scale(0.9); }

/* 语音按钮：描边式，更轻 */
.chat-voice-btn {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
}

/* 输入框包装：胶囊容器，左侧输入 + 右侧内嵌表情钮 */
.chat-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 2px 4px 2px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input-wrap:focus-within {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* 输入框本体：无边框、透明底，由外层胶囊接管 */
.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  font-size: 15px;
  outline: none;
  color: var(--text-primary);
  min-width: 0;
}
.chat-input::placeholder { color: var(--text-muted); }

/* 内嵌表情钮：小圆钮，悬停/点击变主色 */
.chat-emoji-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.15s;
}
.chat-emoji-btn:active { transform: scale(0.88); background: rgba(0, 0, 0, 0.05); }

/* 右侧加号钮：与语音钮对称 */
.chat-more-btn {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
  font-size: 20px;
  font-weight: 300;
}

/* === 长按输入框录音 === */
.chat-input-wrap {
  touch-action: pan-x;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.voice-record-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  background: rgba(19, 23, 29, 0.56);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  overflow: hidden;
  touch-action: none;
}
.voice-record-overlay.active { display: block; }

.voice-record-float {
  position: absolute;
  left: 50%;
  bottom: 38%;
  transform: translateX(-50%);
  width: 112px;
  height: 56px;
  border-radius: 16px;
  background: #b8ef3f;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(117, 183, 27, 0.28);
}
.voice-record-float::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #b8ef3f;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
.voice-live-wave {
  position: relative;
  z-index: 1;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.voice-live-wave i {
  display: block;
  width: 4px;
  height: 8px;
  border-radius: 4px;
  background: #557428;
  animation: voiceWave 0.75s ease-in-out infinite alternate;
}
.voice-live-wave i:nth-child(2), .voice-live-wave i:nth-child(6) { animation-delay: .12s; }
.voice-live-wave i:nth-child(3), .voice-live-wave i:nth-child(5) { animation-delay: .24s; }
.voice-live-wave i:nth-child(4) { animation-delay: .36s; }
@keyframes voiceWave {
  from { height: 7px; opacity: .65; }
  to { height: 25px; opacity: 1; }
}

.voice-record-dock {
  position: absolute;
  left: 50%;
  bottom: -105px;
  transform: translateX(-50%);
  width: min(760px, 160vw);
  height: 390px;
  border-radius: 50% 50% 0 0 / 42% 42% 0 0;
  background: rgba(84, 89, 97, 0.97);
  box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.16);
}
.voice-record-zone {
  position: absolute;
  top: 54px;
  width: 152px;
  height: 86px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.90);
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
  transition: transform .16s, background .16s;
}
.voice-record-zone.cancel { left: calc(50% - 224px); transform: rotate(-11deg); }
.voice-record-zone.convert { right: calc(50% - 224px); transform: rotate(11deg); }
.voice-record-zone.hot {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.08);
}
.voice-record-send {
  position: absolute;
  left: 50%;
  top: 132px;
  transform: translateX(-50%);
  width: 290px;
  height: 185px;
  border-radius: 50% 50% 0 0 / 72% 72% 0 0;
  background: rgba(223, 226, 230, 0.96);
  color: #222831;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 48px;
  font-size: 18px;
  font-weight: 600;
}
.voice-record-duration {
  margin-top: 8px;
  color: #68707a;
  font-size: 12px;
  font-weight: 500;
}
.voice-record-overlay.mode-cancel .voice-record-float { background: #f2a7a7; }
.voice-record-overlay.mode-cancel .voice-record-float::after { background: #f2a7a7; }
.voice-record-overlay.mode-cancel .voice-live-wave i { background: #8b3e3e; }

/* === 聊天里的语音条 === */
.chat-voice-bubble {
  min-width: 86px;
  max-width: 230px;
  height: 44px;
  padding: 0 14px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.chat-row.user .chat-voice-bubble {
  flex-direction: row-reverse;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-row.jyb .chat-voice-bubble {
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-primary);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-bottom-left-radius: 4px;
}
.voice-bubble-waves {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.voice-bubble-waves i {
  display: block;
  width: 3px;
  border-radius: 3px;
  background: currentColor;
  opacity: .8;
}
.voice-bubble-waves i:nth-child(1), .voice-bubble-waves i:nth-child(5) { height: 7px; }
.voice-bubble-waves i:nth-child(2), .voice-bubble-waves i:nth-child(4) { height: 13px; }
.voice-bubble-waves i:nth-child(3) { height: 20px; }
.chat-voice-bubble.playing .voice-bubble-waves i { animation: voiceBubblePlay .55s ease-in-out infinite alternate; }
.chat-voice-bubble.playing .voice-bubble-waves i:nth-child(2) { animation-delay: .12s; }
.chat-voice-bubble.playing .voice-bubble-waves i:nth-child(3) { animation-delay: .24s; }
@keyframes voiceBubblePlay { from { transform: scaleY(.45); } to { transform: scaleY(1); } }
.voice-bubble-duration { font-size: 13px; font-variant-numeric: tabular-nums; }

/* ============================================================
   === 猫窝 / 桌面页 —— 杂志卡片风（参考图一：兔兔 & Alex 桌面） ===
   ============================================================ */
#kli-page-home {
  padding: 28px 22px 40px;
  overflow-y: auto;
}
.desk-clock {
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: 64px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--text-primary);
  line-height: 1.05;
  text-align: center;
  margin-top: 12px;
}
.desk-date {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 6px;
}
.desk-days {
  font-size: 13px;
  color: var(--text-tertiary, #a7adb5);
  text-align: center;
  margin-top: 10px;
  font-style: italic;
}
.desk-circle-row {
  display: flex;
  justify-content: space-between;
  margin: 30px 2px 8px;
}
.desk-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.desk-circle-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}
.desk-circle-icon.memory   { background: #e9e6fb; }
.desk-circle-icon.mood     { background: #fde7f0; }
.desk-circle-icon.heartbeat{ background: #e4f0fb; }
.desk-circle-icon.dream    { background: #e4f2f5; }
.desk-circle-icon.play     { background: #e2eef9; }
.desk-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 24px 4px 10px;
}
.desk-card {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 18px;
  padding: 4px 16px;
  box-shadow: 0 10px 26px rgba(31, 45, 61, 0.07);
  overflow: hidden;
}
.desk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.045);
  cursor: pointer;
}
.desk-row:last-child { border-bottom: none; }
.desk-row-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.desk-row-icon.game   { background: #e2eef9; }
.desk-row-icon.read   { background: #f3ecdc; }
.desk-row-icon.watch  { background: #fde7f0; }
.desk-row-icon.radio  { background: #e9e6fb; }
.desk-row-icon.period { background: #fde7f0; }
.desk-row-icon.pulse  { background: #e4f0fb; }
.desk-row-icon.order  { background: #f3ecdc; }
.desk-row-text {
  flex: 1;
  font-size: 15px;
  color: var(--text-primary);
}
.desk-row-arrow {
  color: #c3c9d1;
  font-size: 18px;
}

/* === 生活记录：迷你经期日历 === */
.mini-period {
  padding: 4px 2px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  margin-bottom: 10px;
}
.mini-period-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.mini-period-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-right: auto;
}
.mini-period-nav {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.mini-period-nav:active { transform: scale(0.9); }
.mini-period-month {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 62px;
  text-align: center;
}
.mini-period-open {
  border: none;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
}
.mini-period-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
  color: var(--text-tertiary, #a7adb5);
  margin-bottom: 4px;
}
.mini-period-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.mini-period-grid .period-day {
  aspect-ratio: 1;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0;
}
.mini-period-grid .period-day.on {
  background: linear-gradient(135deg, #f472b6, #ec4899);
  color: #fff;
  font-weight: 600;
}
.mini-period-grid .period-day.today {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.mini-period-grid .period-day.blank { cursor: default; }
.mini-period-grid .period-day.ov {
  background: rgba(14, 165, 233, 0.16);
  color: #0284c7;
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px #38bdf8;
  border-radius: 50%;
}
.mini-period-grid .period-day.fw {
  background: rgba(56, 189, 248, 0.10);
  color: #0c4a6e;
  border-radius: 8px;
}
.mini-period-grid .period-day.pre {
  color: #ec4899;
  box-shadow: inset 0 0 0 1px rgba(236, 72, 153, 0.5);
  border-radius: 8px;
  font-weight: 500;
}
.mini-period-legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}
.mini-period-legend .lg {
  font-size: 9px;
  color: var(--text-tertiary, #a7adb5);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.mini-period-legend .lg::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.mini-period-legend .lg.on::before { background: #ec4899; }
.mini-period-legend .lg.ov::before { background: #38bdf8; border-radius: 50%; }
.mini-period-legend .lg.fw::before { background: rgba(56, 189, 248, 0.35); }
.mini-period-legend .lg.pre::before { background: transparent; box-shadow: inset 0 0 0 1.5px #ec4899; }

/* === 生活记录：睡眠卡 === */
.sleep-card {
  padding: 2px 2px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  margin-bottom: 8px;
}
.sleep-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.sleep-score {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.sleep-score-unit {
  font-size: 11px;
  color: var(--text-tertiary, #a7adb5);
  font-weight: 400;
}
.sleep-date {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary, #a7adb5);
}
.sleep-chart {
  width: 100%;
  height: 56px;
  display: block;
}
.sleep-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-tertiary, #a7adb5);
  margin-top: 2px;
}
.sleep-detail-btn {
  border: none;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-left: 6px;
}

/* === 睡眠详情弹层 === */
.sleep-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(19, 23, 29, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.sleep-detail-card {
  width: 100%;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  animation: plusPanelUp .22s ease-out;
}
.sleep-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sleep-detail-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.sleep-detail-close {
  border: none;
  background: rgba(0, 0, 0, 0.05);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
}
.sleep-detail-date {
  font-size: 12px;
  color: var(--text-tertiary, #a7adb5);
  margin-top: 6px;
}
.sleep-detail-score {
  font-size: 15px;
  color: var(--text-primary);
  margin: 10px 0 12px;
}
.sleep-detail-score b {
  font-size: 30px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.sleep-detail-time {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.sleep-time-col {
  flex: 1;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
  padding: 9px 6px;
  text-align: center;
}
.sleep-time-label {
  display: block;
  font-size: 10px;
  color: var(--text-tertiary, #a7adb5);
}
.sleep-time-value {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 3px;
}
.sleep-detail-stages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sleep-stage-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sleep-stage-name {
  width: 64px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.sleep-stage-bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}
.sleep-stage-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
}
.sleep-stage-fill.deep { background: linear-gradient(90deg, #4338ca, #6366f1); }
.sleep-stage-fill.light { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }
.sleep-stage-val {
  width: 52px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.sleep-detail-hint {
  font-size: 10px;
  color: var(--text-tertiary, #a7adb5);
  line-height: 1.6;
  margin-top: 12px;
}

/* === 书架：竖放书脊 === */
.shelf-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary, #a7adb5);
  font-style: italic;
}
.shelf-card {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 26px rgba(31, 45, 61, 0.07);
  position: relative;
}
/* 木头书架：深棕木框 + 层板，书脊竖放在板子上 */
.shelf-card.wood {
  background: linear-gradient(180deg, #8a5a33 0%, #7a4d2b 60%, #6b4224 100%);
  border-radius: 14px;
  padding: 14px 14px 20px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25), 0 10px 26px rgba(31, 45, 61, 0.12);
}
.shelf-card.wood::before {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.shelf-books {
  min-height: 120px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 4px 14px;
  border-bottom: 3px solid #5d3a1e;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.wood .shelf-books {
  min-height: 128px;
  border-bottom: 4px solid #4c3018;
  border-radius: 2px;
}
.shelf-empty {
  color: rgba(255, 245, 230, 0.55);
  font-size: 13px;
  padding: 26px 6px;
  font-style: italic;
}
.shelf-book {
  position: relative;
  width: 40px;
  min-width: 40px;
  height: 96px;
  border-radius: 4px 6px 6px 4px;
  background: linear-gradient(135deg, #8b6f47, #6d573a);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shelf-book:nth-child(4n+2) { background: linear-gradient(135deg, #7a5c8f, #5c4370); }
.shelf-book:nth-child(4n+3) { background: linear-gradient(135deg, #4f7a8f, #3a5e70); }
.shelf-book:nth-child(4n+4) { background: linear-gradient(135deg, #8f5c5c, #704444); }
.shelf-book:active { transform: scale(0.94); }
.shelf-book-title {
  writing-mode: vertical-rl;
  font-size: 12px;
  color: #f5ecd9;
  letter-spacing: 2px;
  font-weight: 600;
  max-height: 78px;
  overflow: hidden;
  white-space: nowrap;
}
.shelf-book.reading::after {
  content: '✓';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 加号：木书架右下角 */
.shelf-add {
  position: absolute;
  right: 12px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 245, 230, 0.9);
  color: #6b4224;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.shelf-add:active { transform: scale(0.9); }

/* === 添加书面板 === */
.addbook-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(19, 23, 29, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.addbook-modal-card {
  width: 100%;
  max-width: 310px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  animation: plusPanelUp .22s ease-out;
}
.addbook-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  padding: 11px 13px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 10px;
}
.addbook-opt:active { transform: scale(0.97); }
.addbook-opt-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  background: #e4f0fb;
  flex-shrink: 0;
}
.addbook-opt-name { display: block; font-size: 15px; font-weight: 600; color: var(--text-primary); }
.addbook-opt-desc { display: block; font-size: 12px; color: var(--text-tertiary, #a7adb5); margin-top: 2px; }
.addbook-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.addbook-form input {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}
.addbook-uploading {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 18px 0;
}
.addbook-save {
  border: none;
  border-radius: 12px;
  padding: 10px 0;
  font-size: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* === 读书弹层：本地书内容阅读 === */
.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(19, 23, 29, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.reader-modal-card {
  width: 100%;
  max-width: 400px;
  height: 82%;
  background: #faf7ef;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: plusPanelUp .22s ease-out;
}
.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}
.reader-title {
  font-size: 16px;
  font-weight: 600;
  color: #3a3328;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.reader-close {
  border: none;
  background: rgba(0, 0, 0, 0.05);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}
.reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 40px;
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 16px;
  line-height: 1.9;
  color: #3a3328;
  white-space: pre-wrap;
  word-break: break-word;
}
.reader-loading {
  color: #a7adb5;
  text-align: center;
  padding: 40px 0;
  font-family: inherit;
}

/* === 碎碎念：一墙小纸条 === */
.notes-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(23, 19, 14, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.notes-board {
  width: 100%;
  max-width: 420px;
  height: 88%;
  background: linear-gradient(160deg, #c8a268, #b0894f 55%, #a0773f);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), inset 0 0 60px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.notes-board::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 2px, transparent 2px 4px);
  pointer-events: none;
}
.notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}
.notes-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff8ec;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.notes-close {
  border: none;
  background: rgba(255, 248, 236, 0.25);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  color: #fff8ec;
  cursor: pointer;
}
.notes-wall {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 12px 12px;
  -webkit-overflow-scrolling: touch;
}
.notes-note {
  width: calc(50% - 6px);
  min-height: 92px;
  padding: 14px 12px 10px;
  background: #fdf6d8;
  border-radius: 4px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  line-height: 1.6;
  color: #4a3f28;
  position: relative;
  transform: rotate(-1deg);
  animation: noteIn .3s ease-out both;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.notes-note:nth-child(3n) { transform: rotate(1.5deg); background: #fde8d6; }
.notes-note:nth-child(4n) { transform: rotate(-2deg); background: #dff0e4; }
.notes-note:nth-child(5n) { transform: rotate(2deg); background: #e6e4f7; }
.notes-note::before {
  content: '📌';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}
@keyframes noteIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: rotate(0); }
}
.notes-note-time {
  font-size: 10px;
  color: rgba(74, 63, 40, 0.5);
  margin-top: 6px;
}
.notes-foot {
  padding: 8px 16px 14px;
  font-size: 11px;
  color: rgba(255, 248, 236, 0.75);
  text-align: center;
  flex-shrink: 0;
}
.notes-loading {
  color: rgba(255, 248, 236, 0.8);
  text-align: center;
  padding: 40px 0;
  width: 100%;
  font-size: 13px;
}

/* === 一起听歌：歌单面板 === */
.music-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(19, 23, 29, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.music-card {
  width: 100%;
  max-width: 310px;
  max-height: 80%;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  animation: plusPanelUp .22s ease-out;
  display: flex;
  flex-direction: column;
}
.music-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.music-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  padding: 10px 13px;
  cursor: pointer;
  text-align: left;
}
.music-item:active { transform: scale(0.97); }
.music-item-cover {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.music-item-name { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.music-item-artist { display: block; font-size: 11px; color: var(--text-tertiary, #a7adb5); margin-top: 2px; }
.music-hint {
  font-size: 11px;
  color: var(--text-tertiary, #a7adb5);
  text-align: center;
  margin-top: 12px;
}

/* === Play 游戏面板 === */
.play-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(19, 23, 29, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
}
.play-modal-card {
  width: 100%;
  max-width: 340px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 22px 20px 18px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  animation: plusPanelUp .22s ease-out;
}
.play-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 16px;
}
.play-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.play-option {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 13px 14px;
  cursor: pointer;
  text-align: left;
}
.play-option:active { transform: scale(0.97); }
.play-option-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: #e4f0fb;
  flex-shrink: 0;
}
.play-option-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}
.play-option-desc {
  font-size: 12px;
  color: var(--text-tertiary, #a7adb5);
  display: block;
  margin-top: 2px;
}
.play-close {
  width: 100%;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 13px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: 14px;
}

/* === 经期日历面板 === */
.period-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(19, 23, 29, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.period-modal-card {
  width: 100%;
  max-width: 330px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  animation: plusPanelUp .22s ease-out;
}
.period-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.period-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.period-nav {
  border: none;
  background: rgba(0, 0, 0, 0.05);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
}
.period-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary, #a7adb5);
  margin-bottom: 6px;
}
.period-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.period-day {
  aspect-ratio: 1;
  border: none;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
}
.period-day.blank { background: transparent; cursor: default; }
.period-day.today { box-shadow: inset 0 0 0 1.5px rgba(99, 102, 241, 0.5); }
.period-day.on { background: #f48fb1; color: #fff; font-weight: 600; }
.period-day.pre { background: #fde7f0; color: #b06a85; }
.period-day.on.pre { background: #f06292; }
.period-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-tertiary, #a7adb5);
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot.on { background: #f48fb1; }
.dot.pre { background: #fde7f0; border: 1px solid #f3c4d4; }
.period-close {
  width: 100%;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-radius: 13px;
  padding: 10px 0;
  font-size: 14px;
  cursor: pointer;
  margin-top: 14px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* === 皮肤主题面板 === */
.skin-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(19, 23, 29, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.skin-modal-card {
  width: 100%;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  animation: plusPanelUp .22s ease-out;
}
.skin-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.skin-option {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
}
.skin-option.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.skin-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.skin-name {
  flex: 1;
  font-size: 15px;
  color: var(--text-primary);
}
.skin-check { color: var(--accent); font-weight: 700; opacity: 0; }
.skin-option.sel .skin-check { opacity: 1; }

/* === Token 用量面板 === */
.usage-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(19, 23, 29, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.usage-modal-card {
  width: 100%;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  animation: plusPanelUp .22s ease-out;
}
.usage-balance {
  font-size: 34px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.usage-provider {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.usage-hint {
  font-size: 11px;
  color: var(--text-tertiary, #a7adb5);
  text-align: center;
  margin-top: 14px;
  line-height: 1.6;
}
.usage-refresh {
  width: 100%;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 13px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: 12px;
}

/* === 技能 · MCP 详情面板 === */
.mcp-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(19, 23, 29, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.mcp-modal-card {
  width: 100%;
  max-width: 340px;
  max-height: 86%;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.18);
  animation: plusPanelUp .22s ease-out;
  display: flex;
  flex-direction: column;
}
.mcp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mcp-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.mcp-close {
  border: none;
  background: rgba(0, 0, 0, 0.05);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
}
.mcp-sub {
  font-size: 11px;
  color: var(--text-tertiary, #a7adb5);
  margin: 8px 0 12px;
  line-height: 1.6;
}
.mcp-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.mcp-item {
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  padding: 11px 13px;
}
.mcp-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mcp-item-icon {
  font-size: 16px;
}
.mcp-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  flex: 1;
}
.mcp-item-status {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
}
.mcp-item-status.on { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.mcp-item-status.off { background: rgba(148, 163, 184, 0.15); color: #64748b; }
.mcp-item-what {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.55;
}
.mcp-item-can {
  font-size: 11px;
  color: var(--text-tertiary, #7a828c);
  margin-top: 3px;
  line-height: 1.55;
}
.mcp-item-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.mcp-toggle-label {
  font-size: 11px;
  color: var(--text-tertiary, #7a828c);
}
.mcp-switch {
  width: 42px;
  height: 24px;
  border-radius: 12px;
  border: none;
  background: rgba(0, 0, 0, 0.12);
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s;
}
.mcp-switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: left 0.2s;
}
.mcp-switch.on {
  background: linear-gradient(135deg, #34d399, #22c55e);
}
.mcp-switch.on i { left: 21px; }
.mcp-switch:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ============================================================
   === 设置页 —— 参考图二（Alex 设置） ===
   ============================================================ */
#kli-page-settings {
  padding: 36px 22px 48px;
  overflow-y: auto;
}
.set-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
}
.set-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #f7f1e2;
  border: 1px solid #f0e4c8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 600;
  color: #7a6a4a;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}
.set-name {
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 14px;
}
.set-domain {
  font-size: 12px;
  color: var(--text-tertiary, #a7adb5);
  margin-top: 6px;
  font-style: italic;
}
.set-card {
  background: rgba(255, 255, 255, 0.88);
  border-radius: 18px;
  padding: 4px 16px;
  box-shadow: 0 10px 26px rgba(31, 45, 61, 0.07);
  margin-bottom: 16px;
  overflow: hidden;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.045);
  cursor: pointer;
}
.set-row:last-child { border-bottom: none; }
.set-row-title { font-size: 15px; color: var(--text-primary); flex: none; }
.set-row-desc {
  flex: 1;
  font-size: 12px;
  color: var(--text-tertiary, #a7adb5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.set-row-value {
  font-size: 13px;
  color: var(--text-tertiary, #a7adb5);
  flex: none;
}
.set-row-arrow {
  color: #c3c9d1;
  font-size: 17px;
  flex: none;
}
.set-footer {
  text-align: center;
  font-size: 11px;
  color: #c9cdd4;
  margin-top: 26px;
  font-style: italic;
}
.ver-tag {
  display: block;
  margin-top: 6px;
  font-style: normal;
  color: #d8dde3;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.5px;
}

/* ============================================================
   === 聊天加号面板 —— 微信式联动（参考图三） ===
   放在聊天页输入条之后：展开时输入条在面板上方，一起从底部升起
   ============================================================ */
.chat-plus-panel {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 18px 16px 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: plusPanelUp .22s ease-out;
}
@keyframes plusPanelUp {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.chat-plus-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.chat-plus-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 8px 2px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.chat-plus-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.05);
}
.chat-plus-icon.album    { background: #e4f0fb; }
.chat-plus-icon.camera   { background: #f3ecdc; }
.chat-plus-icon.call     { background: #e9e6fb; }
.chat-plus-icon.location { background: #fde7f0; }
.chat-plus-icon.file     { background: #e2eef9; }

/* 通用隐藏（poke-panel 旧规则保留，新组件统一用 .hidden） */
.hidden { display: none !important; }

/* === Kli visual refinement v11 ========================================= */
:root {
  --bg-surface: #e8edf0;
  --bg-deep: #dce4e8;
  --card-bg: rgba(255, 255, 255, .76);
  --card-bg-hover: rgba(255, 255, 255, .92);
  --card-border: rgba(35, 47, 54, .09);
  --text-primary: #172026;
  --text-secondary: #596971;
  --text-muted: #829198;
  --text-tertiary: #96a2a8;
  --text-faint: #a9b4b9;
  --accent: #4d6672;
  --accent-strong: #354f5b;
  --accent-soft: rgba(77, 102, 114, .12);
  --warm-accent: #a56f5b;
  --surface-shadow: 0 12px 32px rgba(40, 55, 62, .08);
  --surface-shadow-soft: 0 4px 16px rgba(40, 55, 62, .06);
  --hairline: rgba(35, 47, 54, .08);
  --radius-card: 8px;
  --radius-control: 8px;
  --page-gutter: clamp(14px, 4vw, 20px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

:root[data-theme="warm"] {
  --bg-surface: #17181d;
  --bg-deep: #101116;
  --card-bg: rgba(39, 39, 45, .88);
  --card-bg-hover: rgba(49, 48, 55, .96);
  --card-border: rgba(255, 244, 225, .09);
  --text-primary: #f0ebe2;
  --text-secondary: #b9afa1;
  --text-muted: #8f877c;
  --text-tertiary: #81796f;
  --text-faint: #6f6962;
  --accent: #c18e56;
  --accent-strong: #d6a266;
  --accent-soft: rgba(193, 142, 86, .15);
  --warm-accent: #bd7663;
  --surface-shadow: 0 16px 38px rgba(0, 0, 0, .28);
  --surface-shadow-soft: 0 6px 18px rgba(0, 0, 0, .2);
  --hairline: rgba(255, 244, 225, .08);
  color-scheme: dark;
}

:root[data-theme="sakura"] {
  --bg-surface: #f7edf0;
  --bg-deep: #eedde3;
  --card-bg: rgba(255, 252, 253, .82);
  --card-bg-hover: rgba(255, 255, 255, .96);
  --card-border: rgba(119, 66, 81, .1);
  --text-primary: #412d34;
  --text-secondary: #795b65;
  --text-muted: #a1818b;
  --text-tertiary: #ae9099;
  --text-faint: #bca5ac;
  --accent: #a95070;
  --accent-strong: #8d3e5b;
  --accent-soft: rgba(169, 80, 112, .12);
  --warm-accent: #bf735f;
  --surface-shadow: 0 12px 32px rgba(111, 61, 77, .1);
  --hairline: rgba(119, 66, 81, .09);
}

:root[data-theme="mint"] {
  --bg-surface: #e9f2ee;
  --bg-deep: #dce9e3;
  --card-bg: rgba(252, 255, 253, .8);
  --card-bg-hover: rgba(255, 255, 255, .96);
  --card-border: rgba(42, 91, 75, .1);
  --text-primary: #20372f;
  --text-secondary: #557367;
  --text-muted: #819d92;
  --text-tertiary: #91a99f;
  --text-faint: #a3b7af;
  --accent: #3e7f69;
  --accent-strong: #2f6655;
  --accent-soft: rgba(62, 127, 105, .12);
  --warm-accent: #a36f56;
  --surface-shadow: 0 12px 32px rgba(43, 84, 70, .09);
  --hairline: rgba(42, 91, 75, .09);
}

:root[data-theme="paper"] {
  --bg-surface: #f3f0e8;
  --bg-deep: #e8e2d6;
  --card-bg: rgba(255, 253, 248, .82);
  --card-bg-hover: rgba(255, 254, 250, .98);
  --card-border: rgba(78, 68, 54, .1);
  --text-primary: #302e29;
  --text-secondary: #6d675d;
  --text-muted: #969084;
  --text-tertiary: #a39c90;
  --text-faint: #b1aa9f;
  --accent: #6f7566;
  --accent-strong: #555c4f;
  --accent-soft: rgba(111, 117, 102, .13);
  --warm-accent: #a2674f;
  --surface-shadow: 0 12px 30px rgba(69, 62, 51, .09);
  --hairline: rgba(78, 68, 54, .09);
}

:root[data-theme="deepsea"] {
  --bg-surface: #111c24;
  --bg-deep: #0b141a;
  --card-bg: rgba(29, 45, 56, .88);
  --card-bg-hover: rgba(37, 56, 68, .96);
  --card-border: rgba(195, 221, 230, .1);
  --text-primary: #edf5f6;
  --text-secondary: #a9bec4;
  --text-muted: #77929a;
  --text-tertiary: #6f8890;
  --text-faint: #607880;
  --accent: #73a9b5;
  --accent-strong: #8bc0ca;
  --accent-soft: rgba(115, 169, 181, .16);
  --warm-accent: #c18167;
  --surface-shadow: 0 18px 42px rgba(0, 0, 0, .3);
  --surface-shadow-soft: 0 7px 20px rgba(0, 0, 0, .22);
  --hairline: rgba(195, 221, 230, .09);
  color-scheme: dark;
}

:root[data-theme="amber"] {
  --bg-surface: #eee2cd;
  --bg-deep: #e3d1b5;
  --card-bg: rgba(255, 249, 238, .82);
  --card-bg-hover: rgba(255, 252, 245, .98);
  --card-border: rgba(94, 67, 43, .11);
  --text-primary: #3d3025;
  --text-secondary: #77624f;
  --text-muted: #9d8874;
  --text-tertiary: #aa9682;
  --text-faint: #b9a793;
  --accent: #9a6543;
  --accent-strong: #784a31;
  --accent-soft: rgba(154, 101, 67, .13);
  --warm-accent: #ad5f4d;
  --surface-shadow: 0 12px 32px rgba(88, 58, 34, .11);
  --hairline: rgba(94, 67, 43, .1);
}

:root[data-theme="rain"] {
  --bg-surface: #dedee7;
  --bg-deep: #d0d0dc;
  --card-bg: rgba(249, 249, 252, .78);
  --card-bg-hover: rgba(255, 255, 255, .94);
  --card-border: rgba(64, 62, 83, .1);
  --text-primary: #2e2d3b;
  --text-secondary: #666477;
  --text-muted: #8d8b9c;
  --text-tertiary: #9c9aaa;
  --text-faint: #aaa8b6;
  --accent: #66617e;
  --accent-strong: #514c68;
  --accent-soft: rgba(102, 97, 126, .13);
  --warm-accent: #9e665f;
  --surface-shadow: 0 14px 34px rgba(56, 54, 77, .1);
  --hairline: rgba(64, 62, 83, .09);
}

html {
  min-height: 100%;
  background: var(--bg-surface);
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei UI", system-ui, sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 28rem),
    var(--bg-surface);
  transition: background-color 240ms ease, color 200ms ease;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#kli-shell {
  min-height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  background: transparent;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--hairline) 70%, transparent);
}

#kli-content { background: transparent; }
.kli-page {
  padding-left: var(--page-gutter);
  padding-right: var(--page-gutter);
  background: transparent !important;
}

.kli-page-header, .chat-header {
  padding-top: calc(14px + var(--safe-top));
}

.kli-page-title, .chat-name, .desk-clock, .set-name {
  font-family: Georgia, "Songti SC", "STSong", serif;
  font-weight: 600;
  letter-spacing: 0;
}

.kli-page-title { font-size: 28px; line-height: 1.18; }
.kli-page-subtitle { margin-top: 5px; line-height: 1.5; }

#kli-nav {
  max-width: 760px;
  left: 50%;
  transform: translateX(-50%);
  border-top: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg-surface) 84%, transparent);
  box-shadow: 0 -8px 24px color-mix(in srgb, var(--bg-deep) 22%, transparent);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
}

.kli-nav-item {
  min-width: 64px;
  min-height: 54px;
  border-radius: 6px;
  transition: color 180ms ease, background-color 180ms ease, opacity 180ms ease;
}
.kli-nav-item:active { background: var(--accent-soft); }
.kli-nav-icon { filter: grayscale(.28) saturate(.72); transition: filter 180ms ease, transform 180ms ease; }
.kli-nav-item.active .kli-nav-icon { filter: none; transform: translateY(-1px); }

.chat-header {
  margin: 0 calc(var(--page-gutter) * -1);
  padding-left: var(--page-gutter);
  padding-right: var(--page-gutter);
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg-surface) 86%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.chat-avatar, .chat-welcome-avatar, .set-avatar {
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 84%, white), var(--accent-strong));
  color: #fff;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 24%, transparent), inset 0 1px rgba(255,255,255,.3);
}
.chat-avatar { border-radius: 8px; }
.chat-mood { line-height: 1.4; }
.chat-online-dot { box-shadow: 0 0 0 3px var(--bg-surface); }

.chat-messages {
  padding-left: 2px;
  padding-right: 2px;
  scrollbar-gutter: stable;
}
.chat-welcome { padding: 36px 20px; }
.chat-welcome-avatar { border-radius: 8px; }
.chat-welcome p { line-height: 1.7; }

.chat-bubble {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  line-height: 1.62;
  box-shadow: var(--surface-shadow-soft);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.chat-msg.user .chat-bubble:not(.action) {
  background: var(--accent-strong);
  border-color: transparent;
  color: #fff;
}
.chat-bubble.action {
  background: color-mix(in srgb, var(--card-bg) 64%, transparent);
  border-color: color-mix(in srgb, var(--hairline) 60%, transparent);
  box-shadow: none;
}
.inner-thought {
  border-radius: 6px;
  border-color: color-mix(in srgb, #7767a8 24%, transparent);
  background: color-mix(in srgb, #7767a8 8%, var(--card-bg));
  box-shadow: none;
}

.chat-input-bar {
  max-width: 760px;
  left: 50%;
  transform: translateX(-50%);
  border-top: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  backdrop-filter: blur(22px) saturate(1.1);
  -webkit-backdrop-filter: blur(22px) saturate(1.1);
}
.chat-input-wrap {
  min-height: 46px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: inset 0 1px rgba(255,255,255,.35);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}
.chat-input-wrap:focus-within { border-color: color-mix(in srgb, var(--accent) 54%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-more-btn, .chat-voice-btn, .chat-emoji-btn { min-width: 44px; min-height: 44px; }
.chat-more-btn, .chat-voice-btn { border-radius: 8px; border: 1px solid var(--hairline); background: var(--card-bg); }
.chat-more-btn:active, .chat-voice-btn:active, .chat-emoji-btn:active { background: var(--accent-soft); transform: scale(.97); }

.chat-plus-panel, .poke-panel {
  max-width: 760px;
  left: 50%;
  transform: translateX(-50%);
  border-top: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
  box-shadow: 0 -14px 34px color-mix(in srgb, var(--bg-deep) 32%, transparent);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.chat-plus-grid { gap: 18px 12px; }
.chat-plus-item { min-height: 84px; border-radius: 8px; transition: background-color 160ms ease, transform 160ms ease; }
.chat-plus-item:active { background: var(--accent-soft); transform: scale(.97); }
.chat-plus-icon { border-radius: 8px; border: 1px solid var(--hairline); box-shadow: var(--surface-shadow-soft); }
.poke-row { gap: 8px; }
.poke-row button, .poke-send-btn { min-height: 44px; border-radius: 8px; }
.poke-tip { line-height: 1.55; }

.voice-record-float, .voice-record-dock {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: rgba(24, 27, 31, .88);
  box-shadow: 0 22px 60px rgba(0,0,0,.34);
  backdrop-filter: blur(20px);
}
.voice-record-zone, .voice-record-send { border-radius: 8px; }

.heartbeat-card, .desk-card, .sleep-card, .set-card, .home-card {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  background: var(--card-bg);
  box-shadow: var(--surface-shadow);
  backdrop-filter: blur(16px) saturate(1.08);
  -webkit-backdrop-filter: blur(16px) saturate(1.08);
}
.heartbeat-card { overflow: hidden; }
.heartbeat-card::before {
  content: "";
  display: block;
  width: 34px;
  height: 2px;
  margin: -2px 0 14px;
  background: var(--accent);
  opacity: .7;
}
.heartbeat-value { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; }
.heartbeat-card-badge { border-radius: 4px; border: 1px solid var(--hairline); background: var(--accent-soft); }
.desire-bar-fill, .sleep-stage-fill { background: var(--accent); }

#kli-page-home { background: transparent !important; }
.desk-clock { font-variant-numeric: tabular-nums; }
.desk-date, .desk-days { line-height: 1.5; }
.desk-circle { min-width: 58px; min-height: 76px; border-radius: 8px; transition: background-color 170ms ease, transform 170ms ease; }
.desk-circle:active { transform: scale(.97); background: var(--accent-soft); }
.desk-circle-icon { border: 1px solid var(--hairline); box-shadow: var(--surface-shadow-soft); }
.desk-section-title { margin-top: 30px; margin-bottom: 10px; font-family: Georgia, "Songti SC", serif; font-size: 17px; }
.desk-row, .set-row { min-height: 58px; border-color: var(--hairline); }
.desk-row:active, .set-row:active { background: var(--accent-soft); }
.desk-row-icon { border-radius: 6px; }

.shelf-card.wood {
  border-radius: 8px;
  border-color: color-mix(in srgb, #76543d 24%, var(--hairline));
  box-shadow: inset 0 -12px 22px rgba(77, 47, 28, .16), var(--surface-shadow);
}
.shelf-book { border-radius: 3px 3px 1px 1px; box-shadow: 2px 3px 8px rgba(52, 31, 20, .2); }
.shelf-add { min-width: 44px; min-height: 44px; border-radius: 8px; }

.mini-period, .sleep-card { margin: 10px; }
.mini-period-nav, .period-nav { min-width: 44px; min-height: 44px; border-radius: 8px; }
.mini-period-grid > *, .period-grid > * { min-width: 32px; min-height: 32px; }
.sleep-time-value, .sleep-score { font-variant-numeric: tabular-nums; }

.set-profile {
  padding-top: calc(34px + var(--safe-top));
  padding-bottom: 30px;
}
.set-avatar { border-radius: 8px; }
.set-card { overflow: hidden; }
.set-row-title { font-weight: 600; }
.set-row-desc { line-height: 1.45; }
.set-footer { max-width: 32rem; margin-left: auto; margin-right: auto; line-height: 1.7; }

.play-modal, .period-modal, .addbook-modal, .reader-modal, .notes-modal,
.music-modal, .mcp-modal, .skin-modal, .usage-modal, .offline-modal {
  padding: calc(18px + var(--safe-top)) 14px calc(18px + var(--safe-bottom));
  background: rgba(15, 18, 20, .48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.play-modal-card, .period-modal-card, .addbook-modal-card, .reader-modal-card,
.notes-board, .music-card, .mcp-modal-card, .skin-modal-card, .usage-modal-card,
.offline-modal-card {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--card-bg) 94%, var(--bg-surface));
  box-shadow: 0 24px 70px rgba(16, 19, 21, .26);
}
.play-modal-title, .period-title, .notes-title, .mcp-title, .reader-title {
  font-family: Georgia, "Songti SC", serif;
  letter-spacing: 0;
}
.play-option, .addbook-opt, .music-item, .mcp-item, .skin-option {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: color-mix(in srgb, var(--card-bg) 82%, transparent);
  transition: border-color 170ms ease, background-color 170ms ease, transform 170ms ease;
}
.play-option:active, .addbook-opt:active, .music-item:active, .skin-option:active { transform: scale(.985); background: var(--accent-soft); }
.period-close, .play-close, .addbook-save, .usage-refresh, .offline-btn { min-height: 46px; border-radius: 8px; }
.reader-close, .notes-close, .mcp-close { min-width: 44px; min-height: 44px; border-radius: 8px; }
.reader-body { line-height: 1.82; }
.note-paper { border-radius: 4px; box-shadow: 0 8px 18px rgba(64, 48, 36, .14); }
.notes-wall { gap: 14px; }
.mcp-switch { min-width: 48px; min-height: 28px; }
.mcp-item-can, .mcp-item-what, .music-hint, .usage-hint, .notes-foot { line-height: 1.6; }

.skin-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.skin-option { min-height: 58px; padding: 10px 12px; }
.skin-swatch { width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(0,0,0,.1); box-shadow: inset 0 1px rgba(255,255,255,.45); }
.skin-option.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* The existing JS knows the original four labels. CSS keeps new labels correct after reload. */
:root[data-theme="paper"] #set-skin-row .set-row-value,
:root[data-theme="deepsea"] #set-skin-row .set-row-value,
:root[data-theme="amber"] #set-skin-row .set-row-value,
:root[data-theme="rain"] #set-skin-row .set-row-value { font-size: 0; }
:root[data-theme="paper"] #set-skin-row .set-row-value::after { content: "月白"; font-size: 13px; }
:root[data-theme="deepsea"] #set-skin-row .set-row-value::after { content: "深海"; font-size: 13px; }
:root[data-theme="amber"] #set-skin-row .set-row-value::after { content: "琥珀"; font-size: 13px; }
:root[data-theme="rain"] #set-skin-row .set-row-value::after { content: "雨夜"; font-size: 13px; }

#kli-toast { border-radius: 8px; background: color-mix(in srgb, var(--text-primary) 92%, transparent); box-shadow: 0 10px 30px rgba(0,0,0,.2); }
#kli-device-status { border-radius: 6px; backdrop-filter: blur(16px); }

@media (max-width: 374px) {
  :root { --page-gutter: 12px; --nav-height: 62px; }
  .heartbeat-dual { gap: 8px; }
  .heartbeat-card { padding: 13px 11px; }
  .heartbeat-value { font-size: 31px; }
  .desk-circle-row { gap: 4px; }
  .desk-circle { min-width: 52px; }
  .chat-plus-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .skin-options { grid-template-columns: 1fr; }
}

@media (min-width: 431px) {
  :root { --page-gutter: 22px; }
  .heartbeat-grid, #kli-page-home > *, #kli-page-settings > * { max-width: 680px; margin-left: auto; margin-right: auto; }
  .chat-messages { max-width: 680px; width: 100%; margin-left: auto; margin-right: auto; }
  .chat-input-bar { padding-left: max(18px, calc((100% - 680px) / 2)); padding-right: max(18px, calc((100% - 680px) / 2)); }
}

@media (orientation: landscape) and (max-height: 520px) {
  :root { --nav-height: 54px; }
  .kli-page-header { padding-top: calc(8px + var(--safe-top)); padding-bottom: 10px; }
  .set-profile { padding-top: calc(12px + var(--safe-top)); padding-bottom: 14px; }
  .set-avatar { width: 58px; height: 58px; }
  .desk-section-title { margin-top: 18px; }
  .play-modal-card, .period-modal-card, .addbook-modal-card, .mcp-modal-card, .skin-modal-card, .usage-modal-card { max-height: calc(100dvh - 24px); overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@supports not (color: color-mix(in srgb, white, black)) {
  .chat-header, .chat-input-bar, #kli-nav, .chat-plus-panel, .poke-panel { background: var(--bg-surface); }
  .play-modal-card, .period-modal-card, .addbook-modal-card, .reader-modal-card,
  .notes-board, .music-card, .mcp-modal-card, .skin-modal-card, .usage-modal-card,
  .offline-modal-card { background: var(--card-bg); }
}

