/* ===== Global Font Size Variable ===== */
:root { --global-font-size: 14px; }
.chat-msg-bubble      { font-size: var(--global-font-size) !important; }
.chat-msg-sender      { font-size: calc(var(--global-font-size) - 3px) !important; }
.chat-msg-time-divider { font-size: calc(var(--global-font-size) - 3px) !important; }
.chat-input-field      { font-size: var(--global-font-size) !important; }
.chat-conv-name       { font-size: var(--global-font-size) !important; }
.chat-conv-last        { font-size: calc(var(--global-font-size) - 2px) !important; }
.chat-conv-time        { font-size: calc(var(--global-font-size) - 3px) !important; }

/* ===== Chat App ===== */

.chat-page {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 800;
  background: var(--bg);
  background-image: none;
  display: flex; flex-direction: column;
  overflow: hidden;
  contain: layout style paint;
  transform: translateX(100%);
  pointer-events: none;
  will-change: transform;
  transition: transform 0.28s cubic-bezier(.25,.46,.45,.94);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-page.active {
  transform: translateX(0);
  pointer-events: auto;
}

.chat-sub-page {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 810;
  background: var(--bg);
  background-image: none;
  display: flex; flex-direction: column;
  overflow: hidden;
  contain: layout style paint;
  transform: translateX(100%);
  pointer-events: none;
  will-change: transform;
  transition: transform 0.28s cubic-bezier(.25,.46,.45,.94);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-sub-page.active {
  transform: translateX(0);
  pointer-events: auto;
}
.chat-sub-page.keyboard-adjusting {
  transition: none;
}

/* Nav */
.chat-nav {
  display: flex; align-items: center;
  padding: calc(env(safe-area-inset-top, 16px) + 12px) 16px 12px;
  flex-shrink: 0;
}
.chat-nav-inner {
  display: flex; align-items: center;
  width: 100%; position: relative; height: 36px;
}
.chat-nav-back {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1.5px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text); transition: transform 0.15s;
  box-shadow: 0 2px 10px var(--glass-shadow);
  flex-shrink: 0;
}
.chat-nav-back:active { transform: scale(0.9); }
.chat-nav-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  position: absolute; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
}
.chat-nav-actions {
  position: absolute; right: 0; top: 0;
  display: flex; align-items: center; gap: 8px;
  height: 36px;
}
.chat-nav-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1.5px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text); transition: transform 0.15s;
  box-shadow: 0 2px 10px var(--glass-shadow);
}
.chat-nav-btn:active { transform: scale(0.9); }

.chat-nav-search-btn {
  display: none;
}
.chat-nav-more-wrap {
  display: none;
  position: relative;
  flex-shrink: 0;
}
.chat-nav-more-menu {
  display: none;
  position: absolute;
  top: 42px;
  right: 0;
  min-width: 132px;
  padding: 6px 0;
  border-radius: 8px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px var(--glass-shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  z-index: 5;
  overflow: hidden;
}
.chat-nav-more-menu.active {
  display: block;
}
.chat-nav-more-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.chat-nav-more-item:active {
  background: var(--glass);
}

.chat-search-panel {
  display: none;
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 20;
  background: var(--bg);
  flex-direction: column;
}
.chat-search-panel.active {
  display: flex;
}
.chat-search-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 16px) + 8px) 12px 8px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass);
}
.chat-search-back {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.chat-search-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass-strong);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  padding: 0 12px;
}
.chat-search-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px calc(18px + env(safe-area-inset-bottom, 0px));
  scrollbar-width: none;
}
.chat-search-body::-webkit-scrollbar { display: none; }
.chat-search-empty {
  color: var(--text3);
  font-size: 13px;
  text-align: center;
  padding: 36px 10px;
}
.chat-search-result {
  padding: 10px 8px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
}
.chat-search-result-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.chat-search-result-time {
  color: var(--text3);
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}
.chat-search-result-text {
  color: var(--text2);
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat-search-hit {
  animation: chatSearchHit 1.2s ease;
}
@keyframes chatSearchHit {
  0%, 100% { filter: none; }
  18%, 70% { filter: drop-shadow(0 0 10px rgba(255, 220, 80, 0.9)); }
}

/* Conv Nav (conversation & settings sub-pages) */
.chat-conv-nav {
  display: flex; align-items: center;
  padding: calc(env(safe-area-inset-top, 16px) + 12px) 16px 12px;
  flex-shrink: 0;
}
.chat-conv-nav-inner {
  display: flex; align-items: center;
  width: 100%; position: relative; height: 36px;
}
.chat-conv-nav-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  position: absolute; left: 50%; transform: translateX(-50%);
  white-space: nowrap;
}
.chat-conv-nav-actions {
  position: absolute; right: 0; top: 0;
  display: flex; align-items: center; gap: 8px;
  height: 36px;
}

.chat-profile-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--glass-strong);
  border: 1.5px solid var(--glass-border);
  overflow: hidden; cursor: pointer;
  box-shadow: 0 2px 10px var(--glass-shadow);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 14px;
}
.chat-profile-btn img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Body & Tabs */
.chat-body {
  flex: 1; overflow: hidden; position: relative;
}
.chat-tab-panel {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  overflow-y: auto; padding: 0 16px 16px;
  display: none;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chat-tab-panel::-webkit-scrollbar { display: none; }
.chat-tab-panel.active { display: block; }

.chat-tab-bar {
  display: flex; align-items: center; justify-content: space-around;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
}
.chat-tab-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; cursor: pointer; padding: 4px 12px;
  position: relative;
  color: var(--text3); transition: color 0.2s;
}
.chat-tab-item.active { color: var(--text); }
.chat-tab-item svg { width: 22px; height: 22px; }
.chat-tab-label {
  font-size: 10px; font-weight: 600;
}

/* ===== Messages ===== */
.chat-msg-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px;
  color: var(--text3); font-size: 13px; gap: 12px;
}
.chat-msg-empty svg { opacity: 0.3; }

/* Chat message bubbles */
.chat-msg-time-divider {
  text-align: center; font-size: 11px; color: var(--text3);
  padding: 12px 0 6px; font-weight: 500;
}
.chat-msg-row {
  display: flex; align-items: flex-start; gap: 8px;
  margin-bottom: 12px;
}
.chat-msg-row.msg-right {
  flex-direction: row-reverse;
}
.chat-msg-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: var(--text3);
}
.chat-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-msg-bubble-wrap {
  max-width: 70%; min-width: 0;
}
.chat-msg-sender {
  font-size: 11px; color: var(--text3); margin-bottom: 2px; padding-left: 2px;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.chat-msg-sender-name {
  min-width: 0; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-msg-role-badge {
  flex-shrink: 0;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(7, 193, 96, 0.14);
  border: 1px solid rgba(7, 193, 96, 0.28);
  color: #078f49;
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
}
body.dark-mode .chat-msg-role-badge {
  color: #64d98e;
  background: rgba(7, 193, 96, 0.12);
  border-color: rgba(100, 217, 142, 0.24);
}
.chat-msg-group-title {
  max-width: 100%;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(240, 192, 64, 0.18);
  border: 1px solid rgba(240, 192, 64, 0.35);
  color: #9a6a00;
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.dark-mode .chat-msg-group-title {
  color: #f0c040;
  background: rgba(240, 192, 64, 0.14);
  border-color: rgba(240, 192, 64, 0.28);
}
.chat-char-sender {
  display: none;
}
.chat-msg-bubble {
  padding: 10px 14px; border-radius: 18px;
  font-size: 14px; line-height: 1.5; color: var(--text);
  word-break: break-word; white-space: pre-wrap;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 8px var(--glass-shadow);
  will-change: transform;
}
.msg-left .chat-msg-bubble {
  border-top-left-radius: 4px;
}
.msg-right .chat-msg-bubble {
  border-top-right-radius: 4px;
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
}
.msg-right .chat-msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.msg-right .chat-msg-sender {
  text-align: right; padding-right: 2px; padding-left: 0;
}

.chat-conv-item {
  display: flex; align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer; transition: opacity 0.15s, background 0.15s, transform 0.15s;
}
.chat-conv-item:active { opacity: 0.7; }
.chat-conv-item:last-child { border-bottom: none; }
.chat-conv-avatar {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 20px;
}
.chat-conv-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.chat-conv-info {
  flex: 1; min-width: 0; margin-left: 12px;
}
.chat-conv-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-conv-last {
  font-size: 12px; color: var(--text3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-conv-time {
  font-size: 11px; color: var(--text3); flex-shrink: 0;
  white-space: nowrap;
}
.chat-conv-delete {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--glass-border); background: var(--glass-strong);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3); flex-shrink: 0; margin-left: 6px;
  transition: transform 0.15s;
}
.chat-conv-delete:active { transform: scale(0.9); }

/* ===== Contacts ===== */
.chat-contacts-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px;
  color: var(--text3); font-size: 13px; gap: 12px;
}

.chat-friend-group { margin-bottom: 8px; }
.chat-friend-group-header {
  display: flex; align-items: center; padding: 10px 0;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text2);
  gap: 6px;
}
.chat-friend-group-header > svg {
  width: 14px; height: 14px; transition: transform 0.2s; flex-shrink: 0;
}
.chat-friend-group-header.collapsed > svg {
  transform: rotate(-90deg);
}
.chat-fg-count {
  font-size: 11px; color: var(--text3); font-weight: 500; margin-left: auto;
}
.chat-fg-actions {
  display: flex; gap: 4px; margin-left: 6px; flex-shrink: 0;
}
.chat-fg-actions .chat-contact-action-btn {
  width: 24px; height: 24px;
}
.chat-friend-group-body {
  overflow: hidden;
}
.chat-friend-group-body.collapsed { display: none; }

.chat-contact-item {
  display: flex; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer; transition: opacity 0.15s;
}
.chat-contact-item:active { opacity: 0.7; }
.chat-contact-item:last-child { border-bottom: none; }
.chat-contact-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 18px;
}
.chat-contact-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.chat-contact-info {
  flex: 1; min-width: 0; margin-left: 12px;
}
.chat-contact-name {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.chat-contact-meta {
  font-size: 11px; color: var(--text3); margin-top: 2px;
}
.chat-contact-actions {
  display: flex; gap: 4px; flex-shrink: 0; margin-left: 8px;
}
.chat-contact-action-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--glass-border); background: var(--glass-strong);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3); transition: transform 0.15s;
}
.chat-contact-action-btn:active { transform: scale(0.9); }
.chat-contact-item.long-pressing {
  background: var(--glass);
  border-radius: 12px;
  transform: scale(0.985);
}

/* ===== New Contact Form ===== */
.chat-form-body {
  flex: 1; overflow-y: auto; padding: 16px;
  scrollbar-width: none;
}
.chat-form-body::-webkit-scrollbar { display: none; }

.chat-char-header {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 20px;
}
.chat-char-avatar-wrap {
  position: relative; width: 88px;
  flex-shrink: 0; cursor: pointer;
}
.chat-char-avatar-wrap.polaroid-avatar {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 6px;
  padding: 6px 6px 22px 6px;
  box-shadow: 0 3px 16px var(--glass-shadow), 0 1px 4px rgba(0,0,0,0.06);
  transition: transform 0.15s;
}
.chat-char-avatar-wrap.polaroid-avatar:active { transform: scale(0.96) rotate(-1deg); }
.chat-char-avatar-inner {
  width: 100%; aspect-ratio: 1; border-radius: 3px;
  background: var(--glass);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
}
.chat-char-avatar-inner img {
  width: 100%; height: 100%; object-fit: cover;
}
.chat-char-avatar-ph {
  color: var(--text3); font-size: 28px;
}
.polaroid-avatar-label {
  text-align: center; font-size: 9px; color: var(--text3);
  margin-top: 4px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.chat-char-fields {
  flex: 1; display: flex; flex-direction: column; gap: 8px;
  padding-top: 4px;
}
.chat-field-input {
  width: 100%; padding: 8px 12px;
  border-radius: 10px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 13px; font-family: inherit; color: var(--text);
  outline: none;
}
.chat-field-input::placeholder { color: var(--text3); }
.chat-field-input:focus { border-color: var(--text2); }

.chat-form-section {
  margin-bottom: 16px;
}
.chat-form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.chat-form-label {
  font-size: 13px; font-weight: 600; color: var(--text2);
  margin-bottom: 8px; display: block;
}
.chat-form-label-row .chat-form-label {
  margin-bottom: 0;
  min-width: 0;
}
.chat-form-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  color: var(--text3);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.chat-form-textarea {
  width: 100%; min-height: 100px; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 13px; font-family: inherit; color: var(--text);
  outline: none; resize: vertical; line-height: 1.6;
}
.chat-form-textarea::placeholder { color: var(--text3); }
.chat-form-textarea:focus { border-color: var(--text2); }

.chat-form-input {
  width: 100%; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 13px; font-family: inherit; color: var(--text);
  outline: none;
}
.chat-form-input::placeholder { color: var(--text3); }
.chat-form-input:focus { border-color: var(--text2); }

.chat-form-select {
  width: 100%; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 13px; font-family: inherit; color: var(--text);
  outline: none; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* NPC */
.chat-npc-list {
  display: flex; flex-direction: column; gap: 12px;
}
.chat-npc-card {
  background: var(--glass); border: 1.5px solid var(--glass-border);
  border-radius: 14px; padding: 12px;
}
.chat-npc-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.chat-npc-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  overflow: hidden; flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 16px;
}
.chat-npc-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.chat-npc-name-input {
  flex: 1; padding: 6px 10px;
  border-radius: 8px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 13px; font-family: inherit; color: var(--text);
  outline: none;
}
.chat-npc-name-input::placeholder { color: var(--text3); }
.chat-npc-remove {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--glass-border); background: var(--glass-strong);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3); font-size: 14px;
  flex-shrink: 0; transition: transform 0.15s;
}
.chat-npc-remove:active { transform: scale(0.9); }
.chat-npc-setting {
  width: 100%; min-height: 60px; padding: 8px 10px;
  border-radius: 8px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 12px; font-family: inherit; color: var(--text);
  outline: none; resize: vertical; line-height: 1.5;
}
.chat-npc-setting::placeholder { color: var(--text3); }

.chat-npc-voice-input {
  width: 100%; padding: 7px 10px; margin-top: 6px;
  border-radius: 8px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 12px; font-family: inherit; color: var(--text);
  outline: none;
}
.chat-npc-voice-input::placeholder { color: var(--text3); }

.chat-add-npc-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; width: 100%; padding: 10px;
  border-radius: 12px; border: 1.5px dashed var(--glass-border);
  background: transparent;
  font-size: 13px; font-family: inherit; color: var(--text3);
  cursor: pointer; transition: all 0.15s;
}
.chat-add-npc-btn:active { transform: scale(0.98); }

.chat-form-save {
  width: 100%; padding: 14px;
  border-radius: 14px; border: none;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: transform 0.15s;
  margin-top: 12px;
}
.chat-form-save:active { transform: scale(0.97); }

/* ===== Modals ===== */
.chat-modal-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 850;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  will-change: opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.chat-modal-overlay.keyboard-safe-modal,
.chat-edit-overlay.keyboard-safe-modal {
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 20px;
}
.chat-modal-overlay.keyboard-safe-modal > *,
.chat-edit-overlay.keyboard-safe-modal > * {
  max-height: calc(var(--app-visual-viewport-height, 100vh) - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin-top: var(--app-visual-viewport-offset-top, 0px);
}
.chat-modal-overlay .chat-modal-panel,
.chat-modal-overlay .chat-fg-modal-panel,
.chat-modal-overlay .chat-group-select-panel,
.chat-modal-overlay .chat-avatar-modal-panel,
.chat-modal-overlay .cs-modal-panel {
  transform: scale(0.92) translateY(8px);
  transition: transform 0.25s cubic-bezier(.25,.46,.45,.94);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-modal-overlay.active .chat-modal-panel,
.chat-modal-overlay.active .chat-fg-modal-panel,
.chat-modal-overlay.active .chat-group-select-panel,
.chat-modal-overlay.active .chat-avatar-modal-panel,
.chat-modal-overlay.active .cs-modal-panel {
  transform: scale(1) translateY(0);
}
.chat-modal-panel {
  background: var(--bg); background-image: none;
  border-radius: 18px;
  padding: 20px; width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.chat-modal-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  text-align: center; margin-bottom: 16px;
}
.chat-modal-option {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 12px;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  cursor: pointer; transition: all 0.15s;
  margin-bottom: 8px; color: var(--text);
  font-size: 14px; font-weight: 500;
}
.chat-modal-option:last-child { margin-bottom: 0; }
.chat-modal-option:active { transform: scale(0.97); }
.chat-modal-option svg { flex-shrink: 0; }

/* Group select modal */
.chat-group-select-panel {
  background: var(--bg); background-image: none;
  border-radius: 18px;
  padding: 20px; width: 300px; max-height: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  overflow-y: auto;
}
.chat-group-option {
  display: flex; align-items: center; padding: 12px 14px;
  border-radius: 10px; cursor: pointer;
  transition: background 0.15s; margin-bottom: 4px;
  color: var(--text); font-size: 14px;
}
.chat-group-option:active { background: var(--glass); }
.chat-group-option.selected {
  background: var(--glass-strong); font-weight: 600;
}
.chat-group-option svg {
  margin-right: 10px; flex-shrink: 0;
}
.chat-group-option-name {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.chat-group-option-current {
  margin-left: auto; padding: 2px 7px; border-radius: 999px;
  background: var(--glass); color: var(--text3);
  font-size: 11px; font-weight: 500;
}
.chat-group-select-cancel {
  width: 100%; margin-top: 10px; padding: 11px 14px;
  border-radius: 12px; border: 1px solid var(--glass-border);
  background: var(--glass-strong); color: var(--text2);
  font-size: 13px; font-family: inherit; cursor: pointer;
}
.chat-group-select-cancel:active { transform: scale(0.98); }

/* Friend group add modal */
.chat-fg-modal-panel {
  background: var(--bg); background-image: none;
  border-radius: 18px;
  padding: 20px; width: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

/* ===== Create Chat Page ===== */
.chat-create-body {
  flex: 1; overflow-y: auto; padding: 16px;
  scrollbar-width: none;
}
.chat-create-body::-webkit-scrollbar { display: none; }

.chat-section-title {
  font-size: 13px; font-weight: 600; color: var(--text2);
  margin-bottom: 8px; margin-top: 16px;
}
.chat-section-title:first-child { margin-top: 0; }

.chat-group-avatar-wrap {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 12px;
}
.chat-group-avatar-preview {
  width: 64px; height: 64px; flex-shrink: 0;
  border-radius: 14px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-strong);
  border: 1.5px dashed var(--glass-border);
  color: var(--text3); cursor: pointer;
  transition: border-color 0.15s;
}
.chat-group-avatar-preview:active { border-color: var(--text); }
.chat-group-avatar-preview img {
  width: 100%; height: 100%; object-fit: cover;
}

.chat-persona-input {
  width: 100%; min-height: 60px; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 13px; font-family: inherit; color: var(--text);
  outline: none; resize: vertical; line-height: 1.5;
}
.chat-persona-input::placeholder { color: var(--text3); }

.chat-select-list {
  display: flex; flex-direction: column;
}
.chat-select-item {
  display: flex; align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
}
.chat-select-item:last-child { border-bottom: none; }
.chat-select-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-right: 12px;
  transition: all 0.15s;
}
.chat-select-check.checked {
  background: var(--text); border-color: var(--text);
}
.chat-select-check.checked svg { display: block; }
.chat-select-check svg { display: none; }
.chat-select-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  overflow: hidden; flex-shrink: 0; margin-right: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 16px;
}
.chat-select-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.chat-select-name {
  font-size: 14px; font-weight: 500; color: var(--text);
}
.chat-select-tag {
  font-size: 10px; color: var(--text3); margin-left: 6px;
  padding: 2px 6px; border-radius: 6px;
  background: var(--glass); border: 1px solid var(--glass-border);
}

.chat-confirm-btn {
  width: 100%; padding: 14px; margin-top: 16px;
  border-radius: 14px; border: none;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: transform 0.15s;
}
.chat-confirm-btn:active { transform: scale(0.97); }
.chat-confirm-btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* ===== Profile Page ===== */
.profile-user-card {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  border-radius: 18px; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 4px 16px var(--glass-shadow);
}
.profile-avatar-wrap {
  width: 64px; height: 64px; flex-shrink: 0;
  border-radius: 8px; overflow: hidden; cursor: pointer;
  background: var(--glass-strong); border: 2px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); transition: transform 0.15s;
}
.profile-avatar-wrap:active { transform: scale(0.95); }
.profile-avatar-wrap img {
  width: 100%; height: 100%; object-fit: cover;
}
.profile-avatar-ph { display: flex; align-items: center; justify-content: center; }
.profile-user-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px;
  padding-top: 4px;
}
.profile-nickname-input {
  width: 100%; padding: 6px 0; border: none; border-bottom: 1.5px solid var(--glass-border);
  background: transparent; font-size: 16px; font-weight: 700;
  font-family: inherit; color: var(--text); outline: none;
}
.profile-nickname-input::placeholder { color: var(--text3); font-weight: 400; }
.profile-nickname-input:focus { border-bottom-color: var(--text); }
.profile-signature-input {
  width: 100%; padding: 4px 0; border: none; border-bottom: 1px solid transparent;
  background: transparent; font-size: 12px;
  font-family: inherit; color: var(--text2); outline: none;
}
.profile-signature-input::placeholder { color: var(--text3); }
.profile-signature-input:focus { border-bottom-color: var(--glass-border); }

/* Profile Sections */
.profile-section {
  margin-bottom: 10px;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  border-radius: 16px; overflow: hidden;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 2px 10px var(--glass-shadow);
}
.profile-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text);
  transition: background 0.15s;
}
.profile-section-header:active { background: var(--glass-strong); }
.profile-section-arrow {
  width: 16px; height: 16px; transition: transform 0.2s; flex-shrink: 0;
  color: var(--text2);
}
.profile-section-arrow.collapsed { transform: rotate(-90deg); }
.profile-section-count {
  font-size: 11px; color: var(--text3); font-weight: 500; margin-left: auto;
}
.profile-section-add-btn {
  padding: 4px 12px; border-radius: 10px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong); font-size: 11px; font-weight: 600;
  font-family: inherit; color: var(--text2); cursor: pointer;
  transition: transform 0.15s;
}
.profile-section-add-btn:active { transform: scale(0.95); }
.profile-section-body {
  padding: 0 16px 16px;
}

/* Persona cards */
.persona-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin-bottom: 8px;
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  border-radius: 14px; transition: opacity 0.15s;
}
.persona-card:last-child { margin-bottom: 0; }
.persona-card-avatar {
  width: 42px; height: 42px; border-radius: 6px;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 16px;
}
.persona-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.persona-card-info { flex: 1; min-width: 0; }
.persona-card-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.persona-card-meta {
  font-size: 11px; color: var(--text3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.persona-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.persona-card-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--glass-border); background: var(--glass);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3); transition: transform 0.15s;
}
.persona-card-btn:active { transform: scale(0.9); }

/* Profile novel shelf */
.profile-shelf-empty {
  padding: 14px 4px;
  color: var(--text3);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}
.profile-shelf-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 28px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  cursor: pointer;
}
.profile-shelf-item:last-child { margin-bottom: 0; }
.profile-shelf-cover {
  width: 54px;
  min-height: 72px;
  box-shadow: 0 6px 14px rgba(0,0,0,.12);
}
.profile-shelf-cover .novel-cover-title {
  left: 7px;
  right: 7px;
  top: 10px;
  font-size: 11px;
  line-height: 1.25;
}
.profile-shelf-cover .novel-cover-author {
  left: 7px;
  right: 7px;
  bottom: 8px;
  font-size: 9px;
}
.profile-shelf-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.profile-shelf-title {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-shelf-meta {
  color: var(--text3);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-shelf-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.profile-shelf-foot span {
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text3);
  font-size: 10px;
}
.profile-shelf-open {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text3);
  display: grid;
  place-items: center;
}

/* Sticker management */
.sticker-pack-card {
  margin-bottom: 10px; padding: 12px;
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  border-radius: 14px;
}
.sticker-pack-card:last-child { margin-bottom: 0; }
.sticker-pack-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.sticker-pack-name {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.sticker-pack-actions { display: flex; gap: 4px; }
.sticker-pack-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--glass-border); background: var(--glass);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3); transition: transform 0.15s;
}
.sticker-pack-btn:active { transform: scale(0.9); }
.sticker-mini-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.sticker-mini-item {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--glass); border: 1px solid var(--glass-border);
  overflow: hidden; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sticker-mini-item img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

/* Sticker edit page */
.sticker-add-methods {
  display: flex; flex-direction: column; gap: 8px;
}
.sticker-url-row {
  display: flex; gap: 6px; align-items: center;
}
.sticker-upload-row {
  display: flex; gap: 8px;
}
.sticker-preview-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  min-height: 60px;
}
.sticker-preview-item {
  position: relative; aspect-ratio: 1;
  border-radius: 10px; overflow: hidden;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sticker-preview-item img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.sticker-preview-item .sticker-remove-btn {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(220,60,60,0.85); color: #fff;
  font-size: 12px; line-height: 18px; text-align: center;
  cursor: pointer; z-index: 2;
}
.sticker-preview-item .sticker-meaning {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 9px; text-align: center; padding: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Persona select in create chat */
.chat-persona-select-area {
  display: flex; gap: 8px; align-items: center;
}
.chat-persona-select-btn {
  flex: 1; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 13px; font-family: inherit; color: var(--text2);
  cursor: pointer; text-align: left; transition: all 0.15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-persona-select-btn:active { transform: scale(0.98); }
.chat-persona-select-btn.selected { color: var(--text); font-weight: 500; }
.chat-persona-clear-btn {
  padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid var(--glass-border); background: var(--glass);
  font-size: 12px; font-family: inherit; color: var(--text3);
  cursor: pointer; flex-shrink: 0;
}

/* ===== Theme adaptations for Chat ===== */

/* Pink theme */
body.theme-pink .chat-page,
body.theme-pink .chat-sub-page { background: var(--bg); }
body.theme-pink .chat-tab-bar {
  background: rgba(248,238,242,0.65);
  border-top-color: rgba(225,200,212,0.5);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
body.theme-pink .chat-nav-back,
body.theme-pink .chat-nav-btn {
  background: rgba(250,235,240,0.6);
  border-color: rgba(225,200,212,0.5);
}
body.theme-pink .chat-profile-btn {
  background: rgba(248,238,242,0.75);
  border-color: rgba(225,200,212,0.5);
}
body.theme-pink .chat-modal-panel,
body.theme-pink .chat-fg-modal-panel,
body.theme-pink .chat-group-select-panel,
body.theme-pink .chat-avatar-modal-panel {
  background: #faf5f6;
  box-shadow: 0 8px 32px rgba(150,100,120,0.12);
}
body.theme-pink .chat-npc-card,
body.theme-pink .profile-section,
body.theme-pink .profile-user-card {
  background: rgba(250,235,240,0.55);
  border-color: rgba(225,200,212,0.5);
}
body.theme-pink .chat-form-save,
body.theme-pink .chat-confirm-btn { background: #3d3035; color: #faf5f6; }
body.theme-pink .polaroid-avatar {
  background: #f8eff1; border-color: rgba(225,200,212,0.6);
  box-shadow: 0 3px 16px rgba(150,100,120,0.08);
}

body.theme-pink.dark-mode .chat-tab-bar {
  background: rgba(55,40,48,0.6);
  border-top-color: rgba(75,55,65,0.5);
}
body.theme-pink.dark-mode .chat-nav-back,
body.theme-pink.dark-mode .chat-nav-btn {
  background: rgba(55,40,48,0.6);
  border-color: rgba(75,55,65,0.5);
}
body.theme-pink.dark-mode .chat-modal-panel,
body.theme-pink.dark-mode .chat-fg-modal-panel,
body.theme-pink.dark-mode .chat-group-select-panel,
body.theme-pink.dark-mode .chat-avatar-modal-panel {
  background: #241e20;
}
body.theme-pink.dark-mode .polaroid-avatar {
  background: #302028; border-color: rgba(75,55,65,0.5);
}

/* Comic line theme slot */
body.theme-white .chat-page,
body.theme-white .chat-sub-page {
  background: var(--bg);
}
body.theme-white .chat-msg-bubble {
  background: rgba(240,240,240,0.88);
  border-color: rgba(200,200,200,0.5);
}
body.theme-white .msg-right .chat-msg-bubble {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
}
body.theme-white .chat-forward-viewer-bubble {
  background: rgba(240,240,240,0.88);
  border-color: rgba(200,200,200,0.5);
}
body.theme-white.dark-mode .chat-msg-bubble {
  background: rgba(60,60,60,0.82);
  border-color: rgba(90,90,90,0.5);
}
body.theme-white.dark-mode .msg-right .chat-msg-bubble {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
}
body.theme-white.dark-mode .chat-forward-viewer-bubble {
  background: rgba(60,60,60,0.82);
  border-color: rgba(90,90,90,0.5);
}
body.theme-white .chat-tab-bar {
  background: rgba(255,255,255,0.22);
  border-top-color: rgba(255,255,255,0.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.4); backdrop-filter: blur(24px) saturate(1.4);
}
body.theme-white .chat-nav-back,
body.theme-white .chat-nav-btn {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.35);
  -webkit-backdrop-filter: blur(28px) saturate(1.5); backdrop-filter: blur(28px) saturate(1.5);
}
body.theme-white .chat-profile-btn {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.35);
}
body.theme-white .chat-modal-panel,
body.theme-white .chat-fg-modal-panel,
body.theme-white .chat-group-select-panel,
body.theme-white .chat-avatar-modal-panel,
body.theme-white .cs-modal-panel {
  background: rgba(245,245,245,0.92);
  -webkit-backdrop-filter: blur(24px) saturate(1.4); backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: 0 12px 40px rgba(0,0,0,0.10), inset 0 1px 0 rgba(255,255,255,0.5);
}
body.theme-white .chat-npc-card,
body.theme-white .profile-section,
body.theme-white .profile-user-card {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.35);
  -webkit-backdrop-filter: blur(20px) saturate(1.3); backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 4px 16px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.4);
}
body.theme-white .chat-field-input,
body.theme-white .chat-form-textarea,
body.theme-white .chat-form-input,
body.theme-white .chat-form-select,
body.theme-white .chat-persona-input {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.3);
}
body.theme-white .polaroid-avatar {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.35);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
}
body.theme-white .chat-conv-avatar,
body.theme-white .chat-contact-avatar,
body.theme-white .chat-select-avatar,
body.theme-white .chat-npc-avatar {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.3);
}

body.theme-white.dark-mode .chat-tab-bar {
  background: rgba(48,48,48,0.4);
  border-top-color: rgba(80,80,80,0.4);
}
body.theme-white.dark-mode .chat-nav-back,
body.theme-white.dark-mode .chat-nav-btn {
  background: rgba(50,50,50,0.4);
  border-color: rgba(80,80,80,0.4);
}
body.theme-white.dark-mode .chat-modal-panel,
body.theme-white.dark-mode .chat-fg-modal-panel,
body.theme-white.dark-mode .chat-group-select-panel,
body.theme-white.dark-mode .chat-avatar-modal-panel,
body.theme-white.dark-mode .cs-modal-panel {
  background: rgba(42,42,42,0.95);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
body.theme-white.dark-mode .polaroid-avatar {
  background: rgba(50,50,50,0.5); border-color: rgba(80,80,80,0.4);
}

/* Blue theme */
body.theme-blue .chat-page,
body.theme-blue .chat-sub-page {
  background: var(--bg);
}
body.theme-blue .chat-msg-bubble {
  background: rgba(215,232,250,0.72);
  border-color: rgba(180,210,240,0.4);
}
body.theme-blue .msg-right .chat-msg-bubble {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
}
body.theme-blue .chat-forward-viewer-bubble {
  background: rgba(215,232,250,0.72);
  border-color: rgba(180,210,240,0.4);
}
body.theme-blue.dark-mode .chat-msg-bubble {
  background: rgba(38,52,70,0.72);
  border-color: rgba(50,65,85,0.45);
}
body.theme-blue.dark-mode .msg-right .chat-msg-bubble {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
}
body.theme-blue.dark-mode .chat-forward-viewer-bubble {
  background: rgba(38,52,70,0.72);
  border-color: rgba(50,65,85,0.45);
}
body.theme-blue .chat-tab-bar {
  background: linear-gradient(160deg, rgba(220,238,255,0.35), rgba(200,222,248,0.18));
  border-top: none;
  -webkit-backdrop-filter: blur(28px) saturate(1.5); backdrop-filter: blur(28px) saturate(1.5);
  box-shadow: 0 -4px 16px rgba(60,100,160,0.06);
}
body.theme-blue .chat-nav-back,
body.theme-blue .chat-nav-btn {
  border: none; border-radius: 16px;
  background: linear-gradient(160deg, rgba(225,240,255,0.48), rgba(200,222,248,0.28));
  box-shadow: 0 4px 12px rgba(60,100,160,0.10), inset 0 1.5px 2px rgba(255,255,255,0.55);
}
body.theme-blue .chat-profile-btn {
  border: none;
  background: linear-gradient(160deg, rgba(225,240,255,0.5), rgba(200,222,248,0.3));
  box-shadow: 0 3px 10px rgba(60,100,160,0.08);
}
body.theme-blue .chat-modal-panel,
body.theme-blue .chat-fg-modal-panel,
body.theme-blue .chat-group-select-panel,
body.theme-blue .chat-avatar-modal-panel,
body.theme-blue .cs-modal-panel {
  border: none; border-radius: 26px;
  background: linear-gradient(160deg, rgba(230,242,255,0.92), rgba(218,232,250,0.88));
  -webkit-backdrop-filter: blur(32px) saturate(1.5); backdrop-filter: blur(32px) saturate(1.5);
  box-shadow: 0 14px 44px rgba(60,100,160,0.16), inset 0 2px 4px rgba(255,255,255,0.6);
}
body.theme-blue .chat-modal-option {
  border: none; border-radius: 16px;
  background: linear-gradient(160deg, rgba(220,238,255,0.38), rgba(200,222,248,0.2));
  box-shadow: 0 3px 10px rgba(60,100,160,0.06), inset 0 1px 2px rgba(255,255,255,0.4);
}
body.theme-blue .chat-npc-card,
body.theme-blue .profile-section,
body.theme-blue .profile-user-card {
  border: none; border-radius: 20px;
  background: linear-gradient(160deg, rgba(225,240,255,0.38), rgba(200,222,248,0.22));
  -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 6px 18px rgba(60,100,160,0.08), inset 0 1.5px 2px rgba(255,255,255,0.5);
}
body.theme-blue .chat-field-input,
body.theme-blue .chat-form-textarea,
body.theme-blue .chat-form-input,
body.theme-blue .chat-form-select,
body.theme-blue .chat-persona-input,
body.theme-blue .chat-npc-name-input,
body.theme-blue .chat-npc-setting,
body.theme-blue .chat-npc-voice-input,
body.theme-blue .chat-avatar-url-input {
  border: none; border-radius: 14px;
  background: rgba(215,235,255,0.3);
  box-shadow: inset 0 1px 4px rgba(60,100,160,0.06);
}
body.theme-blue .chat-form-save,
body.theme-blue .chat-confirm-btn {
  border-radius: 18px;
  box-shadow: 0 4px 14px rgba(60,100,160,0.12);
}
body.theme-blue .chat-add-npc-btn {
  border: 1.5px dashed rgba(160,190,220,0.4);
  border-radius: 16px;
}
body.theme-blue .chat-conv-item { border-bottom-color: rgba(180,210,240,0.18); }
body.theme-blue .chat-contact-item { border-bottom-color: rgba(180,210,240,0.18); }
body.theme-blue .chat-select-item { border-bottom-color: rgba(180,210,240,0.18); }
body.theme-blue .chat-friend-group-header { color: var(--text2); }
body.theme-blue .chat-conv-avatar,
body.theme-blue .chat-contact-avatar,
body.theme-blue .chat-select-avatar,
body.theme-blue .chat-npc-avatar {
  border: none;
  background: linear-gradient(160deg, rgba(215,235,255,0.45), rgba(195,218,248,0.25));
  box-shadow: 0 3px 8px rgba(60,100,160,0.06), inset 0 1px 2px rgba(255,255,255,0.45);
}
body.theme-blue .chat-conv-delete,
body.theme-blue .chat-contact-action-btn {
  border: none;
  background: linear-gradient(160deg, rgba(220,238,255,0.35), rgba(200,222,248,0.2));
  box-shadow: 0 2px 6px rgba(60,100,160,0.06);
}
body.theme-blue .polaroid-avatar {
  border: none; border-radius: 10px;
  background: linear-gradient(160deg, rgba(230,242,255,0.55), rgba(208,225,248,0.35));
  box-shadow: 0 6px 20px rgba(60,100,160,0.10), inset 0 1.5px 3px rgba(255,255,255,0.5);
}
body.theme-blue .chat-select-check {
  border-color: rgba(160,190,220,0.4);
}
body.theme-blue .chat-select-tag {
  border: none;
  background: rgba(215,235,255,0.3);
}
body.theme-blue .profile-section-add-btn,
body.theme-blue .persona-card-btn,
body.theme-blue .sticker-pack-btn {
  border: none;
  background: linear-gradient(160deg, rgba(220,238,255,0.35), rgba(200,222,248,0.2));
  box-shadow: 0 2px 6px rgba(60,100,160,0.06);
}
body.theme-blue .persona-card,
body.theme-blue .sticker-pack-card {
  border: none;
  background: linear-gradient(160deg, rgba(215,235,255,0.3), rgba(195,218,248,0.15));
  box-shadow: 0 3px 10px rgba(60,100,160,0.05);
}
body.theme-blue .sticker-preview-item,
body.theme-blue .sticker-mini-item {
  border: none;
  box-shadow: 0 2px 6px rgba(60,100,160,0.06);
}
body.theme-blue .chat-persona-select-btn {
  border: none;
  background: rgba(215,235,255,0.3);
  box-shadow: inset 0 1px 4px rgba(60,100,160,0.06);
}

/* Blue dark mode */
body.theme-blue.dark-mode .chat-tab-bar {
  background: linear-gradient(160deg, rgba(32,45,62,0.45), rgba(22,32,45,0.3));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
}
body.theme-blue.dark-mode .chat-nav-back,
body.theme-blue.dark-mode .chat-nav-btn {
  background: linear-gradient(160deg, rgba(42,58,80,0.5), rgba(30,42,58,0.3));
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
body.theme-blue.dark-mode .chat-modal-panel,
body.theme-blue.dark-mode .chat-fg-modal-panel,
body.theme-blue.dark-mode .chat-group-select-panel,
body.theme-blue.dark-mode .chat-avatar-modal-panel,
body.theme-blue.dark-mode .cs-modal-panel {
  border-radius: 26px;
  background: linear-gradient(160deg, rgba(40,55,75,0.92), rgba(30,42,58,0.88));
  box-shadow: 0 14px 44px rgba(0,0,0,0.32), inset 0 2px 3px rgba(80,110,150,0.12);
}
body.theme-blue.dark-mode .chat-modal-option {
  background: linear-gradient(160deg, rgba(42,58,80,0.4), rgba(30,42,58,0.25));
}
body.theme-blue.dark-mode .chat-npc-card,
body.theme-blue.dark-mode .profile-section,
body.theme-blue.dark-mode .profile-user-card {
  background: linear-gradient(160deg, rgba(38,52,70,0.45), rgba(28,38,52,0.28));
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}
body.theme-blue.dark-mode .chat-conv-avatar,
body.theme-blue.dark-mode .chat-contact-avatar,
body.theme-blue.dark-mode .chat-select-avatar {
  background: linear-gradient(160deg, rgba(42,58,80,0.45), rgba(30,42,58,0.3));
}
body.theme-blue.dark-mode .polaroid-avatar {
  background: linear-gradient(160deg, rgba(38,52,70,0.5), rgba(28,38,52,0.35));
}

/* ===== Line theme (极简线条) ===== */
body.theme-line .chat-page,
body.theme-line .chat-sub-page { background: var(--bg); }
body.theme-line .chat-tab-bar {
  background: var(--dock-bg);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-line .chat-nav-back,
body.theme-line .chat-nav-btn {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: none;
}
body.theme-line .chat-profile-btn {
  background: var(--bg);
  border: 1px solid var(--glass-border);
}
body.theme-line .chat-msg-bubble {
  background: var(--dock-bg);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
body.theme-line .msg-right .chat-msg-bubble {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
}
body.theme-line .chat-modal-panel,
body.theme-line .chat-fg-modal-panel,
body.theme-line .chat-group-select-panel,
body.theme-line .chat-avatar-modal-panel,
body.theme-line .cs-modal-panel {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
body.theme-line .chat-modal-option {
  background: var(--bg);
  border: 1px solid var(--glass-border);
}
body.theme-line .chat-npc-card,
body.theme-line .profile-section,
body.theme-line .profile-user-card {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: none;
}
body.theme-line .chat-input-bar {
  background: var(--dock-bg);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-line .chat-input-wrap {
  background: var(--bg);
  border: 1px solid var(--glass-border);
}
body.theme-line .chat-plus-panel {
  background: var(--dock-bg);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-line .chat-plus-icon {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
body.theme-line .chat-sticker-picker {
  background: var(--dock-bg);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-line .chat-multiselect-bar {
  background: var(--dock-bg);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-line .chat-quote-bar {
  background: var(--dock-bg);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-line .cs-char-bar {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: none;
}
body.theme-line .cs-section {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: none;
}
body.theme-line .mem-card {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: none;
}
body.theme-line .mem-stats-bar {
  background: var(--dock-bg);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-line .chat-conv-avatar,
body.theme-line .chat-contact-avatar,
body.theme-line .chat-select-avatar,
body.theme-line .chat-npc-avatar {
  background: var(--dock-bg);
  border: 1px solid var(--glass-border);
}
body.theme-line .chat-msg-avatar {
  background: var(--dock-bg);
  border: 1px solid var(--glass-border);
}
body.theme-line .chat-forward-viewer-bubble {
  background: var(--dock-bg);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
body.theme-line .polaroid-avatar {
  background: var(--bg);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
body.theme-line .chat-form-save,
body.theme-line .chat-confirm-btn { box-shadow: none; }
body.theme-line .chat-load-history-btn {
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-line .chat-modal-overlay {
  backdrop-filter: none; -webkit-backdrop-filter: none;
  background: rgba(0,0,0,0.3);
}
body.theme-line .sticker-picker-item {
  background: var(--bg);
  border: 1px solid var(--glass-border);
}
body.theme-line .chat-field-input,
body.theme-line .chat-form-textarea,
body.theme-line .chat-form-input,
body.theme-line .chat-form-select,
body.theme-line .chat-persona-input {
  background: var(--bg);
  border-color: var(--glass-border);
}

/* ===== Retro theme (千禧年古早电脑风 Y2K Win98/2000) ===== */
body.theme-retro .chat-page,
body.theme-retro .chat-sub-page {
  background: var(--glass);
  background-image: none;
}
body.theme-retro .chat-tab-bar {
  background: var(--dock-bg);
  border-top: 2px solid var(--widget-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border-radius: 0;
  box-shadow: inset 2px 0 0 rgba(255,255,255,0.5);
}
body.theme-retro .chat-nav-back,
body.theme-retro .chat-nav-btn {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border-radius: 4px;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.6),
    inset -2px -2px 0 rgba(0,0,0,0.15);
}
body.theme-retro .chat-nav-back:active,
body.theme-retro .chat-nav-btn:active {
  box-shadow: inset 2px 2px 3px rgba(0,0,0,0.2), inset -1px -1px 0 rgba(255,255,255,0.3);
}
body.theme-retro .chat-profile-btn {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.5), inset -2px -2px 0 rgba(0,0,0,0.12);
}
body.theme-retro .chat-msg-bubble {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  will-change: auto;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.1),
    1px 1px 0 rgba(0,0,0,0.08);
}
body.theme-retro .msg-right .chat-msg-bubble {
  background: #000080;
  color: #fff;
  border: 2px solid #000060;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.15),
    inset -2px -2px 0 rgba(0,0,0,0.2),
    1px 1px 0 rgba(0,0,0,0.1);
}
body.theme-retro .chat-modal-panel,
body.theme-retro .chat-fg-modal-panel,
body.theme-retro .chat-group-select-panel,
body.theme-retro .chat-avatar-modal-panel,
body.theme-retro .cs-modal-panel {
  background: var(--glass);
  border: 2px solid var(--widget-border);
  border-radius: 4px;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.15),
    3px 3px 0 rgba(0,0,0,0.12);
}
body.theme-retro .chat-modal-option {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.1);
}
body.theme-retro .chat-modal-option:active {
  box-shadow: inset 2px 2px 3px rgba(0,0,0,0.15);
}
body.theme-retro .chat-npc-card,
body.theme-retro .profile-section,
body.theme-retro .profile-user-card {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.1),
    1px 1px 0 rgba(0,0,0,0.05);
}
body.theme-retro .chat-input-bar {
  background: var(--dock-bg);
  border-top: 2px solid var(--widget-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border-radius: 0;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.4);
}
body.theme-retro .chat-input-wrap {
  background: #fff;
  border: 2px solid var(--glass-border);
  border-radius: 3px;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.12), inset -1px -1px 0 rgba(255,255,255,0.5);
}
body.theme-retro .chat-plus-panel {
  background: var(--glass);
  border-top: 2px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-retro .chat-plus-icon {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.1),
    1px 1px 0 rgba(0,0,0,0.05);
}
body.theme-retro .chat-sticker-picker {
  background: var(--glass);
  border-top: 2px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-retro .chat-multiselect-bar {
  background: var(--dock-bg);
  border-top: 2px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-retro .chat-quote-bar {
  background: var(--glass);
  border-top: 2px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-retro .cs-char-bar {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.1),
    1px 1px 0 rgba(0,0,0,0.05);
}
body.theme-retro .cs-section {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.5),
    inset -2px -2px 0 rgba(0,0,0,0.1),
    1px 1px 0 rgba(0,0,0,0.05);
}
body.theme-retro .mem-card {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.4),
    inset -2px -2px 0 rgba(0,0,0,0.08),
    1px 1px 0 rgba(0,0,0,0.05);
}
body.theme-retro .mem-stats-bar {
  background: var(--dock-bg);
  border-bottom: 2px solid var(--glass-border);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.4);
}
body.theme-retro .chat-conv-avatar,
body.theme-retro .chat-contact-avatar,
body.theme-retro .chat-select-avatar,
body.theme-retro .chat-npc-avatar {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
}
body.theme-retro .chat-msg-avatar {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
}
body.theme-retro .chat-forward-viewer-bubble {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.4),
    inset -2px -2px 0 rgba(0,0,0,0.08),
    1px 1px 0 rgba(0,0,0,0.06);
}
body.theme-retro .polaroid-avatar {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.4), inset -2px -2px 0 rgba(0,0,0,0.1);
}
body.theme-retro .chat-form-save,
body.theme-retro .chat-confirm-btn {
  border-radius: 4px;
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,0.2),
    inset -2px -2px 0 rgba(0,0,0,0.2),
    1px 1px 0 rgba(0,0,0,0.1);
}
body.theme-retro .chat-form-save:active,
body.theme-retro .chat-confirm-btn:active {
  box-shadow: inset 2px 2px 3px rgba(0,0,0,0.25);
}
body.theme-retro .chat-load-history-btn {
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border-radius: 4px;
}
body.theme-retro .chat-modal-overlay {
  backdrop-filter: none; -webkit-backdrop-filter: none;
  background: rgba(0,0,0,0.45);
}
body.theme-retro .sticker-picker-item {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
}
body.theme-retro .chat-field-input,
body.theme-retro .chat-form-textarea,
body.theme-retro .chat-form-input,
body.theme-retro .chat-form-select,
body.theme-retro .chat-persona-input {
  background: #fff;
  border: 2px solid var(--glass-border);
  border-radius: 3px;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.12), inset -1px -1px 0 rgba(255,255,255,0.5);
}
body.theme-retro .chat-conv-delete,
body.theme-retro .chat-contact-action-btn {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.5), inset -2px -2px 0 rgba(0,0,0,0.1);
}
body.theme-retro .persona-card,
body.theme-retro .sticker-pack-card {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.4), inset -2px -2px 0 rgba(0,0,0,0.08), 1px 1px 0 rgba(0,0,0,0.05);
}
body.theme-retro.dark-mode .chat-input-wrap {
  background: var(--glass-strong);
}
body.theme-retro.dark-mode .chat-field-input,
body.theme-retro.dark-mode .chat-form-textarea,
body.theme-retro.dark-mode .chat-form-input,
body.theme-retro.dark-mode .chat-form-select,
body.theme-retro.dark-mode .chat-persona-input {
  background: var(--glass-strong);
}
body.theme-retro.dark-mode .msg-right .chat-msg-bubble {
  background: #1a1a60;
  border-color: #14144a;
}

/* Remove overlay blur to reduce compositing layers */
.chat-modal-overlay {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Mobile: kill backdrop-filter on chat elements to reduce GPU load */
@media (pointer: coarse), (max-width: 900px) {
  .chat-tab-bar,
  .chat-nav-back,
  .chat-nav-btn,
  .chat-input-bar,
  .chat-plus-panel,
  .chat-sticker-picker,
  .chat-multiselect-bar,
  .chat-modal-panel,
  .chat-fg-modal-panel,
  .chat-group-select-panel,
  .chat-avatar-modal-panel,
  .cs-modal-panel,
  .chat-npc-card,
  .profile-section,
  .profile-user-card,
  .polaroid-avatar,
  .mem-card,
  .cs-char-bar,
  .cs-section,
  .chat-quote-bar,
  .mem-stats-bar,
  .chat-load-history-btn {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  body.theme-white .chat-tab-bar { background: rgba(255,255,255,0.82); }
  body.theme-white .chat-nav-back,
  body.theme-white .chat-nav-btn { background: rgba(255,255,255,0.78); }
  body.theme-white .chat-input-bar { background: rgba(255,255,255,0.82); }
  body.theme-white .chat-plus-panel { background: rgba(255,255,255,0.82); }
  body.theme-white .chat-sticker-picker { background: rgba(255,255,255,0.82); }
  body.theme-white .chat-modal-panel,
  body.theme-white .chat-fg-modal-panel,
  body.theme-white .chat-group-select-panel,
  body.theme-white .chat-avatar-modal-panel,
  body.theme-white .cs-modal-panel { background: rgba(248,248,248,0.96); }
  body.theme-white .chat-npc-card,
  body.theme-white .profile-section,
  body.theme-white .profile-user-card { background: rgba(255,255,255,0.78); }
  body.theme-white .polaroid-avatar { background: rgba(255,255,255,0.82); }

  body.theme-white.dark-mode .chat-tab-bar { background: rgba(48,48,48,0.82); }
  body.theme-white.dark-mode .chat-nav-back,
  body.theme-white.dark-mode .chat-nav-btn { background: rgba(50,50,50,0.78); }
  body.theme-white.dark-mode .chat-input-bar { background: rgba(48,48,48,0.82); }
  body.theme-white.dark-mode .chat-plus-panel { background: rgba(48,48,48,0.82); }
  body.theme-white.dark-mode .chat-sticker-picker { background: rgba(48,48,48,0.82); }
  body.theme-white.dark-mode .chat-modal-panel,
  body.theme-white.dark-mode .chat-fg-modal-panel,
  body.theme-white.dark-mode .chat-group-select-panel,
  body.theme-white.dark-mode .chat-avatar-modal-panel,
  body.theme-white.dark-mode .cs-modal-panel { background: rgba(42,42,42,0.96); }
  body.theme-white.dark-mode .chat-npc-card,
  body.theme-white.dark-mode .profile-section,
  body.theme-white.dark-mode .profile-user-card { background: rgba(50,50,50,0.78); }

  body.theme-blue .chat-tab-bar { background: rgba(218,235,252,0.78); }
  body.theme-blue .chat-nav-back,
  body.theme-blue .chat-nav-btn { background: rgba(220,238,255,0.75); }
  body.theme-blue .chat-input-bar { background: rgba(218,235,252,0.78); }
  body.theme-blue .chat-plus-panel { background: rgba(218,235,252,0.78); }
  body.theme-blue .chat-sticker-picker { background: rgba(218,235,252,0.78); }
  body.theme-blue .chat-modal-panel,
  body.theme-blue .chat-fg-modal-panel,
  body.theme-blue .chat-group-select-panel,
  body.theme-blue .chat-avatar-modal-panel,
  body.theme-blue .cs-modal-panel { background: rgba(232,244,255,0.96); }
  body.theme-blue .chat-npc-card,
  body.theme-blue .profile-section,
  body.theme-blue .profile-user-card { background: rgba(218,235,252,0.75); }
  body.theme-blue .polaroid-avatar { background: rgba(220,238,255,0.78); }

  body.theme-blue.dark-mode .chat-tab-bar { background: rgba(32,45,62,0.78); }
  body.theme-blue.dark-mode .chat-nav-back,
  body.theme-blue.dark-mode .chat-nav-btn { background: rgba(42,58,80,0.75); }
  body.theme-blue.dark-mode .chat-input-bar { background: rgba(32,45,62,0.78); }
  body.theme-blue.dark-mode .chat-plus-panel { background: rgba(32,45,62,0.78); }
  body.theme-blue.dark-mode .chat-sticker-picker { background: rgba(32,45,62,0.78); }
  body.theme-blue.dark-mode .chat-modal-panel,
  body.theme-blue.dark-mode .chat-fg-modal-panel,
  body.theme-blue.dark-mode .chat-group-select-panel,
  body.theme-blue.dark-mode .chat-avatar-modal-panel,
  body.theme-blue.dark-mode .cs-modal-panel { background: rgba(40,55,75,0.96); }
  body.theme-blue.dark-mode .chat-npc-card,
  body.theme-blue.dark-mode .profile-section,
  body.theme-blue.dark-mode .profile-user-card { background: rgba(38,52,70,0.78); }

  /* Pink theme */
  body.theme-pink .chat-tab-bar { background: rgba(248,238,242,0.88); }
  body.theme-pink .chat-nav-back,
  body.theme-pink .chat-nav-btn { background: rgba(250,235,240,0.82); }
  body.theme-pink .chat-input-bar { background: rgba(248,238,242,0.88); }
  body.theme-pink .chat-plus-panel { background: rgba(248,238,242,0.88); }
  body.theme-pink .chat-sticker-picker { background: rgba(248,238,242,0.88); }
  body.theme-pink .chat-modal-panel,
  body.theme-pink .chat-fg-modal-panel,
  body.theme-pink .chat-group-select-panel,
  body.theme-pink .chat-avatar-modal-panel,
  body.theme-pink .cs-modal-panel { background: rgba(250,245,246,0.96); }
  body.theme-pink .chat-npc-card,
  body.theme-pink .profile-section,
  body.theme-pink .profile-user-card { background: rgba(250,235,240,0.82); }
  body.theme-pink .polaroid-avatar { background: rgba(248,239,241,0.88); }

  body.theme-pink.dark-mode .chat-tab-bar { background: rgba(55,40,48,0.82); }
  body.theme-pink.dark-mode .chat-nav-back,
  body.theme-pink.dark-mode .chat-nav-btn { background: rgba(55,40,48,0.78); }
  body.theme-pink.dark-mode .chat-input-bar { background: rgba(55,40,48,0.82); }
  body.theme-pink.dark-mode .chat-plus-panel { background: rgba(55,40,48,0.82); }
  body.theme-pink.dark-mode .chat-sticker-picker { background: rgba(55,40,48,0.82); }
  body.theme-pink.dark-mode .chat-modal-panel,
  body.theme-pink.dark-mode .chat-fg-modal-panel,
  body.theme-pink.dark-mode .chat-group-select-panel,
  body.theme-pink.dark-mode .chat-avatar-modal-panel,
  body.theme-pink.dark-mode .cs-modal-panel { background: rgba(36,30,32,0.96); }
  body.theme-pink.dark-mode .chat-npc-card,
  body.theme-pink.dark-mode .profile-section,
  body.theme-pink.dark-mode .profile-user-card { background: rgba(55,40,48,0.78); }
}

/* ===== Placeholder ===== */
.chat-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%;
  color: var(--text3); font-size: 14px; gap: 12px;
  padding: 60px 20px;
}
.chat-placeholder svg { opacity: 0.3; }

/* ===== Avatar Upload Modal ===== */
.chat-avatar-modal-panel {
  background: var(--bg); background-image: none;
  border-radius: 18px;
  padding: 20px; width: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.chat-avatar-modal-panel h3 {
  font-size: 15px; font-weight: 700; color: var(--text);
  text-align: center; margin-bottom: 12px;
}
.chat-avatar-url-input {
  width: 100%; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 13px; font-family: inherit; color: var(--text);
  outline: none; margin-bottom: 10px;
}
.chat-avatar-url-input::placeholder { color: var(--text3); }
.chat-avatar-btn-row {
  display: flex; gap: 8px; margin-bottom: 8px;
}
.chat-avatar-btn-row .btn-primary,
.chat-avatar-btn-row .btn-secondary {
  flex: 1;
}
.chat-avatar-divider {
  text-align: center; color: var(--text3); font-size: 11px;
  margin-bottom: 8px;
}

/* ===== Balance Section ===== */
.balance-actions-row {
  display: flex; gap: 8px; margin-bottom: 10px;
}
.balance-summary-row {
  display: flex; justify-content: space-between;
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 12px; font-size: 12px;
}
.balance-income-label { color: #2a9d5c; font-weight: 600; }
.balance-expense-label { color: #d45050; font-weight: 600; }
.balance-record-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--glass-border);
}
.balance-record-item:last-child { border-bottom: none; }
.balance-record-info { flex: 1; min-width: 0; }
.balance-record-note {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.balance-record-time { font-size: 11px; color: var(--text3); margin-top: 2px; }
.balance-amount-income { font-size: 14px; font-weight: 700; color: #2a9d5c; flex-shrink: 0; }
.balance-amount-expense { font-size: 14px; font-weight: 700; color: #d45050; flex-shrink: 0; }
.balance-load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
}

/* ===== Favorites ===== */
.fav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
}
.fav-item:last-child { border-bottom: none; }
.fav-item:focus-visible {
  outline: 2px solid var(--text3);
  outline-offset: 3px;
  border-radius: 8px;
}
.fav-item-thumb {
  width: 44px; height: 44px; border-radius: 8px;
  overflow: hidden; flex-shrink: 0;
  background: var(--glass); border: 1px solid var(--glass-border);
  cursor: pointer;
}
.fav-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fav-item-info { flex: 1; min-width: 0; }
.fav-item-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fav-item-content {
  font-size: 11px; color: var(--text3); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.fav-forum-post-card {
  margin: 0 0 10px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.fav-forum-post-card:last-child { margin-bottom: 0; }
.fav-forum-post-card.long-pressing { transform: scale(0.98); }
.fav-forum-type {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  color: var(--text2);
}
.fav-detail-modal-panel {
  width: min(340px, calc(100vw - 40px));
  max-height: min(76vh, 620px);
  display: flex;
  flex-direction: column;
}
.fav-detail-title {
  text-align: left;
  overflow-wrap: anywhere;
}
.fav-detail-image {
  max-width: 100%;
  max-height: 210px;
  object-fit: contain;
  border-radius: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.fav-detail-content {
  min-height: 72px;
  overflow-y: auto;
  padding: 12px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-bottom: 14px;
}

/* ===== Conversation Messages Area ===== */
.chat-messages-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 8px 16px 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  contain: layout style;
  overscroll-behavior-y: contain;
}
.chat-messages-area::-webkit-scrollbar { display: none; }

/* ===== Chat Input & Plus Panel Wrapper ===== */
.chat-input-plus-wrap {
  flex-shrink: 0;
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
}

/* ===== Chat Input Bar ===== */
.chat-input-bar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
}
.chat-input-voice-btn,
.chat-input-emoji-btn,
.chat-input-plus-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2); cursor: pointer;
  border-radius: 50%; transition: transform 0.15s, background 0.15s;
}
.chat-input-voice-btn:active,
.chat-input-emoji-btn:active,
.chat-input-plus-btn:active { transform: scale(0.9); background: var(--glass); }
.chat-input-plus-btn.send-mode { color: var(--text); }
.chat-input-wrap {
  flex: 1; min-width: 0;
  background: var(--glass-strong);
  border: 1.5px solid var(--glass-border);
  border-radius: 20px;
  padding: 6px 14px;
  display: flex; align-items: center;
}
.chat-input-field {
  width: 100%; border: none; background: transparent;
  font-size: 14px; color: var(--text);
  font-family: inherit; resize: none;
  outline: none; line-height: 1.4;
  max-height: 120px;
  scrollbar-width: none;
}
.chat-input-field::-webkit-scrollbar { display: none; }
.chat-input-field::placeholder { color: var(--text3); }

/* ===== Chat Plus Panel ===== */
.chat-plus-panel {
  display: flex; flex-direction: column; align-items: center;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  padding: 0;
  flex-shrink: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s cubic-bezier(.25,.46,.45,.94), padding 0.28s ease;
}
.chat-plus-panel.active {
  max-height: 240px;
  padding: 12px 0 8px;
  overflow: visible;
}
.chat-plus-pages {
  display: flex; width: 100%; overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chat-plus-pages::-webkit-scrollbar { display: none; }
.chat-plus-page {
  min-width: 100%; flex-shrink: 0;
  scroll-snap-align: start;
  padding: 0 16px;
}
.chat-plus-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px 12px;
}
.chat-plus-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; cursor: pointer; transition: transform 0.15s;
}
.chat-plus-item:active { transform: scale(0.92); }
.chat-plus-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--glass-strong);
  border: 1.5px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); box-shadow: 0 2px 8px var(--glass-shadow);
  overflow: hidden;
}
.chat-plus-icon.has-custom-icon,
.chat-nav-btn.has-custom-icon {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: hidden;
}
.chat-plus-icon.has-custom-icon img,
.chat-nav-btn.has-custom-icon img {
  width: 100% !important; height: 100% !important; object-fit: cover !important; border-radius: inherit;
}
.chat-plus-label {
  font-size: 11px; color: var(--text2); font-weight: 500;
  text-align: center; max-width: 64px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-plus-dots {
  display: flex; gap: 6px; justify-content: center;
  padding: 8px 0 0;
}
.chat-plus-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text3); opacity: 0.4;
  transition: all 0.3s;
}
.chat-plus-dot.active {
  width: 16px; border-radius: 3px; opacity: 1;
  background: var(--text);
}

/* ===== Chat Settings Body ===== */
.chat-settings-body {
  flex: 1; overflow-y: auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom, 0px));
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chat-settings-body::-webkit-scrollbar { display: none; }

/* ===== Chat Sidebar Mask ===== */
.chat-sidebar-mask {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 805; background: rgba(0,0,0,0.35);
}

/* ===== Chat Settings (cs-*) ===== */

/* Character info bar */
.cs-char-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--glass);
  border: 1.5px solid var(--glass-border);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 2px 10px var(--glass-shadow);
}
.cs-char-avatar {
  width: 52px; height: 52px; flex-shrink: 0;
  border-radius: 14px; overflow: hidden;
  background: var(--glass-strong);
  border: 1.5px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
}
.cs-char-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.cs-char-info {
  flex: 1; min-width: 0;
}
.cs-char-name {
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cs-char-sig {
  font-size: 12px; color: var(--text3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cs-char-sig-input {
  width: 100%; font-size: 12px; color: var(--text3);
  border: none; border-bottom: 1px dashed transparent;
  background: transparent; outline: none;
  font-family: inherit; padding: 2px 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color 0.2s, color 0.2s;
}
.cs-char-sig-input::placeholder { color: var(--text3); opacity: 0.6; }
.cs-char-sig-input:focus {
  border-bottom-color: var(--text3);
  color: var(--text2);
}
.cs-char-arrow {
  flex-shrink: 0; color: var(--text3);
}

/* Section containers */
.cs-section {
  margin-top: 12px;
  background: var(--glass);
  border: 1.5px solid var(--glass-border);
  border-radius: 16px;
  overflow: hidden;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 2px 10px var(--glass-shadow);
}
.cs-item {
  display: flex; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer; gap: 8px;
}
.cs-item:last-child { border-bottom: none; }
#csAutoReplySection:not(.active) .cs-item:first-child { border-bottom: none; }
.cs-item-label {
  flex: 1;
  font-size: 14px; font-weight: 500; color: var(--text);
}
.cs-item-value {
  font-size: 13px; color: var(--text3);
  max-width: 50%;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  text-align: right;
}
.cs-item-col {
  display: flex; flex-direction: column;
  cursor: default;
}
.cs-item-row {
  display: flex; align-items: center;
  width: 100%; gap: 8px;
}
.cs-item-badge {
  font-size: 13px; font-weight: 600; color: var(--text);
  min-width: 36px; text-align: center;
}

/* Slider */
.cs-slider {
  width: 100%; height: 6px;
  background: var(--glass-border);
  border-radius: 3px;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  touch-action: none;
  cursor: pointer;
  padding: 8px 0;
  margin: 4px 0;
  background-clip: content-box;
}
.cs-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--glass-border);
}
.cs-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 10px var(--glass-shadow), 0 1px 3px rgba(0,0,0,0.12);
  margin-top: -8px;
  transition: transform 0.1s ease;
}
.cs-slider::-webkit-slider-thumb:active {
  transform: scale(1.15);
}
.cs-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--glass-border);
  border: none;
}
.cs-slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 10px var(--glass-shadow), 0 1px 3px rgba(0,0,0,0.12);
}
.cs-slider::-moz-range-thumb:active {
  transform: scale(1.15);
}

/* Switch toggle */
.cs-switch {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.cs-switch input {
  opacity: 0; width: 0; height: 0;
}
.cs-switch-slider {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(120,120,120,0.3);
  border: 1.5px solid rgba(120,120,120,0.25);
  border-radius: 12px;
  transition: background 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}
.cs-switch-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
  left: 2px; top: 50%; transform: translateY(-50%);
}
.cs-switch input:checked + .cs-switch-slider {
  background: var(--text);
  border-color: var(--text);
}
.cs-switch input:checked + .cs-switch-slider::before {
  transform: translateY(-50%) translateX(20px);
}
.cs-switch input:disabled + .cs-switch-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Placeholder tag */
.cs-tag-placeholder {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--glass);
  color: var(--text3);
  margin-left: auto;
}

/* ===== Group Member Management ===== */
.gm-member-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--glass); cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 6px;
}
.gm-member-item:active { background: var(--glass-strong); }
.gm-member-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  background: var(--glass);
  display: flex; align-items: center; justify-content: center;
}
.gm-member-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.gm-member-info {
  flex: 1; min-width: 0;
}
.gm-member-name {
  font-size: 14px; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.gm-member-title {
  font-size: 11px; color: var(--text3);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gm-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 6px;
  flex-shrink: 0; line-height: 1.4;
}
.gm-badge-owner {
  background: #f0c040; color: #5a4200;
}
.gm-badge-admin {
  background: #4dabf7; color: #fff;
}
.gm-badge-muted {
  background: #ff6b6b; color: #fff;
}
.gm-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  margin: 10px 2px 6px;
}
.gm-invite-request {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--glass);
  margin-bottom: 6px;
}
.gm-request-main {
  flex: 1; min-width: 0;
}
.gm-request-title {
  font-size: 13px; color: var(--text);
  margin-bottom: 3px;
}
.gm-request-names,
.gm-request-status {
  font-size: 12px; color: var(--text3);
  line-height: 1.35;
}
.gm-request-actions {
  display: flex; gap: 6px; flex-shrink: 0;
}
.gm-request-btn {
  border: none; border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px; font-family: inherit;
  color: #fff; cursor: pointer;
}
.gm-request-btn.approve { background: #4dabf7; }
.gm-request-btn.reject { background: #ff6b6b; }
.gm-action-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: 10px;
  background: var(--glass); cursor: pointer;
  font-size: 14px; color: var(--text);
  transition: background 0.15s;
  margin-bottom: 6px;
}
.gm-action-btn:active { background: var(--glass-strong); }
.gm-action-btn.danger { color: #ff6b6b; }
.gm-action-btn svg { flex-shrink: 0; }

.gm-invite-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--glass); cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 6px;
}
.gm-invite-item:active { background: var(--glass-strong); }
.gm-invite-item.selected { background: var(--glass-strong); }
.gm-invite-check {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s, border-color 0.15s;
}
.gm-invite-check.checked {
  background: var(--text); border-color: var(--text);
}
.gm-invite-check svg { display: none; }
.gm-invite-check.checked svg { display: block; }

/* Danger section */
.cs-danger-section {
  background: transparent;
  border: none;
  display: flex; flex-direction: column;
  gap: 10px;
  padding: 0;
}
.cs-danger-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 16px;
  border-radius: 16px;
  background: var(--glass-strong);
  border: 1.5px solid var(--glass-border);
  color: var(--text);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.cs-danger-btn:active {
  transform: scale(0.98);
  opacity: 0.8;
}
.cs-delete-btn {
  color: #e55;
  border-color: rgba(220,50,50,0.3);
}

/* Persona list */
.cs-persona-list {
  display: flex; flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px 0;
}
.cs-persona-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--glass); cursor: pointer;
  transition: background 0.15s;
  overflow: hidden;
}
.cs-persona-item:active { background: var(--glass-strong); }
.cs-persona-item.selected {
  background: var(--glass-strong);
  box-shadow: inset 0 0 0 1.5px var(--text);
}
.cs-persona-item-avatar {
  width: 36px; height: 36px; min-width: 36px; min-height: 36px;
  max-width: 36px; max-height: 36px;
  border-radius: 50%; overflow: hidden; flex-shrink: 0;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-strong); color: var(--text2);
}
.cs-persona-item-avatar img {
  width: 36px; height: 36px; max-width: 36px; max-height: 36px;
  object-fit: cover; display: block;
}
.cs-persona-item-info {
  flex: 1; min-width: 0;
}
.cs-persona-item-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cs-persona-item-id {
  font-size: 11px; color: var(--text3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* API form */
.cs-api-form {
  display: flex; flex-direction: column;
  gap: 10px;
}
.cs-api-label {
  font-size: 13px; font-weight: 600;
  color: var(--text2);
}
.cs-api-model-row {
  display: flex; gap: 8px; align-items: center;
}
.cs-api-model-list {
  display: flex; flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
}
.cs-api-model-item {
  padding: 6px 12px; border-radius: 8px;
  background: var(--glass); color: var(--text);
  font-size: 12px; cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.cs-api-model-item:active { background: var(--glass-strong); }
.cs-api-hint {
  font-weight: 400;
  color: var(--text3);
  margin-left: 4px;
}
.cs-api-hint-desc {
  font-size: 11px;
  color: var(--text3);
  margin-top: -6px;
  line-height: 1.4;
}

/* Stats table */
.cs-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cs-stats-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text);
}
.cs-stats-table td:first-child {
  font-weight: 600;
  color: var(--text2);
  width: 40%;
}
.cs-stats-table tr:last-child td {
  border-bottom: none;
}

/* Modal panel (chat settings modals) */
.cs-modal-panel {
  max-height: 80vh;
  overflow-y: auto;
  background: var(--bg); background-image: none;
  border-radius: 18px;
  padding: 20px; width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.cs-modal-panel .btn-primary,
.cs-modal-panel .btn-secondary {
  padding: 10px 16px;
  font-size: 13px;
  border-radius: 12px;
  font-weight: 600;
}
.cs-api-modal {
  max-width: 380px;
}

/* Daily schedule modal */
#chatScheduleModal.keyboard-safe-modal {
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#chatScheduleModal.keyboard-safe-modal > .chat-schedule-modal {
  margin-top: 0;
}
.chat-schedule-modal {
  width: min(380px, calc(100vw - 32px));
  max-height: min(82vh, calc(var(--app-visual-viewport-height, 100vh) - 40px));
  overflow-y: auto;
}
.chat-schedule-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.chat-schedule-header .chat-modal-title {
  margin-bottom: 2px;
  text-align: left;
}
.chat-schedule-target {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.4;
  word-break: break-word;
}
.chat-schedule-close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--glass);
  color: var(--text2);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-schedule-question {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text2);
  padding: 10px 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  border-radius: 10px;
  margin-bottom: 12px;
}
.chat-schedule-body {
  min-height: 64px;
}
.chat-schedule-empty,
.chat-schedule-loading {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text3);
  font-size: 13px;
  text-align: center;
}
.chat-schedule-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: chatScheduleSpin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes chatScheduleSpin {
  to { transform: rotate(360deg); }
}
.chat-schedule-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-schedule-member-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-schedule-member-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  line-height: 1.4;
}
.chat-schedule-member {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass);
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}
.chat-schedule-member.active {
  border-color: var(--text);
  background: var(--glass-strong);
}
.chat-schedule-member-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--glass-strong);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
}
.chat-schedule-member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.chat-schedule-member-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-schedule-member-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-schedule-member-role {
  font-size: 11px;
  color: var(--text3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-schedule-member-picker + .chat-schedule-result,
.chat-schedule-member-picker + .chat-schedule-empty {
  margin-top: 12px;
}
.chat-schedule-date {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.chat-schedule-meta {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
}
.chat-schedule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}
.chat-schedule-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass);
}
.chat-schedule-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  white-space: nowrap;
}
.chat-schedule-item-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.chat-schedule-did {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}
.chat-schedule-thought {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text3);
  word-break: break-word;
}
.chat-schedule-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.chat-schedule-actions .btn-secondary,
.chat-schedule-actions .btn-primary {
  flex: 1;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 15px;
}
.chat-schedule-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ===== Memory Page ===== */
.mem-stats-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 0; padding: 12px 16px; flex-shrink: 0;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
}
.mem-stats-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; flex: 1;
}
.mem-stats-value {
  font-size: 18px; font-weight: 700; color: var(--text);
}
.mem-stats-label {
  font-size: 11px; color: var(--text3); font-weight: 500;
}
.mem-stats-divider {
  width: 1px; height: 28px; background: var(--glass-border); flex-shrink: 0;
}

.mem-tabs {
  display: flex; gap: 0; padding: 8px 16px 0; flex-shrink: 0;
}
.mem-tab {
  flex: 1; text-align: center; padding: 10px 0; font-size: 13px;
  font-weight: 600; color: var(--text3); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.mem-tab.active {
  color: var(--text); border-bottom-color: var(--text);
}

.mem-body {
  flex: 1; overflow: hidden; position: relative;
}
.mem-tab-panel {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  overflow-y: auto; padding: 12px 16px 80px;
  display: none; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.mem-tab-panel::-webkit-scrollbar { display: none; }
.mem-tab-panel.active { display: block; }

.mem-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 20px;
  color: var(--text3); font-size: 14px; gap: 8px;
}
.mem-empty svg { opacity: 0.25; }
.mem-empty-hint {
  font-size: 12px; color: var(--text3); opacity: 0.7;
}

.mem-card {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1.5px solid var(--glass-border);
  border-radius: 16px; padding: 14px 16px;
  margin-bottom: 10px; cursor: pointer;
  box-shadow: 0 2px 10px var(--glass-shadow);
  transition: transform 0.15s, opacity 0.15s;
}
.mem-card:active { transform: scale(0.98); opacity: 0.8; }
.mem-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.mem-card-index {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 20px; padding: 2px 8px; border-radius: 8px;
  background: var(--glass); color: var(--text3);
  font-size: 10px; font-weight: 700; line-height: 1;
}
.mem-card-content {
  font-size: 13px; color: var(--text); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden;
}
.mem-card-time {
  font-size: 11px; color: var(--text3); margin-top: 8px;
}
.mem-card-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 8px; margin-bottom: 6px;
  background: rgba(255,180,60,0.15); color: #d4940a;
}
.dark-mode .mem-card-badge {
  background: rgba(255,180,60,0.2); color: #f0b840;
}
.mem-card-core { border-left: 3px solid #f0b840; }
.mem-card-storyline {
  display: flex; align-items: flex-start; gap: 12px;
}
.mem-card-storyline-avatar {
  width: 44px; height: 44px; min-width: 44px; border-radius: 8px;
  overflow: hidden; flex-shrink: 0;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
}
.mem-card-storyline-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.mem-card-storyline-body {
  flex: 1; min-width: 0;
}
.mem-card-storyline-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}

.mem-add-btn {
  position: absolute; bottom: 24px; right: 20px;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--text); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: transform 0.15s;
  z-index: 5;
}
.mem-add-btn:active { transform: scale(0.9); }

/* Memory Settings Modal */
.mem-settings-panel {
  max-width: 360px;
}
.mem-set-section {
  background: var(--glass-strong);
  border: 1.5px solid var(--glass-border);
  border-radius: 14px; padding: 12px 14px;
  margin-bottom: 10px;
}
.mem-set-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
}
.mem-set-header-label {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.mem-set-arrow {
  color: var(--text3); transition: transform 0.2s;
}
.mem-set-arrow.collapsed { transform: rotate(-90deg); }
.mem-set-item {
  display: flex; align-items: center; justify-content: space-between;
}
.mem-set-item-label {
  font-size: 14px; font-weight: 500; color: var(--text);
}
.mem-set-title {
  font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px;
}
.mem-set-interval {
  display: flex; align-items: center; gap: 6px; margin-top: 10px;
}
.mem-set-hint {
  font-size: 12px; color: var(--text3);
}
.mem-set-num-input {
  width: 56px; padding: 6px 8px; border-radius: 10px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass); font-size: 13px; font-weight: 600;
  color: var(--text); text-align: center;
  font-family: inherit; outline: none;
}
.mem-set-round-info {
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.mem-set-round-badge {
  font-size: 13px; font-weight: 700; color: var(--text);
  background: var(--glass); padding: 2px 10px; border-radius: 8px;
}
.mem-set-range-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
}
.mem-set-sum-btn {
  width: 100%; padding: 10px; border: none; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: opacity 0.15s;
}
.mem-set-sum-btn:active { opacity: 0.8; }
.mem-set-sum-btn:disabled {
  opacity: 0.45; cursor: not-allowed;
}
.mem-set-close-btn {
  width: 100%; padding: 10px; border: 1.5px solid var(--glass-border);
  border-radius: 12px; background: var(--glass-strong);
  font-size: 14px; font-weight: 600; color: var(--text);
  cursor: pointer; font-family: inherit; margin-top: 4px;
  transition: opacity 0.15s;
}
.mem-set-close-btn:active { opacity: 0.7; }

/* Memory Edit Modal */
.mem-edit-panel {
  max-width: 360px;
}
.mem-edit-delete-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px; margin-top: 8px;
  border: 1.5px solid rgba(220,50,50,0.3); border-radius: 12px;
  background: transparent; color: #e55;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: opacity 0.15s;
}
.mem-edit-delete-btn:active { opacity: 0.7; }

/* Memory Refine Modal */
.mem-refine-panel {
  max-width: 420px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.mem-refine-meta {
  font-size: 12px;
  color: var(--text3);
  margin: -2px 0 10px;
  line-height: 1.4;
}
.mem-refine-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
  margin-right: -2px;
}
.mem-refine-item {
  border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  border-radius: 12px;
  padding: 10px;
}
.mem-refine-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.mem-refine-item-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.mem-refine-remove-btn {
  border: 1.5px solid rgba(220,50,50,0.25);
  background: transparent;
  color: #e55;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.mem-refine-item-input {
  min-height: 82px;
  resize: vertical;
}
.mem-refine-add-btn {
  width: 100%;
  padding: 9px 10px;
  margin-top: 10px;
  border: 1.5px dashed var(--glass-border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.mem-refine-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-shrink: 0;
}

/* ===== Mode Indicator ===== */
.chat-mode-indicator {
  font-size: 11px !important; font-weight: 700;
  padding: 0 10px !important; width: auto !important;
  border-radius: 14px !important;
  background: linear-gradient(135deg, rgba(100,200,255,0.2), rgba(100,150,255,0.3)) !important;
  color: var(--text) !important;
  pointer-events: none;
  letter-spacing: 1px;
}

/* ===== Offline Mode Page ===== */
#chatOfflinePage {
  z-index: 815;
}
#chatConvSettingsPage {
  z-index: 820;
}
#memoryPage {
  z-index: 825;
}
#chatOfflinePage .chat-conv-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  flex-shrink: 0;
}
#chatOfflinePage .chat-messages-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 8px 16px 16px;
  scrollbar-width: none;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
#chatOfflinePage .chat-messages-area::-webkit-scrollbar { display: none; }
#chatOfflinePage .chat-input-bar {
  position: relative;
  flex-shrink: 0;
  z-index: 15;
}
#chatOfflinePage .chat-input-plus-btn.active {
  background: var(--glass);
}
#chatOfflinePage .chat-input-plus-btn.active svg {
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}
.chat-offline-plus-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.chat-offline-plus-panel {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translate(-50%, 8px) scale(0.96);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 30;
}
.chat-offline-plus-panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}
.chat-offline-plus-menu-btn {
  min-width: 78px;
  height: 44px;
  border-radius: 14px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: 0 4px 16px var(--glass-shadow);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  padding: 0 12px;
  transition: transform 0.15s, opacity 0.15s;
}
.chat-offline-plus-menu-btn:active {
  transform: scale(0.92);
}
.chat-offline-plus-menu-btn svg {
  display: block;
  flex-shrink: 0;
}
.chat-offline-plus-menu-label {
  display: block;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.chat-conv-nav-title-wrap {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  line-height: 1.2;
}
.chat-conv-nav-title-wrap .chat-conv-nav-title {
  position: static; left: auto; transform: none;
}
.chat-conv-nav-subtitle {
  font-size: 11px; color: var(--text3); font-weight: 400;
  white-space: nowrap;
}
.chat-online-status {
  color: #4caf50;
  transition: color 0.2s;
}
.chat-online-status.is-typing {
  color: var(--text3);
}

.chat-input-send-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer;
  border-radius: 50%; transition: transform 0.15s, background 0.15s;
}
.chat-input-send-btn:active { transform: scale(0.9); background: var(--glass); }
.chat-input-send-btn.is-loading {
  pointer-events: none;
  opacity: 0.6;
}
.offline-send-spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--glass-border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: offlineSpin 0.8s linear infinite;
}
@keyframes offlineSpin {
  to { transform: rotate(360deg); }
}

/* ===== Typing Indicator ===== */
.chat-typing-bubble {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 18px !important;
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text3);
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ===== Reply Interval Input (Inline) ===== */
.cs-interval-inline-item {
  display: flex; align-items: center; gap: 6px;
}
.cs-interval-inline-input {
  width: 52px; padding: 4px 8px;
  border: 1.5px solid var(--glass-border);
  border-radius: 8px; background: var(--glass-strong);
  color: var(--text); font-size: 14px; font-family: inherit;
  text-align: center; outline: none;
  -moz-appearance: textfield;
}
.cs-interval-inline-input:focus { border-color: var(--text3); }
.cs-interval-inline-input::-webkit-outer-spin-button,
.cs-interval-inline-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.cs-item-hint {
  font-size: 11px; color: var(--text3); margin-left: 4px;
}

/* ===== World Book Group Binding ===== */
.cs-wb-group-list {
  max-height: 300px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 4px 0;
}
.cs-wb-group-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--glass); cursor: pointer;
  transition: background 0.15s;
}
.cs-wb-group-item:active { background: var(--glass-strong); }
.cs-wb-group-item.selected { background: var(--glass-strong); }
.cs-wb-check {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s, border-color 0.15s;
}
.cs-wb-check.checked {
  background: var(--text); border-color: var(--text);
}
.cs-wb-check svg { display: none; }
.cs-wb-check.checked svg { display: block; }
.cs-wb-group-item span:nth-child(2) {
  flex: 1; font-size: 14px; color: var(--text);
}
.cs-wb-entries-count {
  font-size: 11px; color: var(--text3);
}

/* ===== Reply Settings Modal ===== */
.cs-reply-section {
  background: var(--glass);
  border-radius: 12px;
  padding: 14px;
}
.cs-reply-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.cs-reply-section-desc {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 10px;
}
.cs-reply-range-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.cs-reply-range-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cs-reply-range-input-wrap label {
  font-size: 11px;
  color: var(--text3);
}
.cs-reply-range-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-strong);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}
.cs-reply-range-input:focus {
  border-color: var(--text3);
}
.cs-reply-range-input::-webkit-outer-spin-button,
.cs-reply-range-input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.cs-reply-range-sep {
  font-size: 16px;
  color: var(--text3);
  padding-bottom: 8px;
  flex-shrink: 0;
}
.cs-reply-range-unit {
  font-size: 13px;
  color: var(--text3);
  padding-bottom: 8px;
  flex-shrink: 0;
}

/* ===== Side Theater ===== */
#sideTheaterPage {
  z-index: 818;
}
#sideTheaterPage .chat-conv-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  flex-shrink: 0;
}
#sideTheaterPage .chat-conv-nav-title-wrap {
  width: calc(100% - 128px);
  max-width: calc(100% - 128px);
  min-width: 0;
  overflow: hidden;
}
#sideTheaterPage .chat-conv-nav-title,
#sideTheaterPage .chat-conv-nav-subtitle {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.side-theater-page-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 20px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.side-theater-page-body::-webkit-scrollbar { display: none; }
.side-theater-modal-panel {
  width: min(360px, calc(100vw - 32px));
  max-height: min(84vh, 680px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.side-theater-modal-head {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 8px;
}
.side-theater-modal-head .side-theater-icon-btn:first-child {
  grid-column: 1;
}
.side-theater-modal-head .chat-modal-title {
  grid-column: 2;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-theater-modal-head .side-theater-icon-btn:last-child {
  grid-column: 3;
}
.side-theater-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--glass);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, background 0.15s;
}
.side-theater-icon-btn:active { transform: scale(0.92); background: var(--glass-strong); }
.side-theater-modal-view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.side-theater-modal-view::-webkit-scrollbar { display: none; }
.side-theater-modal-view.active {
  display: flex;
  flex-direction: column;
}
.side-theater-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin: 8px 0 6px;
}
.side-theater-prompt {
  min-height: 120px;
  resize: none;
}
.side-theater-format-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.side-theater-format-tab {
  height: 38px;
  border: 1.5px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}
.side-theater-format-tab span {
  font-size: 12px;
  color: inherit;
}
.side-theater-format-tab.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.side-theater-format-tab:active { transform: scale(0.97); }
.side-theater-format-note {
  display: none;
  margin: 8px 0 2px;
  padding: 9px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text3);
  font-size: 11px;
  line-height: 1.55;
}
.side-theater-format-note.active {
  display: block;
}
.side-theater-word-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.side-theater-word-row.is-disabled {
  opacity: 0.45;
}
.side-theater-unlimited {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 8px;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.side-theater-unlimited input {
  width: 16px;
  height: 16px;
  accent-color: var(--text);
}
.side-theater-history-btn {
  width: 100%;
  height: 40px;
  border: 1.5px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 12px;
  transition: transform 0.15s, background 0.15s;
}
.side-theater-history-btn:active { transform: scale(0.98); background: var(--glass-strong); }
.side-theater-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.side-theater-actions button {
  flex: 1;
  height: 42px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.side-theater-actions button:active { transform: scale(0.97); }
.side-theater-actions button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}
.side-theater-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-theater-empty {
  padding: 36px 10px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}
.side-theater-history-card {
  display: flex;
  gap: 10px;
  padding: 11px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.side-theater-history-card:active { transform: scale(0.985); background: var(--glass-strong); }
.side-theater-history-main {
  flex: 1;
  min-width: 0;
}
.side-theater-history-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-theater-history-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-theater-history-preview {
  margin-top: 6px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.side-theater-delete-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, color 0.15s;
}
.side-theater-delete-btn:active {
  transform: scale(0.9);
  background: rgba(255, 80, 80, 0.12);
  color: #e54b4b;
}
.side-theater-detail {
  max-width: 760px;
  margin: 0 auto;
}
.side-theater-detail-prompt {
  border: 1px solid var(--glass-border);
  background: var(--glass);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.side-theater-detail-label {
  color: var(--text3);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
}
.side-theater-detail-content {
  min-height: calc(100vh - 150px);
}
.side-theater-text-content {
  color: var(--text);
  font-size: 16px;
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding: 16px 2px 28px;
}
.side-theater-html-frame {
  width: 100%;
  min-height: calc(100vh - 155px);
  height: calc(100vh - 155px);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: #fff;
  display: block;
}

/* ===== Message Context Menu (WeChat-style Popup) ===== */
.chat-ctx-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 900;
  display: none;
}
.chat-ctx-overlay.active { display: block; }
.chat-popup-menu {
  position: fixed;
  z-index: 901;
  background: #4c4c4c;
  border-radius: 10px;
  padding: 6px 2px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
  display: none;
  opacity: 0;
  transform: scale(0.75);
  transition: opacity 0.18s ease, transform 0.2s cubic-bezier(.34,1.56,.64,1);
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-popup-menu.active {
  display: block;
  opacity: 1;
  transform: scale(1);
}
.chat-popup-menu-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 322px;
}
.chat-popup-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 46px;
  padding: 8px 2px 6px;
  cursor: pointer;
  color: #fff;
  border-radius: 6px;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.chat-popup-menu-item:active {
  background: rgba(255,255,255,0.12);
}
.chat-popup-menu-item svg {
  width: 18px; height: 18px;
  margin-bottom: 3px;
  color: #fff;
}
.chat-popup-menu-item span {
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
  color: #ddd;
}
.chat-popup-menu-item.danger svg { color: #ff6b6b; }
.chat-popup-menu-item.danger span { color: #ff6b6b; }
.chat-popup-menu-arrow {
  position: absolute;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}
.chat-popup-menu-arrow.arrow-down {
  bottom: -7px;
  border-top: 8px solid #4c4c4c;
}
.chat-popup-menu-arrow.arrow-up {
  top: -7px;
  border-bottom: 8px solid #4c4c4c;
}

/* ===== Edit Message Modal ===== */
.chat-edit-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 910;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  will-change: opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-edit-overlay.active { opacity: 1; pointer-events: auto; }
.chat-edit-overlay .chat-edit-panel {
  transform: scale(0.92) translateY(8px);
  transition: transform 0.25s cubic-bezier(.25,.46,.45,.94);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-edit-overlay.active .chat-edit-panel {
  transform: scale(1) translateY(0);
}
.chat-edit-panel {
  background: var(--bg); background-image: none;
  border-radius: 18px;
  padding: 20px; width: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.chat-edit-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  text-align: center; margin-bottom: 12px;
}
.chat-edit-textarea {
  width: 100%; min-height: 100px; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  font-size: 14px; font-family: inherit; color: var(--text);
  outline: none; resize: vertical; line-height: 1.5;
}
.chat-edit-textarea:focus { border-color: var(--text2); }
.chat-edit-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 8px;
}
.chat-edit-split-btn {
  min-width: 58px;
  height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.chat-edit-split-btn.active {
  background: #000;
  border-color: #000;
  color: #fff;
}
.chat-edit-split-btn:active { transform: scale(0.96); }
.chat-edit-btns {
  display: flex; gap: 8px; margin-top: 12px;
}
.chat-edit-btn {
  flex: 1; padding: 10px;
  border-radius: 12px; border: none;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: transform 0.15s;
}
.chat-edit-btn:active { transform: scale(0.97); }
.chat-edit-btn-cancel {
  background: var(--glass-strong); color: var(--text2);
  border: 1.5px solid var(--glass-border);
}
.chat-edit-btn-save {
  background: var(--text); color: var(--bg);
}

/* ===== Multi-select Mode ===== */
.chat-messages-area.multiselect .chat-msg-row {
  position: relative;
}
.chat-msg-select-check {
  display: none;
  width: 24px; height: 24px; min-width: 24px;
  margin: 6px 0 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  background: transparent;
  -webkit-appearance: none; appearance: none;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-messages-area.multiselect .chat-msg-select-check {
  display: flex;
}
.chat-msg-select-check::after {
  content: '';
  display: none;
  width: 6px; height: 10px;
  border: solid var(--bg); border-width: 0 2.5px 2.5px 0;
  transform: translateY(-1px) rotate(45deg);
}
.chat-msg-select-check:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.chat-messages-area.multiselect .chat-msg-row.selected .chat-msg-select-check {
  background: var(--text); border-color: var(--text);
}
.chat-messages-area.multiselect .chat-msg-row.selected .chat-msg-select-check::after {
  display: block;
}
.chat-multiselect-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, padding 0.25s ease, opacity 0.2s ease;
}
.chat-multiselect-bar.active {
  max-height: 60px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  opacity: 1;
}
.chat-multiselect-cancel {
  font-size: 14px; color: var(--text2); cursor: pointer;
  padding: 8px 16px; font-weight: 500;
}
.chat-multiselect-cancel:active { opacity: 0.7; }
.chat-multiselect-count {
  font-size: 13px; color: var(--text3);
}
.chat-multiselect-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-multiselect-forward,
.chat-multiselect-favorite,
.chat-multiselect-delete {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 10px;
  transition: opacity 0.15s;
}
.chat-multiselect-forward {
  color: var(--text);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
}
.chat-multiselect-forward svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
}
.chat-multiselect-forward:active { opacity: 0.7; }
.chat-multiselect-favorite {
  color: var(--text);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
}
.chat-multiselect-favorite svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
}
.chat-multiselect-favorite:active { opacity: 0.7; }
.chat-multiselect-delete {
  color: #e55;
  background: rgba(220,50,50,0.1);
}
.chat-multiselect-delete svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: #e55;
}
.chat-multiselect-delete:active { opacity: 0.7; }

/* ===== Quote Bar (above input) ===== */
.chat-quote-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.chat-quote-bar.active {
  display: flex;
}
.chat-quote-bar-left {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.chat-quote-bar-line {
  width: 3px;
  border-radius: 2px;
  background: var(--text);
  flex-shrink: 0;
  opacity: 0.6;
}
.chat-quote-bar-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.chat-quote-bar-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-quote-bar-preview {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-quote-bar-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text3);
  flex-shrink: 0;
  border-radius: 50%;
  transition: background 0.15s;
}
.chat-quote-bar-close:active {
  background: var(--glass-strong);
}

/* ===== Quote Block (inside bubble) ===== */
.chat-quote-block {
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: rgba(0,0,0,0.06);
  border-left: 3px solid var(--text3);
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-quote-block:active {
  opacity: 0.6;
}
.msg-right .chat-quote-block {
  background: rgba(255,255,255,0.15);
  border-left-color: rgba(255,255,255,0.5);
}
.dark-mode .chat-quote-block {
  background: rgba(255,255,255,0.08);
}
.chat-quote-name {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: 2px;
}
.chat-quote-text {
  font-size: 12px;
  opacity: 0.7;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* Quote highlight animation */
@keyframes quoteHighlight {
  0% { box-shadow: 0 0 0 0 rgba(100,180,255,0.5); }
  50% { box-shadow: 0 0 0 4px rgba(100,180,255,0.3); }
  100% { box-shadow: 0 0 0 0 rgba(100,180,255,0); }
}
.chat-msg-row.chat-quote-highlight {
  animation: quoteHighlight 1s ease-out 2;
  border-radius: 12px;
}

/* ===== Bubble Float-in Animation ===== */
@keyframes bubbleFloatIn {
  0% { opacity: 0; transform: translateY(16px) scale(0.97); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-msg-row.bubble-animate {
  animation: bubbleFloatIn 0.38s cubic-bezier(.23,1,.32,1) both;
}
.chat-msg-time-divider.bubble-animate {
  animation: bubbleFloatIn 0.28s cubic-bezier(.23,1,.32,1) both;
}
.chat-system-msg.bubble-animate {
  animation: bubbleFloatIn 0.28s cubic-bezier(.23,1,.32,1) both;
}

/* ===== Load History Button ===== */
.chat-load-history-bar {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 0 6px;
}
.chat-load-history-btn {
  padding: 6px 18px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--glass-border);
  font-size: 12px; color: var(--text3); font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.chat-load-history-btn:active { transform: scale(0.96); opacity: 0.7; }

/* ===== Sticker Picker Panel (WeChat-style) ===== */
.chat-sticker-picker {
  display: flex; flex-direction: column;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s cubic-bezier(.25,.46,.45,.94);
}
.chat-sticker-picker.active {
  max-height: 260px;
}
.sticker-picker-tabs {
  display: flex; align-items: center;
  padding: 6px 8px 0;
  gap: 2px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--glass-border);
}
.sticker-picker-tabs::-webkit-scrollbar { display: none; }
.sticker-picker-tab {
  padding: 6px 12px;
  font-size: 12px; font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  flex-shrink: 0;
}
.sticker-picker-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 600;
}
.sticker-picker-grid {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow-y: auto; overflow-x: hidden;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.sticker-picker-grid::-webkit-scrollbar { display: none; }
.sticker-picker-item {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  transition: transform 0.12s;
}
.sticker-picker-item:active { transform: scale(0.92); }
#chatConvPage .chat-sticker-picker .sticker-picker-item > img,
.chat-sticker-picker .sticker-picker-item > img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
}
.sticker-picker-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--text2);
  background: linear-gradient(transparent, rgba(255,255,255,0.85));
  padding: 8px 2px 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.dark-mode .sticker-picker-label {
  background: linear-gradient(transparent, rgba(30,30,30,0.85));
}
.sticker-picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
  color: var(--text3);
  font-size: 13px;
}

/* Sticker message bubble */
.chat-msg-bubble.sticker-bubble {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 2px !important;
  max-width: 120px;
  color: inherit !important;
}
.msg-right .chat-msg-bubble.sticker-bubble {
  background: transparent !important;
  border: none !important;
}
.chat-msg-bubble.sticker-bubble img {
  width: 100%; height: auto; max-height: 120px;
  object-fit: contain; border-radius: 8px;
}

/* ===== System Message (WeChat-style) ===== */
.chat-system-msg {
  text-align: center; padding: 6px 16px;
  font-size: 12px; color: var(--text3);
  display: flex; justify-content: center;
}
.chat-system-msg-inner {
  display: inline-block;
  background: rgba(0,0,0,0.06);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text3);
  line-height: 1.5;
  max-width: 80%;
  word-break: break-word;
}
.dark-mode .chat-system-msg-inner {
  background: rgba(255,255,255,0.08);
}
.chat-system-recall {
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-system-recall:active {
  opacity: 0.6;
}

/* ===== 拍一拍 Pat-Pat System Message ===== */
.chat-pat-msg {
  padding: 4px 16px;
}
.chat-pat-inner {
  background: rgba(0,0,0,0.04) !important;
  border-radius: 6px !important;
  padding: 4px 12px !important;
  font-size: 11.5px !important;
  color: var(--text3) !important;
  display: inline-flex !important;
  align-items: center;
  gap: 2px;
  animation: patShake 0.5s ease;
}
.dark-mode .chat-pat-inner {
  background: rgba(255,255,255,0.06) !important;
}
.pat-icon {
  font-size: 13px;
  display: inline-block;
  animation: patWave 0.6s ease;
}
@keyframes patShake {
  0% { transform: translateX(0); }
  15% { transform: translateX(-3px); }
  30% { transform: translateX(3px); }
  45% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}
@keyframes patWave {
  0% { transform: rotate(0deg); }
  20% { transform: rotate(20deg); }
  40% { transform: rotate(-15deg); }
  60% { transform: rotate(12deg); }
  80% { transform: rotate(-5deg); }
  100% { transform: rotate(0deg); }
}

/* avatar hover hint for pat */
.chat-msg-avatar {
  cursor: pointer;
  transition: transform 0.15s ease;
}
.chat-msg-avatar:active {
  transform: scale(0.92);
}

/* ===== Recalled Message ===== */
.chat-msg-bubble.recalled {
  font-style: italic; opacity: 0.6; font-size: 13px;
}

/* ===== Favorite Select Modal ===== */
.chat-fav-select-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 920;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  will-change: opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-fav-select-overlay.active { opacity: 1; pointer-events: auto; }
.chat-fav-select-overlay .chat-fav-select-panel {
  transform: scale(0.92) translateY(8px);
  transition: transform 0.25s cubic-bezier(.25,.46,.45,.94);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-fav-select-overlay.active .chat-fav-select-panel {
  transform: scale(1) translateY(0);
}
.chat-fav-select-panel {
  background: var(--bg); background-image: none;
  border-radius: 18px;
  padding: 20px; width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  max-height: 400px; overflow-y: auto;
}
.chat-fav-select-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  text-align: center; margin-bottom: 12px;
}
.chat-fav-select-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px; color: var(--text); font-size: 14px;
}
.chat-fav-select-item:active { background: var(--glass); }
.chat-fav-select-item svg { flex-shrink: 0; color: var(--text2); }

/* ===== Forward Chat Record Card ===== */
.chat-forward-card {
  padding: 10px 12px !important;
  border-radius: 12px !important;
  background: var(--glass-strong) !important;
  border: 1.5px solid var(--glass-border) !important;
  box-shadow: 0 2px 8px var(--glass-shadow) !important;
  cursor: pointer;
  min-width: 180px;
  max-width: 100%;
  color: var(--text) !important;
  transition: opacity 0.15s;
}
.chat-forward-card:active { opacity: 0.7; }
.msg-right .chat-forward-card {
  background: var(--glass-strong) !important;
  border-color: var(--glass-border) !important;
  color: var(--text) !important;
}
.chat-forward-card-title {
  font-size: 13px; font-weight: 600;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 5px;
}
.chat-forward-card-title svg {
  width: 14px; height: 14px; flex-shrink: 0;
  opacity: 0.6;
}
.chat-forward-card-body {
  border-left: 2px solid var(--text3);
  padding-left: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.msg-right .chat-forward-card-body {
  border-left-color: var(--text3);
}
.chat-forward-card-line {
  font-size: 11px; line-height: 1.5;
  opacity: 0.7;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-forward-card-count {
  font-size: 10px; opacity: 0.5;
  margin-top: 4px; text-align: right;
}

/* ===== Novel Reading Record Card ===== */
.chat-novel-reading-record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  max-width: 86%;
  margin: 6px auto;
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text2);
  box-shadow: 0 4px 14px var(--glass-shadow);
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.chat-novel-reading-record:active { opacity: 0.72; }
.chat-novel-reading-record:hover { background: var(--glass-strong); }
.chat-novel-reading-record svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}
.chat-novel-reading-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-novel-reading-main strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-novel-reading-main em {
  color: var(--text3);
  font-size: 10px;
  line-height: 1.2;
  font-style: normal;
}
.chat-novel-record-panel {
  width: min(92vw, 380px);
  max-height: min(78vh, 620px);
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.chat-novel-record-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px;
  scrollbar-width: none;
}
.chat-novel-record-body::-webkit-scrollbar { display: none; }
.chat-novel-record-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 92%;
}
.chat-novel-record-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-novel-record-msg.character { align-self: flex-start; }
.chat-novel-record-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: 0 0 auto;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
}
.chat-novel-record-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-novel-record-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-novel-record-msg.user .chat-novel-record-content { align-items: flex-end; }
.chat-novel-record-name {
  color: var(--text3);
  font-size: 11px;
  line-height: 1.2;
}
.chat-novel-record-bubble {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-novel-record-msg.user .chat-novel-record-bubble {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.chat-novel-record-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* ===== Chat Novel Together ===== */
.chat-novel-together-panel {
  width: min(92vw, 410px);
  max-height: min(84vh, 660px);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.chat-novel-together-role-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
}

.chat-novel-together-role-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
}

.chat-novel-together-role-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-novel-together-role-main,
.chat-novel-together-book-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-novel-together-role-main strong,
.chat-novel-together-book-main strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-novel-together-role-main em,
.chat-novel-together-book-main em,
.chat-novel-together-empty,
.chat-novel-together-switch em,
.chat-novel-together-book-head em,
.chat-novel-together-interval em {
  color: var(--text3);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
}

.chat-novel-together-settings {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
}

.chat-novel-together-switch,
.chat-novel-together-interval {
  min-height: 42px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  box-sizing: border-box;
  color: var(--text2);
  font-size: 12px;
}

.chat-novel-together-switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--text);
}

.chat-novel-together-switch span,
.chat-novel-together-interval span,
.chat-novel-together-book-head span {
  color: var(--text);
  font-weight: 700;
}

.chat-novel-together-switch em {
  margin-left: auto;
  text-align: right;
}

.chat-novel-together-input {
  width: 86px;
  min-width: 0;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass-strong);
  color: var(--text);
  padding: 8px 9px;
  text-align: center;
  outline: none;
  box-sizing: border-box;
}

.chat-novel-together-input:focus {
  border-color: var(--text3);
}

.chat-novel-together-book-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.chat-novel-together-book-list {
  flex: 1;
  min-height: 0;
  max-height: min(48vh, 370px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
  scrollbar-width: none;
}

.chat-novel-together-book-list::-webkit-scrollbar { display: none; }

.chat-novel-together-book {
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  font: inherit;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
}

.chat-novel-together-book:active { opacity: .72; }
.chat-novel-together-book:disabled {
  opacity: .62;
  cursor: wait;
}

.chat-novel-together-cover {
  width: 46px;
  height: 61px;
  min-width: 46px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .12);
}

.chat-novel-together-cover .novel-cover-title {
  left: 7px;
  right: 7px;
  top: 10px;
  font-size: 10px;
  line-height: 1.18;
}

.chat-novel-together-cover .novel-cover-author {
  left: 7px;
  right: 7px;
  bottom: 8px;
  font-size: 8px;
}

.chat-novel-together-book-go {
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chat-novel-together-empty {
  padding: 14px 10px;
  border: 1px dashed var(--glass-border);
  border-radius: 8px;
  text-align: center;
}

/* ===== Video Together ===== */
.chat-video-together-record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  max-width: 86%;
  margin: 6px auto;
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text2);
  box-shadow: 0 4px 14px var(--glass-shadow);
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.chat-video-together-record:active { opacity: 0.72; }
.chat-video-together-record:hover { background: var(--glass-strong); }
.chat-video-together-record svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}
.chat-video-record-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-video-record-main strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-video-record-main em {
  color: var(--text3);
  font-size: 10px;
  line-height: 1.2;
  font-style: normal;
}
.chat-video-record-meta {
  padding: 9px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text2);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-video-record-msg-time {
  color: var(--text3);
  font-size: 10px;
  margin-left: 4px;
}

.video-together-panel {
  width: min(92vw, 390px);
  padding: 16px;
}
.video-together-role-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  margin-bottom: 12px;
}
.video-together-role-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  color: var(--text2);
  font-weight: 800;
}
.video-together-role-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-together-role-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.video-together-role-main strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-together-role-main em {
  color: var(--text3);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
}
.video-together-form {
  display: grid;
  gap: 11px;
}
.video-together-field {
  display: grid;
  gap: 5px;
}
.video-together-field label {
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
}
.video-together-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  padding: 10px 11px;
}
.video-together-input:focus {
  border-color: var(--text3);
}
.video-together-interval-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: center;
}
.video-together-interval-row span {
  color: var(--text3);
  font-size: 12px;
}

.video-together-page {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: none;
  background: #050505;
  color: #f6f6f6;
  overflow: hidden;
}
.video-together-page.active {
  display: block;
}
.video-together-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #050505;
}
.video-together-video {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  background: #050505;
}
.video-together-stage.portrait .video-together-video {
  width: auto;
  height: 100%;
}
.video-together-stage.landscape .video-together-video {
  width: 100%;
  height: auto;
}
.video-together-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 18px;
  background: linear-gradient(180deg, rgba(0,0,0,.68), rgba(0,0,0,0));
}
.video-together-icon-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.42);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.video-together-icon-btn svg {
  width: 20px;
  height: 20px;
}
.video-together-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-shadow: 0 1px 8px rgba(0,0,0,.5);
}
.video-together-title strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.25;
}
.video-together-title em {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,.72);
  font-style: normal;
  font-size: 11px;
  line-height: 1.2;
}
.video-together-dock {
  position: absolute;
  z-index: 6;
  display: none;
  width: 42px;
  height: 42px;
  pointer-events: auto;
}
.video-together-dock.active {
  display: block;
}
.video-together-avatar-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.76);
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  box-shadow: 0 8px 22px rgba(0,0,0,.32);
  padding: 2px;
  cursor: grab;
  touch-action: none;
}
.video-together-avatar-btn:active {
  cursor: grabbing;
  transform: scale(.96);
}
.video-together-avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.18);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.video-together-avatar-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-together-speech {
  position: absolute;
  right: 50px;
  top: 0;
  width: max-content;
  max-width: min(58vw, 260px);
  display: none;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(20,20,20,.86);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.video-together-dock.left-side .video-together-speech {
  left: 50px;
  right: auto;
}
.video-together-speech.active {
  display: block;
  animation: videoTogetherPop .18s ease-out both;
}
@keyframes videoTogetherPop {
  from { opacity: 0; transform: translateY(4px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.video-together-window {
  position: fixed;
  right: 12px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px) + var(--video-together-keyboard-inset, 0px));
  z-index: 7;
  width: min(88vw, 330px);
  height: min(56vh, 430px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  background: rgba(20,20,20,.88);
  color: #fff;
  box-shadow: 0 16px 42px rgba(0,0,0,.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.video-together-window.active {
  display: flex;
}
.video-together-window-head {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 30px;
  gap: 9px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.video-together-window-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.video-together-window-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-together-window-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.video-together-window-title strong,
.video-together-window-title em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-together-window-title strong {
  font-size: 13px;
  line-height: 1.25;
}
.video-together-window-title em {
  color: rgba(255,255,255,.62);
  font-size: 11px;
  font-style: normal;
  line-height: 1.2;
}
.video-together-window-head button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255,255,255,.7);
  font: inherit;
  font-size: 19px;
  cursor: pointer;
}
.video-together-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 11px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.video-together-history::-webkit-scrollbar { display: none; }
.video-together-msg {
  max-width: 86%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.video-together-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}
.video-together-msg.character {
  align-self: flex-start;
  align-items: flex-start;
}
.video-together-msg-name {
  color: rgba(255,255,255,.52);
  font-size: 10px;
  line-height: 1.2;
}
.video-together-msg-bubble {
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 8px;
  background: rgba(255,255,255,.10);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.video-together-msg.user .video-together-msg-bubble {
  background: #fff;
  border-color: #fff;
  color: #111;
}
.video-together-empty {
  padding: 14px 10px;
  border: 1px dashed rgba(255,255,255,.18);
  border-radius: 8px;
  color: rgba(255,255,255,.55);
  text-align: center;
  font-size: 12px;
}
.video-together-compose {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 36px;
  gap: 7px;
  padding: 9px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.video-together-chat-input {
  min-width: 0;
  height: 36px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(255,255,255,.10);
  color: #fff;
  font: inherit;
  font-size: 13px;
  outline: none;
  padding: 0 10px;
}
.video-together-chat-input::placeholder {
  color: rgba(255,255,255,.45);
}
.video-together-magic,
.video-together-send {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(255,255,255,.10);
  color: #fff;
  font: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.video-together-magic.loading {
  cursor: wait;
  background: rgba(255,255,255,.16);
}
.video-together-magic-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.video-together-loading-dot {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: videoTogetherSpin .78s linear infinite;
}
@keyframes videoTogetherSpin {
  to { transform: rotate(360deg); }
}
.video-together-send {
  background: #fff;
  border-color: #fff;
  color: #111;
}
.video-together-magic:disabled,
.video-together-send:disabled,
.video-together-chat-input:disabled {
  opacity: .68;
  cursor: not-allowed;
}
@media (max-width: 480px) {
  .video-together-window {
    left: 10px;
    right: 10px;
    width: auto;
    height: min(52vh, 390px);
  }
}

/* ===== Forward Viewer Overlay ===== */
.chat-forward-viewer {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 930;
  background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(.25,.46,.45,.94);
}
.chat-forward-viewer.active {
  transform: translateX(0);
  pointer-events: auto;
}
.chat-forward-viewer-nav {
  display: flex; align-items: center;
  padding: calc(env(safe-area-inset-top, 16px) + 12px) 16px 12px;
  flex-shrink: 0;
}
.chat-forward-viewer-nav-inner {
  display: flex; align-items: center;
  width: 100%; position: relative; height: 36px;
}
.chat-forward-viewer-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  position: absolute; left: 50%; transform: translateX(-50%);
  white-space: nowrap; max-width: 60%;
  overflow: hidden; text-overflow: ellipsis;
}
.chat-forward-viewer-body {
  flex: 1; overflow-y: auto; padding: 8px 16px 24px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chat-forward-viewer-body::-webkit-scrollbar { display: none; }
.chat-forward-viewer-msg {
  display: flex; align-items: flex-start; gap: 8px;
  margin-bottom: 12px;
}
.chat-forward-viewer-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 12px;
}
.chat-forward-viewer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-forward-viewer-content {
  flex: 1; min-width: 0;
}
.chat-forward-viewer-name {
  font-size: 12px; font-weight: 600; color: var(--text2);
  margin-bottom: 2px;
}
.chat-forward-viewer-bubble {
  padding: 8px 12px; border-radius: 14px;
  border-top-left-radius: 4px;
  font-size: 13px; line-height: 1.5; color: var(--text);
  word-break: break-word; white-space: pre-wrap;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  box-shadow: 0 1px 4px var(--glass-shadow);
  display: inline-block; max-width: 100%;
}
.chat-forward-viewer-bubble.sticker-viewer-bubble {
  background: transparent; border: none; box-shadow: none;
  padding: 2px;
}
.chat-forward-viewer-bubble.sticker-viewer-bubble img {
  max-width: 100px; max-height: 100px; object-fit: contain; border-radius: 6px;
}
.chat-forward-viewer-time {
  font-size: 10px; color: var(--text3); margin-top: 3px;
}

/* ===== Forward Picker (select conv then messages) ===== */
.chat-forward-picker {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 925;
  background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(.25,.46,.45,.94);
}
.chat-forward-picker.active {
  transform: translateX(0);
  pointer-events: auto;
}
.chat-forward-picker-body {
  flex: 1; overflow-y: auto; padding: 0 16px 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chat-forward-picker-body::-webkit-scrollbar { display: none; }
.chat-forward-picker-hint {
  font-size: 13px; color: var(--text3);
  text-align: center; padding: 16px 0 8px;
}
.chat-forward-msg-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
}
.chat-forward-msg-item:last-child { border-bottom: none; }
.chat-forward-msg-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
  transition: all 0.15s;
}
.chat-forward-msg-check.checked {
  background: var(--text); border-color: var(--text);
}
.chat-forward-msg-check.checked::after {
  content: '';
  width: 6px; height: 10px;
  border: solid var(--bg); border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translateY(-1px);
}
.chat-forward-msg-body {
  flex: 1; min-width: 0;
}
.chat-forward-msg-name {
  font-size: 12px; font-weight: 600; color: var(--text2);
}
.chat-forward-msg-text {
  font-size: 13px; color: var(--text); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.chat-forward-msg-time {
  font-size: 11px; color: var(--text3); margin-top: 2px;
}
.chat-forward-confirm-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
  background: var(--glass);
  border-top: 1px solid var(--glass-border);
}
.chat-forward-confirm-count {
  font-size: 13px; color: var(--text3);
}
.chat-forward-confirm-btn {
  padding: 10px 24px;
  border-radius: 12px; border: none;
  background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: transform 0.15s;
}
.chat-forward-confirm-btn:active { transform: scale(0.97); }
.chat-forward-confirm-btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* ===== Voice Message Bubble ===== */
.voice-bubble {
  cursor: pointer;
  padding: 10px 14px !important;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  max-width: 100%;
  min-width: 100px;
}
.voice-bubble:active {
  opacity: 0.82;
  transition: opacity 0.1s;
}
.voice-bubble::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  will-change: transform;
  transform: translateX(-100%);
}
.voice-playing::after {
  opacity: 1;
  animation: voiceShimmer 4s linear infinite;
}
@keyframes voiceShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.voice-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-duration {
  font-size: 12px;
  opacity: 0.5;
  flex-shrink: 0;
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2.5px;
  flex: 1;
  height: 36px;
  overflow: hidden;
}

.voice-wave-bar {
  display: inline-block;
  width: 3px;
  flex-shrink: 0;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.85;
  transform-origin: center center;
  will-change: transform, opacity;
  backface-visibility: hidden;
  animation: voiceIdleWave 3s ease-in-out infinite;
}
.voice-wave-bar:nth-child(1)  { height: 5px;  animation-delay: 0s; }
.voice-wave-bar:nth-child(2)  { height: 8px;  animation-delay: 0.15s; }
.voice-wave-bar:nth-child(3)  { height: 6px;  animation-delay: 0.30s; }
.voice-wave-bar:nth-child(4)  { height: 12px; animation-delay: 0.45s; }
.voice-wave-bar:nth-child(5)  { height: 8px;  animation-delay: 0.60s; }
.voice-wave-bar:nth-child(6)  { height: 14px; animation-delay: 0.75s; }
.voice-wave-bar:nth-child(7)  { height: 7px;  animation-delay: 0.90s; }
.voice-wave-bar:nth-child(8)  { height: 13px; animation-delay: 1.05s; }
.voice-wave-bar:nth-child(9)  { height: 5px;  animation-delay: 1.20s; }
.voice-wave-bar:nth-child(10) { height: 11px; animation-delay: 1.35s; }
.voice-wave-bar:nth-child(11) { height: 16px; animation-delay: 1.50s; }
.voice-wave-bar:nth-child(12) { height: 7px;  animation-delay: 1.65s; }
.voice-wave-bar:nth-child(13) { height: 13px; animation-delay: 1.80s; }
.voice-wave-bar:nth-child(14) { height: 6px;  animation-delay: 1.95s; }
.voice-wave-bar:nth-child(15) { height: 11px; animation-delay: 2.10s; }
.voice-wave-bar:nth-child(16) { height: 8px;  animation-delay: 2.25s; }
.voice-wave-bar:nth-child(17) { height: 15px; animation-delay: 2.40s; }
.voice-wave-bar:nth-child(18) { height: 7px;  animation-delay: 2.55s; }
.voice-wave-bar:nth-child(19) { height: 10px; animation-delay: 2.70s; }
.voice-wave-bar:nth-child(20) { height: 5px;  animation-delay: 2.85s; }

/* Idle: visible undulating wave */
@keyframes voiceIdleWave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.55; }
  50%      { transform: scaleY(1.2); opacity: 0.9; }
}

/* Playing: energetic traveling sine wave */
.voice-playing .voice-wave-bar {
  opacity: 1;
  animation-name: voicePlayWave;
  animation-duration: 1.6s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}
.voice-playing .voice-wave-bar:nth-child(1)  { animation-delay: 0s; }
.voice-playing .voice-wave-bar:nth-child(2)  { animation-delay: 0.08s; }
.voice-playing .voice-wave-bar:nth-child(3)  { animation-delay: 0.16s; }
.voice-playing .voice-wave-bar:nth-child(4)  { animation-delay: 0.24s; }
.voice-playing .voice-wave-bar:nth-child(5)  { animation-delay: 0.32s; }
.voice-playing .voice-wave-bar:nth-child(6)  { animation-delay: 0.40s; }
.voice-playing .voice-wave-bar:nth-child(7)  { animation-delay: 0.48s; }
.voice-playing .voice-wave-bar:nth-child(8)  { animation-delay: 0.56s; }
.voice-playing .voice-wave-bar:nth-child(9)  { animation-delay: 0.64s; }
.voice-playing .voice-wave-bar:nth-child(10) { animation-delay: 0.72s; }
.voice-playing .voice-wave-bar:nth-child(11) { animation-delay: 0.80s; }
.voice-playing .voice-wave-bar:nth-child(12) { animation-delay: 0.88s; }
.voice-playing .voice-wave-bar:nth-child(13) { animation-delay: 0.96s; }
.voice-playing .voice-wave-bar:nth-child(14) { animation-delay: 1.04s; }
.voice-playing .voice-wave-bar:nth-child(15) { animation-delay: 1.12s; }
.voice-playing .voice-wave-bar:nth-child(16) { animation-delay: 1.20s; }
.voice-playing .voice-wave-bar:nth-child(17) { animation-delay: 1.28s; }
.voice-playing .voice-wave-bar:nth-child(18) { animation-delay: 1.36s; }
.voice-playing .voice-wave-bar:nth-child(19) { animation-delay: 1.44s; }
.voice-playing .voice-wave-bar:nth-child(20) { animation-delay: 1.52s; }

@keyframes voicePlayWave {
  0%   { transform: scaleY(0.4); opacity: 0.5; }
  30%  { transform: scaleY(1.3); opacity: 1; }
  60%  { transform: scaleY(0.7); opacity: 0.85; }
  100% { transform: scaleY(0.4); opacity: 0.5; }
}

/* Loading: pulsing sequential wave */
.voice-loading .voice-wave-bar {
  animation-name: voiceLoadPulse;
  animation-duration: 2s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}
.voice-loading .voice-wave-bar:nth-child(1)  { animation-delay: 0s; }
.voice-loading .voice-wave-bar:nth-child(2)  { animation-delay: 0.085s; }
.voice-loading .voice-wave-bar:nth-child(3)  { animation-delay: 0.17s; }
.voice-loading .voice-wave-bar:nth-child(4)  { animation-delay: 0.255s; }
.voice-loading .voice-wave-bar:nth-child(5)  { animation-delay: 0.34s; }
.voice-loading .voice-wave-bar:nth-child(6)  { animation-delay: 0.425s; }
.voice-loading .voice-wave-bar:nth-child(7)  { animation-delay: 0.51s; }
.voice-loading .voice-wave-bar:nth-child(8)  { animation-delay: 0.595s; }
.voice-loading .voice-wave-bar:nth-child(9)  { animation-delay: 0.68s; }
.voice-loading .voice-wave-bar:nth-child(10) { animation-delay: 0.765s; }
.voice-loading .voice-wave-bar:nth-child(11) { animation-delay: 0.85s; }
.voice-loading .voice-wave-bar:nth-child(12) { animation-delay: 0.935s; }
.voice-loading .voice-wave-bar:nth-child(13) { animation-delay: 1.02s; }
.voice-loading .voice-wave-bar:nth-child(14) { animation-delay: 1.105s; }
.voice-loading .voice-wave-bar:nth-child(15) { animation-delay: 1.19s; }
.voice-loading .voice-wave-bar:nth-child(16) { animation-delay: 1.275s; }
.voice-loading .voice-wave-bar:nth-child(17) { animation-delay: 1.36s; }
.voice-loading .voice-wave-bar:nth-child(18) { animation-delay: 1.445s; }
.voice-loading .voice-wave-bar:nth-child(19) { animation-delay: 1.53s; }
.voice-loading .voice-wave-bar:nth-child(20) { animation-delay: 1.615s; }

@keyframes voiceLoadPulse {
  0%, 100% { transform: scaleY(0.35); opacity: 0.25; }
  50%      { transform: scaleY(1.0);  opacity: 0.7; }
}

.voice-text-area {
  margin-top: 4px;
  opacity: 0.75;
  font-size: 13px;
}

/* ===== Bubble Translation ===== */
.bubble-translation-divider {
  border: none;
  border-top: 1px dashed var(--text3);
  margin: 8px 0 6px;
  opacity: 0.45;
}
.bubble-translation-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.45;
}
.msg-right .bubble-translation-divider {
  border-top-color: var(--bg);
  opacity: 0.3;
}
.msg-right .bubble-translation-text {
  color: var(--bg);
  opacity: 0.75;
}
.has-translation {
  cursor: pointer;
}
.vc-msg-bubble .bubble-translation-divider,
.vidcall-msg-bubble .bubble-translation-divider,
.vc-log-msg-bubble .bubble-translation-divider,
.vidcall-log-msg-bubble .bubble-translation-divider {
  border-top-color: var(--text2);
  opacity: 0.45;
}
.vc-msg-bubble .bubble-translation-text,
.vidcall-msg-bubble .bubble-translation-text,
.vc-log-msg-bubble .bubble-translation-text,
.vidcall-log-msg-bubble .bubble-translation-text {
  color: var(--text2);
  opacity: 0.85;
}

.msg-right .voice-wave-bar {
  background: #ffffff;
  opacity: 1;
}
.msg-right .voice-duration {
  color: var(--bg);
  opacity: 0.85;
}

/* ===== Voice Input Modal ===== */
.voice-input-panel {
  max-width: 340px;
}
.voice-input-textarea {
  width: 100%;
  min-height: 100px;
  max-height: 200px;
  border: 1.5px solid var(--glass-border);
  border-radius: 14px;
  background: var(--glass);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.voice-input-textarea:focus {
  border-color: var(--text2);
}
.voice-input-textarea::placeholder {
  color: var(--text3);
}

/* ===== 聊天消息弹窗通知 (仿微信/QQ) ===== */
.chat-toast-notification {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  width: calc(100% - 24px);
  max-width: 400px;
  background: var(--glass-strong, rgba(255,255,255,0.92));
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.3));
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
.chat-toast-notification.show {
  transform: translateX(-50%) translateY(calc(env(safe-area-inset-top, 12px) + 12px));
  opacity: 1;
  pointer-events: auto;
}
.chat-toast-notification:active {
  transform: translateX(-50%) translateY(calc(env(safe-area-inset-top, 12px) + 12px)) scale(0.98);
}
.chat-toast-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--glass, rgba(255,255,255,0.2));
  border: 1px solid var(--glass-border, rgba(255,255,255,0.2));
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text3);
}
.chat-toast-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-toast-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-toast-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-toast-preview {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-toast-close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text3);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-toast-close:active {
  background: var(--glass, rgba(0,0,0,0.05));
}

/* ===== 未读消息红点角标 ===== */
.chat-conv-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: flex-start;
  flex-shrink: 0;
  margin-left: 8px;
  padding-top: 2px;
  gap: 6px;
}
.chat-unread-badge {
  display: none;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #F44336;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
}
.chat-unread-badge.show {
  display: block;
}

/* 桌面Chat图标上的未读角标 */
.chat-home-badge {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #F44336;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
  z-index: 5;
  pointer-events: none;
}
.chat-home-badge.show {
  display: block;
}

/* 消息Tab角标 */
.chat-tab-badge {
  display: none;
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(14px);
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #F44336;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
}
.chat-tab-badge.show {
  display: block;
}

/* ===== Pinned Conversations ===== */
.chat-conv-item.pinned {
  background: var(--glass-strong);
  border-radius: 10px;
  margin: 0 -10px;
  padding: 12px 10px;
  position: relative;
}
.chat-conv-pin-tag {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 14px;
  height: 14px;
  color: var(--text3);
  opacity: 0.5;
  pointer-events: none;
}

/* ===== Conversation Long-press Context Menu ===== */
.chat-conv-ctx-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 900;
  display: none;
}
.chat-conv-ctx-overlay.active {
  display: block;
}
.chat-conv-ctx-menu {
  position: fixed;
  z-index: 901;
  min-width: 120px;
  background: rgba(50, 50, 50, 0.96);
  border-radius: 12px;
  padding: 4px 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  display: none;
  opacity: 0;
  transform: scale(0.88);
  transform-origin: center top;
  transition: opacity 0.18s ease, transform 0.2s cubic-bezier(.34,1.56,.64,1);
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.chat-conv-ctx-menu.active {
  display: block;
  opacity: 1;
  transform: scale(1);
}
.chat-conv-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 14px;
  color: #eee;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  white-space: nowrap;
}
.chat-conv-ctx-item:active {
  background: rgba(255,255,255,0.1);
}
.chat-conv-ctx-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #ccc;
}
.chat-conv-ctx-item.danger {
  color: #ff6b6b;
}
.chat-conv-ctx-item.danger svg {
  color: #ff6b6b;
}

/* ===== Image Message Bubble ===== */
.chat-msg-bubble.chat-img-bubble {
  padding: 4px;
  background: var(--glass);
  border: 1.5px solid var(--glass-border);
  min-width: 160px;
  max-width: 220px;
  overflow: hidden;
}
.chat-msg-bubble.chat-img-bubble img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: cover;
  border-radius: 12px;
}
.msg-right .chat-msg-bubble.chat-img-bubble {
  background: var(--glass);
  color: var(--text);
  border-color: var(--glass-border);
}

/* Image loading placeholder */
.img-loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 24px;
  min-height: 120px;
  background: linear-gradient(135deg, var(--glass) 0%, var(--glass-strong) 100%);
  border-radius: 12px;
}
.img-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.img-loading-text {
  font-size: 12px;
  color: var(--text3);
}

/* ===== Image Description Card (faux-image) ===== */
.chat-msg-bubble.chat-img-desc-card {
  padding: 0;
  background: linear-gradient(145deg, rgba(120,140,170,0.2) 0%, rgba(80,100,130,0.35) 100%);
  border: 1.5px solid var(--glass-border);
  border-radius: 18px;
  overflow: hidden;
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  min-height: 150px;
  position: relative;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.msg-right .chat-msg-bubble.chat-img-desc-card {
  background: linear-gradient(145deg, rgba(100,130,170,0.25) 0%, rgba(70,90,120,0.4) 100%);
  color: var(--text);
  border-color: var(--glass-border);
  border-radius: 18px;
  padding: 0;
}
.img-desc-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 8px;
  color: var(--text2);
  opacity: 0.6;
}
.img-desc-text {
  padding: 4px 16px 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.img-desc-text::-webkit-scrollbar {
  width: 3px;
}
.img-desc-text::-webkit-scrollbar-thumb {
  background: rgba(128,128,128,0.3);
  border-radius: 3px;
}
.img-desc-label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px 10px;
  font-size: 11px;
  color: var(--text3);
  opacity: 0.8;
}

/* ===== Image Viewer Overlay ===== */
.chat-image-viewer-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}
.chat-image-viewer-img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Theme overrides for image cards ===== */
body.theme-pink .chat-img-desc-card {
  background: linear-gradient(145deg, rgba(180,140,160,0.25) 0%, rgba(140,100,120,0.35) 100%);
}
body.theme-pink .msg-right .chat-img-desc-card {
  background: linear-gradient(145deg, rgba(180,140,160,0.3) 0%, rgba(140,100,120,0.4) 100%);
}
body.theme-white .chat-img-desc-card {
  background: linear-gradient(145deg, rgba(200,200,210,0.35) 0%, rgba(170,175,185,0.45) 100%);
}
body.theme-white.dark-mode .chat-img-desc-card {
  background: linear-gradient(145deg, rgba(60,60,70,0.4) 0%, rgba(40,42,50,0.55) 100%);
}
body.theme-blue .chat-img-desc-card {
  background: linear-gradient(145deg, rgba(140,170,210,0.3) 0%, rgba(100,135,180,0.4) 100%);
}
body.theme-blue.dark-mode .chat-img-desc-card {
  background: linear-gradient(145deg, rgba(35,50,75,0.4) 0%, rgba(25,38,58,0.55) 100%);
}
body.theme-line .chat-img-desc-card {
  background: var(--dock-bg);
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
body.theme-retro .chat-img-desc-card {
  background: var(--glass-strong);
  border: 2px solid var(--glass-border);
  border-radius: 4px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.4), inset -2px -2px 0 rgba(0,0,0,0.08), 1px 1px 0 rgba(0,0,0,0.06);
}
/* Override .msg-right .chat-msg-bubble color/bg for desc cards in all themes
   Specificity (0,4,1) beats theme's .msg-right .chat-msg-bubble (0,3,1) */
body.theme-pink .msg-right .chat-msg-bubble.chat-img-desc-card {
  background: linear-gradient(145deg, rgba(180,140,160,0.3) 0%, rgba(140,100,120,0.4) 100%);
  color: var(--text);
  border-color: var(--glass-border);
  padding: 0; border-radius: 18px;
  width: 200px; min-width: 200px; max-width: 200px;
}
body.theme-white .msg-right .chat-msg-bubble.chat-img-desc-card {
  background: linear-gradient(145deg, rgba(200,200,210,0.35) 0%, rgba(170,175,185,0.45) 100%);
  color: var(--text);
  border-color: var(--glass-border);
  padding: 0; border-radius: 18px;
  width: 200px; min-width: 200px; max-width: 200px;
}
body.theme-white.dark-mode .msg-right .chat-msg-bubble.chat-img-desc-card {
  background: linear-gradient(145deg, rgba(60,60,70,0.4) 0%, rgba(40,42,50,0.55) 100%);
  color: var(--text);
  border-color: var(--glass-border);
  padding: 0; border-radius: 18px;
  width: 200px; min-width: 200px; max-width: 200px;
}
body.theme-blue .msg-right .chat-msg-bubble.chat-img-desc-card {
  background: linear-gradient(145deg, rgba(140,170,210,0.3) 0%, rgba(100,135,180,0.4) 100%);
  color: var(--text);
  border-color: var(--glass-border);
  padding: 0; border-radius: 18px;
  width: 200px; min-width: 200px; max-width: 200px;
}
body.theme-blue.dark-mode .msg-right .chat-msg-bubble.chat-img-desc-card {
  background: linear-gradient(145deg, rgba(35,50,75,0.4) 0%, rgba(25,38,58,0.55) 100%);
  color: var(--text);
  border-color: var(--glass-border);
  padding: 0; border-radius: 18px;
  width: 200px; min-width: 200px; max-width: 200px;
}
body.theme-line .msg-right .chat-msg-bubble.chat-img-desc-card {
  background: var(--dock-bg);
  color: var(--text);
  border: 1px solid var(--glass-border);
  box-shadow: none;
  padding: 0; border-radius: 18px;
  width: 200px; min-width: 200px; max-width: 200px;
}
body.theme-retro .msg-right .chat-msg-bubble.chat-img-desc-card {
  background: var(--glass-strong);
  color: var(--text);
  border: 2px solid var(--glass-border);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.4), inset -2px -2px 0 rgba(0,0,0,0.08), 1px 1px 0 rgba(0,0,0,0.06);
  padding: 0; border-radius: 4px;
  width: 200px; min-width: 200px; max-width: 200px;
}
body.theme-pink .chat-img-bubble {
  border-color: rgba(180,140,160,0.4);
}
body.theme-white .chat-img-bubble {
  border-color: rgba(200,200,200,0.5);
}
body.theme-white.dark-mode .chat-img-bubble {
  border-color: rgba(90,90,90,0.5);
}
body.theme-blue .chat-img-bubble {
  border-color: rgba(180,210,240,0.4);
}
body.theme-blue.dark-mode .chat-img-bubble {
  border-color: rgba(50,65,85,0.45);
}
body.theme-line .chat-img-bubble {
  border: 1px solid var(--glass-border);
  box-shadow: none;
}
body.theme-retro .chat-img-bubble {
  border: 2px solid var(--glass-border);
  border-radius: 4px;
}


/* ===== Image Send Modal (Unified) ===== */
.chat-image-unified-panel {
  max-width: 340px;
  width: 90vw;
}
.chat-image-tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid var(--glass-border);
  background: var(--glass);
}
.chat-image-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.chat-image-tab.active {
  color: var(--text);
  background: var(--glass-strong);
}
.chat-image-tab:not(.active):active {
  background: var(--glass);
}
.chat-image-tab-content {
  animation: fadeIn 0.18s ease;
}
.chat-image-desc-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1.5px solid var(--glass-border);
  border-radius: 12px;
  background: var(--glass);
  color: var(--text);
  font-size: 14px;
  resize: vertical;
  margin-bottom: 14px;
  font-family: inherit;
  min-height: 80px;
}
.chat-image-desc-input:focus {
  outline: none;
  border-color: var(--text3);
}
.chat-image-upload-section {
  margin-bottom: 12px;
}
.chat-image-local-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 0;
  border-radius: 12px;
  border: 1.5px dashed var(--glass-border);
  background: var(--glass);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  box-sizing: border-box;
}
.chat-image-local-btn:active {
  transform: scale(0.97);
  background: var(--glass-strong);
}
.chat-image-upload-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--text3);
  font-size: 11px;
}
.chat-image-upload-divider::before,
.chat-image-upload-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}
.chat-image-url-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1.5px solid var(--glass-border);
  border-radius: 12px;
  background: var(--glass);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
  font-family: inherit;
}
.chat-image-url-input:focus {
  outline: none;
  border-color: var(--text3);
}
.chat-image-url-preview {
  margin-bottom: 14px;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid var(--glass-border);
  background: var(--glass);
  max-height: 200px;
}
.chat-image-url-preview img {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: contain;
}

/* User image bubble - keep near avatar */
.msg-right .chat-img-bubble {
  max-width: 220px;
}
.msg-right .chat-img-desc-card {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
}

/* User-sent local/URL image bubble */
.chat-user-image-bubble {
  padding: 4px;
  background: var(--glass);
  border: 1.5px solid var(--glass-border);
  border-radius: 16px;
  min-width: 120px;
  max-width: 220px;
  overflow: hidden;
}
.chat-user-image-bubble img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
}


/* Fix: ensure image bubbles stay adjacent to avatar */
.chat-msg-row.msg-right .chat-msg-bubble-wrap {
  max-width: 70%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.chat-msg-row .chat-msg-bubble.chat-img-bubble {
  max-width: 220px;
  flex-shrink: 1;
}
.chat-msg-row .chat-msg-bubble.chat-img-desc-card {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  flex-shrink: 0;
}
.chat-msg-row.msg-right .chat-msg-bubble.chat-img-bubble {
  max-width: 220px;
  margin-left: auto;
}
.chat-msg-row.msg-right .chat-msg-bubble.chat-img-desc-card {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  margin-left: auto;
}

/* ===== Voice Call - Incoming Overlay ===== */
.vc-incoming-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.vc-incoming-overlay.active {
  display: flex;
}
.vc-incoming-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  opacity: 0.97;
}
.vc-incoming-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
  animation: vcFadeIn 0.4s ease;
}
@keyframes vcFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.vc-incoming-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--glass-border);
  box-shadow: 0 0 40px var(--glass-shadow);
  animation: vcPulseRing 2s ease-in-out infinite;
}
@keyframes vcPulseRing {
  0%, 100% { box-shadow: 0 0 20px var(--glass-shadow); }
  50% { box-shadow: 0 0 50px var(--glass-shadow); }
}
.vc-incoming-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vc-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-strong);
  color: var(--text);
  font-size: 36px;
  font-weight: 600;
}
.vc-incoming-name {
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
}
.vc-incoming-label {
  color: var(--text2);
  font-size: 14px;
  margin-top: -8px;
}
.vc-incoming-wave {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 30px;
  margin: 10px 0;
}
.vc-incoming-wave span {
  display: block;
  width: 3px;
  height: 12px;
  background: var(--text3);
  border-radius: 2px;
  animation: vcWave 1.2s ease-in-out infinite;
}
.vc-incoming-wave span:nth-child(1) { animation-delay: 0s; }
.vc-incoming-wave span:nth-child(2) { animation-delay: 0.15s; }
.vc-incoming-wave span:nth-child(3) { animation-delay: 0.3s; }
.vc-incoming-wave span:nth-child(4) { animation-delay: 0.45s; }
.vc-incoming-wave span:nth-child(5) { animation-delay: 0.6s; }
@keyframes vcWave {
  0%, 100% { height: 8px; opacity: 0.5; }
  50% { height: 24px; opacity: 1; }
}
.vc-incoming-actions {
  display: flex;
  gap: 60px;
  margin-top: 30px;
}
.vc-incoming-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}
.vc-incoming-btn:active {
  transform: scale(0.9);
}
.vc-incoming-btn svg {
  width: 28px;
  height: 28px;
}
.vc-btn-reject svg,
.vc-btn-accept svg {
  padding: 16px;
  border-radius: 50%;
}
.vc-btn-reject svg {
  background: #f44336;
}
.vc-btn-accept svg {
  background: #4CAF50;
}
.vc-incoming-btn span {
  color: var(--text2);
  font-size: 12px;
}

/* ===== Voice Call - Active Call Page ===== */
.vc-page {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9990;
  background: var(--bg);
  display: none;
  flex-direction: column;
}
.vc-page.active {
  display: flex;
  animation: vcSlideUp 0.35s ease;
}
@keyframes vcSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.vc-page-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top, 16px));
  gap: 14px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.vc-page-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--glass-border);
  flex-shrink: 0;
}
.vc-page-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vc-page-info {
  flex: 1;
  min-width: 0;
}
.vc-page-name {
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vc-page-timer {
  color: var(--text2);
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', monospace;
  margin-top: 2px;
}
.vc-page-status {
  color: var(--text2);
  font-size: 12px;
  padding: 4px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  flex-shrink: 0;
}

/* ===== Voice Call - Message Area ===== */
.vc-msg-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}
.vc-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: vcMsgIn 0.3s ease;
}
@keyframes vcMsgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.vc-msg-left {
  align-self: flex-start;
}
.vc-msg-right {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.vc-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.vc-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vc-msg-avatar .vc-avatar-placeholder {
  font-size: 14px;
  border-radius: 50%;
}
.vc-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vc-msg-name {
  font-size: 11px;
  color: var(--text3);
  padding: 0 4px;
}
.vc-msg-right .vc-msg-name {
  text-align: right;
}
.vc-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.vc-msg-left .vc-msg-bubble {
  background: var(--glass);
  color: var(--text);
  border-top-left-radius: 4px;
}
.vc-msg-right .vc-msg-bubble {
  background: var(--glass-strong);
  color: var(--text);
  border-top-right-radius: 4px;
}

/* ===== Voice Call - Typing Indicator ===== */
.vc-typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  flex-shrink: 0;
}
.vc-typing-indicator span {
  display: block;
  width: 6px;
  height: 6px;
  background: var(--text3);
  border-radius: 50%;
  animation: vcTypeDot 1.4s ease-in-out infinite;
}
.vc-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.vc-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes vcTypeDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.vc-typing-indicator em {
  font-style: normal;
  color: var(--text3);
  font-size: 12px;
}

/* ===== Voice Call - Input Bar ===== */
.vc-input-bar {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  background: var(--glass);
}
.vc-input-wrap {
  display: flex;
  width: 100%;
  gap: 8px;
  align-items: center;
}
.vc-input-field {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.vc-input-field::placeholder {
  color: var(--text3);
}
.vc-input-field:focus {
  border-color: var(--text2);
}
.vc-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--glass-strong);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
  color: var(--text);
}
.vc-send-btn:active {
  transform: scale(0.9);
}
.vc-hangup-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #e53935;
  border: none;
  border-radius: 28px;
  padding: 10px 32px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.vc-hangup-btn:active {
  transform: scale(0.95);
  opacity: 0.8;
}

/* ===== Voice Call - Chat System Message (call ended bubble) ===== */
.chat-vc-sys-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 6px 14px;
  background: var(--glass-bg, rgba(0,0,0,0.04));
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s;
  margin: 4px auto;
  max-width: 260px;
}
.chat-vc-sys-msg:hover {
  background: var(--glass-hover, rgba(0,0,0,0.08));
}
.chat-vc-sys-msg svg {
  flex-shrink: 0;
  color: var(--text2);
}
.chat-vc-sys-msg .vc-sys-text {
  font-size: 12px;
  color: var(--text2, #666);
}
.chat-vc-sys-msg .vc-sys-duration {
  font-size: 11px;
  color: var(--text3, #999);
  margin-left: 4px;
}
.chat-vc-sys-msg .vc-sys-members {
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: var(--text3, #aaa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  margin: 0 auto;
}
.chat-vc-rejected {
  text-align: center;
  font-size: 12px;
  color: var(--text3, #999);
  padding: 6px 0;
}
.chat-vc-rejected svg {
  vertical-align: middle;
  margin-right: 4px;
  color: #f44336;
}

/* ===== Character Heart Voice Button ===== */
.char-heart-btn.chat-nav-btn {
  width: auto;
  height: auto;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 4px;
}
.char-heart-btn svg {
  transition: color 0.2s, transform 0.2s;
}
.char-heart-btn:active svg {
  transform: scale(1.2);
}

/* ===== Character Heart Voice Modal ===== */
.chv-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  animation: vcFadeIn 0.25s;
}
.chv-overlay.active {
  display: flex;
}
.chv-panel {
  width: 88%;
  max-width: 380px;
  background: var(--bg);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  overflow: hidden;
  position: relative;
  animation: vcSlideUp 0.3s ease;
}
.chv-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text3);
  cursor: pointer;
  border-radius: 50%;
  z-index: 2;
  transition: background 0.15s;
}
.chv-close:hover {
  background: var(--glass);
}
.chv-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 14px;
}
.chv-avatar {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--glass-border);
  background: var(--glass);
}
.chv-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chv-avatar-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text3);
  background: var(--glass-strong);
}
.chv-info {
  flex: 1;
  min-width: 0;
}
.chv-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chv-mood {
  font-size: 13px;
  color: var(--accent, #07c160);
  margin-top: 3px;
  font-weight: 500;
}
.chv-body {
  padding: 0 20px 10px;
}
.chv-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px 0;
  color: var(--text3);
  font-size: 13px;
}
.chv-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #07c160);
  animation: chvDotPulse 1.2s infinite ease-in-out;
}
.chv-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.chv-loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chvDotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}
.chv-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chv-section {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 14px;
}
.chv-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.chv-section-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chv-heart-text {
  color: var(--text);
  font-style: italic;
  position: relative;
  padding-left: 12px;
}
.chv-heart-text::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent, #07c160);
  opacity: 0.6;
}
.chv-btn-row {
  display: flex; gap: 8px; padding: 0 16px 14px; margin-top: 4px;
}
.chv-refresh-btn, .chv-review-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 10px 0;
  border-radius: 12px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.chv-refresh-btn:active, .chv-review-btn:active { transform: scale(0.95); opacity: 0.8; }
.chv-refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 心声回顾页面 ===== */
.chv-history-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  flex-direction: column;
  animation: vcSlideUp 0.25s ease;
}
.chv-history-overlay.active { display: flex; }
.chv-history-panel {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
}
.chv-history-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.chv-history-back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; color: var(--text1);
  cursor: pointer; border-radius: 10px;
  transition: background 0.15s;
}
.chv-history-back:active { background: var(--glass-border); }
.chv-history-title {
  font-size: 16px; font-weight: 700; color: var(--text1);
}
.chv-history-list {
  flex: 1; overflow-y: auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}
.chv-history-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 60px 20px;
  color: var(--text3); font-size: 13px;
}

/* 心声卡片 */
.chv-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.chv-card:active { transform: scale(0.98); }
.chv-card-avatar {
  width: 42px; height: 42px; min-width: 42px;
  border-radius: 50%; overflow: hidden;
  background: var(--glass-border);
  display: flex; align-items: center; justify-content: center;
}
.chv-card-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.chv-card-avatar-ph {
  font-size: 16px; font-weight: 700; color: var(--text2);
}
.chv-card-body {
  flex: 1; min-width: 0;
}
.chv-card-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.chv-card-name {
  font-size: 14px; font-weight: 600; color: var(--text1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chv-card-time {
  font-size: 11px; color: var(--text3); white-space: nowrap; margin-left: 8px;
}
.chv-card-preview {
  font-size: 12.5px; color: var(--text2); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
.chv-card-mood {
  display: inline-block;
  font-size: 11px; color: var(--accent, #07c160);
  background: rgba(7,193,96,0.1);
  padding: 2px 8px; border-radius: 8px;
  margin-bottom: 4px;
}

/* 心声详情弹窗 */
.chv-detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0,0,0,0.45);
  align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.chv-detail-overlay.active { display: flex; }
.chv-detail-panel {
  width: 88%; max-width: 380px;
  max-height: 82vh;
  background: var(--bg);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  overflow-y: auto;
  position: relative;
  animation: vcSlideUp 0.3s ease;
  padding-bottom: 12px;
}
.chv-detail-close {
  position: absolute; top: 12px; right: 14px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text3); cursor: pointer;
  border-radius: 50%; transition: background 0.15s;
}
.chv-detail-close:hover { background: var(--glass-border); }
.chv-detail-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px 10px;
}
.chv-detail-avatar {
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: var(--glass-border);
  display: flex; align-items: center; justify-content: center;
}
.chv-detail-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.chv-detail-avatar-ph {
  font-size: 16px; font-weight: 700; color: var(--text2);
}
.chv-detail-info { flex: 1; }
.chv-detail-name {
  font-size: 15px; font-weight: 700; color: var(--text1);
}
.chv-detail-time {
  font-size: 11px; color: var(--text3); margin-top: 2px;
}
.chv-detail-body {
  padding: 4px 18px 8px;
}
.chv-detail-delete {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: calc(100% - 36px); margin: 4px auto 0;
  padding: 10px 0;
  border-radius: 12px;
  border: 1.5px solid rgba(255,59,48,0.3);
  background: rgba(255,59,48,0.08);
  font-size: 13px; font-weight: 600; font-family: inherit;
  color: #ff3b30;
  cursor: pointer; transition: all 0.15s;
}
.chv-detail-delete:active { transform: scale(0.95); opacity: 0.7; }

/* ===== Voice Cache Export Modal ===== */
.vce-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  animation: vcFadeIn 0.2s;
}
.vce-overlay.active {
  display: flex;
}
.vce-panel {
  width: 92%;
  max-width: 440px;
  max-height: 80vh;
  background: var(--bg);
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.vce-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.vce-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.vce-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text3);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
}
.vce-close:hover {
  background: var(--glass);
}
.vce-toolbar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 10px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.vce-select-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
}
.vce-count {
  flex: 1;
  font-size: 12px;
  color: var(--text3);
  text-align: center;
}
.vce-export-btn {
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent, #07c160);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.vce-export-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.vce-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.vce-item {
  display: flex;
  align-items: flex-start;
  padding: 10px 16px;
  gap: 10px;
  transition: background 0.12s;
}
.vce-item:hover {
  background: var(--glass);
}
.vce-check {
  margin-top: 4px;
  flex-shrink: 0;
  accent-color: var(--accent, #07c160);
}
.vce-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vce-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.vce-item-sender {
  font-weight: 600;
  color: var(--text);
}
.vce-item-time {
  color: var(--text3);
}
.vce-item-dur {
  color: var(--text3);
  font-size: 11px;
}
.vce-item-text {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vce-item-name-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
}
.vce-item-name {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.vce-item-name:focus {
  border-color: var(--accent, #07c160);
}
.vce-item-ext {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
}
.vce-item-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding-top: 2px;
}
.vce-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--glass);
  color: var(--accent, #07c160);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.vce-play-btn:hover {
  background: var(--glass-strong);
}
.vce-play-btn.playing {
  color: #ff4d4f;
}
.vce-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
  color: var(--text3);
  font-size: 13px;
  gap: 12px;
}

/* ===== Voice Call - Log Modal ===== */
.vc-log-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.vc-log-overlay.active {
  display: flex;
}
.vc-log-panel {
  background: var(--card-bg, #fff);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  animation: vcLogIn 0.3s ease;
}
@keyframes vcLogIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.vc-log-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border, rgba(0,0,0,0.06));
  position: relative;
}
.vc-log-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1, #333);
}
.vc-log-duration {
  font-size: 12px;
  color: var(--text3, #999);
  margin-top: 2px;
}
.vc-log-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text3, #999);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}
.vc-log-close:hover {
  background: var(--glass-hover, rgba(0,0,0,0.05));
}
.vc-log-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.vc-log-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
}
.vc-log-msg-left {
  align-self: flex-start;
}
.vc-log-msg-right {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.vc-log-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.vc-log-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vc-log-msg-avatar .vc-avatar-placeholder {
  font-size: 12px;
  border-radius: 50%;
}
.vc-log-msg-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.vc-log-msg-name {
  font-size: 11px;
  color: var(--text3, #999);
  padding: 0 4px;
}
.vc-log-msg-right .vc-log-msg-name {
  text-align: right;
}
.vc-log-msg-time {
  font-size: 10px;
  color: var(--text3, #aaa);
  margin-left: 6px;
}
.vc-log-msg-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.vc-log-msg-left .vc-log-msg-bubble {
  background: var(--glass-bg, rgba(0,0,0,0.04));
  color: var(--text1, #333);
  border-top-left-radius: 4px;
}
.vc-log-msg-right .vc-log-msg-bubble {
  background: var(--glass-strong);
  color: var(--text);
  border-top-right-radius: 4px;
}

/* ===== Group Call Member Select ===== */
.vc-gs-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9200;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  animation: vcFadeIn 0.2s;
}
.vc-gs-overlay.active {
  display: flex;
}
.vc-gs-panel {
  background: var(--card-bg, #fff);
  border-radius: 16px;
  width: 320px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}
.vc-gs-header {
  display: flex;
  align-items: center;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.06));
  position: relative;
}
.vc-gs-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text1, #333);
}
.vc-gs-close {
  font-size: 22px;
  color: var(--text3, #aaa);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.vc-gs-close:hover {
  background: var(--glass);
}
.vc-gs-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  max-height: 50vh;
}
.vc-gs-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 12px;
}
.vc-gs-item:hover {
  background: var(--glass);
}
.vc-gs-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--glass-bg, #f0f0f0);
}
.vc-gs-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vc-gs-avatar .vc-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: var(--text2, #666);
}
.vc-gs-name {
  flex: 1;
  font-size: 14px;
  color: var(--text1, #333);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vc-gs-check {
  width: 20px;
  height: 20px;
  accent-color: var(--text2);
  cursor: pointer;
  flex-shrink: 0;
}
.vc-gs-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.06));
}
.vc-gs-cancel, .vc-gs-confirm {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.vc-gs-cancel {
  background: var(--glass-bg, #f0f0f0);
  color: var(--text2, #666);
}
.vc-gs-cancel:hover {
  background: var(--hover-bg, #e0e0e0);
}
.vc-gs-confirm {
  background: var(--glass-strong);
  color: var(--text);
}
.vc-gs-confirm:hover {
  opacity: 0.85;
}

/* ============================================= */
/* ===== Video Call - Incoming Overlay ===== */
/* ============================================= */
.vidcall-incoming-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.vidcall-incoming-overlay.active {
  display: flex;
}
.vidcall-incoming-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  opacity: 0.98;
}
.vidcall-incoming-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px;
  animation: vidcallFadeIn 0.4s ease;
}
@keyframes vidcallFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.vidcall-incoming-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--glass-border);
  box-shadow: 0 0 50px var(--glass-shadow);
  animation: vidcallPulse 2s ease-in-out infinite;
}
@keyframes vidcallPulse {
  0%, 100% { box-shadow: 0 0 25px var(--glass-shadow); }
  50% { box-shadow: 0 0 55px var(--glass-shadow); }
}
.vidcall-incoming-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vidcall-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-strong);
  color: var(--text);
  font-size: 36px;
  font-weight: 600;
}
.vidcall-incoming-name {
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
}
.vidcall-incoming-label {
  color: var(--text2);
  font-size: 14px;
  margin-top: -6px;
}
.vidcall-incoming-camera-icon {
  margin: 12px 0;
  animation: vidcallCamBounce 2s ease-in-out infinite;
}
@keyframes vidcallCamBounce {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}
.vidcall-incoming-actions {
  display: flex;
  gap: 60px;
  margin-top: 20px;
}
.vidcall-incoming-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}
.vidcall-incoming-btn:active {
  transform: scale(0.9);
}
.vidcall-incoming-btn svg {
  width: 28px;
  height: 28px;
}
.vidcall-btn-reject svg,
.vidcall-btn-accept svg {
  padding: 16px;
  border-radius: 50%;
}
.vidcall-btn-reject svg {
  background: #f44336;
}
.vidcall-btn-accept svg {
  background: #4CAF50;
}
.vidcall-incoming-btn span {
  color: var(--text2);
  font-size: 12px;
}

/* ===== Video Call - Active Call Page (WeChat/QQ style) ===== */
.vidcall-page {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9990;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.vidcall-page.active {
  display: flex;
  animation: vidcallSlideUp 0.35s ease;
}
@keyframes vidcallSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.vidcall-bg-avatar {
  position: absolute;
  top: -20px; left: -20px; right: -20px; bottom: -20px;
  background-size: cover;
  background-position: center;
  filter: blur(6px) brightness(0.55);
  z-index: 0;
}
.vidcall-bg-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg,
    var(--glass-shadow) 0%,
    transparent 30%,
    transparent 70%,
    var(--glass-shadow) 100%);
  z-index: 1;
}

/* Private: large character avatar center (hidden - blocks messages) */
.vidcall-char-main {
  display: none !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--glass-border);
  box-shadow: 0 0 60px var(--glass-shadow);
  z-index: 2;
  display: none;
}
.vidcall-page.active .vidcall-char-main.vidcall-show {
  display: none;
}
.vidcall-char-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vidcall-char-main .vidcall-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

/* Private: small user PiP avatar top-right */
.vidcall-user-pip {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 16px));
  right: 16px;
  width: 72px;
  height: 96px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--glass-border);
  box-shadow: 0 4px 16px var(--glass-shadow);
  z-index: 5;
  display: none;
  background: var(--glass-strong);
}
.vidcall-user-pip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Group: top member avatar row */
.vidcall-group-bar {
  position: relative;
  z-index: 2;
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  padding-top: max(14px, env(safe-area-inset-top, 14px));
  flex-shrink: 0;
}
.vidcall-group-bar.vidcall-show {
  display: flex;
}
.vidcall-group-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.vidcall-group-member-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--glass-border);
}
.vidcall-group-member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vidcall-group-member-avatar .vidcall-avatar-placeholder {
  font-size: 18px;
}
.vidcall-group-member-name {
  font-size: 10px;
  color: var(--text3);
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* Info bar (name + timer + status) */
.vidcall-info-bar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 18px 8px;
  gap: 6px;
  flex-shrink: 0;
}
.vidcall-top-name {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
  text-align: center;
}
.vidcall-top-wave {
  display: flex;
  gap: 3px;
  align-items: center;
  height: 20px;
}
.vidcall-top-wave span {
  display: block;
  width: 3px;
  height: 10px;
  border-radius: 2px;
  background: var(--text2);
  animation: vidcallWave 1.2s ease-in-out infinite;
}
.vidcall-top-wave span:nth-child(1) { animation-delay: 0s; }
.vidcall-top-wave span:nth-child(2) { animation-delay: 0.15s; }
.vidcall-top-wave span:nth-child(3) { animation-delay: 0.3s; }
.vidcall-top-wave span:nth-child(4) { animation-delay: 0.45s; }
.vidcall-top-wave span:nth-child(5) { animation-delay: 0.6s; }
@keyframes vidcallWave {
  0%, 100% { height: 6px; opacity: 0.4; }
  50% { height: 20px; opacity: 1; }
}
.vidcall-top-timer {
  color: var(--text2);
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

/* Message area */
.vidcall-msg-area {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}
.vidcall-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: vidcallMsgIn 0.3s ease;
}
@keyframes vidcallMsgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.vidcall-msg-left {
  align-self: flex-start;
}
.vidcall-msg-right {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.vidcall-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.vidcall-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vidcall-msg-avatar .vidcall-avatar-placeholder {
  font-size: 14px;
  border-radius: 50%;
}
.vidcall-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.vidcall-msg-name {
  font-size: 11px;
  color: var(--text3);
  padding: 0 4px;
}
.vidcall-msg-right .vidcall-msg-name {
  text-align: right;
}
.vidcall-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.vidcall-msg-left .vidcall-msg-bubble {
  background: var(--glass);
  color: var(--text);
  border-top-left-radius: 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.vidcall-msg-right .vidcall-msg-bubble {
  background: var(--glass-strong);
  color: var(--text);
  border-top-right-radius: 4px;
}

/* Typing indicator */
.vidcall-typing-indicator {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  flex-shrink: 0;
}
.vidcall-typing-indicator span {
  display: block;
  width: 6px;
  height: 6px;
  background: var(--text3);
  border-radius: 50%;
  animation: vidcallTypeDot 1.4s ease-in-out infinite;
}
.vidcall-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.vidcall-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes vidcallTypeDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.vidcall-typing-indicator em {
  font-style: normal;
  color: var(--text3);
  font-size: 12px;
}

/* Bottom bar */
.vidcall-bottom-bar {
  position: relative;
  z-index: 2;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.vidcall-input-wrap {
  display: flex;
  width: 100%;
  gap: 8px;
  align-items: center;
}
.vidcall-input-field {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.vidcall-input-field::placeholder {
  color: var(--text3);
}
.vidcall-input-field:focus {
  border-color: var(--text2);
}
.vidcall-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--glass-strong);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
  color: var(--text);
}
.vidcall-send-btn:active {
  transform: scale(0.9);
}
.vidcall-hangup-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #e53935;
  border: none;
  border-radius: 28px;
  padding: 10px 32px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.vidcall-hangup-btn:active {
  transform: scale(0.95);
  opacity: 0.8;
}

/* ===== Video Call - System Message (call ended bubble in chat) ===== */
.chat-vidcall-sys-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 6px 14px;
  background: var(--glass-bg, rgba(0,0,0,0.04));
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s;
  margin: 4px auto;
  max-width: 260px;
}
.chat-vidcall-sys-msg:hover {
  background: var(--glass-hover, rgba(0,0,0,0.08));
}
.chat-vidcall-sys-msg svg {
  flex-shrink: 0;
  color: var(--text2);
}
.chat-vidcall-sys-msg .vidcall-sys-text {
  font-size: 12px;
  color: var(--text2, #666);
}
.chat-vidcall-sys-msg .vidcall-sys-duration {
  font-size: 11px;
  color: var(--text3, #999);
  margin-left: 4px;
}
.chat-vidcall-sys-msg .vidcall-sys-members {
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: var(--text3, #aaa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  margin: 0 auto;
}
.chat-vidcall-rejected {
  text-align: center;
  font-size: 12px;
  color: var(--text3, #999);
  padding: 6px 0;
}
.chat-vidcall-rejected svg {
  vertical-align: middle;
  margin-right: 4px;
  color: #f44336;
}

/* ===== Video Call - Log Modal ===== */
.vidcall-log-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.vidcall-log-overlay.active {
  display: flex;
}
.vidcall-log-panel {
  background: var(--card-bg, #fff);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  animation: vidcallLogIn 0.3s ease;
}
@keyframes vidcallLogIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.vidcall-log-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border, rgba(0,0,0,0.06));
  position: relative;
}
.vidcall-log-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1, #333);
}
.vidcall-log-duration {
  font-size: 12px;
  color: var(--text3, #999);
  margin-top: 2px;
}
.vidcall-log-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text3, #999);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}
.vidcall-log-close:hover {
  background: var(--glass-hover, rgba(0,0,0,0.05));
}
.vidcall-log-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.vidcall-log-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
}
.vidcall-log-msg-left {
  align-self: flex-start;
}
.vidcall-log-msg-right {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.vidcall-log-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.vidcall-log-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vidcall-log-msg-avatar .vidcall-avatar-placeholder {
  font-size: 12px;
  border-radius: 50%;
}
.vidcall-log-msg-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.vidcall-log-msg-name {
  font-size: 11px;
  color: var(--text3, #999);
  padding: 0 4px;
}
.vidcall-log-msg-right .vidcall-log-msg-name {
  text-align: right;
}
.vidcall-log-msg-time {
  font-size: 10px;
  color: var(--text3, #aaa);
  margin-left: 6px;
}
.vidcall-log-msg-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.vidcall-log-msg-left .vidcall-log-msg-bubble {
  background: var(--glass-bg, rgba(0,0,0,0.04));
  color: var(--text1, #333);
  border-top-left-radius: 4px;
}
.vidcall-log-msg-right .vidcall-log-msg-bubble {
  background: var(--glass-strong);
  color: var(--text);
  border-top-right-radius: 4px;
}

/* ===== Video Call Group Member Select ===== */
.vidcall-gs-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9200;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  animation: vidcallFadeIn 0.2s;
}
.vidcall-gs-overlay.active {
  display: flex;
}
.vidcall-gs-panel {
  background: var(--card-bg, #fff);
  border-radius: 16px;
  width: 320px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}
.vidcall-gs-header {
  display: flex;
  align-items: center;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.06));
  position: relative;
}
.vidcall-gs-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text1, #333);
}
.vidcall-gs-close {
  font-size: 22px;
  color: var(--text3, #aaa);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.vidcall-gs-close:hover {
  background: var(--glass);
}
.vidcall-gs-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  max-height: 50vh;
}
.vidcall-gs-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 12px;
}
.vidcall-gs-item:hover {
  background: var(--glass);
}
.vidcall-gs-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--glass-bg, #f0f0f0);
}
.vidcall-gs-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vidcall-gs-avatar .vidcall-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: var(--text2, #666);
}
.vidcall-gs-name {
  flex: 1;
  font-size: 14px;
  color: var(--text1, #333);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vidcall-gs-check {
  width: 20px;
  height: 20px;
  accent-color: var(--text2);
  cursor: pointer;
  flex-shrink: 0;
}
.vidcall-gs-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.06));
}
.vidcall-gs-cancel, .vidcall-gs-confirm {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.vidcall-gs-cancel {
  background: var(--glass-bg, #f0f0f0);
  color: var(--text2, #666);
}
.vidcall-gs-cancel:hover {
  background: var(--hover-bg, #e0e0e0);
}
.vidcall-gs-confirm {
  background: var(--glass-strong);
  color: var(--text);
}
.vidcall-gs-confirm:hover {
  opacity: 0.85;
}

/* ===== Location Card Bubble ===== */
.chat-location-card {
  padding: 0 !important;
  border-radius: 12px !important;
  overflow: hidden;
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  cursor: pointer;
  background: var(--glass-strong) !important;
  border: 1.5px solid var(--glass-border) !important;
  box-shadow: 0 2px 8px var(--glass-shadow) !important;
}
.chat-location-card:active { opacity: 0.78; }
.chat-location-map {
  width: 100%;
  height: 100px;
  background: var(--glass);
  position: relative;
  overflow: hidden;
}
.chat-location-map::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse 60px 30px at 35% 60%, var(--glass-strong) 0%, transparent 70%),
    radial-gradient(ellipse 40px 20px at 70% 40%, var(--glass-strong) 0%, transparent 70%);
  pointer-events: none;
}
.chat-location-map-grid {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    linear-gradient(to right, var(--glass-border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--glass-border) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.5;
  pointer-events: none;
}
.chat-location-pin {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -100%);
  z-index: 2;
  color: var(--text);
}
.chat-location-pin svg {
  filter: drop-shadow(0 2px 3px var(--glass-shadow));
}
.chat-location-pin svg .loc-pin-dot {
  fill: var(--glass-strong);
}
.chat-location-pin-pulse {
  position: absolute;
  bottom: -2px; left: 50%;
  transform: translateX(-50%);
  width: 12px; height: 5px;
  background: var(--text3);
  opacity: 0.35;
  border-radius: 50%;
}
.chat-location-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-location-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-location-addr {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-location-dist {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
}

/* msg-right: same card style, override the default .msg-right .chat-msg-bubble inversion */
.msg-right .chat-msg-bubble.chat-location-card {
  background: var(--glass-strong) !important;
  border-color: var(--glass-border) !important;
  color: var(--text) !important;
}
.msg-right .chat-location-name { color: var(--text); }
.msg-right .chat-location-addr { color: var(--text2); }
.msg-right .chat-location-dist { color: var(--text3); }
.chat-msg-row.msg-right .chat-msg-bubble.chat-location-card {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  margin-left: auto;
}

/* ===== Shared Music Card ===== */
.chat-msg-bubble-wrap.chat-music-wrap {
  max-width: calc(100% - 44px);
}
.chat-music-card,
.msg-right .chat-msg-bubble.chat-music-card {
  width: min(274px, calc(100vw - 86px));
  min-width: min(250px, calc(100vw - 86px));
  max-width: min(274px, calc(100vw - 86px));
  padding: 11px 11px 9px !important;
  border-radius: 18px !important;
  border: 1px solid #eef0f3 !important;
  background:
    radial-gradient(circle at 17% 14%, rgba(255,255,255,0.92) 0, rgba(255,255,255,0) 34%),
    linear-gradient(145deg, #ffffff 0%, #f8fafc 100%) !important;
  color: #111827 !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07) !important;
  overflow: hidden;
  white-space: normal;
}
.chat-music-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.chat-music-cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 53px;
  height: 53px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 50%;
  background: #f3f4f6;
  box-shadow: inset 0 0 0 3px #fff, 0 1px 5px rgba(15, 23, 42, 0.08);
}
.chat-music-cover::after {
  content: '';
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06);
}
.chat-music-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.chat-music-card.is-playing .chat-music-cover img {
  animation: chatMusicCoverRotate 7s linear infinite;
}
@keyframes chatMusicCoverRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.chat-music-cover-placeholder {
  color: #9ca3af;
  font-size: 22px;
}
.chat-music-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 1px;
}
.chat-music-copy strong {
  color: #111827;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-music-copy em,
.chat-music-copy small {
  color: #6b7280;
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-music-copy small {
  color: #a0a6b2;
}
.chat-music-play {
  width: 31px;
  height: 31px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #111827;
  background: #f5f6f8;
}
.chat-music-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chat-music-meta span {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 10px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-music-progress {
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #9ca3af;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.chat-music-progress input[type="range"] {
  flex: 1;
  height: 3px;
  margin: 0;
  accent-color: #111827;
  cursor: pointer;
}
.chat-music-progress input[type="range"]:disabled {
  cursor: default;
  opacity: 0.58;
}
.chat-music-foot {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid #f1f2f4;
  color: #a0a6b2;
  font-size: 10px;
  letter-spacing: 0;
}

/* ===== Listen Together Invite ===== */
.chat-music-together-invite-overlay {
  position: fixed;
  inset: 0;
  z-index: 10030;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: rgba(8, 10, 16, 0.38);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
}
.chat-music-together-invite-overlay.active {
  display: flex;
}
.chat-music-together-invite-panel {
  width: min(320px, calc(100vw - 48px));
  box-sizing: border-box;
  padding: 24px 22px 22px;
  border: 1px solid color-mix(in srgb, var(--glass-border) 82%, rgba(255,255,255,0.5));
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 35%, color-mix(in srgb, #8b5cf6 14%, transparent), transparent 42%),
    color-mix(in srgb, var(--bg) 88%, var(--glass-strong));
  color: var(--text);
  box-shadow: 0 28px 72px rgba(8, 10, 18, 0.32);
  text-align: center;
  animation: chatMusicTogetherPanelIn 0.3s cubic-bezier(.2,.8,.2,1);
}
@keyframes chatMusicTogetherPanelIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-music-together-invite-kicker {
  color: var(--text3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.chat-music-together-invite-song {
  min-width: 0;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-music-together-invite-song strong,
.chat-music-together-invite-song span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-music-together-invite-song strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}
.chat-music-together-invite-song span {
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
}
.chat-music-together-avatar-stage {
  position: relative;
  width: 154px;
  height: 154px;
  margin: 18px auto 10px;
  display: grid;
  place-items: center;
}
.chat-music-together-ring {
  position: absolute;
  inset: 20px;
  border: 1px solid color-mix(in srgb, #a78bfa 62%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 24px color-mix(in srgb, #8b5cf6 34%, transparent);
  animation: chatMusicTogetherRing 2.4s ease-out infinite;
}
.chat-music-together-ring.ring-two {
  animation-delay: -0.8s;
}
.chat-music-together-ring.ring-three {
  animation-delay: -1.6s;
}
@keyframes chatMusicTogetherRing {
  0% { opacity: 0.82; transform: scale(0.72); }
  72%, 100% { opacity: 0; transform: scale(1.34); }
}
.chat-music-together-avatar {
  position: relative;
  z-index: 2;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid color-mix(in srgb, #fff 88%, var(--glass-border));
  border-radius: 50%;
  background: var(--glass-strong);
  color: var(--text);
  box-shadow:
    0 0 0 8px color-mix(in srgb, #8b5cf6 12%, transparent),
    0 16px 36px rgba(15, 23, 42, 0.18);
}
.chat-music-together-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.chat-music-together-invite-name {
  color: var(--text2);
  font-size: 13px;
  font-weight: 750;
}
.chat-music-together-invite-actions {
  margin-top: 19px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}
.chat-music-together-invite-btn {
  min-height: 43px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}
.chat-music-together-invite-btn:active {
  transform: scale(0.96);
}
.chat-music-together-invite-btn:disabled {
  cursor: default;
  opacity: 0.58;
}
.chat-music-together-invite-btn:disabled:active {
  transform: none;
}
.chat-music-together-invite-btn.reject {
  background: color-mix(in srgb, var(--text) 7%, var(--glass));
  color: var(--text2);
}
.chat-music-together-invite-btn.accept {
  background: #111827;
  color: #fff;
}
.chat-music-together-system {
  width: fit-content;
  max-width: min(86vw, 380px);
  margin: 8px auto;
  min-height: 28px;
  box-sizing: border-box;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--glass-strong) 84%, transparent);
  color: var(--text3);
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
}
.chat-music-together-system svg {
  flex: 0 0 auto;
}
.chat-music-together-system-duration {
  flex: 0 0 auto;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
@media (prefers-reduced-motion: reduce) {
  .chat-music-together-invite-panel,
  .chat-music-together-ring {
    animation: none;
  }
}

/* ===== Share Music Search ===== */
.chat-music-share-panel {
  width: min(354px, calc(100vw - 28px));
  max-height: min(70vh, 560px);
  padding: 0;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #eef0f3;
  color: #111827;
}
.chat-music-share-header {
  position: relative;
  padding: 18px 18px 12px;
  text-align: center;
  color: #111827;
}
.chat-music-share-header strong {
  font-size: 16px;
  font-weight: 650;
}
.chat-music-share-header button {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #9ca3af;
  font-size: 23px;
  cursor: pointer;
}
.chat-music-search-box {
  display: flex;
  gap: 8px;
  padding: 0 15px;
}
.chat-music-search-box input {
  min-width: 0;
  flex: 1;
  height: 39px;
  padding: 0 13px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f7f8fa;
  color: #111827;
  font: inherit;
  font-size: 13px;
  outline: none;
}
.chat-music-search-box input:focus {
  border-color: #c9ced7;
  background: #fff;
}
.chat-music-search-box button {
  height: 39px;
  padding: 0 15px;
  border: 0;
  border-radius: 12px;
  background: #111827;
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.chat-music-search-status {
  min-height: 34px;
  padding: 11px 17px 8px;
  color: #9ca3af;
  font-size: 11px;
}
.chat-music-search-results {
  max-height: min(45vh, 390px);
  padding: 0 10px 12px;
  overflow-y: auto;
}
.chat-music-search-empty {
  padding: 42px 10px 50px;
  color: #9ca3af;
  font-size: 12px;
  text-align: center;
}
.chat-music-result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 7px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #111827;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.chat-music-result:active {
  background: #f7f8fa;
}
.chat-music-result:disabled {
  opacity: 0.55;
  cursor: default;
}
.chat-music-result-cover {
  width: 43px;
  height: 43px;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
  background: #f3f4f6;
  color: #9ca3af;
}
.chat-music-result-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-music-result-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-music-result-copy strong,
.chat-music-result-copy em,
.chat-music-result-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-music-result-copy strong {
  font-size: 13px;
  font-weight: 600;
}
.chat-music-result-copy em {
  color: #6b7280;
  font-size: 11px;
  font-style: normal;
}
.chat-music-result-copy small {
  color: #9ca3af;
  font-size: 10px;
  line-height: 1.2;
}
.chat-music-result-action {
  flex-shrink: 0;
  padding: 6px 9px;
  border-radius: 11px;
  background: #f5f6f8;
  color: #4b5563;
  font-size: 11px;
}

/* ===== Location Send Modal ===== */
.location-send-panel {
  width: 300px;
  max-width: 88vw;
}
.location-send-panel h3 {
  text-align: center;
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--text);
}
.location-form-group {
  margin-bottom: 12px;
}
.location-form-group label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 4px;
  font-weight: 500;
}
.location-form-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1.5px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.location-form-input:focus {
  border-color: var(--text3);
}
.location-form-input::placeholder {
  color: var(--text3);
}

/* ===== @ Mention Panel ===== */
.at-mention-panel {
  position: absolute;
  bottom: 100%;
  left: 0; right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg);
  border-top: 1px solid var(--glass-border);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.10);
  z-index: 50;
  display: none;
  -webkit-overflow-scrolling: touch;
}
.at-mention-panel.active {
  display: block;
}
.at-mention-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.at-mention-item:active {
  background: var(--glass);
}
.at-mention-item-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--glass);
  display: flex; align-items: center; justify-content: center;
}
.at-mention-item-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.at-mention-item-name {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.at-mention-all-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary, #07c160);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.chat-msg-at-tag {
  color: var(--primary, #07c160);
  font-weight: 500;
}

/* ===== Proactive Message Settings ===== */
.cs-auto-msg-options {
  padding: 0 16px 8px;
  display: none;
}
.cs-auto-msg-options.active {
  display: block;
}
.cs-auto-msg-interval {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
}
.cs-auto-msg-interval-label {
  font-size: 13px;
  color: var(--text3);
  white-space: nowrap;
}
.cs-auto-msg-interval-input {
  width: 70px;
  padding: 4px 8px;
  border: 1.5px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  outline: none;
}
.cs-auto-msg-interval-input:focus {
  border-color: var(--primary, #07c160);
}
.cs-auto-msg-hint {
  font-size: 11px;
  color: var(--text3);
  padding: 4px 0 0;
  line-height: 1.5;
}

/* ===== Share Memory with Group Chat ===== */
.cs-share-mem-options {
  padding: 0 16px 8px;
  display: none;
}
.cs-share-mem-options.active {
  display: block;
}
.cs-share-mem-hint {
  font-size: 11px;
  color: var(--text3);
  padding: 4px 0 8px;
  line-height: 1.5;
}
.cs-share-mem-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cs-share-mem-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--glass);
  cursor: pointer;
  transition: background 0.15s;
}
.cs-share-mem-item:active {
  background: var(--glass-border);
}
.cs-share-mem-item.selected {
  background: rgba(var(--primary-rgb, 7, 193, 96), 0.12);
  border: 1.5px solid var(--primary, #07c160);
}
.cs-share-mem-item-avatar {
  width: 32px; height: 32px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--glass);
  display: flex; align-items: center; justify-content: center;
}
.cs-share-mem-item-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.cs-share-mem-item-info {
  flex: 1;
  min-width: 0;
}
.cs-share-mem-item-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-share-mem-item-desc {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}
.cs-share-mem-item-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--text3);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.cs-share-mem-item.selected .cs-share-mem-item-check {
  border-color: var(--primary, #07c160);
  background: var(--primary, #07c160);
}
.cs-share-mem-item.selected .cs-share-mem-item-check::after {
  content: '';
  width: 6px; height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

/* ========== 红包卡片 ========== */
.chat-rp-card {
  display: flex; flex-direction: column; gap: 0;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  border-radius: 14px; min-width: 210px; max-width: 240px;
  cursor: pointer; transition: opacity 0.2s; position: relative; overflow: hidden;
}
.chat-rp-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--glass-border); border-radius: 14px 14px 0 0;
}
.chat-rp-card:active { opacity: 0.75; }
.chat-rp-card-top {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px;
}
.chat-rp-card-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--text2); color: var(--bg); font-size: 20px;
}
.chat-rp-card-icon svg { stroke: var(--bg); }
.chat-rp-card-body { flex: 1; min-width: 0; }
.chat-rp-card-msg {
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.4;
}
.chat-rp-card-label {
  font-size: 11px; color: var(--text3); margin-top: 3px;
}
.chat-rp-card.rp-claimed { opacity: 0.65; }
.chat-rp-card.rp-claimed::before { background: var(--glass-border); }
.chat-rp-card.rp-claimed .chat-rp-card-icon { background: var(--text3); }
.chat-rp-card.rp-returned { opacity: 0.5; }
.chat-rp-card.rp-returned::before { background: var(--glass-border); opacity: 0.5; }
.chat-rp-card.rp-returned .chat-rp-card-icon { background: var(--text3); opacity: 0.6; }
.chat-rp-card-footer {
  font-size: 10px; color: var(--text3); padding: 6px 14px 8px;
  border-top: 1px solid var(--glass-border);
}

/* ========== 发红包弹窗 ========== */
.rp-send-panel {
  width: 92vw; max-width: 340px; border-radius: 18px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.rp-send-header {
  position: relative; text-align: center; padding: 16px 16px 10px;
}
.rp-send-close {
  position: absolute; top: 12px; right: 14px; font-size: 22px;
  cursor: pointer; color: var(--text3); line-height: 1;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.rp-send-title {
  font-size: 17px; font-weight: 700; color: var(--text);
}
.rp-send-tab-bar {
  display: flex; gap: 0; margin: 0 16px; border-radius: 10px; overflow: hidden;
  border: 1.5px solid var(--glass-border);
}
.rp-send-tab {
  flex: 1; text-align: center; padding: 8px 0; font-size: 13px; font-weight: 600;
  color: var(--text3); cursor: pointer; transition: all 0.2s;
  background: transparent;
}
.rp-send-tab.active {
  background: var(--text2); color: var(--bg);
}
.rp-send-body { padding: 16px; }
.rp-send-field-group {
  margin-bottom: 14px;
}
.rp-send-field-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text2);
  margin-bottom: 6px;
}
.rp-send-input {
  width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  border: 1.5px solid var(--glass-border); background: var(--bg);
  color: var(--text); font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.rp-send-input:focus { border-color: var(--text2); }
.rp-send-input::placeholder { color: var(--text3); }
.rp-send-amount-wrap {
  display: flex; align-items: center; gap: 6px;
}
.rp-send-currency {
  font-size: 20px; font-weight: 700; color: var(--text);
}
.rp-send-hint {
  display: block; font-size: 11px; color: var(--text3); margin-top: 4px;
}
.rp-send-total {
  text-align: center; font-size: 36px; font-weight: 800; color: var(--text);
  margin: 16px 0 12px; font-family: 'Nunito', sans-serif;
}
.rp-send-btn {
  width: 100%; padding: 12px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  background: var(--text2); color: var(--bg);
  transition: opacity 0.2s; font-family: inherit;
}
.rp-send-btn:active { opacity: 0.8; }
.rp-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.rp-send-balance {
  text-align: center; font-size: 11px; color: var(--text3); margin-top: 10px;
}

/* ========== 拆红包弹窗 ========== */
.rp-open-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 99999;
  background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center;
  animation: rpOverlayIn 0.3s ease;
}
@keyframes rpOverlayIn {
  from { opacity: 0; } to { opacity: 1; }
}
.rp-open-modal {
  width: 80vw; max-width: 300px; border-radius: 20px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  text-align: center; position: relative;
  animation: rpModalIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes rpModalIn {
  from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; }
}
.rp-open-close {
  position: absolute; top: 10px; right: 12px; font-size: 22px;
  cursor: pointer; color: var(--text3); line-height: 1; z-index: 2;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.rp-open-top { padding: 28px 20px 16px; }
.rp-open-avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 10px;
  overflow: hidden; border: 2px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  background: var(--glass); color: var(--text3);
}
.rp-open-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rp-open-sender {
  font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px;
}
.rp-open-message {
  font-size: 13px; color: var(--text2); line-height: 1.5;
}
.rp-open-btn-wrap { padding: 10px 0 28px; }
.rp-open-btn {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--text2); cursor: pointer;
  transition: transform 0.2s; position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.rp-open-btn:active { transform: scale(0.92); }
.rp-open-text {
  font-size: 28px; font-weight: 900; color: var(--bg);
  font-family: 'Nunito', 'PingFang SC', sans-serif;
}
.rp-open-btn.opening {
  animation: rpBtnSpin 0.8s ease-in-out;
  pointer-events: none;
}
@keyframes rpBtnSpin {
  0% { transform: rotateY(0deg) scale(1); }
  40% { transform: rotateY(180deg) scale(1.1); }
  70% { transform: rotateY(360deg) scale(1.05); }
  100% { transform: rotateY(360deg) scale(0); opacity: 0; }
}
.rp-open-result {
  padding: 0 20px 8px; animation: rpAmountIn 0.5s ease;
}
@keyframes rpAmountIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.rp-open-amount {
  font-size: 42px; font-weight: 900; color: var(--text);
  font-family: 'Nunito', sans-serif; line-height: 1.2;
}
.rp-open-amount-label {
  font-size: 13px; color: var(--text3); margin-top: 2px;
}
.rp-open-detail {
  padding: 8px 20px 20px; font-size: 12px; color: var(--text3);
  cursor: pointer;
}
.rp-open-detail:hover { text-decoration: underline; }

/* ========== 红包详情面板 ========== */
.rp-detail-panel {
  width: 92vw; max-width: 380px; max-height: 80vh; border-radius: 18px;
  overflow-y: auto; background: var(--glass-strong);
  border: 1.5px solid var(--glass-border);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.rp-detail-header {
  text-align: center; padding: 20px 16px 16px; position: relative;
  border-bottom: 1px solid var(--glass-border);
}
.rp-detail-avatar {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 8px;
  overflow: hidden; border: 2px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  background: var(--glass); color: var(--text3);
}
.rp-detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rp-detail-sender { font-size: 14px; font-weight: 600; color: var(--text); }
.rp-detail-message { font-size: 12px; color: var(--text3); margin-top: 4px; }
.rp-detail-amount {
  font-size: 28px; font-weight: 800; color: var(--text); margin-top: 8px;
  font-family: 'Nunito', sans-serif;
}
.rp-detail-body { padding: 12px 16px; }
.rp-detail-list-title {
  font-size: 12px; color: var(--text3); margin-bottom: 8px; font-weight: 600;
}
.rp-detail-list { padding: 0; }
.rp-detail-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--glass-border);
}
.rp-detail-item:last-child { border-bottom: none; }
.rp-detail-item-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass); color: var(--text3); font-size: 14px;
}
.rp-detail-item-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rp-detail-item-info { flex: 1; min-width: 0; }
.rp-detail-item-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.rp-detail-item-time { font-size: 11px; color: var(--text3); margin-top: 2px; }
.rp-detail-item-amount {
  font-size: 14px; font-weight: 700; color: var(--text);
  font-family: 'Nunito', sans-serif; flex-shrink: 0;
}
.rp-best-luck {
  display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 6px;
  background: var(--text2); color: var(--bg); font-weight: 700;
}

/* ========== 转账卡片 ========== */
.chat-tf-card {
  display: flex; flex-direction: column; gap: 0;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  border-radius: 14px; min-width: 210px; max-width: 240px;
  cursor: pointer; transition: opacity 0.2s; position: relative; overflow: hidden;
}
.chat-tf-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--glass-border); border-radius: 14px 14px 0 0;
}
.chat-tf-card:active { opacity: 0.75; }
.chat-tf-card-top {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px;
}
.chat-tf-card-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--text2); color: var(--bg); font-size: 20px;
}
.chat-tf-card-icon svg { stroke: var(--bg); }
.chat-tf-card-body { flex: 1; min-width: 0; }
.chat-tf-card-amount {
  font-size: 18px; font-weight: 800; color: var(--text);
  font-family: 'Nunito', sans-serif; line-height: 1.3;
}
.chat-tf-card-msg {
  font-size: 12px; color: var(--text2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-tf-card-footer {
  font-size: 10px; color: var(--text3); padding: 6px 14px 8px;
  border-top: 1px solid var(--glass-border);
}
.chat-tf-card.tf-accepted { opacity: 0.65; }
.chat-tf-card.tf-accepted::before { background: var(--glass-border); }
.chat-tf-card.tf-accepted .chat-tf-card-icon { background: var(--text3); }
.chat-tf-card.tf-returned { opacity: 0.5; }
.chat-tf-card.tf-returned::before { background: var(--glass-border); opacity: 0.5; }
.chat-tf-card.tf-returned .chat-tf-card-icon { background: var(--text3); opacity: 0.6; }

/* ========== 发起转账弹窗 ========== */
.tf-send-panel {
  width: 92vw; max-width: 340px; border-radius: 18px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.tf-send-header {
  position: relative; text-align: center; padding: 16px 16px 10px;
}
.tf-send-close {
  position: absolute; top: 12px; right: 14px; font-size: 22px;
  cursor: pointer; color: var(--text3); line-height: 1;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.tf-send-title {
  font-size: 17px; font-weight: 700; color: var(--text);
}
.tf-send-to {
  font-size: 12px; color: var(--text3); margin-top: 4px;
}
.tf-send-body { padding: 16px; }
.tf-send-field-group {
  margin-bottom: 14px;
}
.tf-send-field-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text2);
  margin-bottom: 6px;
}
.tf-send-input {
  width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  border: 1.5px solid var(--glass-border); background: var(--bg);
  color: var(--text); font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.tf-send-input:focus { border-color: var(--text2); }
.tf-send-input::placeholder { color: var(--text3); }
.tf-send-amount-wrap {
  display: flex; align-items: center; gap: 6px;
}
.tf-send-currency {
  font-size: 20px; font-weight: 700; color: var(--text);
}
.tf-send-hint {
  display: block; font-size: 11px; color: var(--text3); margin-top: 4px;
}
.tf-send-total {
  text-align: center; font-size: 36px; font-weight: 800; color: var(--text);
  margin: 16px 0 12px; font-family: 'Nunito', sans-serif;
}
.tf-send-btn {
  width: 100%; padding: 12px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  background: var(--text2); color: var(--bg);
  transition: opacity 0.2s; font-family: inherit;
}
.tf-send-btn:active { opacity: 0.8; }
.tf-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tf-send-balance {
  text-align: center; font-size: 11px; color: var(--text3); margin-top: 10px;
}
.tf-send-target-group {
  margin-bottom: 14px;
}
.tf-send-target-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text2);
  margin-bottom: 6px;
}
.tf-send-target-select {
  width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  border: 1.5px solid var(--glass-border); background: var(--bg);
  color: var(--text); font-family: inherit; outline: none;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* ========== 收到转账确认弹窗 ========== */
.tf-receive-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 99999;
  background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center;
  animation: rpOverlayIn 0.3s ease;
}
.tf-receive-modal {
  width: 80vw; max-width: 300px; border-radius: 20px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  text-align: center; position: relative;
  animation: rpModalIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.tf-receive-close {
  position: absolute; top: 10px; right: 12px; font-size: 22px;
  cursor: pointer; color: var(--text3); line-height: 1; z-index: 2;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.tf-receive-top { padding: 28px 20px 16px; }
.tf-receive-avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 10px;
  overflow: hidden; border: 2px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  background: var(--glass); color: var(--text3);
}
.tf-receive-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tf-receive-sender {
  font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px;
}
.tf-receive-message {
  font-size: 13px; color: var(--text2); line-height: 1.5;
}
.tf-receive-amount {
  font-size: 36px; font-weight: 900; color: var(--text);
  font-family: 'Nunito', sans-serif; line-height: 1.2; margin: 12px 0 4px;
}
.tf-receive-amount-label {
  font-size: 13px; color: var(--text3);
}
.tf-receive-actions {
  display: flex; gap: 12px; padding: 20px 24px 24px; justify-content: center;
}
.tf-receive-btn {
  flex: 1; padding: 10px 0; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s; font-family: inherit;
}
.tf-receive-btn:active { opacity: 0.8; }
.tf-receive-btn-return {
  background: var(--glass); color: var(--text2); border: 1.5px solid var(--glass-border);
}
.tf-receive-btn-accept {
  background: var(--text2); color: var(--bg);
}

/* ========== 礼物卡片 ========== */
.chat-gf-card {
  display: flex; flex-direction: column; gap: 0;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  border-radius: 14px; min-width: 210px; max-width: 240px;
  cursor: pointer; transition: opacity 0.2s; position: relative; overflow: hidden;
}
.chat-gf-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--glass-border); border-radius: 14px 14px 0 0;
}
.chat-gf-card:active { opacity: 0.75; }
.chat-gf-card-top {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px;
}
.chat-gf-card-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--text2); color: var(--bg); font-size: 20px;
}
.chat-gf-card-icon svg { stroke: var(--bg); }
.chat-gf-card-body { flex: 1; min-width: 0; }
.chat-gf-card-name {
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-gf-card-msg {
  font-size: 12px; color: var(--text2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-gf-card-footer {
  font-size: 10px; color: var(--text3); padding: 6px 14px 8px;
  border-top: 1px solid var(--glass-border);
}
.chat-gf-card.gf-accepted { opacity: 0.65; }
.chat-gf-card.gf-accepted::before { background: var(--glass-border); }
.chat-gf-card.gf-accepted .chat-gf-card-icon { background: var(--text3); }
.chat-gf-card.gf-returned { opacity: 0.5; }
.chat-gf-card.gf-returned::before { background: var(--glass-border); opacity: 0.5; }
.chat-gf-card.gf-returned .chat-gf-card-icon { background: var(--text3); opacity: 0.6; }
.chat-gf-card.gf-lottery .chat-gf-card-icon { border-radius: 50%; }

/* ========== 外卖代付卡片 ========== */
.chat-dl-card {
  display: flex; flex-direction: column; gap: 0;
  background: var(--glass); border: 1.5px solid var(--glass-border);
  border-radius: 14px; min-width: 220px; max-width: 260px;
  cursor: pointer; transition: opacity 0.2s, transform 0.2s; position: relative; overflow: hidden;
  box-shadow: 0 8px 24px rgba(255, 179, 0, 0.13);
}
.chat-dl-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--glass-border); border-radius: 14px 14px 0 0;
}
.chat-dl-card:active { opacity: 0.75; transform: scale(0.99); }
.chat-dl-card-top {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px;
}
.chat-dl-card-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #ffb300; color: #fff; font-size: 20px;
  overflow: hidden;
}
.chat-dl-card-icon svg { stroke: #fff; }
.chat-dl-card-icon img { display: block; }
.chat-dl-card-body { flex: 1; min-width: 0; }
.chat-dl-card-name {
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-dl-card-msg {
  font-size: 12px; color: var(--text2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-dl-card-amount {
  font-size: 18px; font-weight: 800; color: #ffb300; flex-shrink: 0;
  white-space: nowrap;
}
.chat-dl-card-footer {
  font-size: 10px; color: var(--text3); padding: 6px 14px 8px;
  border-top: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: space-between;
}
.chat-dl-card-brand {
  font-weight: 600; color: #ffb300; opacity: 0.8;
}
.chat-dl-card-status {
  display: flex; align-items: center; gap: 3px;
}
.chat-dl-card.dl-paid { opacity: 0.7; }
.chat-dl-card.dl-paid::before { background: var(--glass-border); }
.chat-dl-card.dl-paid .chat-dl-card-icon { background: #4caf50; }
.chat-dl-card.dl-paid .chat-dl-card-amount { color: #4caf50; }
.chat-dl-card.dl-paid .chat-dl-card-brand { color: #4caf50; }
.chat-dl-card.dl-paid .chat-dl-card-status svg { stroke: #4caf50; }
.chat-dl-card.dl-rejected { opacity: 0.5; }
.chat-dl-card.dl-rejected::before { background: var(--glass-border); opacity: 0.5; }
.chat-dl-card.dl-rejected .chat-dl-card-icon { background: var(--text3); opacity: 0.6; }
.chat-dl-card.dl-rejected .chat-dl-card-amount { color: var(--text3); }
.chat-dl-card.dl-rejected .chat-dl-card-brand { color: var(--text3); }
.chat-dl-card.dl-rejected .chat-dl-card-status svg { stroke: var(--text3); }

/* ========== 外卖代付弹窗 ========== */
.dl-pay-modal {
  width: 82vw; max-width: 320px; border-radius: 20px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  box-shadow: 0 12px 40px var(--glass-shadow);
  text-align: center;
}
.dl-pay-header {
  padding: 24px 20px 12px;
}
.dl-pay-avatar {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 8px;
  overflow: hidden; background: var(--glass);
  display: flex; align-items: center; justify-content: center;
}
.dl-pay-avatar svg { stroke: var(--text3); }
.dl-pay-sender {
  font-size: 15px; font-weight: 600; color: var(--text);
}
.dl-pay-info {
  padding: 0 20px 16px;
}
.dl-pay-item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--glass-border);
}
.dl-pay-item-row:last-child { border-bottom: none; }
.dl-pay-label {
  font-size: 13px; color: var(--text3); flex-shrink: 0;
}
.dl-pay-value {
  font-size: 14px; color: var(--text); font-weight: 500; text-align: right;
  max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dl-pay-amount {
  font-size: 18px; font-weight: 800; color: #ffb300;
}
.dl-pay-actions {
  padding: 0 20px 20px; display: flex; flex-direction: column; gap: 10px;
}
.dl-pay-btn {
  width: 100%; padding: 12px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  background: #ffb300; color: #fff; transition: opacity 0.15s;
  font-family: inherit;
}
.dl-pay-btn:active { opacity: 0.8; }
.dl-pay-btn.dl-pay-btn-disabled {
  background: var(--text3); opacity: 0.5; cursor: not-allowed;
}
.dl-reject-btn {
  width: 100%; padding: 10px; border: 1.5px solid var(--glass-border);
  border-radius: 12px; font-size: 14px; font-weight: 600;
  cursor: pointer; background: transparent; color: var(--text2);
  transition: opacity 0.15s; font-family: inherit;
}
.dl-reject-btn:active { opacity: 0.7; }

/* ========== 发起代付弹窗 ========== */
.dl-send-panel {
  width: 92vw; max-width: 360px; border-radius: 18px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
}
.dl-send-header {
  position: relative; text-align: center; padding: 16px 16px 10px;
}
.dl-send-close {
  position: absolute; top: 12px; right: 14px; font-size: 22px;
  cursor: pointer; color: var(--text3); line-height: 1;
}
.dl-send-title {
  font-size: 17px; font-weight: 700; color: var(--text);
}
.dl-send-body { padding: 16px; }
.dl-send-field-group { margin-bottom: 14px; }
.dl-send-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text2);
  margin-bottom: 6px;
}
.dl-send-input {
  width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  border: 1.5px solid var(--glass-border); background: var(--glass);
  color: var(--text); outline: none; transition: border-color 0.2s;
  box-sizing: border-box;
}
.dl-send-input:focus { border-color: #ffb300; }
.dl-send-input::placeholder { color: var(--text3); }
.dl-send-amount-wrap {
  display: flex; align-items: center; gap: 6px;
}
.dl-send-currency {
  font-size: 20px; font-weight: 700; color: #ffb300;
}
.dl-send-total {
  text-align: center; font-size: 36px; font-weight: 800; color: #ffb300;
  margin: 10px 0;
}
.dl-send-btn {
  width: 100%; padding: 12px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  background: #ffb300; color: #fff; transition: opacity 0.15s;
  font-family: inherit;
}
.dl-send-btn:active { opacity: 0.8; }
.dl-send-balance {
  text-align: center; font-size: 11px; color: var(--text3); margin-top: 10px;
}

/* ========== 发送礼物弹窗 ========== */
.gf-send-panel {
  width: 92vw; max-width: 360px; border-radius: 18px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
}
.gf-send-header {
  position: relative; text-align: center; padding: 16px 16px 10px;
}
.gf-send-close {
  position: absolute; top: 12px; right: 14px; font-size: 22px;
  cursor: pointer; color: var(--text3); line-height: 1;
}
.gf-send-title {
  font-size: 17px; font-weight: 700; color: var(--text);
}
.gf-send-to {
  font-size: 12px; color: var(--text3); margin-top: 4px;
}
.gf-send-body { padding: 16px; }
.gf-send-tab-bar {
  display: flex; gap: 0; border-radius: 10px; overflow: hidden;
  border: 1.5px solid var(--glass-border); margin-bottom: 14px;
}
.gf-send-tab {
  flex: 1; text-align: center; padding: 8px 0; font-size: 13px; font-weight: 600;
  cursor: pointer; color: var(--text3); background: transparent; transition: all 0.2s;
}
.gf-send-tab.active {
  background: var(--text2); color: var(--bg);
}
.gf-send-field-group { margin-bottom: 14px; }
.gf-send-label, .gf-send-field-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text2);
  margin-bottom: 6px;
}
.gf-send-input, .gf-send-select {
  width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  border: 1.5px solid var(--glass-border); background: var(--glass);
  color: var(--text); outline: none; transition: border-color 0.2s;
  box-sizing: border-box;
}
.gf-send-input:focus, .gf-send-select:focus { border-color: var(--text2); }
.gf-send-input::placeholder { color: var(--text3); }
.gf-send-amount-wrap {
  display: flex; align-items: center; gap: 6px;
}
.gf-send-currency {
  font-size: 20px; font-weight: 700; color: var(--text);
}
.gf-send-hint {
  display: block; font-size: 11px; color: var(--text3); margin-top: 4px;
}
.gf-send-total {
  text-align: center; font-size: 36px; font-weight: 800; color: var(--text);
  margin: 10px 0;
}
.gf-send-btn {
  width: 100%; padding: 12px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  background: var(--text2); color: var(--bg); transition: opacity 0.15s;
}
.gf-send-btn:active { opacity: 0.8; }
.gf-send-balance {
  text-align: center; font-size: 11px; color: var(--text3); margin-top: 10px;
}
.gf-send-target-group { margin-bottom: 14px; }

/* ========== 收到礼物确认弹窗 ========== */
.gf-receive-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 99999;
  background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center;
}
.gf-receive-modal {
  width: 80vw; max-width: 300px; border-radius: 20px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  box-shadow: 0 12px 40px var(--glass-shadow);
  position: relative; text-align: center;
}
.gf-receive-close {
  position: absolute; top: 10px; right: 12px; font-size: 22px;
  cursor: pointer; color: var(--text3); line-height: 1; z-index: 1;
}
.gf-receive-top { padding: 28px 20px 16px; }
.gf-receive-avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 10px;
  overflow: hidden; background: var(--glass);
  display: flex; align-items: center; justify-content: center; color: var(--text3);
}
.gf-receive-avatar img { width: 100%; height: 100%; object-fit: cover; }
.gf-receive-sender {
  font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px;
}
.gf-receive-message {
  font-size: 13px; color: var(--text2); line-height: 1.5;
}
.gf-receive-gift-icon {
  margin: 12px auto; color: var(--text2);
}
.gf-receive-name {
  font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 6px;
}
.gf-receive-actions {
  display: flex; gap: 12px; padding: 20px 24px 24px; justify-content: center;
}
.gf-receive-btn {
  flex: 1; padding: 10px 0; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.gf-receive-btn:active { opacity: 0.8; }
.gf-receive-btn-return {
  background: var(--glass); color: var(--text2); border: 1.5px solid var(--glass-border);
}
.gf-receive-btn-accept {
  background: var(--text2); color: var(--bg);
}

/* ========== 拆礼物动画弹窗 ========== */
.gf-unwrap-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 100000;
  background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
}
.gf-unwrap-modal {
  width: 80vw; max-width: 300px; border-radius: 20px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  box-shadow: 0 12px 40px var(--glass-shadow);
  text-align: center; padding: 30px 20px;
}
.gf-unwrap-anim { position: relative; height: 120px; margin-bottom: 16px; }
.gf-unwrap-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 80px; height: 80px;
}
.gf-unwrap-lid {
  width: 90px; height: 24px; border-radius: 6px; margin-left: -5px;
  background: var(--text2); position: relative; z-index: 2;
  animation: gfLidOpen 0.6s ease forwards 0.3s;
}
.gf-unwrap-base {
  width: 80px; height: 56px; border-radius: 0 0 8px 8px;
  background: var(--text2); opacity: 0.7;
}
@keyframes gfLidOpen {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(-30px) rotate(-15deg); opacity: 0; }
}
.gf-unwrap-particles {
  position: absolute; top: 30%; left: 50%;
  pointer-events: none;
}
.gf-unwrap-particle {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text2); opacity: 0;
  animation: gfParticle 0.8s ease forwards;
}
@keyframes gfParticle {
  0% { transform: translate(0, 0) scale(0); opacity: 1; }
  50% { transform: translate(var(--tx, 20px), var(--ty, -20px)) scale(1); opacity: 0.8; }
  100% { transform: translate(var(--tx, 20px), var(--ty, -20px)) scale(0.3); opacity: 0; }
}
.gf-unwrap-details { animation: gfDetailsFadeIn 0.4s ease forwards; }
@keyframes gfDetailsFadeIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
.gf-unwrap-gift-name {
  font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 6px;
}
.gf-unwrap-gift-price {
  font-size: 28px; font-weight: 900; color: var(--text); margin-bottom: 8px;
  font-family: 'Nunito', sans-serif;
}
.gf-unwrap-gift-msg {
  font-size: 13px; color: var(--text2); margin-bottom: 4px; line-height: 1.5;
}
.gf-unwrap-gift-from {
  font-size: 12px; color: var(--text3); margin-bottom: 16px;
}
.gf-unwrap-done-btn {
  padding: 10px 40px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--text2); color: var(--bg);
}
.gf-unwrap-done-btn:active { opacity: 0.8; }

/* ========== 抽奖礼物详情弹窗 ========== */
.gf-lottery-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 99999;
  background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center;
}
.gf-lottery-modal {
  width: 85vw; max-width: 340px; border-radius: 20px; overflow: hidden;
  background: var(--glass-strong); border: 1.5px solid var(--glass-border);
  box-shadow: 0 12px 40px var(--glass-shadow);
  position: relative; max-height: 80vh; overflow-y: auto;
}
.gf-lottery-close {
  position: absolute; top: 10px; right: 12px; font-size: 22px;
  cursor: pointer; color: var(--text3); line-height: 1; z-index: 1;
}
.gf-lottery-header {
  text-align: center; padding: 20px 16px 10px;
}
.gf-lottery-title {
  font-size: 17px; font-weight: 700; color: var(--text);
}
.gf-lottery-subtitle {
  font-size: 12px; color: var(--text3); margin-top: 4px;
}
.gf-lottery-info {
  text-align: center; padding: 0 16px 12px;
  border-bottom: 1px solid var(--glass-border);
}
.gf-lottery-gift-name {
  font-size: 18px; font-weight: 800; color: var(--text); margin-bottom: 4px;
}
.gf-lottery-gift-price {
  font-size: 14px; color: var(--text2); font-weight: 600;
}
.gf-lottery-gift-msg {
  font-size: 12px; color: var(--text3); margin-top: 4px;
}
.gf-lottery-status {
  text-align: center; padding: 10px 16px; font-size: 13px; color: var(--text2); font-weight: 600;
}
.gf-lottery-participants, .gf-lottery-winners { padding: 0 16px; }
.gf-lottery-section-title {
  font-size: 12px; font-weight: 600; color: var(--text3); margin-bottom: 6px; margin-top: 8px;
}
.gf-lottery-person {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--glass-border);
}
.gf-lottery-person:last-child { border-bottom: none; }
.gf-lottery-person-name { font-weight: 600; }
.gf-lottery-person-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
  background: var(--glass); color: var(--text2);
}
.gf-lottery-person-tag.winner {
  background: var(--text2); color: var(--bg); font-weight: 600;
}
.gf-lottery-actions {
  padding: 12px 16px 16px; text-align: center;
}
.gf-lottery-join-btn {
  width: 100%; padding: 10px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--text2); color: var(--bg); transition: opacity 0.15s;
}
.gf-lottery-join-btn:active { opacity: 0.8; }
.gf-lottery-join-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== 朋友圈 Moments ===== */
#chatTabMoments { padding: 0; }
.moments-bg-area {
  position: relative;
  width: 100%;
  height: 220px;
  background: linear-gradient(135deg, var(--glass-strong) 0%, var(--glass) 100%);
  border-radius: 0 0 0 0;
  overflow: visible;
  cursor: pointer;
  margin-bottom: 40px;
  background-size: cover;
  background-position: center;
}
.moments-bg-area.has-bg .moments-bg-placeholder { display: none; }
.moments-bg-placeholder {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--text3); font-size: 12px;
}
.moments-bg-placeholder svg { opacity: 0.3; }
.moments-bg-profile {
  position: absolute; bottom: -30px; right: 16px;
  display: flex; align-items: flex-end; gap: 10px;
}
.moments-bg-nickname {
  font-size: 15px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5), 0 0 8px rgba(0,0,0,0.3);
  margin-bottom: 36px;
}
.moments-bg-area:not(.has-bg) .moments-bg-nickname {
  color: var(--text);
  text-shadow: none;
}
.moments-bg-avatar {
  width: 60px; height: 60px; border-radius: 12px;
  background: var(--glass-strong);
  border: 3px solid var(--bg);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.moments-bg-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Feed */
.moments-feed {
  display: flex; flex-direction: column; gap: 0;
  padding: 0 16px 16px;
}
.moments-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 20px; gap: 10px;
  color: var(--text3); font-size: 13px;
}
.moments-empty svg { opacity: 0.3; }

/* Card */
.moments-card {
  padding: 16px 0;
  border-bottom: 1px solid var(--glass-border);
}
.moments-card:last-child { border-bottom: none; }
.moments-card-header {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 8px;
}
.moments-card-avatar {
  width: 40px; height: 40px; border-radius: 6px;
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
}
.moments-card-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.moments-card-info { flex: 1; min-width: 0; }
.moments-card-name {
  font-size: 14px; font-weight: 700; color: var(--text);
  margin-bottom: 2px;
}
.moments-card-time {
  font-size: 11px; color: var(--text3);
}
.moments-card-menu {
  flex-shrink: 0;
}
.moments-card-delete {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3);
  transition: all 0.15s;
}
.moments-card-delete:active { transform: scale(0.9); }
.moments-card-delete:hover { color: #e55; }

.moments-card-text {
  font-size: 14px; line-height: 1.6; color: var(--text);
  margin-bottom: 8px; white-space: pre-wrap; word-break: break-word;
  padding-left: 50px;
}

/* Image Grid */
.moments-img-grid {
  display: grid; gap: 4px;
  margin-bottom: 8px;
  padding-left: 50px;
}
.moments-img-grid.grid-1 {
  grid-template-columns: 1fr;
  max-width: 240px;
}
.moments-img-grid.grid-2 {
  grid-template-columns: 1fr 1fr;
  max-width: 300px;
}
.moments-img-grid.grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
  max-width: 300px;
}
.moments-img-grid.grid-4 {
  grid-template-columns: 1fr 1fr;
  max-width: 300px;
}
.moments-img-grid.grid-6 {
  grid-template-columns: 1fr 1fr 1fr;
  max-width: 300px;
}
.moments-img-grid.grid-9 {
  grid-template-columns: 1fr 1fr 1fr;
  max-width: 300px;
}
.moments-img-item {
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  background: var(--glass);
}
.moments-img-item img {
  width: 100%; height: 100%; object-fit: cover;
  cursor: pointer;
}
.moments-img-desc {
  display: flex; align-items: flex-start; justify-content: center;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  padding: 8px;
  height: 100%; box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.moments-img-desc span {
  font-size: 11px; color: var(--text2);
  text-align: center; word-break: break-word;
  line-height: 1.4;
}

.moments-location {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text3);
  margin-bottom: 6px;
  padding-left: 50px;
}
.moments-visibility-tag {
  font-size: 11px; color: var(--text3);
  padding-left: 50px; margin-bottom: 4px;
}

/* Actions */
.moments-card-actions {
  display: flex; align-items: center; gap: 20px;
  padding-left: 50px; margin-top: 6px; margin-bottom: 4px;
}
.moments-action-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; color: var(--text3);
  transition: all 0.15s;
}
.moments-action-btn:active { transform: scale(0.85); }
.moments-action-btn:hover { color: var(--text); }
.moments-refresh-btn.spinning svg {
  animation: momentsSpin 0.8s linear infinite;
}
@keyframes momentsSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Interaction (likes & comments) */
.moments-interaction {
  padding-left: 50px; margin-top: 4px;
}
.moments-likes {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 8px 10px;
  background: var(--glass);
  border-radius: 4px;
  font-size: 13px; color: var(--text);
  line-height: 1.5;
}
.moments-likes svg {
  flex-shrink: 0; margin-top: 3px; color: #e55;
}
.moments-likes span {
  word-break: break-word;
}
.moments-comments {
  background: var(--glass);
  border-radius: 4px;
  padding: 6px 10px;
}
.moments-likes + .moments-comments {
  border-top: 1px solid var(--glass-border);
  border-radius: 0 0 4px 4px;
}
.moments-comment-item {
  font-size: 13px; line-height: 1.6;
  color: var(--text); padding: 2px 0;
  cursor: pointer;
  word-break: break-word;
}
.moments-comment-author-name {
  font-weight: 700; color: var(--text);
}
.moments-comment-reply {
  color: var(--text3); font-weight: 400;
}
.moments-comment-text {
  font-weight: 400;
}
.moments-comment-delete {
  font-size: 11px; color: #e55;
  margin-left: 8px; cursor: pointer;
  font-weight: 400;
}

/* Comment Bar */
.moments-comment-bar {
  position: fixed; bottom: var(--moments-keyboard-inset, 0px); left: 0; right: 0;
  z-index: 860;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--glass-border);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.moments-comment-bar.active {
  transform: translateY(0);
}
.moments-comment-input {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass);
  font-size: 14px; font-family: inherit;
  color: var(--text); outline: none;
}
.moments-comment-input::placeholder { color: var(--text3); }
.moments-comment-input:focus { border-color: var(--text); }
.moments-comment-send {
  padding: 8px 16px; border-radius: 20px;
  font-size: 13px; flex-shrink: 0;
}
.moments-comment-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  font-size: 18px; color: var(--text3);
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* Publish Modal */
.moments-publish-overlay {
  z-index: 850;
  background: transparent;
}
.moments-publish-panel {
  position: absolute; top: 0; left: 0; right: 0; bottom: auto;
  height: var(--moments-visual-viewport-height, 100%);
  transform: translateY(var(--moments-visual-viewport-offset-top, 0px));
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.moments-publish-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 16px) + 12px) 16px 12px;
  flex-shrink: 0;
}
.moments-publish-title {
  font-size: 16px; font-weight: 700; color: var(--text);
}
.moments-publish-body {
  flex: 1; overflow-y: auto; padding: 16px;
  scrollbar-width: none;
}
.moments-publish-body::-webkit-scrollbar { display: none; }
.moments-publish-textarea {
  width: 100%; padding: 12px;
  border: none; background: transparent;
  font-size: 15px; font-family: inherit;
  color: var(--text); outline: none;
  resize: none; line-height: 1.6;
  min-height: 100px;
}
.moments-publish-textarea::placeholder { color: var(--text3); }
.moments-publish-section-title {
  font-size: 12px; font-weight: 600; color: var(--text3);
  margin: 12px 0 8px; padding-left: 2px;
}

/* Publish Image Grid */
.moments-pub-img-grid-wrap {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.moments-pub-img-item {
  width: 80px; height: 80px; border-radius: 8px;
  overflow: hidden; position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-border);
}
.moments-pub-img-item img {
  width: 100%; height: 100%; object-fit: cover;
}
.moments-pub-img-desc {
  display: flex; align-items: center; justify-content: center;
  padding: 6px;
}
.moments-pub-img-desc span {
  font-size: 10px; color: var(--text2);
  text-align: center; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.moments-pub-img-remove {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 12px; text-align: center; line-height: 18px;
  cursor: pointer;
}
.moments-pub-img-add {
  width: 80px; height: 80px; border-radius: 8px;
  border: 1.5px dashed var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text3);
  transition: all 0.15s;
}
.moments-pub-img-add:active { transform: scale(0.95); }

/* Visibility Selection */
.moments-vis-select {
  width: 100%; padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--glass-border);
  background: var(--glass);
  font-size: 14px; font-family: inherit;
  color: var(--text); outline: none;
  -webkit-appearance: none; appearance: none;
  cursor: pointer;
}
.moments-vis-list {
  margin-top: 8px;
  max-height: 200px; overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 8px;
  background: var(--glass);
}
.moments-vis-option {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 6px; cursor: pointer;
  font-size: 13px; color: var(--text);
  border-radius: 6px;
  transition: background 0.1s;
}
.moments-vis-option:active { background: var(--glass-strong); }
.moments-vis-option input[type="checkbox"] {
  width: 16px; height: 16px; flex-shrink: 0;
  accent-color: var(--text);
}
.moments-vis-avatar {
  width: 28px; height: 28px; border-radius: 6px;
  overflow: hidden; flex-shrink: 0;
  background: var(--glass-strong);
  display: flex; align-items: center; justify-content: center;
}
.moments-vis-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Image Preview */
.moments-img-preview-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 900;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
  cursor: pointer;
}
.moments-img-preview-overlay.active {
  opacity: 1; pointer-events: auto;
}
.moments-img-preview-overlay img {
  max-width: 90%; max-height: 90%;
  object-fit: contain; border-radius: 4px;
}

/* Moments: Pink theme */
body.theme-pink .moments-publish-panel { background: #faf5f6; }
body.theme-pink .moments-comment-bar { background: #faf5f6; }
body.theme-pink .moments-likes,
body.theme-pink .moments-comments { background: rgba(250,235,240,0.5); }
body.theme-pink .moments-bg-area:not(.has-bg) {
  background: linear-gradient(135deg, #f7eaed, #f0dce2);
}
body.theme-pink.dark-mode .moments-publish-panel { background: #241e20; }
body.theme-pink.dark-mode .moments-comment-bar { background: #241e20; }
body.theme-pink.dark-mode .moments-likes,
body.theme-pink.dark-mode .moments-comments { background: rgba(55,40,48,0.5); }

/* Moments: comic line theme slot */
body.theme-white .moments-publish-panel { background: var(--bg); }
body.theme-white .moments-likes,
body.theme-white .moments-comments {
  background: rgba(245,245,245,0.6);
}
body.theme-white .moments-comment-bar { background: var(--bg); }
body.theme-white .moments-comment-input {
  background: rgba(255,255,255,0.3); border-color: rgba(255,255,255,0.4);
}
body.theme-white.dark-mode .moments-likes,
body.theme-white.dark-mode .moments-comments {
  background: rgba(60,60,60,0.5);
}

/* Moments: Blue theme */
body.theme-blue .moments-bg-area:not(.has-bg) {
  background: linear-gradient(135deg, rgba(215,232,252,0.6), rgba(195,218,248,0.4));
}
body.theme-blue .moments-publish-panel {
  background: linear-gradient(160deg, rgba(230,242,255,0.96), rgba(218,232,250,0.96));
}
body.theme-blue .moments-comment-bar {
  background: linear-gradient(160deg, rgba(230,242,255,0.96), rgba(218,232,250,0.96));
  border-top-color: rgba(180,210,240,0.25);
}
body.theme-blue .moments-likes,
body.theme-blue .moments-comments {
  background: linear-gradient(160deg, rgba(225,240,255,0.35), rgba(200,222,248,0.2));
  border: none;
}
body.theme-blue .moments-comment-input {
  border: none; border-radius: 20px;
  background: rgba(215,235,255,0.35);
}
body.theme-blue .moments-card {
  border-bottom-color: rgba(180,210,240,0.18);
}
body.theme-blue .moments-vis-select,
body.theme-blue .moments-vis-list {
  border: none; background: rgba(215,235,255,0.3);
}
body.theme-blue .moments-pub-img-add,
body.theme-blue .moments-pub-img-item {
  border-color: rgba(180,210,240,0.25);
}
body.theme-blue .moments-bg-avatar {
  border-color: rgba(230,242,255,0.96);
}
body.theme-blue.dark-mode .moments-publish-panel {
  background: linear-gradient(160deg, rgba(40,55,75,0.96), rgba(30,42,58,0.96));
}
body.theme-blue.dark-mode .moments-comment-bar {
  background: linear-gradient(160deg, rgba(40,55,75,0.96), rgba(30,42,58,0.96));
}
body.theme-blue.dark-mode .moments-likes,
body.theme-blue.dark-mode .moments-comments {
  background: linear-gradient(160deg, rgba(38,52,70,0.4), rgba(28,38,52,0.25));
}

/* Moments: Line theme */
body.theme-line .moments-bg-area:not(.has-bg) {
  background: var(--dock-bg);
}
body.theme-line .moments-publish-panel { background: var(--bg); }
body.theme-line .moments-comment-bar { background: var(--bg); }
body.theme-line .moments-likes,
body.theme-line .moments-comments {
  background: var(--dock-bg);
  border: 1px solid var(--glass-border);
}
body.theme-line .moments-comment-input {
  background: var(--bg); border: 1px solid var(--glass-border);
}
body.theme-line .moments-card { border-bottom: 1px solid var(--glass-border); }
body.theme-line .moments-vis-select,
body.theme-line .moments-vis-list {
  background: var(--bg); border: 1px solid var(--glass-border);
}
body.theme-line .moments-bg-avatar {
  border-radius: 4px; border-color: var(--bg);
}

/* Moments: Retro theme */
body.theme-retro .moments-bg-area:not(.has-bg) {
  background: #008080;
}
body.theme-retro .moments-bg-nickname { color: #fff; text-shadow: 1px 1px 0 #000; }
body.theme-retro .moments-publish-panel {
  background: var(--glass);
}
body.theme-retro .moments-comment-bar {
  background: var(--glass);
  border-top: 2px solid var(--glass-border);
}
body.theme-retro .moments-likes,
body.theme-retro .moments-comments {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 2px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.4), inset -2px -2px 0 rgba(0,0,0,0.1);
}
body.theme-retro .moments-comment-input {
  border: 2px solid var(--glass-border);
  border-radius: 3px;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.12), inset -1px -1px 0 rgba(255,255,255,0.5);
}
body.theme-retro .moments-card-avatar { border-radius: 4px; }
body.theme-retro .moments-bg-avatar { border-radius: 4px; }
body.theme-retro .moments-img-item { border-radius: 2px; }
body.theme-retro .moments-pub-img-item { border-radius: 4px; }
body.theme-retro .moments-pub-img-add { border-radius: 4px; }
body.theme-retro .moments-vis-select {
  border: 2px solid var(--glass-border);
  border-radius: 3px;
}
body.theme-retro .moments-vis-list {
  border: 2px solid var(--glass-border);
  border-radius: 3px;
}
body.theme-retro .moments-comment-send { border-radius: 4px; }


/* ===== Werewolf Review Card ===== */
.chat-werewolf-review-card {
  position: relative;
  overflow: hidden;
  width: min(78vw, 330px);
  padding: 0 !important;
  border: 1px solid rgba(188, 54, 70, 0.42) !important;
  border-radius: 18px !important;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 222, 160, 0.22), transparent 34%),
    linear-gradient(145deg, rgba(18, 19, 32, 0.96), rgba(57, 18, 27, 0.94) 58%, rgba(16, 12, 18, 0.98)) !important;
  color: #fff7ea !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34), inset 0 0 0 1px rgba(255,255,255,0.05) !important;
  cursor: pointer;
  white-space: normal !important;
}
.msg-right .chat-werewolf-review-card {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 222, 160, 0.22), transparent 34%),
    linear-gradient(145deg, rgba(18, 19, 32, 0.96), rgba(57, 18, 27, 0.94) 58%, rgba(16, 12, 18, 0.98)) !important;
  color: #fff7ea !important;
  border-color: rgba(188, 54, 70, 0.42) !important;
}
.chat-werewolf-review-card:active { transform: scale(0.985); }
.chat-werewolf-card-glow {
  position: absolute;
  inset: -38% -22% auto auto;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(191, 48, 64, 0.28);
  filter: blur(18px);
  pointer-events: none;
}
.chat-werewolf-card-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
}
.chat-werewolf-moon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(255, 236, 188, 0.13);
  border: 1px solid rgba(255, 236, 188, 0.24);
  color: #ffe8a4;
  font-size: 24px;
  box-shadow: inset 0 0 14px rgba(255, 236, 188, 0.08);
}
.chat-werewolf-card-title-wrap { min-width: 0; flex: 1; }
.chat-werewolf-card-kicker {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: rgba(255, 232, 164, 0.72);
  font-weight: 800;
}
.chat-werewolf-card-title {
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 900;
  color: #fff7ea;
}
.chat-werewolf-card-open {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.82);
  font-size: 11px;
  font-weight: 700;
}
.chat-werewolf-card-result {
  position: relative;
  margin: 0 14px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.08);
  color: #ffe6ba;
  font-size: 12px;
  line-height: 1.45;
}
.chat-werewolf-card-meta {
  margin: 9px 14px 0;
  color: rgba(255,255,255,0.66);
  font-size: 11px;
  line-height: 1.4;
}
.chat-werewolf-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 10px 14px 0;
}
.chat-werewolf-chip {
  max-width: 135px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.78);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-werewolf-chip.muted { opacity: 0.65; }
.chat-werewolf-card-preview {
  margin: 10px 14px 0;
  color: rgba(255,255,255,0.78);
  font-size: 12px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat-werewolf-card-foot {
  margin-top: 12px;
  padding: 9px 14px 11px;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: rgba(255, 232, 164, 0.75);
  font-size: 11px;
  text-align: right;
}
.chat-werewolf-review-overlay {
  z-index: 1200;
  background: rgba(5, 4, 8, 0.66);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.chat-werewolf-review-panel {
  width: min(92vw, 560px);
  max-height: calc(var(--app-visual-viewport-height, 100vh) - 44px);
  overflow-y: auto;
  border-radius: 24px;
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 232, 164, 0.18), transparent 28%),
    linear-gradient(155deg, rgba(18, 18, 30, 0.98), rgba(47, 18, 25, 0.98) 60%, rgba(10, 8, 12, 0.99));
  color: #fff7ea;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 26px 70px rgba(0,0,0,0.5);
}
.chat-werewolf-review-hero {
  position: relative;
  padding: 24px 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chat-werewolf-review-kicker {
  color: rgba(255, 232, 164, 0.72);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.16em;
}
.chat-werewolf-review-hero h3 {
  margin: 4px 36px 4px 0;
  color: #fff7ea;
  font-size: 24px;
  line-height: 1.2;
}
.chat-werewolf-review-hero p {
  margin: 0;
  color: rgba(255,255,255,0.62);
  font-size: 12px;
  line-height: 1.45;
}
.chat-werewolf-review-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.09);
  color: #fff7ea;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.chat-werewolf-review-result {
  margin: 14px 18px 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.86);
  font-size: 13px;
  line-height: 1.6;
}
.chat-werewolf-review-result { color: #ffe6ba; font-weight: 700; }
.chat-werewolf-review-section-title {
  margin: 18px 18px 8px;
  color: rgba(255, 232, 164, 0.82);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.chat-werewolf-review-grid {
  margin: 0 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.chat-werewolf-review-player {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  border-radius: 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.07);
  min-width: 0;
}
.chat-werewolf-review-player span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.chat-werewolf-review-player em {
  color: #ffe6ba;
  font-style: normal;
  font-size: 11px;
  flex: 0 0 auto;
}
.chat-werewolf-review-player small {
  color: rgba(255,255,255,0.55);
  font-size: 10px;
  flex: 0 0 auto;
}
.chat-werewolf-review-content {
  margin: 0 18px 20px;
  padding: 15px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}
@media (max-width: 420px) {
  .chat-werewolf-review-grid { grid-template-columns: 1fr; }
  .chat-werewolf-review-panel { width: 94vw; border-radius: 20px; }
}
