/* ====== 启动加载器 ====== */
#startup-loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg, #ededed);
  z-index: 9999;
  transition: opacity 0.3s ease;
}
#startup-loader.hidden {
  opacity: 0;
  pointer-events: none;
}
.startup-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.startup-text {
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-3);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== 基础变量 ====== */
:root {
  --primary: #2c2c3a;
  --primary-light: #4a4a5a;
  --header-bg: #2c2c3a;
  --header-text: #ffffff;
  --bg: #ededed;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --text: #333333;
  --text-2: #666666;
  --text-3: #999999;
  --ai-bubble: #ffffff;
  --user-bubble: #2c2c3a;
  --border: #e0e0e0;
  --danger: #e74c3c;
  --success: #00b894;
  --radius: 20px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 52px;
  --input-h: 52px;
}

[data-theme="dark"] {
  --header-bg: #1a1a1a;
  --header-text: #e0e0e0;
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --text: #e5e5e5;
  --text-2: #999999;
  --text-3: #666666;
  --ai-bubble: #1c1c1e;
  --user-bubble: #2c2c2e;
  --border: #38383a;
  --primary: #3a3a4a;
  --primary-light: #5a5a6a;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  position: fixed;
  overflow: hidden;
  font-family: "汉仪劲楷", "HYJingKai", "楷体", "KaiTi", "STKaiti", "华文楷体", "PingFang SC", "Microsoft YaHei", serif;
  font-size: 18px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* ====== 页面切换 ====== */
.page {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.page.active { display: flex; }

/* ====== 通用头部 ====== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  height: calc(var(--header-h) + var(--safe-top));
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-btn:active { background: var(--surface-2); }

/* ====== 角色列表 ====== */
.character-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(110px + var(--safe-bottom));
}

.character-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 0.5px solid var(--border);
}
.character-card:active { transform: scale(0.97); }

.char-avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  overflow: hidden;
}
.char-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.char-info { flex: 1; min-width: 0; }
.char-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-preview {
  font-size: 14px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====== FAB ====== */
.fab {
  position: absolute;
  bottom: calc(20px + var(--safe-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(44, 44, 58, 0.35);
  z-index: 10;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.88); }

/* ====== 空状态 ====== */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 120px;
  color: var(--text-3);
}
.empty-state.show { display: flex; }
.empty-state p { font-size: 16px; margin-bottom: 4px; }
.empty-state .sub { font-size: 13px; }
.empty-icon { margin-bottom: 16px; opacity: 0.3; }

/* ====== Chat 空状态 ====== */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  text-align: center;
  padding: 40px 20px;
}
.chat-empty-state p { font-size: 16px; margin-bottom: 4px; }
.chat-empty-state .sub { font-size: 13px; }
.chat-empty-state .empty-icon { margin-bottom: 16px; opacity: 0.3; }

/* ====== 聊天页面 —— 深色Header ====== */
.chat-header {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: calc(var(--safe-top) + 6px) 4px 6px;
  height: calc(var(--header-h) + var(--safe-top));
  background: var(--header-bg);
  flex-shrink: 0;
}
.chat-header .icon-btn {
  color: rgba(255,255,255,0.7);
  padding: 4px;
}
.chat-header .icon-btn:active { background: rgba(255,255,255,0.1); }
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}
.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-header-text { flex: 1; min-width: 0; }
.chat-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--header-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-status {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

/* ====== Chat 联系人列表视图 ====== */
#page-chat {
  flex-direction: column;
  padding-bottom: calc(56px + var(--safe-bottom));
}
#page-chat.active {
  display: flex;
}
.chat-contacts {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.chat-contacts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.chat-contacts-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.chat-contacts-header .icon-btn {
  color: var(--primary);
}
.chat-contacts-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 16px calc(20px + var(--safe-bottom));
}
.chat-contacts-list .character-card {
  background: var(--surface);
  margin-bottom: 10px;
}
.chat-contacts-empty {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  text-align: center;
  padding: 40px 20px;
}
.chat-contacts-empty.show { display: flex; }
.chat-contacts-empty p { font-size: 16px; margin-bottom: 4px; }
.chat-contacts-empty .sub { font-size: 13px; }

/* ====== Chat 聊天对话视图 ====== */
.chat-conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* ====== 语音通话 ====== */
.chat-header .voice-call-btn.active {
  color: #2ade6b;
  animation: callPulse 1.5s ease infinite;
}

.voice-call-bar {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 0.5px solid var(--border);
  min-height: 118px;
  flex-shrink: 0;
}
.voice-call-bar.show { display: flex; }

.call-status {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  opacity: 0.65;
}
.call-status.listening {
  color: #07c160;
  opacity: 1;
  animation: callPulse 1.5s ease infinite;
}

.call-subtitle {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  text-align: center;
  max-width: 100%;
  min-height: 21px;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.call-end-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: #fa5151;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(250, 81, 81, 0.35);
  transition: transform 0.15s ease;
}
.call-end-btn:active { transform: scale(0.92); }

@keyframes callPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ====== 统计面板 ====== */
.stats-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
}
.stats-panel.show { max-height: 70px; }
.stats-row {
  display: flex;
  justify-content: space-around;
  padding: 10px 8px;
}
.stat-item {
  text-align: center;
  flex: 1;
}
.stat-num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}
.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ====== 消息区域 ====== */
.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 6px;
  display: flex;
  flex-direction: column;
}

/* ====== 加载更多 ====== */
.load-more {
  text-align: center;
  padding: 10px 16px;
  margin: 4px auto 10px;
  font-size: 13px;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: inline-block;
  align-self: center;
}
.load-more:active {
  background: var(--border);
  color: var(--text);
}

/* ====== 时间分隔线 ====== */
.time-divider {
  text-align: center;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-3);
  opacity: 0.7;
}

/* ====== 消息行 ====== */
.msg-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  animation: msgIn 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
}
.msg-row.pressing {
  background: rgba(255,80,80,0.15);
  border-radius: 10px;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* AI消息在左侧 */
.msg-row.ai {
  align-self: flex-start;
  flex-direction: row;
  margin-right: 8%;
}

/* 用户消息在右侧 */
.msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-left: 8%;
}

.msg-body { flex: 1; min-width: 0; max-width: 92%; }

/* ====== 时间戳 ====== */
.msg-time {
  font-size: 10px;
  color: var(--text-3);
  margin-bottom: 2px;
  padding-left: 2px;
}
.msg-row.user .msg-time { text-align: right; padding-right: 2px; }

/* ====== 气泡 ====== */
.msg-bubble {
  padding: 9px 14px;
  border-radius: 18px;
  font-size: 18px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}
.msg-row.ai .msg-bubble {
  background: var(--ai-bubble);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.msg-row.user .msg-bubble {
  background: var(--user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg-bubble .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--text);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ====== 操作按钮行 ====== */
.msg-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  padding-left: 2px;
}
.msg-row.user .msg-actions { justify-content: flex-end; padding-right: 2px; }
.msg-actions button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.msg-actions button:active { background: var(--surface-2); }
.msg-actions button.playing {
  background: var(--primary);
  color: white;
}
.msg-actions button.loading {
  pointer-events: none;
}
.tts-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.msg-actions button.liked { color: #e74c3c; }

/* ====== 长按消息操作菜单（微信风格） ====== */
.msg-action-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: background 0.2s;
}
.msg-action-overlay.show { background: rgba(0,0,0,0.4); }
.msg-action-sheet {
  width: 100%;
  max-width: 500px;
  background: var(--surface-2);
  border-radius: 16px 16px 0 0;
  padding: 8px 12px calc(12px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.22s ease-out;
}
.msg-action-overlay.show .msg-action-sheet { transform: translateY(0); }
.msg-action-tip {
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  padding: 8px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-action-btn {
  display: block;
  width: 100%;
  padding: 14px 0;
  margin-top: 6px;
  background: var(--surface);
  border: none;
  border-radius: 12px;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.12s;
}
.msg-action-btn:active { opacity: 0.6; }
.msg-action-btn.danger { color: #e74c3c; }
.msg-action-btn.cancel { margin-top: 10px; font-weight: 600; }

/* ====== 语音输入按钮 ====== */
.voice-btn {
  flex: none;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.voice-btn:active { transform: scale(0.92); }
.voice-btn.recording {
  background: #e74c3c;
  color: #fff;
  animation: voicePulse 1.2s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(231,76,60,0); }
}

/* ====== Thinking 折叠区 ====== */
.thinking-section {
  margin-bottom: 4px;
}
.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: none;
  border-radius: 14px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.thinking-toggle:active { background: var(--border); }
.thinking-toggle svg { transition: transform 0.2s; flex-shrink: 0; }
.thinking-toggle.open svg { transform: rotate(90deg); }
.thinking-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}
.thinking-content.show { max-height: 300px; }
.thinking-content-inner {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 8px 12px;
  margin-top: 4px;
  border-left: 3px solid var(--primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ====== 输入栏 ====== */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 10px calc(6px + var(--safe-bottom));
  background: #f7f7f7;
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
}
[data-theme="dark"] .input-bar { background: #1c1c1e; }
.input-bar textarea {
  flex: 1;
  border: 0.5px solid var(--border);
  background: var(--surface);
  border-radius: 22px;
  padding: 8px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}
.input-bar textarea:focus {
  border-color: var(--primary);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.send-btn:disabled { opacity: 0.4; cursor: default; }
.send-btn:active:not(:disabled) { transform: scale(0.85); }

/* ====== 角色编辑页 ====== */
.editor-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px calc(20px + var(--safe-bottom));
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: var(--primary);
  color: white;
  overflow: hidden;
}
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.emoji-input {
  width: 60px;
  text-align: center;
  font-size: 20px;
  border: 1.5px solid var(--primary);
  border-radius: 12px;
  padding: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.color-dot {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.12s;
}
.color-dot:active { transform: scale(0.85); }
.color-dot.selected {
  border-color: var(--text);
  transform: scale(1.1);
}

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--primary); }
.form-group textarea { line-height: 1.5; }
.form-group .hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 5px;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(44, 44, 58, 0.25);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.form-actions button { flex: 1; }

.btn-primary {
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s;
}
.btn-primary:active { transform: scale(0.97); }

.btn-danger {
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.15s;
}
.btn-outline:active { background: var(--surface-2); }
.btn-outline.danger { color: var(--danger); border-color: var(--danger); }

/* ====== 设置页 ====== */
.settings-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(20px + var(--safe-bottom));
}
.settings-section { margin-bottom: 28px; }
.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-left: 4px;
}
.settings-section-title.settings-collapsible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.settings-toggle-icon {
  display: inline-block;
  font-size: 16px;
  color: var(--text-3);
  transition: transform 0.2s;
  padding-right: 4px;
}

/* 快速配置卡片 */
.quick-config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.quick-config-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.quick-config-item:last-child { border-bottom: none; }
.quick-config-item:active { background: var(--surface-2); }
.quick-config-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.quick-config-info { flex: 1; min-width: 0; }
.quick-config-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.quick-config-desc {
  font-size: 12px;
  color: var(--text-3);
}
.quick-config-arrow {
  font-size: 18px;
  color: var(--text-3);
  padding-right: 2px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.toggle-label { font-size: 16px; color: var(--text); line-height: 1.4; }
.toggle-hint { font-size: 12px; color: var(--text-2); line-height: 1.3; }
.backup-status { font-size: 13px; color: var(--text-2); padding: 4px 2px 10px; }

/* ====== 声音克隆 ====== */
.voice-clone-section {
  margin-top: 20px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.voice-clone-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}
.file-upload-area:active {
  border-color: var(--primary);
  background: var(--surface);
}
.file-upload-area.has-file {
  border-style: solid;
  border-color: var(--success);
  padding: 14px 16px;
}
#voiceFilePlaceholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 14px;
}
#voiceFilePlaceholder svg {
  color: var(--text-3);
}
.custom-voice-list {
  margin-top: 12px;
}
.custom-voice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.custom-voice-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.custom-voice-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.custom-voice-uri {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.custom-voice-delete {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  border-radius: 8px;
  margin-left: 8px;
}
.custom-voice-delete:active {
  background: rgba(231, 76, 60, 0.1);
}

.switch {
  position: relative;
  width: 50px;
  height: 30px;
}
.switch input { display: none; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 30px;
  transition: 0.3s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.switch input:checked + .slider {
  background: var(--primary);
  border-color: var(--primary);
}
.switch input:checked + .slider::before { transform: translateX(20px); }

.about {
  text-align: center;
  padding: 24px 0;
  color: var(--text-3);
}
.about .sub { font-size: 12px; margin-top: 4px; }

/* ====== 事件卡（记忆卡片） ====== */
.event-card {
  align-self: center;
  width: 92%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0;
  cursor: pointer;
  transition: background 0.15s;
}
.event-card:active { background: var(--border); }
.event-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
}
.event-card-header svg { color: var(--primary); flex-shrink: 0; }
.event-card-date { color: var(--text-2); font-weight: 500; }
.event-card-count { margin-left: auto; font-size: 11px; }
.event-card-summary {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  max-height: 60px;
  overflow: hidden;
  transition: max-height 0.3s ease;
  white-space: pre-wrap;
  word-break: break-word;
}
.event-card.expanded .event-card-summary { max-height: 500px; }
.event-card-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.event-card-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--surface);
  border-radius: 8px;
  color: var(--text-2);
  border: 0.5px solid var(--border);
}

/* ====== 搜索栏 ====== */
.search-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.search-bar.show { display: flex; }
.search-bar input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.search-bar input:focus { border-color: var(--primary); }
.search-close-btn {
  background: none;
  border: none;
  color: var(--text-2);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-close-btn:active { background: var(--surface-2); }

/* ====== 搜索结果 ====== */
.search-results {
  display: none;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.search-results.show { display: block; }
.search-result-item {
  padding: 10px 14px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.search-result-item:active { background: var(--surface-2); }
.search-result-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 2px;
}
.search-result-role { font-weight: 500; color: var(--text-2); }
.search-result-time { margin-left: auto; }
.search-tag {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--primary);
  color: white;
  border-radius: 4px;
}
.search-result-preview {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-empty {
  padding: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
}

/* 搜索高亮动画 */
@keyframes searchHighlight {
  0% { background: rgba(255, 193, 7, 0.3); }
  100% { background: transparent; }
}
.search-highlight {
  animation: searchHighlight 2s ease;
  border-radius: 12px;
}

/* ====== Toast ====== */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ====== Typing ====== */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 6px 4px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ====== 底栏导航 ====== */
.tab-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid rgba(0,0,0,0.08);
  z-index: 20;
}
[data-theme="dark"] .tab-bar {
  background: rgba(28,28,30,0.85);
  border-top-color: rgba(255,255,255,0.06);
}
.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 12px;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.2s;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  min-width: 56px;
}
.tab-item svg { transition: stroke 0.2s; }
.tab-item span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.tab-item.active {
  color: var(--primary);
}
.tab-item:active {
  opacity: 0.7;
}

/* ====== Home 页面 ====== */
#page-home {
  background: #f0f0f0 url('bg-pattern.jpg?v=26') center top / 100% auto no-repeat;
  background-attachment: local;
}
.home-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(80px + var(--safe-bottom));
}
.home-couple-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px 16px 18px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  border: 0.5px solid var(--border);
  text-align: center;
  position: relative;
}
/* 卡通形象上方浮动日期，与图片融合 */
.home-date-float {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  border: 0.5px solid rgba(255,255,255,0.6);
  z-index: 2;
}
.home-date-day {
  font-size: 34px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -1px;
}
.home-date-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}
.home-date-month {
  font-size: 11px;
  color: var(--text-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.home-date-week {
  font-size: 10px;
  color: var(--text-3);
  font-weight: 500;
}
.home-couple-img {
  width: 100%;
  max-width: 240px;
  height: auto;
  display: block;
  margin: 0 auto 6px;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.home-couple-together {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.home-couple-together-label {
  font-size: 13px;
  color: var(--text-3);
  letter-spacing: 1px;
}
.home-couple-together-num {
  font-size: 28px;
  font-weight: 700;
  color: #e85d75;
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1.1;
}
.home-couple-together-unit {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-2);
}
.home-couple-subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 6px;
  line-height: 1.5;
}
.home-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-left: 4px;
}
.home-quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.home-quick-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px 14px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  border: 0.5px solid var(--border);
}
.home-quick-card:active { transform: scale(0.96); }
.home-quick-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.home-quick-icon.memo { background: #fff3e0; color: #e67e22; }
.home-quick-icon.draw { background: #f3e5f5; color: #8e44ad; }
.home-quick-icon.add { background: #e3f2fd; color: #2980b9; }
.home-quick-icon.chess { background: #e8eaf6; color: #3f51b5; }
[data-theme="dark"] .home-quick-icon.memo { background: #3e2723; }
[data-theme="dark"] .home-quick-icon.draw { background: #2a1a3a; }
[data-theme="dark"] .home-quick-icon.add { background: #1a2a3a; }
[data-theme="dark"] .home-quick-icon.chess { background: #1a2240; }
.home-quick-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.home-quick-count {
  font-size: 12px;
  color: var(--text-3);
}

/* ====== Diary 页面（朋友圈/动态） ====== */
.diary-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  background: var(--bg);
}
.diary-cover {
  position: relative;
  height: 180px;
  background: linear-gradient(135deg, #c2e9fb 0%, #a1c4fd 100%);
  overflow: hidden;
  flex-shrink: 0;
}
.diary-cover-bg {
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.4)"/><circle cx="70" cy="40" r="3" fill="rgba(255,255,255,0.3)"/><circle cx="40" cy="70" r="2.5" fill="rgba(255,255,255,0.35)"/></svg>');
  background-size: 80px 80px;
  opacity: 0.8;
}
.diary-cover-user {
  position: absolute;
  right: 16px;
  bottom: -22px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.diary-cover-name {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
  margin-bottom: 24px;
}
.diary-cover-avatar {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: #a259ff;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  overflow: hidden;
}
.diary-cover-avatar img { width: 100%; height: 100%; object-fit: cover; }

.moments-list {
  padding: 32px 16px calc(80px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 0;
}
.moments-item {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 0.5px solid var(--border);
}
.moments-item:last-child { border-bottom: none; }
.moments-avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
}
.moments-avatar img { width: 100%; height: 100%; object-fit: cover; }
.moments-content {
  flex: 1;
  min-width: 0;
}
.moments-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.moments-name {
  font-size: 16px;
  font-weight: 700;
  color: #576b95;
}
.moments-time {
  font-size: 12px;
  color: var(--text-3);
  flex-shrink: 0;
}
.moments-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.moments-actions {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
}
.moments-actions button {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-3);
  background: transparent;
  border: none;
  padding: 2px 0;
  cursor: pointer;
  font-family: inherit;
}
.moments-actions button svg { opacity: 0.8; }
.moments-actions button:active { opacity: 0.6; }
.moments-like-btn.liked { color: var(--danger); }
.moments-comment-btn span { min-width: 18px; }

.moments-comment-box {
  background: #f7f7f7;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.moments-likes-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 0.5px solid #e6e6e6;
  color: #576b95;
  font-size: 13px;
}
.moments-comment-line {
  word-break: break-word;
  margin-bottom: 3px;
}
.moments-comment-line:last-child { margin-bottom: 0; }
.moments-comment-author { color: #576b95; font-weight: 600; }

/* 右下角浮动加号 */
.diary-fab {
  position: fixed;
  bottom: calc(76px + var(--safe-bottom));
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: transform 0.15s, box-shadow 0.15s;
}
.diary-fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.diary-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 32px;
  color: var(--text-2);
  text-align: center;
}
.diary-empty svg { margin-bottom: 16px; opacity: 0.4; }
.diary-empty p { font-size: 15px; margin: 0 0 6px; }
.diary-empty .sub { font-size: 13px; color: var(--text-3); }

/* 评论面板 */
.moments-comments {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.moments-empty-comment {
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 32px;
}
.moments-comment-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: flex-start;
}
.moments-comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.moments-comment-bubble {
  flex: 1;
  background: #f5f5f5;
  border-radius: 12px;
  padding: 8px 12px;
}
.moments-comment-name {
  font-size: 12px;
  color: #576b95;
  font-weight: 600;
  margin-bottom: 2px;
}
.moments-comment-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.45;
}
.moments-comment-input {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 0.5px solid var(--border);
}
.moments-comment-input input {
  flex: 1;
  border: none;
  border-radius: 18px;
  padding: 10px 14px;
  background: #f5f5f5;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.moments-comment-input button {
  padding: 0 16px;
  border: none;
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.diary-comment-popup .popup-content {
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

/* 日记编辑弹窗 */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.popup-content {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}
.diary-editor-popup { max-width: 480px; }
.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 600;
}

/* ====== Memo（语音备忘录）页面 ====== */
.memo-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px calc(80px + var(--safe-bottom));
}
.memo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 80px;
  color: var(--text-3);
  text-align: center;
}
.memo-empty p { font-size: 16px; margin-bottom: 4px; }
.memo-empty .sub { font-size: 13px; }
.memo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.memo-item {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  border: 0.5px solid var(--border);
}
.memo-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.memo-item-char {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}
.memo-item-char-avatar {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.memo-item-time {
  font-size: 11px;
  color: var(--text-3);
}
.memo-item-content {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 80px;
  overflow: hidden;
}
.memo-item-actions {
  display: flex;
  gap: 8px;
}
.memo-item-actions button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 0.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.memo-item-actions button:active {
  background: var(--border);
  color: var(--text);
}
.memo-item-actions button.playing {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ====== 收藏按钮（消息旁 ⭐） ====== */
.msg-star-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  transition: color 0.15s, transform 0.15s;
}
.msg-star-btn:hover { color: #f0c040; }
.msg-star-btn.starred {
  color: #f0c040;
  animation: starPop 0.3s ease;
}
.msg-star-btn:active { transform: scale(0.85); }
@keyframes starPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ====== More / 设置页面适配 ====== */
.settings-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(80px + var(--safe-bottom));
}

/* 编辑器页也需要底栏空间 */
.editor-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px calc(80px + var(--safe-bottom));
}

/* ====== 你画我猜游戏 ====== */
.game-draw-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}
.game-draw-select {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 20px;
}
.game-draw-option {
  background: var(--surface);
  border-radius: 18px;
  padding: 22px 18px;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
  border: 0.5px solid var(--border);
  transition: transform 0.12s;
}
.game-draw-option:active { transform: scale(0.96); }
.game-draw-option-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.game-draw-option-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.game-draw-option-desc {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.4;
}
.game-draw-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 12px;
  font-size: 14px;
  color: var(--text-2);
}
.game-draw-info #drawRoleLabel { font-weight: 600; color: var(--primary); }
.game-draw-canvas-wrap {
  position: relative;
  background: #fafafa;
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 360px;
  touch-action: none;
  margin-bottom: 12px;
}
[data-theme="dark"] .game-draw-canvas-wrap { background: #1a1a1a; }
.game-draw-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.draw-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: var(--text-3);
  font-weight: 600;
  pointer-events: none;
  text-align: center;
  line-height: 1.5;
}
.game-draw-controls { margin-top: 8px; }
.draw-guess-input-wrap {
  display: flex;
  gap: 10px;
}
.draw-guess-input-wrap input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.draw-guess-input-wrap input:focus { border-color: var(--primary); }
.draw-guess-input-wrap button {
  padding: 12px 20px;
  font-size: 16px;
}
.draw-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.draw-tool-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.draw-tool-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.draw-color-pick {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: var(--surface);
}
.draw-width-slider {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}
.draw-width-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}
.draw-submit-btn { padding: 10px 16px; font-size: 14px; }
.draw-new-btn {
  display: block;
  margin: 16px auto;
  padding: 12px 32px;
}

/* ====== 一起下棋游戏 ====== */
.game-chess-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}
.chess-select-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 8px;
}
.chess-type-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 22px 18px;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
  border: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.12s;
}
.chess-type-card:active { transform: scale(0.96); }
.chess-type-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--surface-2);
  flex-shrink: 0;
}
.chess-type-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}
.chess-type-desc {
  font-size: 13px;
  color: var(--text-3);
}
.chess-info-bar {
  text-align: center;
  padding: 4px 0 8px;
  font-size: 14px;
  color: var(--text-2);
  font-weight: 600;
}
.chess-score-bar {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px 10px;
  font-size: 14px;
  color: var(--text-2);
  font-weight: 500;
}
.chess-score-bar #chessTurn { color: var(--primary); font-weight: 600; }
.chess-board-wrap {
  background: #fafafa;
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 380px;
  touch-action: manipulation;
  margin-bottom: 12px;
}
[data-theme="dark"] .chess-board-wrap { background: #1a1a1a; }
.chess-board-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.chess-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}
.chess-btn {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.chess-btn:active { background: var(--surface-2); color: var(--text); }
.chess-btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ====== 游戏角色选择弹窗 ====== */
.game-char-select {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-char-select-inner {
  background: var(--surface);
  border-radius: 18px;
  padding: 20px;
  width: 90%;
  max-width: 360px;
  max-height: 70vh;
  overflow-y: auto;
}
.game-char-select-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  text-align: center;
}
.game-char-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  cursor: pointer;
  margin-bottom: 8px;
  border: 0.5px solid var(--border);
  transition: background 0.12s;
}
.game-char-select-item:active { background: var(--surface-2); }
.game-char-select-item-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.game-char-select-item-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
